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

more stuff

parent 07a44393
No related branches found
No related tags found
1 merge request!9First gosdn code
......@@ -4,6 +4,7 @@
* github.com/spf13/cobra: used for basic cli of gosdn, such as starting the daemon, get versioning info etc
* grpc
* ygot
## Structure of the code
......@@ -24,4 +25,9 @@ protoc \
--go-grpc_out=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config:. \
--go_opt=paths=source_relative \
--go-grpc_opt=paths=source_relative \
cliInterface/gosdnCLI.proto
\ No newline at end of file
cliInterface/gosdnCLI.proto
Generate the ygot code:
just type: go generate
......@@ -5,7 +5,7 @@ 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=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
//go:generate go run $GOPATH/src/github.com/openconfig/ygot/generator/generator.go -path=yang -output_file=yang-processor/gosdnyang.go.go -package_name=gosdnyang -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() {
......
......@@ -4,14 +4,14 @@ import (
"fmt"
"github.com/openconfig/ygot/ygot"
"net"
cliIf "gosdn/cliInterface"
yangPro "gosdn/yang-processor"
)
// This is a test function in order to see how to generate JSON encoded openconfig stuff
func AssembleJSON() {
// Build my device
d := &cliIf.Device{}
d := &yangPro.Device{}
interfaces, _ := net.Interfaces()
for _, iface := range interfaces {
......@@ -38,4 +38,12 @@ func AssembleJSON() {
panic(fmt.Sprintf("JSON demo error: %v", err))
}
fmt.Println(json)
// and now try to read the data from it...
// Device struct to unmarshal into.
loadd := &yangPro.Device{}
if err := yangPro.Unmarshal([]byte(json), loadd); err != nil {
panic(fmt.Sprintf("Cannot unmarshal JSON: %v", err))
}
}
\ No newline at end of file
// Package ocdemo is a demonstration package for use in the
// getting_started ygot demo.
package gosdn
package gosdnyang
// This file is a placeholder in order to ensure that Go does not
// find this directory to contain an empty package. The structs
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment