Skip to content
Snippets Groups Projects
Commit b9f003fe authored by S.H.'s avatar S.H.
Browse files

Introduce functions to add network Elements and to log in, using the grpc api...

Introduce functions to add network Elements and to log in, using the grpc api directly under `api/`, not `controller/api` to go around issue with reused grpc.ClientConn in the wrapper at `controller/api`, go back to using shared ssl folder for gosdn instances again
parent c290dfd8
No related branches found
No related tags found
No related merge requests found
Pipeline #262015 failed
*.bak
twin*
...@@ -98,7 +98,7 @@ func DeriveConfig(clabconfig *ClabConfig, newIPv4Subnet, newIPv6Subnet string, p ...@@ -98,7 +98,7 @@ func DeriveConfig(clabconfig *ClabConfig, newIPv4Subnet, newIPv6Subnet string, p
derivedConfig := *clabconfig derivedConfig := *clabconfig
derivedConfig.Topology.Nodes = make(map[string]Node) derivedConfig.Topology.Nodes = make(map[string]Node)
derivedConfig.Topology.Links = append([]Link{}, clabconfig.Topology.Links...) // Copy links derivedConfig.Topology.Links = append([]Link{}, clabconfig.Topology.Links...) // Copy links
portOffset := 5 // TODO set dynamically in some way portOffset := 5 // TODO set dynamically in some way
derivedConfig.Name = fmt.Sprintf("%s-%s", clabconfig.Name, postfix) derivedConfig.Name = fmt.Sprintf("%s-%s", clabconfig.Name, postfix)
subnetParts := strings.Split(newIPv4Subnet, ".") subnetParts := strings.Split(newIPv4Subnet, ".")
...@@ -114,13 +114,13 @@ func DeriveConfig(clabconfig *ClabConfig, newIPv4Subnet, newIPv6Subnet string, p ...@@ -114,13 +114,13 @@ func DeriveConfig(clabconfig *ClabConfig, newIPv4Subnet, newIPv6Subnet string, p
if strings.HasPrefix(name, "gosdn") { if strings.HasPrefix(name, "gosdn") {
node.Cmd = "--config /app/configs/containerlab-gosdn-twin.toml" node.Cmd = "--config /app/configs/containerlab-gosdn-twin.toml"
node.Binds = []string{"../../../applications/rtdt-manager/data/ssl/gosdn:/app/ssl"} //node.Binds = []string{"../../../applications/rtdt-manager/data/ssl/gosdn:/app/ssl"}
}
//use separate ssl folders, testing
if strings.HasPrefix(name, "gnmi-target") {
node.Binds = []string{"../../../applications/rtdt-manager/data/ssl/gnmi-target:/etc/gnmi-target/ssl"}
} }
//
// //use separate ssl folders, testing
// if strings.HasPrefix(name, "gnmi-target") {
// node.Binds = []string{"../../../applications/rtdt-manager/data/ssl/gnmi-target:/etc/gnmi-target/ssl"}
// }
// Ports: host side needs to be incremented or there will be conflicts // Ports: host side needs to be incremented or there will be conflicts
// for now just use 5 as increment // for now just use 5 as increment
for i, portBinding := range node.Ports { for i, portBinding := range node.Ports {
......
name: gosdn_csbi_arista_base_test-twin
mgmt:
network: gosdn_csbi_arista_base-test-twin
ipv4-subnet: 172.101.0.0/16
ipv6-subnet: 2001:db9::/64
mtu: 1500
topology:
nodes:
centos0-test-twin:
kind: linux
image: centos:8
mgmt-ipv4: 172.101.0.3
group: server
centos1-test-twin:
kind: linux
image: centos:8
mgmt-ipv4: 172.101.0.4
group: server
gnmi-target-switch0-test-twin:
kind: linux
image: registry.code.fbi.h-da.de/danet/gnmi-target/debian:master
ports:
- 7035:7030
cmd: start --ca_file /etc/gnmi-target/ssl/ca.crt --cert /etc/gnmi-target/ssl/certs/gnmi-target-selfsigned.crt --key /etc/gnmi-target/ssl/private/gnmi-target-selfsigned.key
mgmt-ipv4: 172.101.0.11
binds:
- ../../../artifacts/ssl/gnmi-target:/etc/gnmi-target/ssl
startup-delay: 5
gnmi-target-switch1-test-twin:
kind: linux
image: registry.code.fbi.h-da.de/danet/gnmi-target/debian:master
ports:
- 7036:7030
cmd: start --ca_file /etc/gnmi-target/ssl/ca.crt --cert /etc/gnmi-target/ssl/certs/gnmi-target-selfsigned.crt --key /etc/gnmi-target/ssl/private/gnmi-target-selfsigned.key
mgmt-ipv4: 172.101.0.12
binds:
- ../../../artifacts/ssl/gnmi-target:/etc/gnmi-target/ssl
startup-delay: 5
gosdn-test-twin:
kind: linux
image: gosdn
ports:
- 55060:55055
- 8085:8080
- 40005:40000
cmd: --config /app/configs/containerlab-gosdn.toml
mgmt-ipv4: 172.101.0.5
env:
GOSDN_ADMIN_PASSWORD: TestPassword
binds:
- ../../../artifacts/ssl/gosdn:/app/ssl
mongodb-express-test-twin:
kind: linux
image: mongo-express:1.0.2
ports:
- 8086:8081
mgmt-ipv4: 172.101.0.14
env:
ME_CONFIG_BASICAUTH: "false"
ME_CONFIG_MONGODB_AUTH_PASSWORD: example
ME_CONFIG_MONGODB_AUTH_USERNAME: root
ME_CONFIG_MONGODB_SERVER: mongodb
mongodb-test-twin:
kind: linux
image: mongo:7
ports:
- 27022:27017
mgmt-ipv4: 172.101.0.13
env:
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_ROOT_USERNAME: root
plugin-registry-test-twin:
kind: linux
image: plugin-registry
mgmt-ipv4: 172.101.0.16
rabbitmq-test-twin:
kind: linux
image: rabbitmq:3-management
ports:
- 127.0.0.1:5677:5672
- 127.0.0.1:15677:15672
mgmt-ipv4: 172.101.0.15
links:
- endpoints:
- gnmi-target-switch0-test-twin:eth1
- gnmi-target-switch1-test-twin:eth1
- endpoints:
- gnmi-target-switch0-test-twin:eth2
- centos0-test-twin:eth1
- endpoints:
- gnmi-target-switch1-test-twin:eth2
- centos1-test-twin:eth1
name: gosdn_csbi_arista_base_test-twin name: gosdn_csbi_arista_base-TEST-TWIN
mgmt: mgmt:
network: gosdn_csbi_arista_base-test-twin network: gosdn_csbi_arista_base-TEST-TWIN
ipv4-subnet: 172.101.0.0/16 ipv4-subnet: 172.101.0.0/16
ipv6-subnet: 2001:db9::/64 ipv6-subnet: 2001:db9::/64
mtu: 1500 mtu: 1500
topology: topology:
nodes: nodes:
centos0-test-twin: centos0:
kind: linux kind: linux
image: centos:8 image: centos:8
mgmt-ipv4: 172.101.0.3 mgmt-ipv4: 172.101.0.3
group: server group: server
centos1-test-twin: centos1:
kind: linux kind: linux
image: centos:8 image: centos:8
mgmt-ipv4: 172.101.0.4 mgmt-ipv4: 172.101.0.4
group: server group: server
gnmi-target-switch0-test-twin: gnmi-target-switch0:
kind: linux kind: linux
image: registry.code.fbi.h-da.de/danet/gnmi-target/debian:master image: registry.code.fbi.h-da.de/danet/gnmi-target/debian:master
ports: ports:
...@@ -26,7 +26,7 @@ topology: ...@@ -26,7 +26,7 @@ topology:
binds: binds:
- ../../../artifacts/ssl/gnmi-target:/etc/gnmi-target/ssl - ../../../artifacts/ssl/gnmi-target:/etc/gnmi-target/ssl
startup-delay: 5 startup-delay: 5
gnmi-target-switch1-test-twin: gnmi-target-switch1:
kind: linux kind: linux
image: registry.code.fbi.h-da.de/danet/gnmi-target/debian:master image: registry.code.fbi.h-da.de/danet/gnmi-target/debian:master
ports: ports:
...@@ -36,20 +36,29 @@ topology: ...@@ -36,20 +36,29 @@ topology:
binds: binds:
- ../../../artifacts/ssl/gnmi-target:/etc/gnmi-target/ssl - ../../../artifacts/ssl/gnmi-target:/etc/gnmi-target/ssl
startup-delay: 5 startup-delay: 5
gosdn-test-twin: gosdn:
kind: linux kind: linux
image: gosdn image: gosdn
ports: ports:
- 55060:55055 - 55060:55055
- 8085:8080 - 8085:8080
- 40005:40000 - 40005:40000
cmd: --config /app/configs/containerlab-gosdn.toml cmd: --config /app/configs/containerlab-gosdn-twin.toml
mgmt-ipv4: 172.101.0.5 mgmt-ipv4: 172.101.0.5
env: env:
GOSDN_ADMIN_PASSWORD: TestPassword GOSDN_ADMIN_PASSWORD: TestPassword
binds: binds:
- ../../../artifacts/ssl/gosdn:/app/ssl - ../../../artifacts/ssl/gosdn:/app/ssl
mongodb-express-test-twin: mongodb:
kind: linux
image: mongo:7
ports:
- 27022:27017
mgmt-ipv4: 172.101.0.13
env:
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_ROOT_USERNAME: root
mongodb-express:
kind: linux kind: linux
image: mongo-express:1.0.2 image: mongo-express:1.0.2
ports: ports:
...@@ -60,20 +69,11 @@ topology: ...@@ -60,20 +69,11 @@ topology:
ME_CONFIG_MONGODB_AUTH_PASSWORD: example ME_CONFIG_MONGODB_AUTH_PASSWORD: example
ME_CONFIG_MONGODB_AUTH_USERNAME: root ME_CONFIG_MONGODB_AUTH_USERNAME: root
ME_CONFIG_MONGODB_SERVER: mongodb ME_CONFIG_MONGODB_SERVER: mongodb
mongodb-test-twin: plugin-registry:
kind: linux
image: mongo:7
ports:
- 27022:27017
mgmt-ipv4: 172.101.0.13
env:
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_ROOT_USERNAME: root
plugin-registry-test-twin:
kind: linux kind: linux
image: plugin-registry image: plugin-registry
mgmt-ipv4: 172.101.0.16 mgmt-ipv4: 172.101.0.16
rabbitmq-test-twin: rabbitmq:
kind: linux kind: linux
image: rabbitmq:3-management image: rabbitmq:3-management
ports: ports:
...@@ -82,11 +82,11 @@ topology: ...@@ -82,11 +82,11 @@ topology:
mgmt-ipv4: 172.101.0.15 mgmt-ipv4: 172.101.0.15
links: links:
- endpoints: - endpoints:
- gnmi-target-switch0-test-twin:eth1 - gnmi-target-switch0:eth1
- gnmi-target-switch1-test-twin:eth1 - gnmi-target-switch1:eth1
- endpoints: - endpoints:
- gnmi-target-switch0-test-twin:eth2 - gnmi-target-switch0:eth2
- centos0-test-twin:eth1 - centos0:eth1
- endpoints: - endpoints:
- gnmi-target-switch1-test-twin:eth2 - gnmi-target-switch1:eth2
- centos1-test-twin:eth1 - centos1:eth1
package gosdnutil package gosdnutil
import ( import (
"time"
mnepb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/networkelement"
pnd "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" pnd "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
tpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport"
rtdt_auth "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/rtdt-auth" rtdt_auth "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/rtdt-auth"
"code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/util" "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/util"
"fmt" "fmt"
uuid "github.com/google/uuid"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
...@@ -15,13 +20,43 @@ func FetchPnd(conn *grpc.ClientConn, auth *rtdt_auth.RtdtAuth) (*pnd.PrincipalNe ...@@ -15,13 +20,43 @@ func FetchPnd(conn *grpc.ClientConn, auth *rtdt_auth.RtdtAuth) (*pnd.PrincipalNe
ctx := auth.CreateContextWithAuthorization() ctx := auth.CreateContextWithAuthorization()
pndResponse, err := pndService.GetPndList(ctx, &pnd.GetPndListRequest{Timestamp: util.Now()}) pndResponse, err := pndService.GetPndList(ctx, &pnd.GetPndListRequest{Timestamp: util.Now()})
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to retrieve PND information:\npndresponse: %v\nerror: %w\n", pndResponse, err) return nil, fmt.Errorf("Failed to retrieve PND information:\npndresponse: %v\nerror: %w\n", pndResponse, err)
} }
if pndList := pndResponse.GetPnd(); pndList != nil { if pndList := pndResponse.GetPnd(); pndList != nil {
fmt.Println("pndUUID is now: ", pndList[0].Id) fmt.Println("pndUUID is now: ", pndList[0].Id)
p = pndList[0] // TODO: Only supports one pnd for now p = pndList[0] // TODO: Only supports one pnd for now
return p, nil return p, nil
} else { } else {
return nil, fmt.Errorf("Failed to retrieve PND from Pnd List: %w", err) return nil, fmt.Errorf("Failed to retrieve PND from Pnd List: %w", err)
} }
} }
// This function is necessary because AddNetworkElement from gosdn api uses a shared connection for all created services
func AddNetworkElement(rtdtAuth *rtdt_auth.RtdtAuth, addr, mneName, mneUUID string, opt *tpb.TransportOption, pluginID, pid uuid.UUID, gNMISubscribePaths []string) (*mnepb.AddListResponse, error) {
// Here wee use the pb generated code directly instead of using nbi
mneClient := mnepb.NewNetworkElementServiceClient(rtdtAuth.GetConn())
req := &mnepb.AddListRequest{
Timestamp: time.Now().UnixNano(),
Mne: []*mnepb.SetMne{
{
Address: opt.GetAddress(),
MneName: mneName,
PluginId: pluginID.String(),
Pid: pid.String(),
TransportOption: opt,
GnmiSubscribePaths: gNMISubscribePaths,
MneId: mneUUID,
},
},
Pid: pid.String(),
}
switch t := opt.Type; t {
case spb.Type_TYPE_CONTAINERISED, spb.Type_TYPE_PLUGIN:
req.Mne[0].TransportOption.Type = t
default:
}
listResponse, err := mneClient.AddList(rtdtAuth.CreateContextWithAuthorization(), req)
// Return AddListResponse
return listResponse, err
}
...@@ -15,10 +15,10 @@ import ( ...@@ -15,10 +15,10 @@ import (
) )
func main() { func main() {
gosdn_addr1 := "172.100.0.5:55055" gosdn_addr2 := "172.100.0.5:55055"
gosdn_addr2 := "172.101.0.5:55055" gosdn_addr1 := "172.101.0.5:55055"
mneAddr1 := "172.100.0.11:7030" mneAddr2 := "172.100.0.11:7030"
mneAddr2 := "172.101.0.11:7030" mneAddr1 := "172.101.0.11:7030"
var sessionToken1 string var sessionToken1 string
var sessionToken2 string var sessionToken2 string
...@@ -60,7 +60,7 @@ func main() { ...@@ -60,7 +60,7 @@ func main() {
//pluginUUID, _ := uuid.Parse("823aad29-69be-42f0-b279-90f2c1b6a94d") //pluginUUID, _ := uuid.Parse("823aad29-69be-42f0-b279-90f2c1b6a94d")
//pluginID0, _ := uuid.Parse("d1c269a2-6482-4010-b0d8-679dff73153b") // TODO Get this dynamically //pluginID0, _ := uuid.Parse("d1c269a2-6482-4010-b0d8-679dff73153b") // TODO Get this dynamically
pluginID, _ := uuid.Parse("e2c358b3-6482-4010-b0d8-679dff73153b") // TODO Get this dynamically pluginID1, _ := uuid.Parse("e2c358b3-6482-4010-b0d8-679dff73153b") // TODO Get this dynamically
//fmt.Println("pluginID: ", pluginID) //fmt.Println("pluginID: ", pluginID)
opt := &tpb.TransportOption{ opt := &tpb.TransportOption{
...@@ -72,12 +72,12 @@ func main() { ...@@ -72,12 +72,12 @@ func main() {
GnmiTransportOption: &tpb.GnmiTransportOption{}, GnmiTransportOption: &tpb.GnmiTransportOption{},
}, },
} }
listResponse, err := api.AddNetworkElement(ctx1, gosdn_addr1, "elem1", "", opt, pluginID, pndID1, nil) listResponse, err := api.AddNetworkElement(ctx1, gosdn_addr1, "elem1", "", opt, pluginID1, pndID1, nil)
if err != nil { if err != nil {
fmt.Println("Failed to add network element: ", err) fmt.Println("Failed to add network element: ", err)
return return
} else { } else {
fmt.Println("Successfylly added network element!") fmt.Println("Successfully added network element!")
} }
_ = listResponse _ = listResponse
...@@ -87,7 +87,7 @@ func main() { ...@@ -87,7 +87,7 @@ func main() {
// Create Connection 2 // Create Connection 2
dialOption2 := grpc.WithTransportCredentials(insecure.NewCredentials()) dialOption2 := grpc.WithTransportCredentials(insecure.NewCredentials())
conn2, err := grpc.NewClient(gosdn_addr2, dialOption2, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(100*1024*1024))) conn2, err := grpc.NewClient(gosdn_addr2, dialOption2, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(100*1024*1024)))
conn2.Connect() conn2.Connect()
// Log in to controller // Log in to controller
// Register // Register
loginResponse2, err := api.Login(context.Background(), gosdn_addr2, "admin", "TestPassword") loginResponse2, err := api.Login(context.Background(), gosdn_addr2, "admin", "TestPassword")
...@@ -95,7 +95,7 @@ func main() { ...@@ -95,7 +95,7 @@ func main() {
fmt.Println("Couldn't log in to gosdn controller:", err) fmt.Println("Couldn't log in to gosdn controller:", err)
return return
} else { } else {
fmt.Println("Successully logged in to gosdn controller at", gosdn_addr2) fmt.Println("Successfully logged in to gosdn controller at", gosdn_addr2)
time.Sleep(time.Second) time.Sleep(time.Second)
} }
sessionToken2 = loginResponse2.GetToken() sessionToken2 = loginResponse2.GetToken()
...@@ -142,7 +142,7 @@ func main() { ...@@ -142,7 +142,7 @@ func main() {
fmt.Println("Failed to add network element: ", err) fmt.Println("Failed to add network element: ", err)
return return
} else { } else {
fmt.Println("Successfylly added network element!") fmt.Println("Successfully added network element!")
} }
_ = listResponse2 _ = listResponse2
conn2.Close() conn2.Close()
......
...@@ -4,12 +4,14 @@ import ( ...@@ -4,12 +4,14 @@ import (
"context" "context"
"fmt" "fmt"
"code.fbi.h-da.de/danet/gosdn/controller/api" rbac_pb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
"google.golang.org/grpc" "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/util"
grpc "google.golang.org/grpc"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
) )
type RtdtAuth struct { type RtdtAuth struct {
cc grpc.ClientConnInterface
userName string userName string
password string password string
address string address string
...@@ -19,7 +21,17 @@ type RtdtAuth struct { ...@@ -19,7 +21,17 @@ type RtdtAuth struct {
// Source: documentation on https://code.fbi.h-da.de/danet/gosdn // Source: documentation on https://code.fbi.h-da.de/danet/gosdn
func NewRtdtAuth(userName, url, password string, conn *grpc.ClientConn) *RtdtAuth { func NewRtdtAuth(userName, url, password string, conn *grpc.ClientConn) *RtdtAuth {
loginResponse, err := api.Login(context.Background(), url, userName, password) var authServiceClient rbac_pb.AuthServiceClient
authServiceClient = rbac_pb.NewAuthServiceClient(conn)
loginRequest := rbac_pb.LoginRequest{
Timestamp: util.Now(),
Username: userName,
Pwd: password,
}
// TODO Add dial option?
loginResponse, err := authServiceClient.Login(context.Background(), &loginRequest)
if err != nil { if err != nil {
fmt.Println("Encountered error while trying to log in: ", err) fmt.Println("Encountered error while trying to log in: ", err)
return nil return nil
...@@ -29,12 +41,12 @@ func NewRtdtAuth(userName, url, password string, conn *grpc.ClientConn) *RtdtAut ...@@ -29,12 +41,12 @@ func NewRtdtAuth(userName, url, password string, conn *grpc.ClientConn) *RtdtAut
password: password, password: password,
address: url, address: url,
sessionTok: loginResponse.GetToken(), sessionTok: loginResponse.GetToken(),
cc: conn,
} }
} }
// createContextWithAuthorization creates a context with the token received after login. // createContextWithAuthorization creates a context with the token received after login.
func (r *RtdtAuth) CreateContextWithAuthorization() context.Context { func (r *RtdtAuth) CreateContextWithAuthorization() context.Context {
fmt.Println("Creating Context with session token: ", r.sessionTok)
md := metadata.Pairs("authorize", r.sessionTok) md := metadata.Pairs("authorize", r.sessionTok)
return metadata.NewOutgoingContext(context.Background(), md) return metadata.NewOutgoingContext(context.Background(), md)
} }
...@@ -52,3 +64,6 @@ func (r RtdtAuth) GetUsername() string { ...@@ -52,3 +64,6 @@ func (r RtdtAuth) GetUsername() string {
func (r RtdtAuth) GetPassword() string { func (r RtdtAuth) GetPassword() string {
return r.password return r.password
} }
func (r RtdtAuth) GetConn() grpc.ClientConnInterface {
return r.cc
}
...@@ -18,7 +18,6 @@ import ( ...@@ -18,7 +18,6 @@ import (
rtdt_topology "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/rtdt-topology" rtdt_topology "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/rtdt-topology"
"code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/util" "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/util"
yangparser "code.fbi.h-da.de/danet/gosdn/applications/venv-manager/yang-parser" yangparser "code.fbi.h-da.de/danet/gosdn/applications/venv-manager/yang-parser"
"code.fbi.h-da.de/danet/gosdn/controller/api"
"code.fbi.h-da.de/danet/gosdn/models/generated/openconfig" "code.fbi.h-da.de/danet/gosdn/models/generated/openconfig"
uuid "github.com/google/uuid" uuid "github.com/google/uuid"
gnmi "github.com/openconfig/gnmi/proto/gnmi" gnmi "github.com/openconfig/gnmi/proto/gnmi"
...@@ -67,8 +66,8 @@ func NewVEnv(name, topoYamlFile, user, pass string, wg *sync.WaitGroup) *VEnv { ...@@ -67,8 +66,8 @@ func NewVEnv(name, topoYamlFile, user, pass string, wg *sync.WaitGroup) *VEnv {
} }
} }
fmt.Printf("[%s] - Sleep for 5 seconds to give containers time to settle..\n", name) fmt.Printf("[%s] - Sleep for 10 seconds to give containers time to settle..\n", name)
time.Sleep(time.Second * 5) time.Sleep(time.Second * 10)
// Now log into gosdn physical network // Now log into gosdn physical network
dialOption := grpc.WithTransportCredentials(insecure.NewCredentials()) dialOption := grpc.WithTransportCredentials(insecure.NewCredentials())
gosdnconn, err := grpc.NewClient(gosdnAddress, dialOption, grpc.WithDefaultCallOptions()) gosdnconn, err := grpc.NewClient(gosdnAddress, dialOption, grpc.WithDefaultCallOptions())
...@@ -77,9 +76,7 @@ func NewVEnv(name, topoYamlFile, user, pass string, wg *sync.WaitGroup) *VEnv { ...@@ -77,9 +76,7 @@ func NewVEnv(name, topoYamlFile, user, pass string, wg *sync.WaitGroup) *VEnv {
return nil return nil
} else { } else {
fmt.Printf("[%s] - Successfully created connection to gosdn\n", name) fmt.Printf("[%s] - Successfully created connection to gosdn\n", name)
fmt.Printf("[%s] - State of conn: \n%v\n\n", name, gosdnconn)
} }
time.Sleep(time.Second * 2)
gosdnauth := rtdt_auth.NewRtdtAuth(user, gosdnAddress, pass, gosdnconn) // logs in and stores token gosdnauth := rtdt_auth.NewRtdtAuth(user, gosdnAddress, pass, gosdnconn) // logs in and stores token
if gosdnauth == nil { if gosdnauth == nil {
fmt.Printf("[%s] - Couldn't log in to gosdn, quitting!\n", name) fmt.Printf("[%s] - Couldn't log in to gosdn, quitting!\n", name)
...@@ -139,9 +136,9 @@ func NewVEnv(name, topoYamlFile, user, pass string, wg *sync.WaitGroup) *VEnv { ...@@ -139,9 +136,9 @@ func NewVEnv(name, topoYamlFile, user, pass string, wg *sync.WaitGroup) *VEnv {
fmt.Printf("[%s] - Found target: %s with addr: %s\n", name, node, addr) fmt.Printf("[%s] - Found target: %s with addr: %s\n", name, node, addr)
fmt.Printf("[%s] - Gosdn controller at %s\n", name, gosdnAddress) fmt.Printf("[%s] - Gosdn controller at %s\n", name, gosdnAddress)
ctx := gosdnauth.CreateContextWithAuthorization()
//listResponse, err := api.AddNetworkElement(ctx, val.MgmtIPv4+":7030", node, "", opt, mneUUID, pid, []string{"/"}) //listResponse, err := api.AddNetworkElement(ctx, val.MgmtIPv4+":7030", node, "", opt, mneUUID, pid, []string{"/"})
listResponse, err := api.AddNetworkElement(ctx, gosdnAddress, node, "", opt, pluginID, pndID, []string{"/interfaces"}) listResponse, err := gosdnutil.AddNetworkElement(gosdnauth, gosdnAddress, node, "", opt, pluginID, pndID, []string{"/"})
//listResponse, err := api.AddNetworkElement(ctx, gosdnAddress, node, "", opt, pluginID, pndID, []string{"/interfaces"})
if err != nil { if err != nil {
fmt.Printf("[%s] - Failed to add network elements: %v\n", name, err) fmt.Printf("[%s] - Failed to add network elements: %v\n", name, err)
return nil return nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment