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
e77187f5
Commit
e77187f5
authored
4 years ago
by
Martin Stiemerling
Browse files
Options
Downloads
Patches
Plain Diff
moved cli grpc calls to seprate file
parent
2f26a74b
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!30
Gosdn cli features flow
,
!18
Develop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nucleus/cli-handling.go
+44
-0
44 additions, 0 deletions
nucleus/cli-handling.go
nucleus/nucleus-core.go
+0
-39
0 additions, 39 deletions
nucleus/nucleus-core.go
with
44 additions
and
39 deletions
nucleus/cli-handling.go
0 → 100644
+
44
−
0
View file @
e77187f5
package
nucleus
import
(
pb
"code.fbi.h-da.de/cocsn/gosdn/cliInterface"
"context"
"google.golang.org/grpc"
"log"
"net"
)
// server is used to implement helloworld.GreeterServer.
type
server
struct
{
pb
.
UnimplementedGreeterServer
core
*
Core
}
// SayHello implements helloworld.GreeterServer
func
(
s
*
server
)
SayHello
(
ctx
context
.
Context
,
in
*
pb
.
HelloRequest
)
(
*
pb
.
HelloReply
,
error
)
{
log
.
Printf
(
"Received: %v"
,
in
.
GetName
())
return
&
pb
.
HelloReply
{
Message
:
"Hello "
+
in
.
GetName
()},
nil
}
func
(
s
*
server
)
Shutdown
(
ctx
context
.
Context
,
in
*
pb
.
ShutdownRequest
)
(
*
pb
.
ShutdownReply
,
error
)
{
log
.
Printf
(
"Received: %v"
,
in
.
GetName
())
isRunning
=
false
return
&
pb
.
ShutdownReply
{
Message
:
"Shutdown "
+
in
.
GetName
()},
nil
}
func
getCLIGoing
(
core
*
Core
)
{
log
.
Println
(
"Starting: GetCLIGoing"
)
// Boot-up the control interface for the cli
cliControlListener
,
err
:=
net
.
Listen
(
"tcp"
,
core
.
config
.
CliSocket
)
if
err
!=
nil
{
log
.
Fatalf
(
"failed to listen: %v"
,
err
)
}
cliControlServer
:=
grpc
.
NewServer
()
pb
.
RegisterGreeterServer
(
cliControlServer
,
&
server
{
core
:
core
})
if
err
:=
cliControlServer
.
Serve
(
cliControlListener
);
err
!=
nil
{
log
.
Fatalf
(
"failed to serve: %v"
,
err
)
}
log
.
Println
(
"Started: GetCLIGoing"
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
nucleus/nucleus-core.go
+
0
−
39
View file @
e77187f5
package
nucleus
package
nucleus
import
(
import
(
pb
"code.fbi.h-da.de/cocsn/gosdn/cliInterface"
"code.fbi.h-da.de/cocsn/gosdn/database"
"code.fbi.h-da.de/cocsn/gosdn/database"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces"
"context"
_
"github.com/mattn/go-sqlite3"
"google.golang.org/grpc"
"log"
"log"
"net"
"time"
"time"
)
)
// server is used to implement helloworld.GreeterServer.
type
server
struct
{
pb
.
UnimplementedGreeterServer
core
*
Core
}
// SayHello implements helloworld.GreeterServer
func
(
s
*
server
)
SayHello
(
ctx
context
.
Context
,
in
*
pb
.
HelloRequest
)
(
*
pb
.
HelloReply
,
error
)
{
log
.
Printf
(
"Received: %v"
,
in
.
GetName
())
return
&
pb
.
HelloReply
{
Message
:
"Hello "
+
in
.
GetName
()},
nil
}
func
(
s
*
server
)
Shutdown
(
ctx
context
.
Context
,
in
*
pb
.
ShutdownRequest
)
(
*
pb
.
ShutdownReply
,
error
)
{
log
.
Printf
(
"Received: %v"
,
in
.
GetName
())
isRunning
=
false
return
&
pb
.
ShutdownReply
{
Message
:
"Shutdown "
+
in
.
GetName
()},
nil
}
func
getCLIGoing
(
core
*
Core
)
{
log
.
Println
(
"Starting: GetCLIGoing"
)
// Boot-up the control interface for the cli
cliControlListener
,
err
:=
net
.
Listen
(
"tcp"
,
core
.
config
.
CliSocket
)
if
err
!=
nil
{
log
.
Fatalf
(
"failed to listen: %v"
,
err
)
}
cliControlServer
:=
grpc
.
NewServer
()
pb
.
RegisterGreeterServer
(
cliControlServer
,
&
server
{
core
:
core
})
if
err
:=
cliControlServer
.
Serve
(
cliControlListener
);
err
!=
nil
{
log
.
Fatalf
(
"failed to serve: %v"
,
err
)
}
log
.
Println
(
"Started: GetCLIGoing"
)
}
/*
/*
* This function is used to start the core of the controller and any auxiliary services.
* This function is used to start the core of the controller and any auxiliary services.
...
...
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