Skip to content
Snippets Groups Projects
Commit b1ce2afb authored by Fabian Seidl's avatar Fabian Seidl
Browse files

updated cli description, prepared sub response handling, removed test case for now

parent ed403e48
No related branches found
No related tags found
3 merge requests!376Add additional example application hostname-checker,!343Add basic application framework and example application to show interaction between events an NBI,!342Resolve "Add an option to send gNMI Subscribe requests via SBI"
Pipeline #108246 passed
This commit is part of merge request !342. Comments created here will be created in the context of that merge request.
...@@ -45,9 +45,9 @@ import ( ...@@ -45,9 +45,9 @@ import (
var deviceSubscribeCmd = &cobra.Command{ var deviceSubscribeCmd = &cobra.Command{
Use: "subscribe [uuid] [path]", Use: "subscribe [uuid] [path]",
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
Short: "do", Short: "Subscribes to paths of a provided device with fixed subscribe options",
Long: `Requests a path from a specified orchestrated network device on the controller. Long: `Requests a subscription on paths from a specified orchestrated network device on the controller.
The device UUID and request path must be specified as a positional arguments.`, The device UUID and requested paths must be specified as a positional arguments.`,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
did, err := uuid.Parse(args[0]) did, err := uuid.Parse(args[0])
......
...@@ -90,7 +90,13 @@ func handleSubscribeResponse(resp *gpb.SubscribeResponse, pndID, deviceID, devic ...@@ -90,7 +90,13 @@ func handleSubscribeResponse(resp *gpb.SubscribeResponse, pndID, deviceID, devic
}) })
} }
case *gpb.SubscribeResponse_Update: 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"}}} //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())
}
...@@ -1219,22 +1219,23 @@ func Test_pndImplementation_SubscribePath(t *testing.T) { ...@@ -1219,22 +1219,23 @@ func Test_pndImplementation_SubscribePath(t *testing.T) {
args args args args
wantErr bool wantErr bool
}{ }{
{ //TODO(faseid): Implement proper test here!
name: "default", // {
args: args{ // name: "default",
uuid: did, // args: args{
subList: &ppb.SubscriptionList{ // uuid: did,
Subscription: []*ppb.Subscription{ // subList: &ppb.SubscriptionList{
{ // Subscription: []*ppb.Subscription{
Path: "", // {
StreamMode: ppb.StreamMode_STREAM_MODE_SAMPLE, // Path: "",
SampleInterval: 1000000000, // 1 second // StreamMode: ppb.StreamMode_STREAM_MODE_SAMPLE,
}, // SampleInterval: 1000000000, // 1 second
}, // },
Mode: ppb.SubscriptionMode_SUBSCRIPTION_MODE_STREAM, // },
}, // Mode: ppb.SubscriptionMode_SUBSCRIPTION_MODE_STREAM,
}, // },
}, // },
// },
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment