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
f86fac1f
Commit
f86fac1f
authored
4 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
comments
parent
842e0219
No related branches found
No related tags found
3 merge requests
!97
Resolve "PND handling via CLI and database"
,
!91
"Overhaul Architecture"
,
!90
Develop
Pipeline
#63919
passed with warnings
4 years ago
Stage: test
Stage: deploy
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
nucleus/cli-handling.go
+24
-2
24 additions, 2 deletions
nucleus/cli-handling.go
nucleus/controller.go
+1
-1
1 addition, 1 deletion
nucleus/controller.go
nucleus/device.go
+1
-0
1 addition, 0 deletions
nucleus/device.go
nucleus/principalNetworkDomain.go
+13
-0
13 additions, 0 deletions
nucleus/principalNetworkDomain.go
with
39 additions
and
3 deletions
nucleus/cli-handling.go
+
24
−
2
View file @
f86fac1f
...
@@ -158,6 +158,8 @@ func (s *server) TAPIGetLink(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIR
...
@@ -158,6 +158,8 @@ func (s *server) TAPIGetLink(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIR
return
&
pb
.
TAPIReply
{
Message
:
"Done"
},
nil
return
&
pb
.
TAPIReply
{
Message
:
"Done"
},
nil
}
}
//CreatePND creates a new PND and adds it to the principalNetworkDomain map of
//the core
func
(
s
*
server
)
CreatePND
(
ctx
context
.
Context
,
in
*
pb
.
CreatePNDRequest
)
(
*
pb
.
CreatePNDReply
,
error
)
{
func
(
s
*
server
)
CreatePND
(
ctx
context
.
Context
,
in
*
pb
.
CreatePNDRequest
)
(
*
pb
.
CreatePNDReply
,
error
)
{
log
.
Info
(
"Received: Create a PND with the name"
,
in
.
GetName
())
log
.
Info
(
"Received: Create a PND with the name"
,
in
.
GetName
())
sbi
:=
s
.
core
.
southboundInterfaces
[
in
.
GetSbi
()]
sbi
:=
s
.
core
.
southboundInterfaces
[
in
.
GetSbi
()]
...
@@ -167,6 +169,8 @@ func (s *server) CreatePND(ctx context.Context, in *pb.CreatePNDRequest) (*pb.Cr
...
@@ -167,6 +169,8 @@ func (s *server) CreatePND(ctx context.Context, in *pb.CreatePNDRequest) (*pb.Cr
return
&
pb
.
CreatePNDReply
{
Message
:
"Created new PND: "
+
id
.
String
()},
nil
return
&
pb
.
CreatePNDReply
{
Message
:
"Created new PND: "
+
id
.
String
()},
nil
}
}
//GetAllPNDs is a request to get all current registered PNDs and returns a slim
//variant of PNDs and their respective devices
func
(
s
*
server
)
GetAllPNDs
(
ctx
context
.
Context
,
in
*
emptypb
.
Empty
)
(
*
pb
.
AllPNDsReply
,
error
)
{
func
(
s
*
server
)
GetAllPNDs
(
ctx
context
.
Context
,
in
*
emptypb
.
Empty
)
(
*
pb
.
AllPNDsReply
,
error
)
{
log
.
Info
(
"Received: Get all PNDs"
)
log
.
Info
(
"Received: Get all PNDs"
)
var
pnds
[]
*
pb
.
PND
var
pnds
[]
*
pb
.
PND
...
@@ -192,14 +196,17 @@ func (s *server) GetAllPNDs(ctx context.Context, in *emptypb.Empty) (*pb.AllPNDs
...
@@ -192,14 +196,17 @@ func (s *server) GetAllPNDs(ctx context.Context, in *emptypb.Empty) (*pb.AllPNDs
return
&
pb
.
AllPNDsReply
{
Pnds
:
pnds
},
nil
return
&
pb
.
AllPNDsReply
{
Pnds
:
pnds
},
nil
}
}
//GetAllSBINames returns all registered SBIs from core.
func
(
s
*
server
)
GetAllSBINames
(
ctx
context
.
Context
,
in
*
emptypb
.
Empty
)
(
*
pb
.
AllSBINamesReply
,
error
)
{
func
(
s
*
server
)
GetAllSBINames
(
ctx
context
.
Context
,
in
*
emptypb
.
Empty
)
(
*
pb
.
AllSBINamesReply
,
error
)
{
sbiNames
:=
make
([]
string
,
len
(
s
.
core
.
southboundInterfaces
))
var
sbiNames
[]
string
for
_
,
s
:=
range
s
.
core
.
southboundInterfaces
{
for
_
,
s
:=
range
s
.
core
.
southboundInterfaces
{
sbiNames
=
append
(
sbiNames
,
s
.
SbiIdentifier
())
sbiNames
=
append
(
sbiNames
,
s
.
SbiIdentifier
())
}
}
return
&
pb
.
AllSBINamesReply
{
SbiNames
:
sbiNames
},
nil
return
&
pb
.
AllSBINamesReply
{
SbiNames
:
sbiNames
},
nil
}
}
//AddDevice adds a new Device to a specific PND
//currently this is only working with gnmi transports
func
(
s
*
server
)
AddDevice
(
ctx
context
.
Context
,
in
*
pb
.
AddDeviceRequest
)
(
*
pb
.
AddDeviceReply
,
error
)
{
func
(
s
*
server
)
AddDevice
(
ctx
context
.
Context
,
in
*
pb
.
AddDeviceRequest
)
(
*
pb
.
AddDeviceReply
,
error
)
{
log
.
Info
(
"Received: AddDevice"
)
log
.
Info
(
"Received: AddDevice"
)
uuidPND
,
err
:=
uuid
.
Parse
(
in
.
UuidPND
)
uuidPND
,
err
:=
uuid
.
Parse
(
in
.
UuidPND
)
...
@@ -208,6 +215,7 @@ func (s *server) AddDevice(ctx context.Context, in *pb.AddDeviceRequest) (*pb.Ad
...
@@ -208,6 +215,7 @@ func (s *server) AddDevice(ctx context.Context, in *pb.AddDeviceRequest) (*pb.Ad
}
}
pnd
,
exists
:=
s
.
core
.
principalNetworkDomains
[
uuidPND
]
pnd
,
exists
:=
s
.
core
.
principalNetworkDomains
[
uuidPND
]
if
exists
!=
true
{
if
exists
!=
true
{
log
.
Info
(
err
)
return
&
pb
.
AddDeviceReply
{
Message
:
err
.
Error
()},
err
return
&
pb
.
AddDeviceReply
{
Message
:
err
.
Error
()},
err
}
}
sbi
:=
s
.
core
.
principalNetworkDomains
[
uuidPND
]
.
GetSBIs
()[
"default"
]
sbi
:=
s
.
core
.
principalNetworkDomains
[
uuidPND
]
.
GetSBIs
()[
"default"
]
...
@@ -224,39 +232,53 @@ func (s *server) AddDevice(ctx context.Context, in *pb.AddDeviceRequest) (*pb.Ad
...
@@ -224,39 +232,53 @@ func (s *server) AddDevice(ctx context.Context, in *pb.AddDeviceRequest) (*pb.Ad
newDevice
:=
NewDevice
(
sbi
,
in
.
Device
.
Address
,
in
.
Device
.
Username
,
newDevice
:=
NewDevice
(
sbi
,
in
.
Device
.
Address
,
in
.
Device
.
Username
,
in
.
Device
.
Password
,
transport
)
in
.
Device
.
Password
,
transport
)
pnd
.
AddDevice
(
newDevice
)
err
=
pnd
.
AddDevice
(
newDevice
)
if
err
!=
nil
{
log
.
Info
(
err
)
return
&
pb
.
AddDeviceReply
{
Message
:
err
.
Error
()},
err
}
return
&
pb
.
AddDeviceReply
{
Message
:
"Added new Device: "
+
newDevice
.
Config
.
Uuid
.
String
()},
err
return
&
pb
.
AddDeviceReply
{
Message
:
"Added new Device: "
+
newDevice
.
Config
.
Uuid
.
String
()},
err
}
}
//HandleDeviceGetRequest handles a GET request via pnd.Request()
func
(
s
*
server
)
HandleDeviceGetRequest
(
ctx
context
.
Context
,
in
*
pb
.
DeviceGetRequest
)
(
*
pb
.
DeviceGetReply
,
error
)
{
func
(
s
*
server
)
HandleDeviceGetRequest
(
ctx
context
.
Context
,
in
*
pb
.
DeviceGetRequest
)
(
*
pb
.
DeviceGetReply
,
error
)
{
log
.
Info
(
"Received: HandleDeviceGetRequest"
)
log
.
Info
(
"Received: HandleDeviceGetRequest"
)
uuidPND
,
err
:=
uuid
.
Parse
(
in
.
GetUuidPND
())
uuidPND
,
err
:=
uuid
.
Parse
(
in
.
GetUuidPND
())
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Info
(
err
)
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
}
}
uuidDevice
,
err
:=
uuid
.
Parse
(
in
.
GetUuidDevice
())
uuidDevice
,
err
:=
uuid
.
Parse
(
in
.
GetUuidDevice
())
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Info
(
err
)
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
}
}
pnd
,
exists
:=
s
.
core
.
principalNetworkDomains
[
uuidPND
]
pnd
,
exists
:=
s
.
core
.
principalNetworkDomains
[
uuidPND
]
if
exists
!=
true
{
if
exists
!=
true
{
err
:=
errors
.
New
(
"Couldnt find PND: UUID is wrong"
)
err
:=
errors
.
New
(
"Couldnt find PND: UUID is wrong"
)
log
.
Info
(
err
)
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
}
}
//the specific device a request will be sent to
device
,
exists
:=
s
.
core
.
principalNetworkDomains
[
uuidPND
]
.
GetDevice
(
uuidDevice
)
device
,
exists
:=
s
.
core
.
principalNetworkDomains
[
uuidPND
]
.
GetDevice
(
uuidDevice
)
if
exists
!=
true
{
if
exists
!=
true
{
err
:=
errors
.
New
(
"Couldnt find device: UUID is wrong"
)
err
:=
errors
.
New
(
"Couldnt find device: UUID is wrong"
)
log
.
Info
(
err
)
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
}
}
//GET request for the provided path
err
=
pnd
.
Request
(
uuidDevice
,
in
.
GetPath
())
err
=
pnd
.
Request
(
uuidDevice
,
in
.
GetPath
())
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Info
(
err
)
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
}
}
d
,
err
:=
json
.
MarshalIndent
(
device
,
""
,
"
\t
"
)
d
,
err
:=
json
.
MarshalIndent
(
device
,
""
,
"
\t
"
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Info
(
err
)
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
return
&
pb
.
DeviceGetReply
{
Message
:
err
.
Error
()},
err
}
}
...
...
This diff is collapsed.
Click to expand it.
nucleus/controller.go
+
1
−
1
View file @
f86fac1f
...
@@ -43,7 +43,7 @@ func (c *Core) AttachDatabase() {
...
@@ -43,7 +43,7 @@ func (c *Core) AttachDatabase() {
c
.
database
=
database
.
NewDatabaseClient
()
c
.
database
=
database
.
NewDatabaseClient
()
}
}
// CreateSouthboundInterfaces initializes the controller with his SBIs
// CreateSouthboundInterfaces initializes the controller with his
supported
SBIs
func
(
c
*
Core
)
CreateSouthboundInterfaces
()
{
func
(
c
*
Core
)
CreateSouthboundInterfaces
()
{
arista
:=
&
AristaOC
{}
arista
:=
&
AristaOC
{}
c
.
southboundInterfaces
[
arista
.
SbiIdentifier
()]
=
arista
c
.
southboundInterfaces
[
arista
.
SbiIdentifier
()]
=
arista
...
...
This diff is collapsed.
Click to expand it.
nucleus/device.go
+
1
−
0
View file @
f86fac1f
...
@@ -19,6 +19,7 @@ type Device struct {
...
@@ -19,6 +19,7 @@ type Device struct {
Transport
Transport
`json:"-"`
Transport
Transport
`json:"-"`
}
}
//NewDevice creates a Device
func
NewDevice
(
sbi
SouthboundInterface
,
addr
,
username
,
password
string
,
func
NewDevice
(
sbi
SouthboundInterface
,
addr
,
username
,
password
string
,
transport
Transport
)
*
Device
{
transport
Transport
)
*
Device
{
return
&
Device
{
return
&
Device
{
...
...
This diff is collapsed.
Click to expand it.
nucleus/principalNetworkDomain.go
+
13
−
0
View file @
f86fac1f
...
@@ -41,18 +41,22 @@ func NewPND(name, description string, sbi SouthboundInterface) PrincipalNetworkD
...
@@ -41,18 +41,22 @@ func NewPND(name, description string, sbi SouthboundInterface) PrincipalNetworkD
}
}
}
}
//GetName returns the name of the PND
func
(
pnd
*
pndImplementation
)
GetName
()
string
{
func
(
pnd
*
pndImplementation
)
GetName
()
string
{
return
pnd
.
name
return
pnd
.
name
}
}
//GetDevice returns a specific device via the given uuid
func
(
pnd
*
pndImplementation
)
GetDevice
(
uuid
uuid
.
UUID
)
(
*
Device
,
bool
)
{
func
(
pnd
*
pndImplementation
)
GetDevice
(
uuid
uuid
.
UUID
)
(
*
Device
,
bool
)
{
return
pnd
.
getDevice
(
uuid
)
return
pnd
.
getDevice
(
uuid
)
}
}
//GetDescription returns the current description of the PND
func
(
pnd
*
pndImplementation
)
GetDescription
()
string
{
func
(
pnd
*
pndImplementation
)
GetDescription
()
string
{
return
pnd
.
description
return
pnd
.
description
}
}
//GetSBIs returns the registered SBIs
func
(
pnd
*
pndImplementation
)
GetSBIs
()
map
[
string
]
SouthboundInterface
{
func
(
pnd
*
pndImplementation
)
GetSBIs
()
map
[
string
]
SouthboundInterface
{
return
pnd
.
sbi
return
pnd
.
sbi
}
}
...
@@ -62,18 +66,25 @@ func (pnd *pndImplementation) Destroy() error {
...
@@ -62,18 +66,25 @@ func (pnd *pndImplementation) Destroy() error {
return
destroy
()
return
destroy
()
}
}
//AddSbi adds a SBI to the PND which will be supported
func
(
pnd
*
pndImplementation
)
AddSbi
(
sbi
SouthboundInterface
)
error
{
func
(
pnd
*
pndImplementation
)
AddSbi
(
sbi
SouthboundInterface
)
error
{
return
pnd
.
addSbi
(
sbi
)
return
pnd
.
addSbi
(
sbi
)
}
}
//AddSbi removes a SBI from the PND
//TODO: this should to recursivly through
//devices and remove the devices using
//this SBI
func
(
pnd
*
pndImplementation
)
RemoveSbi
(
sbiIdentifier
string
)
error
{
func
(
pnd
*
pndImplementation
)
RemoveSbi
(
sbiIdentifier
string
)
error
{
return
pnd
.
removeSbi
(
sbiIdentifier
)
return
pnd
.
removeSbi
(
sbiIdentifier
)
}
}
//AddDevice adds a new device to the PND
func
(
pnd
*
pndImplementation
)
AddDevice
(
device
*
Device
)
error
{
func
(
pnd
*
pndImplementation
)
AddDevice
(
device
*
Device
)
error
{
return
pnd
.
addDevice
(
device
)
return
pnd
.
addDevice
(
device
)
}
}
//RemoveDevice removes a device from the PND
func
(
pnd
*
pndImplementation
)
RemoveDevice
(
uuid
uuid
.
UUID
)
error
{
func
(
pnd
*
pndImplementation
)
RemoveDevice
(
uuid
uuid
.
UUID
)
error
{
return
pnd
.
removeDevice
(
uuid
)
return
pnd
.
removeDevice
(
uuid
)
}
}
...
@@ -109,6 +120,7 @@ func (pnd *pndImplementation) getDevice(uuid uuid.UUID) (*Device, bool) {
...
@@ -109,6 +120,7 @@ func (pnd *pndImplementation) getDevice(uuid uuid.UUID) (*Device, bool) {
return
device
,
exists
return
device
,
exists
}
}
//Request sends a request for a specific device
func
(
pnd
*
pndImplementation
)
Request
(
uuid
uuid
.
UUID
,
path
string
)
error
{
func
(
pnd
*
pndImplementation
)
Request
(
uuid
uuid
.
UUID
,
path
string
)
error
{
d
:=
pnd
.
devices
[
uuid
]
d
:=
pnd
.
devices
[
uuid
]
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
...
@@ -123,6 +135,7 @@ func (pnd *pndImplementation) Request(uuid uuid.UUID, path string) error {
...
@@ -123,6 +135,7 @@ func (pnd *pndImplementation) Request(uuid uuid.UUID, path string) error {
return
nil
return
nil
}
}
//RequestAll sends a request for all registered devices
func
(
pnd
*
pndImplementation
)
RequestAll
(
path
string
)
error
{
func
(
pnd
*
pndImplementation
)
RequestAll
(
path
string
)
error
{
for
k
:=
range
pnd
.
devices
{
for
k
:=
range
pnd
.
devices
{
if
err
:=
pnd
.
Request
(
k
,
path
);
err
!=
nil
{
if
err
:=
pnd
.
Request
(
k
,
path
);
err
!=
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