GetCurrentDevice will list devices managed
Change-Id: I83202aa5b4f9af8e4b1e662b589ce8d795808a8d
diff --git a/demo_test/cmd_client/Note b/demo_test/cmd_client/Note
index ca0c094..4781181 100644
--- a/demo_test/cmd_client/Note
+++ b/demo_test/cmd_client/Note
@@ -47,11 +47,14 @@
Set IP 192.168.4.27 port 8888 vendor "edgecore" freq 180
attach:192.168.4.27:8888:edgecore:180
--------------------------------------------------------------------------------------
-set multi-deivies info Example:
+set multi-device info Example:
attach:192.168.4.27:8888:edgecore:180
attach:192.168.3.34:8888:edgecore:180
--------------------------------------------------------------------------------------
+Get Current List of Devices monitored showdevices
+ Return from server: 192.168.4.26:8888,192.168.4.27:8888
+--------------------------------------------------------------------------------------
UnSubscribe all events(ResourceAdded/ResourceRemoved/Alert) unsub:192.168.4.27:8888:add:rm:alert
--------------------------------------------------------------------------------------
Subscribe all events(ResourceAdded/ResourceRemoved/Alert) sub:192.168.4.27:8888:add:rm:alert
diff --git a/demo_test/test.go b/demo_test/test.go
index 05582ad..d1d7ca9 100644
--- a/demo_test/test.go
+++ b/demo_test/test.go
@@ -128,8 +128,11 @@
vendorinfo.Vendor = vendor
var ret_msg *importer.EventList
ret_msg, err := cc.GetEventList(ctx, vendorinfo)
-
- return err, ret_msg.Events
+ if err != nil {
+ return err, nil
+ } else {
+ return err, ret_msg.Events
+ }
}
/*///////////////////////////////////////////////////////////////////////*/
@@ -143,8 +146,11 @@
currentdeviceinfo.IpAddress = ip_address
var ret_msg *importer.EventList
ret_msg, err := cc.GetCurrentEventList(ctx, currentdeviceinfo)
-
- return err, ret_msg.Events
+ if err != nil {
+ return err, nil
+ } else {
+ return err, ret_msg.Events
+ }
}
/*///////////////////////////////////////////////////////////////////////*/
@@ -161,6 +167,23 @@
return err
}
+/*///////////////////////////////////////////////////////////////////////*/
+// Allows user to get the current devices that are monitored
+//
+//
+/*///////////////////////////////////////////////////////////////////////*/
+func GetCurrentDevices() (error, []string) {
+ fmt.Println("Testing GetCurrentDevices\n")
+ empty := new(importer.Empty)
+ var ret_msg *importer.DeviceList
+ ret_msg, err := cc.GetCurrentDevices(ctx, empty)
+ if err != nil {
+ return err, nil
+ } else {
+ return err, ret_msg.Ip
+ }
+}
+
func init() {
Formatter := new(log.TextFormatter)
Formatter.TimestampFormat = "02-01-2006 15:04:05"
@@ -439,6 +462,26 @@
}
}
+ case "showdevices":
+ cmd_size := len(s)
+ fmt.Print("cmd is :", cmd, cmd_size)
+ if cmd_size > 2 || cmd_size < 0 {
+ fmt.Print("error event !!")
+ newmessage = "error event !!"
+ } else {
+ err, currentlist := GetCurrentDevices()
+
+ if err != nil {
+ errStatus, _ := status.FromError(err)
+ fmt.Println(errStatus.Message())
+ fmt.Println(errStatus.Code())
+ newmessage = errStatus.Message()
+ fmt.Print("showdevices error!!")
+ } else {
+ fmt.Print("showdevices ", currentlist)
+ newmessage = strings.Join(currentlist[:], ", ")
+ }
+ }
case "QUIT":
loop = false
newmessage = "QUIT"