Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
98c85cce
Commit
98c85cce
authored
9 months ago
by
Fabian Seidl
Browse files
Options
Downloads
Patches
Plain Diff
change way paths/opts are provided for subscriptions
parent
05a8db89
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controller/northbound/server/submanagement.go
+1
-3
1 addition, 3 deletions
controller/northbound/server/submanagement.go
controller/nucleus/networkElementWatcher.go
+25
-5
25 additions, 5 deletions
controller/nucleus/networkElementWatcher.go
with
26 additions
and
8 deletions
controller/northbound/server/submanagement.go
+
1
−
3
View file @
98c85cce
...
@@ -27,8 +27,7 @@ func (s *SubManagementServer) ResetAllSubscriptions(ctx context.Context, request
...
@@ -27,8 +27,7 @@ func (s *SubManagementServer) ResetAllSubscriptions(ctx context.Context, request
s
.
networkElementWatchter
.
StopAndRemoveAllNetworkElementSubscriptions
()
s
.
networkElementWatchter
.
StopAndRemoveAllNetworkElementSubscriptions
()
// Requires some rework of current way how paths/options are provided to the watcher.
s
.
networkElementWatchter
.
SubscribeToNetworkElements
(
subscriptions
)
s
.
networkElementWatchter
.
SubscribeToNetworkElements
(
subscriptions
[
0
]
.
Opts
)
return
&
subpb
.
ResetAllSubscriptionsResponse
{
return
&
subpb
.
ResetAllSubscriptionsResponse
{
Timestamp
:
time
.
Now
()
.
UnixNano
(),
Timestamp
:
time
.
Now
()
.
UnixNano
(),
...
@@ -42,7 +41,6 @@ func (s *SubManagementServer) GetAll(ctx context.Context, request *subpb.GetAllR
...
@@ -42,7 +41,6 @@ func (s *SubManagementServer) GetAll(ctx context.Context, request *subpb.GetAllR
subInfosToReturn
:=
make
([]
*
subpb
.
Subscription
,
0
)
subInfosToReturn
:=
make
([]
*
subpb
.
Subscription
,
0
)
for
_
,
info
:=
range
subInfos
{
for
_
,
info
:=
range
subInfos
{
tmpPaths
:=
make
([]
*
subpb
.
Path
,
0
)
tmpPaths
:=
make
([]
*
subpb
.
Path
,
0
)
for
_
,
path
:=
range
info
.
Opts
.
Paths
{
for
_
,
path
:=
range
info
.
Opts
.
Paths
{
tmpPaths
=
append
(
tmpPaths
,
&
subpb
.
Path
{
tmpPaths
=
append
(
tmpPaths
,
&
subpb
.
Path
{
...
...
This diff is collapsed.
Click to expand it.
controller/nucleus/networkElementWatcher.go
+
25
−
5
View file @
98c85cce
...
@@ -60,9 +60,10 @@ func NewNetworkElementWatcher(mneService networkelement.Service, eventService ev
...
@@ -60,9 +60,10 @@ func NewNetworkElementWatcher(mneService networkelement.Service, eventService ev
// SubscribeToNetworkElements subscribes to every available network element in each network domain according to provided SubscribeOptions.
// SubscribeToNetworkElements subscribes to every available network element in each network domain 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
)
SubscribeToNetworkElements
(
opts
*
gnmi
.
SubscribeOptions
)
{
func
(
n
*
NetworkElementWatcher
)
SubscribeToNetworkElements
(
subScriptionInfos
[]
*
networkelementSubscriptionHelper
)
{
if
opts
==
nil
{
var
tmpOpts
*
gnmi
.
SubscribeOptions
opts
=
&
gnmi
.
SubscribeOptions
{
if
len
(
subScriptionInfos
)
==
0
{
tmpOpts
=
&
gnmi
.
SubscribeOptions
{
Mode
:
gNMISubscribeMode
,
Mode
:
gNMISubscribeMode
,
StreamMode
:
gNMIStreamMode
,
StreamMode
:
gNMIStreamMode
,
SampleInterval
:
subscribeSampleInterval
,
SampleInterval
:
subscribeSampleInterval
,
...
@@ -76,7 +77,15 @@ func (n *NetworkElementWatcher) SubscribeToNetworkElements(opts *gnmi.SubscribeO
...
@@ -76,7 +77,15 @@ func (n *NetworkElementWatcher) SubscribeToNetworkElements(opts *gnmi.SubscribeO
}
}
for
_
,
mne
:=
range
mnes
{
for
_
,
mne
:=
range
mnes
{
n
.
subscribeToNetworkElement
(
mne
,
opts
)
if
len
(
subScriptionInfos
)
>
0
{
tmpOpts
,
err
=
getOptionsForMne
(
mne
.
ID
()
.
String
(),
subScriptionInfos
)
if
err
!=
nil
{
log
.
Infof
(
"Couldn't find options for mne %s, reason: %v.
\n
Skipping subscription."
,
mne
.
Name
(),
err
)
continue
}
}
n
.
subscribeToNetworkElement
(
mne
,
tmpOpts
)
}
}
}
}
...
@@ -141,7 +150,6 @@ func (n *NetworkElementWatcher) callSubscribe(stopContext context.Context, mne n
...
@@ -141,7 +150,6 @@ func (n *NetworkElementWatcher) callSubscribe(stopContext context.Context, mne n
}
}
func
(
n
*
NetworkElementWatcher
)
addToNetworkElementSubscriptions
(
subID
uuid
.
UUID
,
devSub
*
networkelementSubscriptionHelper
)
{
func
(
n
*
NetworkElementWatcher
)
addToNetworkElementSubscriptions
(
subID
uuid
.
UUID
,
devSub
*
networkelementSubscriptionHelper
)
{
//TODO: improve handling of subscriptions, like be able to expose to apps so specific subscriptions instead of only all can be stopped in the future
n
.
networkelementSubcriptions
[
subID
]
=
devSub
n
.
networkelementSubcriptions
[
subID
]
=
devSub
}
}
...
@@ -262,3 +270,15 @@ func (n *NetworkElementWatcher) GetSubscriptionInformations(subID uuid.UUID) (*n
...
@@ -262,3 +270,15 @@ func (n *NetworkElementWatcher) GetSubscriptionInformations(subID uuid.UUID) (*n
return
information
,
nil
return
information
,
nil
}
}
// getOptionsForMne checks if there is a match of the mneID with all the mne IDs provided in the slice of subscription
// information and returns the related subscribe options or an error.
func
getOptionsForMne
(
mneID
string
,
subInfos
[]
*
networkelementSubscriptionHelper
)
(
*
gnmi
.
SubscribeOptions
,
error
)
{
for
_
,
subInfo
:=
range
subInfos
{
if
subInfo
.
MneID
==
mneID
{
return
subInfo
.
Opts
,
nil
}
}
return
nil
,
fmt
.
Errorf
(
"error: did not find subscription infos matching to provided mne ID: %s"
,
mneID
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment