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
52013a12
Commit
52013a12
authored
2 years ago
by
Fabian Seidl
Browse files
Options
Downloads
Patches
Plain Diff
linter pleasing
parent
9b3a32c8
No related branches found
No related tags found
1 merge request
!416
Resolve "Refactor how PNDs are implemented in the code"
Pipeline
#137711
failed
2 years ago
Stage: build
Stage: test
Stage: analyze
Stage: integration-test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controller/nucleus/pndFilesystemStore.go
+26
-30
26 additions, 30 deletions
controller/nucleus/pndFilesystemStore.go
controller/nucleus/principalNetworkDomain.go
+2
-5
2 additions, 5 deletions
controller/nucleus/principalNetworkDomain.go
with
28 additions
and
35 deletions
controller/nucleus/pndFilesystemStore.go
+
26
−
30
View file @
52013a12
...
...
@@ -5,7 +5,6 @@ import (
"os"
"sync"
cpb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi"
"code.fbi.h-da.de/danet/gosdn/controller/customerrs"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement"
...
...
@@ -13,18 +12,15 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/store"
"github.com/google/uuid"
log
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
// FilesystemPndStore provides a filesystem implementation for a pnd store.
type
FilesystemPndStore
struct
{
pendingChannels
map
[
uuid
.
UUID
]
chan
networkelement
.
Details
pluginService
plugin
.
Service
csbiClient
cpb
.
CsbiServiceClient
pathToPndFile
string
fileMutex
sync
.
Mutex
//
csbiClient cpb.CsbiServiceClient
pathToPndFile
string
fileMutex
sync
.
Mutex
}
// NewFilesystemPndStore returns a filesystem implementation for a pnd store.
...
...
@@ -197,26 +193,26 @@ func (t *FilesystemPndStore) RemovePendingChannel(id uuid.UUID) {
delete
(
t
.
pendingChannels
,
id
)
}
func
(
t
*
FilesystemPndStore
)
callback
(
id
uuid
.
UUID
,
ch
chan
networkelement
.
Details
)
{
if
ch
!=
nil
{
t
.
AddPendingChannel
(
id
,
ch
)
log
.
Infof
(
"pending channel %v added"
,
id
)
}
else
{
t
.
RemovePendingChannel
(
id
)
log
.
Infof
(
"pending channel %v removed"
,
id
)
}
}
func
(
t
*
FilesystemPndStore
)
getCsbiClient
()
(
cpb
.
CsbiServiceClient
,
error
)
{
if
t
.
csbiClient
==
nil
{
orchestrator
:=
viper
.
GetString
(
"csbi-orchestrator"
)
conn
,
err
:=
grpc
.
Dial
(
orchestrator
,
grpc
.
WithTransportCredentials
(
insecure
.
NewCredentials
()))
if
err
!=
nil
{
return
nil
,
err
}
t
.
csbiClient
=
cpb
.
NewCsbiServiceClient
(
conn
)
}
return
t
.
csbiClient
,
nil
}
//
func (t *FilesystemPndStore) callback(id uuid.UUID, ch chan networkelement.Details) {
//
if ch != nil {
//
t.AddPendingChannel(id, ch)
//
log.Infof("pending channel %v added", id)
//
} else {
//
t.RemovePendingChannel(id)
//
log.Infof("pending channel %v removed", id)
//
}
//
}
//
func (t *FilesystemPndStore) getCsbiClient() (cpb.CsbiServiceClient, error) {
//
if t.csbiClient == nil {
//
orchestrator := viper.GetString("csbi-orchestrator")
//
conn, err := grpc.Dial(orchestrator, grpc.WithTransportCredentials(insecure.NewCredentials()))
//
if err != nil {
//
return nil, err
//
}
//
t.csbiClient = cpb.NewCsbiServiceClient(conn)
//
}
//
return t.csbiClient, nil
//
}
This diff is collapsed.
Click to expand it.
controller/nucleus/principalNetworkDomain.go
+
2
−
5
View file @
52013a12
...
...
@@ -3,10 +3,7 @@ package nucleus
import
(
"go.mongodb.org/mongo-driver/bson"
cpb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement"
"github.com/google/uuid"
log
"github.com/sirupsen/logrus"
...
...
@@ -49,8 +46,8 @@ type pndImplementation struct {
//nolint
Id
uuid
.
UUID
`json:"id,omitempty"`
csbiClient
cpb
.
CsbiServiceClient
callback
func
(
uuid
.
UUID
,
chan
networkelement
.
Details
)
//
csbiClient cpb.CsbiServiceClient
//
callback func(uuid.UUID, chan networkelement.Details)
}
func
(
pnd
*
pndImplementation
)
ID
()
uuid
.
UUID
{
...
...
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