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
5c920a6f
Commit
5c920a6f
authored
4 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
pnds can be stored and loaded via gub
also added createPND for cli
parent
2b98e54a
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
configs/gosdn.toml
+1
-0
1 addition, 0 deletions
configs/gosdn.toml
nucleus/cli-handling.go
+9
-0
9 additions, 0 deletions
nucleus/cli-handling.go
nucleus/controller.go
+39
-8
39 additions, 8 deletions
nucleus/controller.go
nucleus/nucleus-core.go
+6
-2
6 additions, 2 deletions
nucleus/nucleus-core.go
with
55 additions
and
10 deletions
configs/gosdn.toml
+
1
−
0
View file @
5c920a6f
...
...
@@ -3,3 +3,4 @@ db.socket = "bolt://172.17.0.4:7687"
db.user
=
""
db.password
=
""
db.crypto
=
false
pnd.path
=
"./pnds.gob"
This diff is collapsed.
Click to expand it.
nucleus/cli-handling.go
+
9
−
0
View file @
5c920a6f
...
...
@@ -152,3 +152,12 @@ func (s *server) TAPIGetLink(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIR
// TODO: Implement
return
&
pb
.
TAPIReply
{
Message
:
"Done"
},
nil
}
func
(
s
*
server
)
CreatePND
(
ctx
context
.
Context
,
in
*
pb
.
PNDRequest
)
(
*
pb
.
PNDReply
,
error
)
{
log
.
Info
(
"Received: "
,
in
.
GetName
())
path
:=
viper
.
GetString
(
"pnd.path"
)
//TODO: change sbi
s
.
core
.
principalNetworkDomains
[
uuid
.
New
()]
=
NewPND
(
in
.
GetName
(),
in
.
GetDescription
(),
s
.
core
.
southboundInterfaces
[
"test"
])
s
.
core
.
savePNDs
(
path
)
return
&
pb
.
PNDReply
{
Message
:
"Created new PND: "
+
in
.
GetName
()},
nil
}
This diff is collapsed.
Click to expand it.
nucleus/controller.go
+
39
−
8
View file @
5c920a6f
package
nucleus
import
(
"cod
e.fbi.h-da.de/cocsn/gosdn/database
"
"
en
cod
ing/gob
"
"fmt"
"os"
"code.fbi.h-da.de/cocsn/gosdn/database"
"github.com/google/uuid"
log
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"os"
)
// Core is the representation of the controllers core
type
Core
struct
{
southboundInterfaces
map
[
string
]
SouthboundInterface
prinipalNetworkDomains
map
[
uuid
.
UUID
]
PrincipalNetworkDomain
database
database
.
Database
IsRunning
chan
bool
southboundInterfaces
map
[
string
]
SouthboundInterface
prin
c
ipalNetworkDomains
map
[
uuid
.
UUID
]
PrincipalNetworkDomain
database
database
.
Database
IsRunning
chan
bool
}
//Initialize does start-up housekeeping like reading controller config files
...
...
@@ -31,16 +33,45 @@ func (c *Core) Initialize(IsRunningChannel chan bool) {
if
err
!=
nil
{
log
.
Fatal
(
fmt
.
Errorf
(
"Fatal error config file: %s
\n
"
,
err
))
}
path
:=
viper
.
GetString
(
"pnd.path"
)
gob
.
Register
(
&
pndImplementation
{})
c
.
AttachDatabase
()
if
err
:=
c
.
loadPNDs
(
path
);
err
!=
nil
{
log
.
Info
(
err
)
}
c
.
IsRunning
=
IsRunningChannel
}
// AttachDatabase connects to the database and passes the connectio to the controller core
// AttachDatabase connects to the database and passes the connectio
n
to the controller core
func
(
c
*
Core
)
AttachDatabase
()
{
c
.
database
=
database
.
NewDatabaseClient
()
}
// TODO: the load and save functions for pnds are just temporary and should be
// moved to the database
// SavePNDs imports the PNDs from last session
func
(
c
*
Core
)
savePNDs
(
path
string
)
error
{
f
,
err
:=
os
.
Create
(
path
)
if
err
!=
nil
{
return
err
}
defer
f
.
Close
()
return
gob
.
NewEncoder
(
f
)
.
Encode
(
c
.
principalNetworkDomains
)
}
// loadPNDs imports the PNDs from last session
func
(
c
*
Core
)
loadPNDs
(
path
string
)
error
{
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
return
err
}
defer
f
.
Close
()
return
gob
.
NewDecoder
(
f
)
.
Decode
(
&
c
.
principalNetworkDomains
)
}
// Shutdown waits for the shutdown signal and gracefully shuts down once it arrived
func
(
c
*
Core
)
Shutdown
()
{
<-
c
.
IsRunning
...
...
@@ -52,4 +83,4 @@ func (c *Core) Shutdown() {
}
log
.
Info
(
"Shutdown complete"
)
os
.
Exit
(
0
)
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
nucleus/nucleus-core.go
+
6
−
2
View file @
5c920a6f
package
nucleus
import
(
"time"
"code.fbi.h-da.de/cocsn/gosdn/database"
"github.com/google/uuid"
log
"github.com/sirupsen/logrus"
"time"
)
//StartAndRun is used to start the core of the controller and any auxiliary services.
...
...
@@ -13,7 +15,9 @@ func StartAndRun(IsRunningChannel chan bool) {
// Initialize the Core
core
:=
Core
{
database
:
database
.
Database
{},
principalNetworkDomains
:
make
(
map
[
uuid
.
UUID
]
PrincipalNetworkDomain
),
southboundInterfaces
:
make
(
map
[
string
]
SouthboundInterface
),
database
:
database
.
Database
{},
}
core
.
Initialize
(
IsRunningChannel
)
// Start the GRCP CLI
...
...
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