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

fix adding subscriptions

parent 397f5cb7
No related branches found
No related tags found
No related merge requests found
Pipeline #234039 passed
...@@ -46,10 +46,10 @@ var subAddCmd = &cobra.Command{ ...@@ -46,10 +46,10 @@ var subAddCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
spinner, _ := pterm.DefaultSpinner.Start("Adding subscription") spinner, _ := pterm.DefaultSpinner.Start("Adding subscription")
// TODO: add option to provide sub options?? // Note: Currently, doesn't support providing options/paths.
_, err := api.Add(createContextWithAuthorization(), viper.GetString("controllerAPIEndpoint"), mneUUID, nil) _, err := api.Add(createContextWithAuthorization(), viper.GetString("controllerAPIEndpoint"), mneUUID, nil)
if err != nil { if err != nil {
pterm.Error.Println(err) spinner.Fail(err)
return return
} }
spinner.Success() spinner.Success()
......
...@@ -138,22 +138,26 @@ func (s *SubManagementServer) Add(ctx context.Context, request *subpb.AddRequest ...@@ -138,22 +138,26 @@ func (s *SubManagementServer) Add(ctx context.Context, request *subpb.AddRequest
}, err }, err
} }
var paths [][]string var gNMISubScribeOptions *gnmi.SubscribeOptions
for _, path := range request.Subscription.Paths { if request.Subscription != nil {
var elems []string var paths [][]string
for _, elem := range path.Elem { for _, path := range request.Subscription.Paths {
elems = append(elems, elem) var elems []string
for _, elem := range path.Elem {
elems = append(elems, elem)
}
paths = append(paths, elems)
} }
paths = append(paths, elems) gNMISubScribeOptions = &gnmi.SubscribeOptions{
}
err = s.networkElementWatchter.SubscribeToNetworkElementWithID(mneID,
&gnmi.SubscribeOptions{
Mode: request.Subscription.SubscribeOptions.GnmiMode, Mode: request.Subscription.SubscribeOptions.GnmiMode,
StreamMode: request.Subscription.SubscribeOptions.GnmiStreamMode, StreamMode: request.Subscription.SubscribeOptions.GnmiStreamMode,
SampleInterval: request.Subscription.SubscribeOptions.SampleInterval, SampleInterval: request.Subscription.SubscribeOptions.SampleInterval,
Paths: paths, Paths: paths,
}, }
}
err = s.networkElementWatchter.SubscribeToNetworkElementWithID(mneID,
gNMISubScribeOptions,
) )
if err != nil { if err != nil {
return &subpb.AddResponse{ return &subpb.AddResponse{
......
...@@ -108,6 +108,14 @@ func (n *NetworkElementWatcher) SubscribeToNetworkElement(mne networkelement.Net ...@@ -108,6 +108,14 @@ func (n *NetworkElementWatcher) SubscribeToNetworkElement(mne networkelement.Net
// SubscribeToNetworkElementWithID subscribes to the network element matching the provided ID according to provided SubscribeOptions. // SubscribeToNetworkElementWithID subscribes to the network element matching the provided ID according to provided SubscribeOptions.
// SubscribeOptions can be nil. Use nil for a fixed, pre-defined set of gNMI subscription options (streaming in sample mode each second). // SubscribeOptions can be nil. Use nil for a fixed, pre-defined set of gNMI subscription options (streaming in sample mode each second).
func (n *NetworkElementWatcher) SubscribeToNetworkElementWithID(mneID uuid.UUID, opts *gnmi.SubscribeOptions) error { func (n *NetworkElementWatcher) SubscribeToNetworkElementWithID(mneID uuid.UUID, opts *gnmi.SubscribeOptions) error {
if opts == nil {
opts = &gnmi.SubscribeOptions{
Mode: gNMISubscribeMode,
StreamMode: gNMIStreamMode,
SampleInterval: subscribeSampleInterval,
}
}
mne, err := n.mneService.Get(store.Query{ID: mneID}) mne, err := n.mneService.Get(store.Query{ID: mneID})
if err != nil { if err != nil {
log.Error(err) log.Error(err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment