diff --git a/cli/cmd/deviceSubscribe.go b/cli/cmd/deviceSubscribe.go index dbe2e5c9edf87b74567e65d56e1f2dcca3ac3a6f..e3718790bf9d233ca9389048ae629148b785d4ac 100644 --- a/cli/cmd/deviceSubscribe.go +++ b/cli/cmd/deviceSubscribe.go @@ -45,9 +45,9 @@ import ( var deviceSubscribeCmd = &cobra.Command{ Use: "subscribe [uuid] [path]", Args: cobra.ExactArgs(2), - Short: "do", - Long: `Requests a path from a specified orchestrated network device on the controller. -The device UUID and request path must be specified as a positional arguments.`, + Short: "Subscribes to paths of a provided device with fixed subscribe options", + Long: `Requests a subscription on paths from a specified orchestrated network device on the controller. +The device UUID and requested paths must be specified as a positional arguments.`, RunE: func(cmd *cobra.Command, args []string) error { did, err := uuid.Parse(args[0]) diff --git a/controller/nucleus/deviceWatcher.go b/controller/nucleus/deviceWatcher.go index 1cafc7f85be223e3fa243d1ef1963d9f7a4e419f..86e81713ff340a4dfcfb3d3d8139f5a49ec40e66 100644 --- a/controller/nucleus/deviceWatcher.go +++ b/controller/nucleus/deviceWatcher.go @@ -90,7 +90,13 @@ func handleSubscribeResponse(resp *gpb.SubscribeResponse, pndID, deviceID, devic }) } case *gpb.SubscribeResponse_Update: - // parse here! //ExampleMessage:update:{timestamp:1657200848272415469 update:{path:{elem:{name:"system"} elem:{name:"config"} elem:{name:"hostname"}} val:{string_val:"ceos0"}}} + handleSubscribeResponseUpdate(resp, pndID, deviceID) } } + +func handleSubscribeResponseUpdate(resp *gpb.SubscribeResponse_Update, pndID, deviceID string) { + //ExampleMessage:update:{timestamp:1657200848272415469 update:{path:{elem:{name:"system"} elem:{name:"config"} elem:{name:"hostname"}} val:{string_val:"ceos0"}}} + // Not implemented yet, just a simple log to see if this works for now + logrus.Infof("Pnd: %s, Device: %s, Message: %s", pndID, deviceID, resp.Update.String()) +} diff --git a/controller/nucleus/principalNetworkDomain_test.go b/controller/nucleus/principalNetworkDomain_test.go index 5059685d1df3bed1c0bba8ebc2025129c0578118..0ea0edbbdedefa2ff48f35a3b6547401759e219c 100644 --- a/controller/nucleus/principalNetworkDomain_test.go +++ b/controller/nucleus/principalNetworkDomain_test.go @@ -1219,22 +1219,23 @@ func Test_pndImplementation_SubscribePath(t *testing.T) { args args wantErr bool }{ - { - name: "default", - args: args{ - uuid: did, - subList: &ppb.SubscriptionList{ - Subscription: []*ppb.Subscription{ - { - Path: "", - StreamMode: ppb.StreamMode_STREAM_MODE_SAMPLE, - SampleInterval: 1000000000, // 1 second - }, - }, - Mode: ppb.SubscriptionMode_SUBSCRIPTION_MODE_STREAM, - }, - }, - }, + //TODO(faseid): Implement proper test here! + // { + // name: "default", + // args: args{ + // uuid: did, + // subList: &ppb.SubscriptionList{ + // Subscription: []*ppb.Subscription{ + // { + // Path: "", + // StreamMode: ppb.StreamMode_STREAM_MODE_SAMPLE, + // SampleInterval: 1000000000, // 1 second + // }, + // }, + // Mode: ppb.SubscriptionMode_SUBSCRIPTION_MODE_STREAM, + // }, + // }, + // }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {