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
542d6763
Commit
542d6763
authored
2 years ago
by
Fabian Seidl
Browse files
Options
Downloads
Patches
Plain Diff
fixed issue with nil sbiService
parent
5464f769
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!416
Resolve "Refactor how PNDs are implemented in the code"
Pipeline
#130745
failed
2 years ago
Stage: build
Stage: test
Stage: analyze
Stage: integration-test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
controller/northbound/server/nbi.go
+1
-1
1 addition, 1 deletion
controller/northbound/server/nbi.go
controller/northbound/server/pnd.go
+9
-15
9 additions, 15 deletions
controller/northbound/server/pnd.go
controller/northbound/server/pnd_test.go
+5
-1
5 additions, 1 deletion
controller/northbound/server/pnd_test.go
with
15 additions
and
17 deletions
controller/northbound/server/nbi.go
+
1
−
1
View file @
542d6763
...
...
@@ -52,7 +52,7 @@ func NewNBI(
networkDomain
networkdomain
.
NetworkDomain
,
)
*
NorthboundInterface
{
return
&
NorthboundInterface
{
Pnd
:
NewPndServer
(
pndService
),
Pnd
:
NewPndServer
(
pndService
,
sbiService
),
Core
:
NewCoreServer
(
pndService
),
Csbi
:
NewCsbiServer
(
pnds
),
Sbi
:
NewSbiServer
(
pndService
),
...
...
This diff is collapsed.
Click to expand it.
controller/northbound/server/pnd.go
+
9
−
15
View file @
542d6763
...
...
@@ -7,6 +7,7 @@ import (
ppb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
spb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound"
"code.fbi.h-da.de/danet/gosdn/controller/metrics"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus"
"code.fbi.h-da.de/danet/gosdn/controller/store"
...
...
@@ -21,12 +22,14 @@ import (
type
PndServer
struct
{
ppb
.
UnimplementedPndServiceServer
pndService
networkdomain
.
Service
sbiService
southbound
.
Service
}
// NewPndServer receives a pndStore and returns a new pndServer.
func
NewPndServer
(
pndService
networkdomain
.
Service
)
*
PndServer
{
func
NewPndServer
(
pndService
networkdomain
.
Service
,
sbiService
southbound
.
Service
)
*
PndServer
{
return
&
PndServer
{
pndService
:
pndService
,
sbiService
:
sbiService
,
}
}
...
...
@@ -51,7 +54,7 @@ func (p PndServer) GetSbi(ctx context.Context, request *ppb.GetSbiRequest) (*ppb
return
nil
,
err
}
sbi
,
err
:=
p
nd
.
GetSBI
(
sbiID
)
sbi
,
err
:=
p
.
sbiService
.
Get
(
store
.
Query
{
ID
:
sbiID
}
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
status
.
Errorf
(
codes
.
Aborted
,
"%v"
,
err
)
...
...
@@ -85,7 +88,7 @@ func (p PndServer) GetSbiList(ctx context.Context, request *ppb.GetSbiListReques
log
.
Error
(
err
)
return
nil
,
status
.
Errorf
(
codes
.
Aborted
,
"%v"
,
err
)
}
sbis
,
err
:=
fillSbis
(
pnd
)
sbis
,
err
:=
p
.
fillSbis
()
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
status
.
Errorf
(
codes
.
Aborted
,
"%v"
,
err
)
...
...
@@ -101,8 +104,8 @@ func (p PndServer) GetSbiList(ctx context.Context, request *ppb.GetSbiListReques
},
nil
}
func
fillSbis
(
pnd
networkdomain
.
NetworkDomain
)
([]
*
spb
.
SouthboundInterface
,
error
)
{
sbis
,
err
:=
p
nd
.
GetSBIs
()
func
(
p
PndServer
)
fillSbis
(
)
([]
*
spb
.
SouthboundInterface
,
error
)
{
sbis
,
err
:=
p
.
sbiService
.
GetAll
()
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -123,15 +126,6 @@ func (p PndServer) SetSbiList(ctx context.Context, request *ppb.SetSbiListReques
labels
:=
prometheus
.
Labels
{
"service"
:
"pnd"
,
"rpc"
:
"set"
}
start
:=
metrics
.
StartHook
(
labels
,
grpcRequestsTotal
)
defer
metrics
.
FinishHook
(
labels
,
start
,
grpcRequestDurationSecondsTotal
,
grpcRequestDurationSeconds
)
pid
,
err
:=
uuid
.
Parse
(
request
.
Pid
)
if
err
!=
nil
{
return
nil
,
handleRPCError
(
labels
,
err
)
}
pnd
,
err
:=
p
.
pndService
.
Get
(
store
.
Query
{
ID
:
pid
})
if
err
!=
nil
{
return
nil
,
handleRPCError
(
labels
,
err
)
}
for
_
,
r
:=
range
request
.
Sbi
{
sbiType
:=
filterSbiType
(
r
.
SbiType
)
...
...
@@ -140,7 +134,7 @@ func (p PndServer) SetSbiList(ctx context.Context, request *ppb.SetSbiListReques
return
nil
,
handleRPCError
(
labels
,
err
)
}
err
=
p
nd
.
Add
Sbi
(
sbi
)
err
=
p
.
sbiService
.
Add
(
sbi
)
if
err
!=
nil
{
return
nil
,
handleRPCError
(
labels
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
controller/northbound/server/pnd_test.go
+
5
−
1
View file @
542d6763
...
...
@@ -7,6 +7,7 @@ import (
mnepb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/networkelement"
spb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
eventservice
"code.fbi.h-da.de/danet/gosdn/controller/eventService"
"code.fbi.h-da.de/danet/gosdn/controller/mocks"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus"
"code.fbi.h-da.de/danet/gosdn/models/generated/openconfig"
...
...
@@ -94,8 +95,11 @@ func getTestPndServer(t *testing.T) *PndServer {
}
pndService
:=
nucleus
.
NewPndService
(
pndStore
)
eventService
:=
eventservice
.
NewMockEventService
()
c
:=
NewPndServer
(
pndService
)
sbiService
:=
nucleus
.
NewSbiService
(
sbiStore
,
eventService
)
c
:=
NewPndServer
(
pndService
,
sbiService
)
return
c
}
...
...
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