Skip to content
Snippets Groups Projects

"Overhaul Architecture"

Merged Ghost User requested to merge 67-overhaul-architecture into develop
3 files
+ 66
1
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 62
0
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
Loading