Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gNMI Target
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
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
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
gNMI Target
Commits
078bab5a
Verified
Commit
078bab5a
authored
1 year ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
0647c88b
Branches
renovate/go-golang.org/x/crypto-vulnerability
No related tags found
No related merge requests found
Pipeline
#189015
failed
1 year ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
handler/handler.go
+4
-4
4 additions, 4 deletions
handler/handler.go
internal/gnmiserver/server.go
+16
-11
16 additions, 11 deletions
internal/gnmiserver/server.go
internal/gnmiserver/subscribe.go
+6
-0
6 additions, 0 deletions
internal/gnmiserver/subscribe.go
with
26 additions
and
15 deletions
handler/handler.go
+
4
−
4
View file @
078bab5a
...
...
@@ -19,23 +19,23 @@ type Config struct {
}
func
(
c
*
Config
)
Lock
()
{
logrus
.
Debug
(
"Lock config"
)
c
.
mu
.
Lock
()
logrus
.
Debug
(
"Lock config"
)
}
func
(
c
*
Config
)
Unlock
()
{
logrus
.
Debug
(
"Unlock config"
)
c
.
mu
.
Unlock
()
logrus
.
Debug
(
"Unlock config"
)
}
func
(
c
*
Config
)
RLock
()
{
logrus
.
Debug
(
"RLock config"
)
c
.
mu
.
RLock
()
logrus
.
Debug
(
"RLock config"
)
}
func
(
c
*
Config
)
RUnlock
()
{
logrus
.
Debug
(
"RUnlock config"
)
c
.
mu
.
RUnlock
()
logrus
.
Debug
(
"RUnlock config"
)
}
// PathHandler handles configuration changes and adjusts the targets config
...
...
This diff is collapsed.
Click to expand it.
internal/gnmiserver/server.go
+
16
−
11
View file @
078bab5a
...
...
@@ -337,22 +337,26 @@ func (s *Server) doReplaceOrUpdate(jsonTree map[string]interface{}, op pb.Update
switch
node
:=
curNode
.
(
type
)
{
case
map
[
string
]
interface
{}
:
// Set node value.
if
i
==
len
(
fullPath
.
Elem
)
-
1
{
if
elem
.
GetKey
()
==
nil
{
if
grpcStatusError
:=
setPathWithoutAttribute
(
op
,
node
,
elem
,
nodeVal
);
grpcStatusError
!=
nil
{
if
node
!=
nil
{
if
i
==
len
(
fullPath
.
Elem
)
-
1
{
if
elem
.
GetKey
()
==
nil
{
if
grpcStatusError
:=
setPathWithoutAttribute
(
op
,
node
,
elem
,
nodeVal
);
grpcStatusError
!=
nil
{
return
nil
,
grpcStatusError
}
break
}
if
grpcStatusError
:=
setPathWithAttribute
(
op
,
node
,
elem
,
nodeVal
);
grpcStatusError
!=
nil
{
return
nil
,
grpcStatusError
}
break
}
if
grpcStatusError
:=
setPathWithAttribute
(
op
,
node
,
elem
,
nodeVal
);
grpcStatusError
!=
nil
{
return
nil
,
grpcStatusError
}
break
}
logrus
.
Info
(
"doReplaceOrUpdate, node: "
,
node
)
if
curNode
,
schema
=
getChildNode
(
node
,
schema
,
elem
,
true
);
curNode
==
nil
{
return
nil
,
status
.
Errorf
(
codes
.
NotFound
,
"path elem not found: %v"
,
elem
)
logrus
.
Debug
(
"doReplaceOrUpdate, node: "
,
node
)
if
curNode
,
schema
=
getChildNode
(
node
,
schema
,
elem
,
true
);
curNode
==
nil
{
return
nil
,
status
.
Errorf
(
codes
.
NotFound
,
"path elem not found: %v"
,
elem
)
}
}
else
{
logrus
.
Debugf
(
"node is nil for path elem: %s"
,
elem
.
String
())
}
case
[]
interface
{}
:
return
nil
,
status
.
Errorf
(
codes
.
NotFound
,
"incompatible path elem: %v"
,
elem
)
...
...
@@ -687,6 +691,7 @@ func (s *Server) Set(ctx context.Context, req *pb.SetRequest) (*pb.SetResponse,
s
.
config
.
Lock
()
defer
s
.
config
.
Unlock
()
logrus
.
Debug
(
"Current data: "
,
s
.
config
.
Data
)
// Obtain current configuration as JSON
jsonTree
,
err
:=
ygot
.
ConstructIETFJSON
(
s
.
config
.
Data
,
&
ygot
.
RFC7951JSONConfig
{})
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
internal/gnmiserver/subscribe.go
+
6
−
0
View file @
078bab5a
...
...
@@ -37,9 +37,12 @@ func (s *Server) Subscribe(stream gnmi.GNMI_SubscribeServer) error {
// NOTE: Using ytypes.GetNode might not be the best solution to
// check if a given path exists. Since we do not really care about
// the node at all in this case.
s
.
config
.
RLock
()
if
_
,
err
:=
ytypes
.
GetNode
(
s
.
model
.
schemaTreeRoot
,
s
.
config
.
Data
,
sub
.
GetPath
());
err
!=
nil
{
s
.
config
.
RUnlock
()
return
status
.
Error
(
codes
.
Internal
,
fmt
.
Sprintf
(
"The provided path: %s, does not exist, subscribe not possible."
,
path
.
String
()))
}
s
.
config
.
RUnlock
()
// Print the path a subscription is requested for.
log
.
Infof
(
"Received subscribe for gnmi path %s with mode %s"
,
path
.
String
(),
subscriptions
.
GetMode
()
.
String
())
...
...
@@ -112,11 +115,14 @@ func (s *Server) streamOnChangeSubscriptionHandler(notificationSubscriber *notif
log
.
Error
(
err
)
return
}
s
.
config
.
RLock
()
node
,
err
:=
ytypes
.
GetNode
(
s
.
model
.
schemaTreeRoot
,
s
.
config
.
Data
,
path
)
if
err
!=
nil
{
s
.
config
.
RUnlock
()
log
.
Error
(
err
)
return
}
s
.
config
.
RUnlock
()
var
notifications
[]
*
gnmi
.
Notification
if
node
[
0
]
.
Schema
.
IsLeaf
()
{
...
...
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