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
3a906b3b
Commit
3a906b3b
authored
4 years ago
by
Manuel Kieweg
Browse files
Options
Downloads
Patches
Plain Diff
export ParseSchema
parent
8a11ab6e
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!95
path traversal library
,
!91
"Overhaul Architecture"
,
!90
Develop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/path-traversal/path_traversal.go
+6
-9
6 additions, 9 deletions
cmd/path-traversal/path_traversal.go
nucleus/util/path_traversal.go
+15
-2
15 additions, 2 deletions
nucleus/util/path_traversal.go
with
21 additions
and
11 deletions
cmd/path-traversal/path_traversal.go
+
6
−
9
View file @
3a906b3b
...
...
@@ -2,20 +2,17 @@ package main
import
(
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util"
schema
"code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"code.fbi.h-da.de/cocsn/yang-models/generated/arista"
)
func
main
()
{
tree
:=
schem
a
.
Schema
Tree
schema
,
_
:=
arist
a
.
Schema
()
paths
:=
util
.
NewPaths
()
for
_
,
v
:=
range
tree
{
if
v
.
Parent
!=
nil
{
if
v
.
Parent
.
Name
==
"device"
{
pathElement
:=
paths
.
ProcessEntry
(
v
)
pathElement
.
Print
()
}
}
paths
.
ParseSchema
(
schema
,
"device"
)
for
_
,
v
:=
range
paths
{
v
.
Print
()
}
}
This diff is collapsed.
Click to expand it.
nucleus/util/path_traversal.go
+
15
−
2
View file @
3a906b3b
...
...
@@ -3,6 +3,7 @@ package util
import
(
"fmt"
"github.com/openconfig/goyang/pkg/yang"
"github.com/openconfig/ygot/ytypes"
)
type
PathElement
struct
{
...
...
@@ -32,7 +33,7 @@ func NewPaths() Paths {
type
Paths
map
[
string
]
*
PathElement
func
(
p
Paths
)
P
rocessEntry
(
e
*
yang
.
Entry
)
*
PathElement
{
func
(
p
Paths
)
p
rocessEntry
(
e
*
yang
.
Entry
)
*
PathElement
{
if
e
.
Dir
!=
nil
{
elem
:=
&
PathElement
{
Children
:
make
([]
*
PathElement
,
len
(
e
.
Dir
)),
...
...
@@ -40,7 +41,7 @@ func (p Paths)ProcessEntry(e *yang.Entry) *PathElement {
}
i
:=
0
for
_
,
v
:=
range
e
.
Dir
{
elem
.
Children
[
i
]
=
p
.
P
rocessEntry
(
v
)
elem
.
Children
[
i
]
=
p
.
p
rocessEntry
(
v
)
i
++
}
p
[
e
.
Name
]
=
elem
...
...
@@ -50,4 +51,16 @@ func (p Paths)ProcessEntry(e *yang.Entry) *PathElement {
Name
:
e
.
Name
,
}
return
leaf
}
func
(
p
Paths
)
ParseSchema
(
schema
*
ytypes
.
Schema
,
root
string
)
error
{
tree
:=
schema
.
SchemaTree
for
_
,
v
:=
range
tree
{
if
v
.
Parent
!=
nil
{
if
v
.
Parent
.
Name
==
root
{
p
.
processEntry
(
v
)
}
}
}
return
nil
}
\ No newline at end of file
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