Skip to content
Snippets Groups Projects
Commit 7f4d2e92 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

added path traversal demo

parent 567685a5
Branches
Tags
2 merge requests!91"Overhaul Architecture",!90Develop
Pipeline #60770 passed with warnings
This commit is part of merge request !91. Comments created here will be created in the context of that merge request.
package main
import (
schema "code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"fmt"
"github.com/openconfig/goyang/pkg/yang"
)
type PathElement struct {
Children []*PathElement
Name string
}
func (p *PathElement)Print() {
printPE(0, p)
}
func printPE(indent int, pe *PathElement) {
for i := 0; i < indent; i++ {
fmt.Print(" ")
}
fmt.Println(pe.Name)
if len(pe.Children) > 0 {
for _,p := range pe.Children {
printPE(indent+1, p)
}
}
}
func main() {
tree := schema.SchemaTree
paths := make(map[string]*PathElement)
for k,v := range tree {
if v.Parent != nil {
if v.Parent.Name == "device" {
pathElement := processEntry(v)
pathElement.Print()
paths[k] = pathElement
}
}
}
}
func processEntry(e *yang.Entry) *PathElement {
if e.Dir != nil {
elem := &PathElement{
Children: make([]*PathElement, len(e.Dir)),
Name: e.Name,
}
i := 0
for _,v := range e.Dir {
elem.Children[i] = processEntry(v)
i++
}
return elem
}
leaf := &PathElement{
Name: e.Name,
}
return leaf
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ go 1.14
require (
code.fbi.h-da.de/cocsn/swagger/apis v0.0.0-20200924152423-61030cab7b88
code.fbi.h-da.de/cocsn/yang-models v0.0.3
code.fbi.h-da.de/cocsn/yang-models v0.0.4
github.com/aristanetworks/goarista v0.0.0-20201120222254-94a892eb0c6a
github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591
github.com/go-openapi/runtime v0.19.22
......@@ -14,6 +14,7 @@ require (
github.com/google/uuid v1.1.2
github.com/neo4j/neo4j-go-driver v1.8.3
github.com/openconfig/gnmi v0.0.0-20200617225440-d2b4e6a45802
github.com/openconfig/goyang v0.2.2
github.com/openconfig/reference v0.0.0-20190727015836-8dfd928c9696
github.com/openconfig/ygot v0.10.0
github.com/rivo/tview v0.0.0-20201018122409-d551c850a743
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment