From 07a44393e581e0191e02685505e79725c951bed5 Mon Sep 17 00:00:00 2001
From: Martin Stiemerling <mls.ietf@gmail.com>
Date: Fri, 18 Sep 2020 16:10:55 +0200
Subject: [PATCH] Looks ok for a start but not close to perfect

---
 main.go                 |  3 +--
 nucleus/controller.go   | 12 +++++++-----
 nucleus/nucleus-core.go | 13 +++++++++----
 nucleus/root.go         |  2 +-
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/main.go b/main.go
index 088523b32..080ba4e69 100644
--- a/main.go
+++ b/main.go
@@ -5,10 +5,9 @@ import (
 )
 
 // 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() {
-	println("This is the network superintendent...")
 
 	// hand off to cmd for further processing
 	nucleus.Execute()
diff --git a/nucleus/controller.go b/nucleus/controller.go
index b35703203..cf30cc842 100644
--- a/nucleus/controller.go
+++ b/nucleus/controller.go
@@ -2,29 +2,31 @@ package nucleus
 
 import (
 	"fmt"
+	"github.com/openconfig/ygot/ygot"
 	"net"
+	cliIf "gosdn/cliInterface"
 )
 
+// This is a test function in order to see how to generate JSON encoded openconfig stuff
+
 func AssembleJSON() {
 	// Build my device
-	//d := &gosdn.Device{}
+	d := &cliIf.Device{}
 
 	interfaces, _ := net.Interfaces()
 	for _, iface := range interfaces {
 		fmt.Println(iface.Name)
-/*
+
 		i, err := d.NewInterface(iface.Name)
 		if err != nil {
 			panic(err)
 		}
 		i.Mtu = ygot.Uint16(234)
 		//i.Mtu = ygot.Uint16(iface.MTU)
- */
 	}
 
 	// EmitJSON from the ygot library directly does .Validate() and outputs JSON in
 	// the specified format.
-	/*
 	json, err := ygot.EmitJSON(d, &ygot.EmitJSONConfig{
 		Format: ygot.RFC7951,
 		Indent: "  ",
@@ -35,5 +37,5 @@ func AssembleJSON() {
 	if err != nil {
 		panic(fmt.Sprintf("JSON demo error: %v", err))
 	}
-	fmt.Println(json)*/
+	fmt.Println(json)
 }
\ No newline at end of file
diff --git a/nucleus/nucleus-core.go b/nucleus/nucleus-core.go
index 2b4de231c..e7f60b1d0 100644
--- a/nucleus/nucleus-core.go
+++ b/nucleus/nucleus-core.go
@@ -52,13 +52,12 @@ func getCLIGoing() {
 
 func StartUp() {
 
+	log.Println ("This is the network superintendent...")
 	log.Println("Starting my ducks")
+	// Start the GRCP CLI
 	go getCLIGoing()
-
-	AssembleJSON()
-
-
 	log.Println("and ready for take off")
+
 }
 
 /*
@@ -69,6 +68,12 @@ func StartUp() {
 func Run() {
 	isRunning := true
 
+
+	// Test ygot
+	AssembleJSON()
+
+
+
 	for isRunning {
 		time.Sleep(10*time.Second)
 		isRunning = false
diff --git a/nucleus/root.go b/nucleus/root.go
index acb8fff77..c934fa710 100644
--- a/nucleus/root.go
+++ b/nucleus/root.go
@@ -21,7 +21,7 @@ var versionCmd = &cobra.Command{
 }
 
 var rootCmd = &cobra.Command{
-	Use:   "beachhead",
+	Use:   "goSDN",
 	Short: "A yet still incomplete attempt to build an network operating system, but...:-)",
 	Long: "Incomplete network operating system. Complete documentation is available at XXX",
 	Run: func(cmd *cobra.Command, args []string) {
-- 
GitLab