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
bea49da9
Commit
bea49da9
authored
4 years ago
by
Manuel Kieweg
Browse files
Options
Downloads
Patches
Plain Diff
proper bytes.Buffer instead of makeshift []byte
parent
68888f89
No related branches found
No related tags found
2 merge requests
!28
Resolve "Proper IO Buffer for MCP Client"
,
!18
Develop
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
nucleus/nucleus-core.go
+1
-1
1 addition, 1 deletion
nucleus/nucleus-core.go
restconf/client/ciena/client.go
+18
-16
18 additions, 16 deletions
restconf/client/ciena/client.go
restconf/util/unmarshal.go
+3
-4
3 additions, 4 deletions
restconf/util/unmarshal.go
with
22 additions
and
21 deletions
nucleus/nucleus-core.go
+
1
−
1
View file @
bea49da9
...
...
@@ -58,7 +58,7 @@ func StartUp(socket, filename string) {
log
.
Info
(
"Starting my ducks"
)
// Init the Core
core
:=
Core
{
clients
:
make
(
map
[
string
]
interfaces
.
Client
,
0
),
clients
:
make
(
map
[
string
]
interfaces
.
Client
),
database
:
database
.
Database
{},
}
core
.
Init
(
socket
,
filename
)
...
...
This diff is collapsed.
Click to expand it.
restconf/client/ciena/client.go
+
18
−
16
View file @
bea49da9
package
ciena
import
(
"bytes"
"code.fbi.h-da.de/cocsn/gosdn/database"
"code.fbi.h-da.de/cocsn/gosdn/log"
"code.fbi.h-da.de/cocsn/gosdn/restconf/util"
apiclient
"code.fbi.h-da.de/cocsn/swagger/apis/mcp/client"
"crypto/tls"
...
...
@@ -16,7 +18,7 @@ type MCPClient struct {
transport
*
httptransport
.
Runtime
client
*
apiclient
.
ServiceTopologyTAPI
database
*
database
.
Database
buf
*
[]
byte
buf
fer
*
byte
s
.
Buffer
}
func
(
c
MCPClient
)
GetConfig
()
string
{
...
...
@@ -25,7 +27,7 @@ func (c MCPClient) GetConfig() string {
}
//NewMCPClient creates a client
func
NewMCPClient
(
endpoint
,
username
,
password
string
,
database
*
database
.
Database
)
MCPClient
{
func
NewMCPClient
(
endpoint
,
username
,
password
string
,
database
*
database
.
Database
)
*
MCPClient
{
// create the transport
transport
:=
httptransport
.
New
(
endpoint
,
"/"
,
nil
)
transport
.
Transport
.
(
*
http
.
Transport
)
.
TLSClientConfig
=
&
tls
.
Config
{
InsecureSkipVerify
:
true
}
...
...
@@ -36,37 +38,37 @@ func NewMCPClient(endpoint, username, password string, database *database.Databa
transport
.
DefaultAuthentication
=
basicAuth
client
:=
apiclient
.
New
(
transport
,
strfmt
.
Default
)
buf
:=
make
([]
byte
,
0
)
transport
.
Consumers
[
runtime
.
JSONMime
]
=
util
.
YANGConsumer
{
Data
:
&
buf
}
buf
fer
:=
new
(
bytes
.
Buffer
)
transport
.
Consumers
[
runtime
.
JSONMime
]
=
util
.
YANGConsumer
{
Data
:
buf
fer
}
return
MCPClient
{
return
&
MCPClient
{
transport
:
transport
,
client
:
client
,
database
:
database
,
buf
:
&
buf
,
database
:
database
,
buf
fer
:
buf
fer
,
}
}
func
(
c
*
MCPClient
)
GetConnections
()
error
{
c
.
buf
=
nil
defer
c
.
buffer
.
Reset
()
_
,
err
:=
c
.
client
.
TapiConnectivityCore
.
GetTapiCoreContextConnection
(
nil
)
c
.
database
.
StoreConnections
(
string
(
*
c
.
buf
))
c
.
buf
=
nil
c
.
database
.
StoreConnections
(
c
.
buffer
.
String
(
))
log
.
Debug
(
c
.
buffer
.
String
())
return
err
}
func
(
c
*
MCPClient
)
GetNodes
()
error
{
c
.
buf
=
nil
defer
c
.
buffer
.
Reset
()
_
,
err
:=
c
.
client
.
TapiTopologyCore
.
GetTapiCoreContextTopologyMcpBaseTopologyNode
(
nil
)
c
.
database
.
StoreNodes
(
string
(
*
c
.
buf
))
c
.
buf
=
nil
c
.
database
.
StoreNodes
(
c
.
buffer
.
String
(
))
log
.
Debug
(
c
.
buffer
.
String
())
return
err
}
func
(
c
*
MCPClient
)
GetNodeEdgePoints
()
error
{
c
.
buf
=
nil
defer
c
.
buffer
.
Reset
()
_
,
err
:=
c
.
client
.
TapiTopologyCore
.
GetTapiCoreContextTopologyMcpBaseTopologyNodeEdgePoint
(
nil
)
c
.
database
.
StoreNodeEdgePoints
(
string
(
*
c
.
buf
))
c
.
buf
=
nil
c
.
database
.
StoreNodeEdgePoints
(
c
.
buffer
.
String
(
))
log
.
Debug
(
c
.
buffer
.
String
())
return
err
}
This diff is collapsed.
Click to expand it.
restconf/util/unmarshal.go
+
3
−
4
View file @
bea49da9
package
util
import
(
"bytes"
"io"
"io/ioutil"
)
type
YANGConsumer
struct
{
Data
*
[]
byte
Data
*
byte
s
.
Buffer
}
func
(
yc
YANGConsumer
)
Consume
(
reader
io
.
Reader
,
_
interface
{})
error
{
var
err
error
=
nil
*
yc
.
Data
,
err
=
ioutil
.
ReadAll
(
reader
)
_
,
err
:=
yc
.
Data
.
ReadFrom
(
reader
)
return
err
}
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