Skip to content
Snippets Groups Projects
Commit 07a44393 authored by Martin Stiemerling's avatar Martin Stiemerling
Browse files

Looks ok for a start but not close to perfect

parent fa53225c
Branches
Tags
1 merge request!9First gosdn code
...@@ -5,10 +5,9 @@ import ( ...@@ -5,10 +5,9 @@ import (
) )
// Generate the code out of the yang modules // Generate the code out of the yang modules
//go:generate go run $GOPATH/src/github.com/openconfig/ygot/generator/generator.go -path=yang -output_file=goSDN/goSDNgo.go -package_name=gosdn -generate_fakeroot -fakeroot_name=device -compress_paths=true -shorten_enum_leaf_names -exclude_modules=ietf-interfaces yang/openconfig-interfaces.yang yang/openconfig-if-ip.yang //go:generate go run $GOPATH/src/github.com/openconfig/ygot/generator/generator.go -path=yang -output_file=cliInterface/cliInterface.go -package_name=cliInterface -generate_fakeroot -fakeroot_name=device -compress_paths=true -shorten_enum_leaf_names -exclude_modules=ietf-interfaces yang/openconfig-interfaces.yang yang/openconfig-if-ip.yang
func main() { func main() {
println("This is the network superintendent...")
// hand off to cmd for further processing // hand off to cmd for further processing
nucleus.Execute() nucleus.Execute()
......
...@@ -2,29 +2,31 @@ package nucleus ...@@ -2,29 +2,31 @@ package nucleus
import ( import (
"fmt" "fmt"
"github.com/openconfig/ygot/ygot"
"net" "net"
cliIf "gosdn/cliInterface"
) )
// This is a test function in order to see how to generate JSON encoded openconfig stuff
func AssembleJSON() { func AssembleJSON() {
// Build my device // Build my device
//d := &gosdn.Device{} d := &cliIf.Device{}
interfaces, _ := net.Interfaces() interfaces, _ := net.Interfaces()
for _, iface := range interfaces { for _, iface := range interfaces {
fmt.Println(iface.Name) fmt.Println(iface.Name)
/*
i, err := d.NewInterface(iface.Name) i, err := d.NewInterface(iface.Name)
if err != nil { if err != nil {
panic(err) panic(err)
} }
i.Mtu = ygot.Uint16(234) i.Mtu = ygot.Uint16(234)
//i.Mtu = ygot.Uint16(iface.MTU) //i.Mtu = ygot.Uint16(iface.MTU)
*/
} }
// EmitJSON from the ygot library directly does .Validate() and outputs JSON in // EmitJSON from the ygot library directly does .Validate() and outputs JSON in
// the specified format. // the specified format.
/*
json, err := ygot.EmitJSON(d, &ygot.EmitJSONConfig{ json, err := ygot.EmitJSON(d, &ygot.EmitJSONConfig{
Format: ygot.RFC7951, Format: ygot.RFC7951,
Indent: " ", Indent: " ",
...@@ -35,5 +37,5 @@ func AssembleJSON() { ...@@ -35,5 +37,5 @@ func AssembleJSON() {
if err != nil { if err != nil {
panic(fmt.Sprintf("JSON demo error: %v", err)) panic(fmt.Sprintf("JSON demo error: %v", err))
} }
fmt.Println(json)*/ fmt.Println(json)
} }
\ No newline at end of file
...@@ -52,13 +52,12 @@ func getCLIGoing() { ...@@ -52,13 +52,12 @@ func getCLIGoing() {
func StartUp() { func StartUp() {
log.Println ("This is the network superintendent...")
log.Println("Starting my ducks") log.Println("Starting my ducks")
// Start the GRCP CLI
go getCLIGoing() go getCLIGoing()
AssembleJSON()
log.Println("and ready for take off") log.Println("and ready for take off")
} }
/* /*
...@@ -69,6 +68,12 @@ func StartUp() { ...@@ -69,6 +68,12 @@ func StartUp() {
func Run() { func Run() {
isRunning := true isRunning := true
// Test ygot
AssembleJSON()
for isRunning { for isRunning {
time.Sleep(10*time.Second) time.Sleep(10*time.Second)
isRunning = false isRunning = false
......
...@@ -21,7 +21,7 @@ var versionCmd = &cobra.Command{ ...@@ -21,7 +21,7 @@ var versionCmd = &cobra.Command{
} }
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "beachhead", Use: "goSDN",
Short: "A yet still incomplete attempt to build an network operating system, but...:-)", Short: "A yet still incomplete attempt to build an network operating system, but...:-)",
Long: "Incomplete network operating system. Complete documentation is available at XXX", Long: "Incomplete network operating system. Complete documentation is available at XXX",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment