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
fc971085
Commit
fc971085
authored
4 years ago
by
Martin Stiemerling
Browse files
Options
Downloads
Patches
Plain Diff
addresses issue
#27
and move to channels for starting the shutdown
parent
44e6c9ba
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!18
Develop
Pipeline
#52156
passed
4 years ago
Stage: test
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
main.go
+5
-3
5 additions, 3 deletions
main.go
nucleus/cli-handling.go
+2
-2
2 additions, 2 deletions
nucleus/cli-handling.go
nucleus/controller.go
+16
-1
16 additions, 1 deletion
nucleus/controller.go
nucleus/nucleus-core.go
+7
-15
7 additions, 15 deletions
nucleus/nucleus-core.go
with
30 additions
and
21 deletions
main.go
+
5
−
3
View file @
fc971085
...
...
@@ -17,10 +17,12 @@ func main() {
cliSocket
:=
*
cliListenAddr
+
":"
+
*
cliListenPort
log
.
Loglevel
(
log
.
DEBUG
)
// Setup a channel to communicate if goSDN should shutdown.
IsRunningChannel
:=
make
(
chan
bool
)
// hand off to cmd for further processing
nucleus
.
StartUp
(
cliSocket
,
*
configFileName
)
log
.
Info
(
"Startup completed"
)
nucleus
.
Run
()
nucleus
.
StartAndRun
(
cliSocket
,
*
configFileName
,
IsRunningChannel
)
// nothing to see here, please move on!
}
This diff is collapsed.
Click to expand it.
nucleus/cli-handling.go
+
2
−
2
View file @
fc971085
...
...
@@ -28,8 +28,8 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe
}
func
(
s
*
server
)
Shutdown
(
ctx
context
.
Context
,
in
*
pb
.
ShutdownRequest
)
(
*
pb
.
ShutdownReply
,
error
)
{
log
.
Info
(
"Received: %v"
,
in
.
GetName
())
i
sRunning
=
false
log
.
Info
(
"
Shutdown
Received: %v"
,
in
.
GetName
())
s
.
core
.
I
sRunning
<-
false
return
&
pb
.
ShutdownReply
{
Message
:
"Shutdown "
+
in
.
GetName
()},
nil
}
...
...
This diff is collapsed.
Click to expand it.
nucleus/controller.go
+
16
−
1
View file @
fc971085
...
...
@@ -23,9 +23,10 @@ type Core struct {
clients
map
[
string
]
interfaces
.
Client
database
database
.
Database
config
controllerConfig
IsRunning
chan
bool
}
func
(
c
*
Core
)
Init
(
socket
,
configfile
string
)
{
func
(
c
*
Core
)
Init
(
socket
,
configfile
string
,
IsRunningChannel
chan
bool
)
{
if
configfile
==
""
{
configfile
=
"gosdn.toml"
}
...
...
@@ -47,8 +48,11 @@ func (c *Core) Init(socket, configfile string) {
c
.
AttachDatabase
()
c
.
IsRunning
=
IsRunningChannel
//TODO: Create client config/CLI adapter
c
.
clients
[
"ciena-mcp"
]
=
ciena
.
NewMCPClient
(
"141.100.70.170"
,
""
,
""
,
&
c
.
database
)
}
func
(
c
*
Core
)
AttachDatabase
()
{
...
...
@@ -56,6 +60,15 @@ func (c *Core) AttachDatabase() {
}
func
(
c
*
Core
)
Shutdown
()
{
stopIt
:=
<-
c
.
IsRunning
if
(
stopIt
==
false
)
{
log
.
Debug
(
"Shutdown() received action to shutdown"
)
}
else
{
log
.
Debug
(
"Shutdown() received something else."
)
}
f
,
err
:=
os
.
Create
(
c
.
config
.
ConfigPath
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
...
...
@@ -64,4 +77,6 @@ func (c *Core) Shutdown() {
if
err
:=
enc
.
Encode
(
c
.
config
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
os
.
Exit
(
0
)
}
This diff is collapsed.
Click to expand it.
nucleus/nucleus-core.go
+
7
−
15
View file @
fc971085
...
...
@@ -11,32 +11,24 @@ import (
* This function is used to start the core of the controller and any auxiliary services.
*/
// Next-up: backend database.
func
StartUp
(
socket
,
filename
string
)
{
func
StartAndRun
(
socket
,
filename
string
,
IsRunningChannel
chan
bool
)
{
log
.
Info
(
"This is the network superintendent..."
)
log
.
Info
(
"Starting my ducks"
)
// Init the Core
core
:=
Core
{
clients
:
make
(
map
[
string
]
interfaces
.
Client
),
database
:
database
.
Database
{},
}
core
.
Init
(
socket
,
filename
)
core
.
Init
(
socket
,
filename
,
IsRunningChannel
)
// Start the GRCP CLI
go
getCLIGoing
(
&
core
)
log
.
Info
(
"and ready for take off"
)
}
go
core
.
Shutdown
()
/*
* nucleus.Run() is the "main loop" of the controller
*/
var
isRunning
=
true
func
Run
()
{
log
.
Info
(
"and ready for take off"
)
for
isRunning
{
//Just to produce some signs of vitality...
for
(
true
)
{
time
.
Sleep
(
10
*
time
.
Second
)
log
.
Debug
(
"Still alive..."
)
}
...
...
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