Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
07a44393
Commit
07a44393
authored
4 years ago
by
Martin Stiemerling
Browse files
Options
Downloads
Patches
Plain Diff
Looks ok for a start but not close to perfect
parent
fa53225c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!9
First gosdn code
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
main.go
+1
-2
1 addition, 2 deletions
main.go
nucleus/controller.go
+7
-5
7 additions, 5 deletions
nucleus/controller.go
nucleus/nucleus-core.go
+9
-4
9 additions, 4 deletions
nucleus/nucleus-core.go
nucleus/root.go
+1
-1
1 addition, 1 deletion
nucleus/root.go
with
18 additions
and
12 deletions
main.go
+
1
−
2
View file @
07a44393
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
nucleus/controller.go
+
7
−
5
View file @
07a44393
...
@@ -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
This diff is collapsed.
Click to expand it.
nucleus/nucleus-core.go
+
9
−
4
View file @
07a44393
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
nucleus/root.go
+
1
−
1
View file @
07a44393
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment