LN0739_FM_FR8: relaxing the active alarm and alarm history restrictions
- new alarms can still be added if max active alarm threshold or alarm
  history threshold is reached. Alarm manager raised new alarm under
  such situations.
- Review comments closed.
- Review comments closed.

Change-Id: I885418dcc19c587d1139f8251eda735b4a2bba00
Signed-off-by: vipin <vipin.mavila@nokia.com>
diff --git a/cli/alarm-cli.go b/cli/alarm-cli.go
index 665f968..97ccb91 100755
--- a/cli/alarm-cli.go
+++ b/cli/alarm-cli.go
@@ -74,6 +74,18 @@
 			postAlarm(flags, readAlarmParams(flags, true), alarm.AlarmActionClear)
 		})
 
+	// Configure an alarm manager
+	commando.
+		Register("configure").
+		SetShortDescription("Configure alarm manager with given parameters").
+		AddFlag("mal", "max active alarms", commando.Int, nil).
+		AddFlag("mah", "max alarm history", commando.Int, nil).
+		AddFlag("host", "Alarm manager host address", commando.String, "localhost").
+		AddFlag("port", "Alarm manager host address", commando.String, "8080").
+		SetAction(func(args map[string]commando.ArgValue, flags map[string]commando.FlagValue) {
+			postAlarmConfig(flags)
+		})
+
 	// parse command-line arguments
 	commando.Parse(nil)
 }
@@ -162,3 +174,24 @@
 	t.SetStyle(table.StyleColoredBright)
 	t.Render()
 }
+
+func postAlarmConfig(flags map[string]commando.FlagValue) {
+	host, _ := flags["host"].GetString()
+	port, _ := flags["port"].GetString()
+	maxactivealarms, _ := flags["mal"].GetInt()
+	maxalarmhistory, _ := flags["mah"].GetInt()
+	targetUrl := fmt.Sprintf("http://%s:%s/ric/v1/alarms/config", host, port)
+
+	m := alarm.AlarmConfigParams{MaxActiveAlarms: maxactivealarms, MaxAlarmHistory: maxalarmhistory}
+	jsonData, err := json.Marshal(m)
+	if err != nil {
+		fmt.Println("json.Marshal failed: %v", err)
+		return
+	}
+
+	resp, err := http.Post(targetUrl, "application/json", bytes.NewBuffer(jsonData))
+	if err != nil || resp == nil {
+		fmt.Println("Couldn't fetch post alarm configuration due to error: %v", err)
+		return
+	}
+}