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
44e6c9ba
Commit
44e6c9ba
authored
4 years ago
by
Martin Stiemerling
Browse files
Options
Downloads
Patches
Plain Diff
tapi calls accessible via grpc-cli
parent
b8b527de
No related branches found
No related tags found
1 merge request
!18
Develop
Pipeline
#52144
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gosdn-cli/gosdn-cli.go
+58
-4
58 additions, 4 deletions
gosdn-cli/gosdn-cli.go
nucleus/cli-handling.go
+3
-0
3 additions, 0 deletions
nucleus/cli-handling.go
with
61 additions
and
4 deletions
gosdn-cli/gosdn-cli.go
+
58
−
4
View file @
44e6c9ba
...
...
@@ -43,7 +43,9 @@ var commandList = map[string]commandOptions{
"hello"
:
{
"hello"
,
"test connection to goSDN controller"
,
goSDNSayHello
},
"shutdown"
:
{
"shutdown"
,
"request goSDN controller to shutdown"
,
goSDNShutdown
},
"testdb"
:
{
"testdb"
,
"test all database connections"
,
goSDNTestDB
},
"tapigetnodes"
:
{
"testdb"
,
"test all database connections"
,
goSDNTestDB
},
"tapigetedge"
:
{
"tapigetedge"
,
"get list of edges"
,
TAPIGetEdge
},
"tapigetedgenode"
:
{
"tapigetedgenode"
,
"get list of edgenodes"
,
TAPIGetEdgeNode
},
"tapigetlink"
:
{
"tapigetlink"
,
"get list of links"
,
TAPIGetLink
},
}
/*
...
...
@@ -119,8 +121,6 @@ func main() {
}
}
func
goSDNSayHello
(
conn
*
grpc
.
ClientConn
)
{
func
goSDNSayHello
(
conn
*
grpc
.
ClientConn
)
{
c
:=
pb
.
NewGrpcCliClient
(
conn
)
...
...
@@ -158,5 +158,59 @@ func goSDNShutdown(conn *grpc.ClientConn) {
}
func
goSDNTestDB
(
conn
*
grpc
.
ClientConn
)
{
// TODO: fill with code
// TODO: fill with code
and also see if grpc interface has this stub implemented.
}
func
TAPIGetEdge
(
conn
*
grpc
.
ClientConn
)
{
c
:=
pb
.
NewGrpcCliClient
(
conn
)
// Contact the server and print out its response.
name
:=
defaultName
if
len
(
os
.
Args
)
>
1
{
name
=
os
.
Args
[
0
]
}
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
)
defer
cancel
()
r
,
err
:=
c
.
TAPIGetEdge
(
ctx
,
&
pb
.
TAPIRequest
{
Name
:
name
})
if
err
!=
nil
{
log
.
Fatalf
(
"could not request shutdown: %v"
,
err
)
}
log
.
Printf
(
"TAPIGetEdge said: %s"
,
r
.
GetMessage
())
}
func
TAPIGetEdgeNode
(
conn
*
grpc
.
ClientConn
)
{
c
:=
pb
.
NewGrpcCliClient
(
conn
)
// Contact the server and print out its response.
name
:=
defaultName
if
len
(
os
.
Args
)
>
1
{
name
=
os
.
Args
[
0
]
}
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
)
defer
cancel
()
r
,
err
:=
c
.
TAPIGetEdgeNode
(
ctx
,
&
pb
.
TAPIRequest
{
Name
:
name
})
if
err
!=
nil
{
log
.
Fatalf
(
"could not request shutdown: %v"
,
err
)
}
log
.
Printf
(
"TAPIGetEdgeNode said: %s"
,
r
.
GetMessage
())
}
func
TAPIGetLink
(
conn
*
grpc
.
ClientConn
)
{
c
:=
pb
.
NewGrpcCliClient
(
conn
)
// Contact the server and print out its response.
name
:=
defaultName
if
len
(
os
.
Args
)
>
1
{
name
=
os
.
Args
[
0
]
}
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
)
defer
cancel
()
r
,
err
:=
c
.
TAPIGetLink
(
ctx
,
&
pb
.
TAPIRequest
{
Name
:
name
})
if
err
!=
nil
{
log
.
Fatalf
(
"could not request shutdown: %v"
,
err
)
}
log
.
Printf
(
"TAPIGetLink said: %s"
,
r
.
GetMessage
())
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
nucleus/cli-handling.go
+
3
−
0
View file @
44e6c9ba
...
...
@@ -55,6 +55,7 @@ func (s *server) TAPIGetEdge(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIR
log
.
Info
(
"Received: %v"
,
in
.
GetName
())
if
err
:=
s
.
core
.
clients
[
"ciena-mcp"
]
.
(
*
ciena
.
MCPClient
)
.
GetNodes
();
err
!=
nil
{
log
.
Error
(
err
)
return
&
pb
.
TAPIReply
{
Message
:
"TAPI error"
},
nil
}
return
&
pb
.
TAPIReply
{
Message
:
"Done"
},
nil
}
...
...
@@ -63,6 +64,7 @@ func (s *server) TAPIGetEdgeNode(ctx context.Context, in *pb.TAPIRequest) (*pb.T
log
.
Info
(
"Received: %v"
,
in
.
GetName
())
if
err
:=
s
.
core
.
clients
[
"ciena-mcp"
]
.
(
*
ciena
.
MCPClient
)
.
GetNodeEdgePoints
();
err
!=
nil
{
log
.
Error
(
err
)
return
&
pb
.
TAPIReply
{
Message
:
"TAPI error"
},
nil
}
return
&
pb
.
TAPIReply
{
Message
:
"Done"
},
nil
}
...
...
@@ -71,6 +73,7 @@ func (s *server) TAPIGetLink(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIR
log
.
Info
(
"Received: %v"
,
in
.
GetName
())
if
err
:=
s
.
core
.
clients
[
"ciena-mcp"
]
.
(
*
ciena
.
MCPClient
)
.
GetLinks
();
err
!=
nil
{
log
.
Error
(
err
)
return
&
pb
.
TAPIReply
{
Message
:
"TAPI error"
},
nil
}
return
&
pb
.
TAPIReply
{
Message
:
"Done"
},
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