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
8dac05dc
Commit
8dac05dc
authored
3 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
8edcc098
Branches
Branches containing commit
No related tags found
1 merge request
!284
Improve usability and better output formatting for gosndc
Pipeline
#99524
failed
3 years ago
Stage: build
Stage: test
Stage: analyze
Stage: integration-test
This commit is part of merge request
!284
. Comments created here will be created in the context of that merge request.
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cli/adapter/PndAdapter.go
+1
-1
1 addition, 1 deletion
cli/adapter/PndAdapter.go
cli/cmd/deviceCreate.go
+8
-6
8 additions, 6 deletions
cli/cmd/deviceCreate.go
cli/cmd/deviceDelete.go
+14
-8
14 additions, 8 deletions
cli/cmd/deviceDelete.go
cli/cmd/deviceGet.go
+22
-6
22 additions, 6 deletions
cli/cmd/deviceGet.go
with
45 additions
and
21 deletions
cli/adapter/PndAdapter.go
+
1
−
1
Edit
View file @
8dac05dc
...
@@ -119,7 +119,7 @@ func (p *PndAdapter) ChangeOND(duid uuid.UUID, operation ppb.ApiOperation, path
...
@@ -119,7 +119,7 @@ func (p *PndAdapter) ChangeOND(duid uuid.UUID, operation ppb.ApiOperation, path
// Request sends an API call to the controller requesting the specified path
// Request sends an API call to the controller requesting the specified path
// for the specified device
// for the specified device
func
(
p
*
PndAdapter
)
Request
(
did
uuid
.
UUID
,
path
string
)
(
proto
.
Messag
e
,
error
)
{
func
(
p
*
PndAdapter
)
Request
(
did
uuid
.
UUID
,
path
string
)
(
*
ppb
.
GetPathRespons
e
,
error
)
{
resp
,
err
:=
api
.
GetPath
(
p
.
endpoint
,
p
.
id
.
String
(),
did
.
String
(),
path
)
resp
,
err
:=
api
.
GetPath
(
p
.
endpoint
,
p
.
id
.
String
(),
did
.
String
(),
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
This diff is collapsed.
Click to expand it.
cli/cmd/deviceCreate.go
+
8
−
6
Edit
View file @
8dac05dc
...
@@ -53,6 +53,7 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`,
...
@@ -53,6 +53,7 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`,
spinner
,
_
:=
pterm
.
DefaultSpinner
.
Start
(
"Creating new device"
)
spinner
,
_
:=
pterm
.
DefaultSpinner
.
Start
(
"Creating new device"
)
err
:=
checkIPPort
(
address
)
err
:=
checkIPPort
(
address
)
if
err
!=
nil
{
if
err
!=
nil
{
spinner
.
Fail
(
err
)
return
err
return
err
}
}
...
@@ -74,6 +75,7 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`,
...
@@ -74,6 +75,7 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`,
}
}
sid
,
err
:=
uuid
.
Parse
(
cliSbi
)
sid
,
err
:=
uuid
.
Parse
(
cliSbi
)
if
err
!=
nil
{
if
err
!=
nil
{
spinner
.
Fail
(
err
)
return
err
return
err
}
}
...
@@ -82,13 +84,13 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`,
...
@@ -82,13 +84,13 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`,
return
err
return
err
}
}
if
resp
.
GetStatus
()
==
pnd
.
Status_STATUS_OK
{
for
_
,
r
:=
range
resp
.
GetResponses
()
{
// TODO: we should return a ID here, changes needed for AddDevice()
if
r
.
GetStatus
()
==
pnd
.
Status_STATUS_OK
{
spinner
.
Success
(
"Device has been created with ID: "
)
spinner
.
Success
(
"Device has been created with ID: "
,
r
.
GetId
())
return
nil
}
else
{
spinner
.
Fail
(
"An error occured while creating Device with ID: "
,
r
.
GetId
(),
r
.
GetStatus
())
}
}
}
spinner
.
Warning
(
"Creating new device: "
,
resp
.
GetStatus
())
return
nil
return
nil
},
},
}
}
...
...
This diff is collapsed.
Click to expand it.
cli/cmd/deviceDelete.go
+
14
−
8
Edit
View file @
8dac05dc
...
@@ -34,7 +34,7 @@ package cmd
...
@@ -34,7 +34,7 @@ package cmd
import
(
import
(
ppb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
ppb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
"github.com/google/uuid"
"github.com/google/uuid"
log
"github.com/
sirupsen/logrus
"
"github.com/
pterm/pterm
"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -46,16 +46,22 @@ var deviceDeleteCmd = &cobra.Command{
...
@@ -46,16 +46,22 @@ var deviceDeleteCmd = &cobra.Command{
Long
:
`Delete a path for a given orchestrated network device.
Long
:
`Delete a path for a given orchestrated network device.
The device UUID and request path must be specified as a positional arguments.`
,
The device UUID and request path must be specified as a positional arguments.`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
spinner
,
_
:=
pterm
.
DefaultSpinner
.
Start
(
"Create a path deletion request."
)
did
,
err
:=
uuid
.
Parse
(
args
[
0
])
did
,
err
:=
uuid
.
Parse
(
args
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
spinner
.
Fail
(
err
)
return
err
}
}
log
.
Info
(
pndAdapter
.
ChangeOND
(
resp
,
err
:=
pndAdapter
.
ChangeOND
(
did
,
ppb
.
ApiOperation_API_OPERATION_DELETE
,
args
[
1
])
did
,
for
_
,
r
:=
range
resp
.
Responses
{
ppb
.
ApiOperation_API_OPERATION_DELETE
,
if
r
.
Status
==
ppb
.
Status_STATUS_OK
{
args
[
1
],
spinner
.
Success
(
"A change for path deletion for Device: "
,
did
.
String
(),
"has been created -> Change ID: "
,
r
.
GetId
())
))
}
else
{
spinner
.
Fail
(
"An error occured while creating a path deletion request for Device with ID: "
,
r
.
GetId
(),
r
.
GetStatus
())
}
}
return
nil
},
},
}
}
...
...
This diff is collapsed.
Click to expand it.
cli/cmd/deviceGet.go
+
22
−
6
Edit
View file @
8dac05dc
...
@@ -33,7 +33,7 @@ package cmd
...
@@ -33,7 +33,7 @@ package cmd
import
(
import
(
"github.com/google/uuid"
"github.com/google/uuid"
log
"github.com/
sirupsen/logrus
"
"github.com/
pterm/pterm
"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/encoding/protojson"
)
)
...
@@ -46,21 +46,37 @@ var deviceGetCmd = &cobra.Command{
...
@@ -46,21 +46,37 @@ var deviceGetCmd = &cobra.Command{
Long
:
`Requests a path from a specified orchestrated network device on the controller.
Long
:
`Requests a path from a specified orchestrated network device on the controller.
The device UUID and request path must be specified as a positional arguments.`
,
The device UUID and request path must be specified as a positional arguments.`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
E
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
did
,
err
:=
uuid
.
Parse
(
args
[
0
])
did
,
err
:=
uuid
.
Parse
(
args
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
pterm
.
Error
.
Println
(
err
)
return
err
}
}
m
es
sage
,
err
:=
pndAdapter
.
Request
(
r
es
,
err
:=
pndAdapter
.
Request
(
did
,
did
,
args
[
1
],
args
[
1
],
)
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
err
)
pterm
.
Error
.
Println
(
err
)
return
err
}
}
log
.
Info
(
protojson
.
Format
(
message
))
for
_
,
n
:=
range
res
.
Device
{
title
:=
pterm
.
Sprintf
(
"gNMI Notification for device with ID: "
,
did
)
panel1
:=
pterm
.
DefaultBox
.
WithTitle
(
"Timestamp:"
)
.
Sprint
(
n
.
GetTimestamp
())
panel2
:=
pterm
.
DefaultBox
.
WithTitle
(
"Requested Path:"
)
.
Sprint
(
args
[
1
])
panel3
:=
pterm
.
DefaultBox
.
WithTitle
(
"Result:"
)
.
Sprint
(
protojson
.
Format
(
n
.
Update
[
0
]))
panels
,
_
:=
pterm
.
DefaultPanel
.
WithPanels
(
pterm
.
Panels
{
{{
Data
:
panel1
}},
{{
Data
:
panel2
}},
{{
Data
:
panel3
}},
})
.
Srender
()
pterm
.
DefaultBox
.
WithTitle
(
title
)
.
WithTitleTopCenter
()
.
WithRightPadding
(
0
)
.
WithBottomPadding
(
0
)
.
Println
(
panels
)
}
return
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