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
28b0f2c9
Commit
28b0f2c9
authored
4 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
added functions to retrieve instances of sbis
parent
b2efd44b
No related branches found
No related tags found
3 merge requests
!97
Resolve "PND handling via CLI and database"
,
!91
"Overhaul Architecture"
,
!90
Develop
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
nucleus/controller.go
+4
-3
4 additions, 3 deletions
nucleus/controller.go
nucleus/device.go
+0
-1
0 additions, 1 deletion
nucleus/device.go
nucleus/json_Helper.go
+2
-4
2 additions, 4 deletions
nucleus/json_Helper.go
nucleus/southbound.go
+36
-11
36 additions, 11 deletions
nucleus/southbound.go
with
42 additions
and
19 deletions
nucleus/controller.go
+
4
−
3
View file @
28b0f2c9
...
@@ -79,9 +79,10 @@ func (c *Core) UnMarshallPNDs() error {
...
@@ -79,9 +79,10 @@ func (c *Core) UnMarshallPNDs() error {
// CreateSouthboundInterfaces initializes the controller with his SBIs
// CreateSouthboundInterfaces initializes the controller with his SBIs
func
(
c
*
Core
)
CreateSouthboundInterfaces
()
{
func
(
c
*
Core
)
CreateSouthboundInterfaces
()
{
if
len
(
c
.
southboundInterfaces
)
==
0
{
if
len
(
c
.
southboundInterfaces
)
==
0
{
sbi
:=
&
AristaOC
{}
arista
:=
GetAristaOCInstance
()
sbi
.
SetDefaults
()
c
.
southboundInterfaces
[
arista
.
SbiIdentifier
()]
=
arista
c
.
southboundInterfaces
[
sbi
.
SbiIdentifier
()]
=
sbi
openconfig
:=
GetOpenconfigInstance
()
c
.
southboundInterfaces
[
openconfig
.
SbiIdentifier
()]
=
openconfig
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
nucleus/device.go
+
0
−
1
View file @
28b0f2c9
...
@@ -42,7 +42,6 @@ func (d *Device) UnmarshalJSON(b []byte) error {
...
@@ -42,7 +42,6 @@ func (d *Device) UnmarshalJSON(b []byte) error {
},
},
Transport
:
nil
,
Transport
:
nil
,
}
}
device
.
SBI
.
SetDefaults
()
device
.
Transport
=
device
.
SBI
.
GetTransport
()
device
.
Transport
=
device
.
SBI
.
GetTransport
()
device
.
Device
=
device
.
SBI
.
Schema
()
.
Root
device
.
Device
=
device
.
SBI
.
Schema
()
.
Root
...
...
This diff is collapsed.
Click to expand it.
nucleus/json_Helper.go
+
2
−
4
View file @
28b0f2c9
...
@@ -48,12 +48,10 @@ func getSouthboundInterfaceFromJSONMap(m map[string]interface{}) SouthboundInter
...
@@ -48,12 +48,10 @@ func getSouthboundInterfaceFromJSONMap(m map[string]interface{}) SouthboundInter
switch
sbi
:=
m
[
"name"
];
sbi
{
switch
sbi
:=
m
[
"name"
];
sbi
{
case
"arista"
:
case
"arista"
:
newSBI
=
&
AristaOC
{}
newSBI
=
GetAristaOCInstance
()
newSBI
.
SetDefaults
()
case
"openconfig"
:
case
"openconfig"
:
newSBI
=
&
OpenConfig
{}
newSBI
=
GetOpenconfigInstance
()
newSBI
.
SetDefaults
()
}
}
return
newSBI
return
newSBI
}
}
This diff is collapsed.
Click to expand it.
nucleus/southbound.go
+
36
−
11
View file @
28b0f2c9
package
nucleus
package
nucleus
import
(
import
(
"sync"
"code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
log
"github.com/golang/glog"
log
"github.com/golang/glog"
...
@@ -9,13 +11,16 @@ import (
...
@@ -9,13 +11,16 @@ import (
"github.com/openconfig/ygot/ytypes"
"github.com/openconfig/ygot/ytypes"
)
)
var
lock
=
&
sync
.
Mutex
{}
var
singleOpenConfig
*
OpenConfig
var
singleArista
*
AristaOC
// SouthboundInterface provides an
// SouthboundInterface provides an
// interface for SBI implementations
// interface for SBI implementations
type
SouthboundInterface
interface
{
type
SouthboundInterface
interface
{
// Deprecated
// Deprecated
SbiIdentifier
()
string
SbiIdentifier
()
string
SetDefaults
()
SetNode
()
func
(
schema
*
yang
.
Entry
,
root
interface
{},
path
*
gpb
.
Path
,
val
interface
{},
opts
...
ytypes
.
SetNodeOpt
)
error
SetNode
()
func
(
schema
*
yang
.
Entry
,
root
interface
{},
path
*
gpb
.
Path
,
val
interface
{},
opts
...
ytypes
.
SetNodeOpt
)
error
Schema
()
*
ytypes
.
Schema
Schema
()
*
ytypes
.
Schema
SetTransport
(
t
Transport
)
SetTransport
(
t
Transport
)
...
@@ -31,10 +36,6 @@ type OpenConfig struct {
...
@@ -31,10 +36,6 @@ type OpenConfig struct {
schema
*
ytypes
.
Schema
schema
*
ytypes
.
Schema
}
}
func
(
oc
*
OpenConfig
)
SetDefaults
()
{
oc
.
Name
=
"openconfig"
}
func
(
oc
*
OpenConfig
)
SbiIdentifier
()
string
{
func
(
oc
*
OpenConfig
)
SbiIdentifier
()
string
{
return
oc
.
Name
return
oc
.
Name
}
}
...
@@ -64,18 +65,27 @@ func (oc *OpenConfig) SetTransport(t Transport) {
...
@@ -64,18 +65,27 @@ func (oc *OpenConfig) SetTransport(t Transport) {
oc
.
Transport
=
t
oc
.
Transport
=
t
}
}
func
GetOpenconfigInstance
()
SouthboundInterface
{
if
singleOpenConfig
==
nil
{
lock
.
Lock
()
defer
lock
.
Unlock
()
if
singleOpenConfig
==
nil
{
log
.
Info
(
"creating OpenConfig instance"
)
singleOpenConfig
=
&
OpenConfig
{}
singleOpenConfig
.
Name
=
"openconfig"
t
:=
&
Gnmi
{
SetNode
:
singleOpenConfig
.
SetNode
()}
singleOpenConfig
.
Transport
=
t
}
}
return
singleOpenConfig
}
type
AristaOC
struct
{
type
AristaOC
struct
{
Name
string
`json:"name"`
Name
string
`json:"name"`
Transport
Transport
`json:"-"`
Transport
Transport
`json:"-"`
schema
*
ytypes
.
Schema
schema
*
ytypes
.
Schema
}
}
func
(
oc
*
AristaOC
)
SetDefaults
()
{
oc
.
Name
=
"arista"
t
:=
&
Gnmi
{
SetNode
:
oc
.
SetNode
()}
oc
.
Transport
=
t
}
func
(
oc
*
AristaOC
)
SbiIdentifier
()
string
{
func
(
oc
*
AristaOC
)
SbiIdentifier
()
string
{
return
oc
.
Name
return
oc
.
Name
}
}
...
@@ -104,3 +114,18 @@ func (oc *AristaOC) GetTransport() Transport {
...
@@ -104,3 +114,18 @@ func (oc *AristaOC) GetTransport() Transport {
func
(
oc
*
AristaOC
)
SetTransport
(
t
Transport
)
{
func
(
oc
*
AristaOC
)
SetTransport
(
t
Transport
)
{
oc
.
Transport
=
t
oc
.
Transport
=
t
}
}
func
GetAristaOCInstance
()
SouthboundInterface
{
if
singleArista
==
nil
{
lock
.
Lock
()
defer
lock
.
Unlock
()
if
singleArista
==
nil
{
log
.
Info
(
"creating AristaOC instance"
)
singleArista
=
&
AristaOC
{}
singleArista
.
Name
=
"arista"
t
:=
&
Gnmi
{
SetNode
:
singleArista
.
SetNode
()}
singleArista
.
Transport
=
t
}
}
return
singleArista
}
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