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

fix adding subscriptions

parent 1856c2c0
Branches
No related tags found
No related merge requests found
Pipeline #228785 passed
This commit is part of merge request !1080. Comments created here will be created in the context of that merge request.
...@@ -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,6 +138,8 @@ func (s *SubManagementServer) Add(ctx context.Context, request *subpb.AddRequest ...@@ -138,6 +138,8 @@ func (s *SubManagementServer) Add(ctx context.Context, request *subpb.AddRequest
}, err }, err
} }
var gNMISubScribeOptions *gnmi.SubscribeOptions
if request.Subscription != nil {
var paths [][]string var paths [][]string
for _, path := range request.Subscription.Paths { for _, path := range request.Subscription.Paths {
var elems []string var elems []string
...@@ -146,14 +148,16 @@ func (s *SubManagementServer) Add(ctx context.Context, request *subpb.AddRequest ...@@ -146,14 +148,16 @@ func (s *SubManagementServer) Add(ctx context.Context, request *subpb.AddRequest
} }
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