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
4d84a0b3
Commit
4d84a0b3
authored
4 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
changes to support sending and saving devices
parent
c1242e9f
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
cmd/gnmi/gnmi.go
+2
-2
2 additions, 2 deletions
cmd/gnmi/gnmi.go
nucleus/cli-handling.go
+45
-3
45 additions, 3 deletions
nucleus/cli-handling.go
nucleus/device.go
+1
-1
1 addition, 1 deletion
nucleus/device.go
nucleus/principalNetworkDomain.go
+11
-1
11 additions, 1 deletion
nucleus/principalNetworkDomain.go
with
59 additions
and
7 deletions
cmd/gnmi/gnmi.go
+
2
−
2
View file @
4d84a0b3
...
...
@@ -13,16 +13,16 @@ import (
func
main
()
{
sbi
:=
&
nucleus
.
OpenConfig
{}
device
:=
nucleus
.
Device
{
Uuid
:
uuid
.
New
(),
Device
:
&
openconfig
.
Device
{},
SBI
:
sbi
,
Config
:
nucleus
.
DeviceConfig
{
Uuid
:
uuid
.
New
(),
Address
:
"141.100.70.170:6030"
,
Username
:
"admin"
,
Password
:
"arista"
,
},
}
pnd
:=
nucleus
.
NewPND
(
"openconfig"
,
sbi
)
pnd
:=
nucleus
.
NewPND
(
"openconfig"
,
"test description"
,
sbi
)
if
err
:=
pnd
.
AddDevice
(
device
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
This diff is collapsed.
Click to expand it.
nucleus/cli-handling.go
+
45
−
3
View file @
4d84a0b3
...
...
@@ -153,8 +153,8 @@ func (s *server) TAPIGetLink(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIR
return
&
pb
.
TAPIReply
{
Message
:
"Done"
},
nil
}
func
(
s
*
server
)
CreatePND
(
ctx
context
.
Context
,
in
*
pb
.
PNDRequest
)
(
*
pb
.
PNDReply
,
error
)
{
log
.
Info
(
"Received: "
,
in
.
GetName
())
func
(
s
*
server
)
CreatePND
(
ctx
context
.
Context
,
in
*
pb
.
Create
PNDRequest
)
(
*
pb
.
Create
PNDReply
,
error
)
{
log
.
Info
(
"Received:
Create a PND with the name
"
,
in
.
GetName
())
path
:=
viper
.
GetString
(
"pnd.path"
)
sbi
:=
&
OpenConfig
{}
id
:=
uuid
.
New
()
...
...
@@ -162,5 +162,47 @@ func (s *server) CreatePND(ctx context.Context, in *pb.PNDRequest) (*pb.PNDReply
if
err
:=
s
.
core
.
savePNDs
(
path
);
err
!=
nil
{
log
.
Info
(
err
)
}
return
&
pb
.
PNDReply
{
Message
:
"Created new PND: "
+
id
.
String
()},
nil
return
&
pb
.
CreatePNDReply
{
Message
:
"Created new PND: "
+
id
.
String
()},
nil
}
func
(
s
*
server
)
GetAllPNDs
(
ctx
context
.
Context
,
in
*
emptypb
.
Empty
)
(
*
pb
.
AllPNDsReply
,
error
)
{
var
pnds
[]
*
pb
.
PND
for
uuidPND
,
pnd
:=
range
s
.
core
.
principalNetworkDomains
{
var
devices
[]
*
pb
.
Device
for
uuidDevice
,
device
:=
range
pnd
.
(
*
pndImplementation
)
.
Devices
{
tmpDevice
:=
pb
.
Device
{
Uuid
:
uuidDevice
.
String
(),
Address
:
device
.
Config
.
Address
,
Username
:
device
.
Config
.
Username
,
Password
:
device
.
Config
.
Password
}
devices
=
append
(
devices
,
&
tmpDevice
)
}
tmpPND
:=
pb
.
PND
{
Uuid
:
uuidPND
.
String
(),
Name
:
pnd
.
GetName
(),
Description
:
pnd
.
GetDescription
(),
Sbi
:
pnd
.
GetDefaultSBIName
(),
Devices
:
devices
}
pnds
=
append
(
pnds
,
&
tmpPND
)
}
return
&
pb
.
AllPNDsReply
{
Pnds
:
pnds
},
nil
}
func
(
s
*
server
)
AddDevice
(
ctx
context
.
Context
,
in
*
pb
.
AddDeviceRequest
)
(
*
pb
.
AddDeviceReply
,
error
)
{
uuidPND
,
err
:=
uuid
.
Parse
(
in
.
UuidPND
)
pnd
:=
s
.
core
.
principalNetworkDomains
[
uuidPND
]
newDevice
:=
Device
{
Uuid
:
uuid
.
New
(),
Device
:
nil
,
SBI
:
nil
,
Config
:
DeviceConfig
{
Address
:
in
.
Device
.
Address
,
Username
:
in
.
Device
.
Username
,
Password
:
in
.
Device
.
Password
,
},
}
devicesMap
:=
pnd
.
(
*
pndImplementation
)
.
Devices
devicesMap
[
newDevice
.
Uuid
]
=
newDevice
return
&
pb
.
AddDeviceReply
{
Message
:
"Added new Device: "
+
newDevice
.
Uuid
.
String
()},
err
}
This diff is collapsed.
Click to expand it.
nucleus/device.go
+
1
−
1
View file @
4d84a0b3
...
...
@@ -11,6 +11,7 @@ import (
)
type
Device
struct
{
Uuid
uuid
.
UUID
Device
ygot
.
GoStruct
SBI
SouthboundInterface
Config
DeviceConfig
...
...
@@ -53,7 +54,6 @@ func (d Device) Add(resp interface{}) error {
}
type
DeviceConfig
struct
{
Uuid
uuid
.
UUID
Address
string
Username
string
Password
string
...
...
This diff is collapsed.
Click to expand it.
nucleus/principalNetworkDomain.go
+
11
−
1
View file @
4d84a0b3
...
...
@@ -8,6 +8,8 @@ import (
// interface for PND implementations
type
PrincipalNetworkDomain
interface
{
GetName
()
string
GetDescription
()
string
GetDefaultSBIName
()
string
Destroy
()
error
AddSbi
(
SouthboundInterface
)
error
RemoveSbi
(
string
)
error
...
...
@@ -39,6 +41,14 @@ func (pnd *pndImplementation) GetName() string {
return
pnd
.
Name
}
func
(
pnd
*
pndImplementation
)
GetDescription
()
string
{
return
pnd
.
Description
}
func
(
pnd
*
pndImplementation
)
GetDefaultSBIName
()
string
{
return
pnd
.
Sbi
[
"default"
]
.
SbiIdentifier
()
}
// Interface satisfaction
func
(
pnd
*
pndImplementation
)
Destroy
()
error
{
return
destroy
()
...
...
@@ -77,7 +87,7 @@ func (pnd *pndImplementation) removeSbi(sbiIdentifier string) error {
}
func
(
pnd
*
pndImplementation
)
addDevice
(
device
Device
)
error
{
pnd
.
Devices
[
device
.
Config
.
Uuid
]
=
device
pnd
.
Devices
[
device
.
Uuid
]
=
device
return
nil
}
...
...
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