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

Catch case in which sdnConfig isn't set in CreateDevices() (TODO: pass sdnConfig in)

parent d2737db7
No related branches found
No related tags found
No related merge requests found
Pipeline #263554 failed
...@@ -91,12 +91,9 @@ func GetNodeTemplate(kind, ipv4subnet string) *Node { ...@@ -91,12 +91,9 @@ func GetNodeTemplate(kind, ipv4subnet string) *Node {
return nil return nil
} }
ipOffset := digit + 17 ipOffset := digit + 17
fmt.Println("ipv4subnet: ", ipv4subnet)
ipv4subnetSplit := strings.Split(ipv4subnet, ".") ipv4subnetSplit := strings.Split(ipv4subnet, ".")
fmt.Printf("ipv4subnetSplit[0],[1],[2],[3]=%s:%s", ipv4subnetSplit[0], ipv4subnetSplit[1])
ipv4subnetSplit[3] = strconv.Itoa(ipOffset) ipv4subnetSplit[3] = strconv.Itoa(ipOffset)
ipv4 := strings.Join(ipv4subnetSplit, ".") ipv4 := strings.Join(ipv4subnetSplit, ".")
fmt.Println("ipv4 for centos node:", ipv4)
return &Node{ return &Node{
MgmtIPv4: ipv4, MgmtIPv4: ipv4,
Kind: "linux", Kind: "linux",
...@@ -149,6 +146,7 @@ func WriteConfig(filename string, config *ClabConfig) error { ...@@ -149,6 +146,7 @@ func WriteConfig(filename string, config *ClabConfig) error {
return nil return nil
} }
// incrementPort takes a port as a string, adds an offset, and returns the new port as a string. // incrementPort takes a port as a string, adds an offset, and returns the new port as a string.
func incrementPort(port string, offset int) (string, error) { func incrementPort(port string, offset int) (string, error) {
portNum, err := strconv.Atoi(port) portNum, err := strconv.Atoi(port)
...@@ -241,7 +239,6 @@ func DeriveConfig(clabconfig *ClabConfig, newIPv4Subnet, newIPv6Subnet string, p ...@@ -241,7 +239,6 @@ func DeriveConfig(clabconfig *ClabConfig, newIPv4Subnet, newIPv6Subnet string, p
return &derivedConfig, nil return &derivedConfig, nil
} }
func ClabDestroy(fullPath string) error { func ClabDestroy(fullPath string) error {
fmt.Println("Trying to destroy venv: ", fullPath) fmt.Println("Trying to destroy venv: ", fullPath)
cmd := exec.Command("sudo", "containerlab", "destroy", "-t", fullPath) cmd := exec.Command("sudo", "containerlab", "destroy", "-t", fullPath)
......
...@@ -77,7 +77,6 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig ...@@ -77,7 +77,6 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig
fmt.Printf("Error: Couldn't create devices!") fmt.Printf("Error: Couldn't create devices!")
return err return err
} }
return nil
// Now setup the just-created environment // Now setup the just-created environment
// Need to: // Need to:
...@@ -87,6 +86,7 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig ...@@ -87,6 +86,7 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig
fmt.Printf("Error occured while trying to construct topology in r.realnet: %v\n", err) fmt.Printf("Error occured while trying to construct topology in r.realnet: %v\n", err)
return err return err
} }
return nil
err = r.realnet.UploadClabConfig() err = r.realnet.UploadClabConfig()
if err != nil { if err != nil {
fmt.Printf("Error: Couldnt upload clab config: %v\n", err) fmt.Printf("Error: Couldnt upload clab config: %v\n", err)
...@@ -134,7 +134,6 @@ func (r *RtdtManager) ProduceClabConfig(clabName string, c *clabconfig.ClabConfi ...@@ -134,7 +134,6 @@ func (r *RtdtManager) ProduceClabConfig(clabName string, c *clabconfig.ClabConfi
} }
for _, node := range sdnConfig.Nodes { for _, node := range sdnConfig.Nodes {
var clabNode *clabconfig.Node var clabNode *clabconfig.Node
fmt.Println("Nodename:", node.Name)
clabNode = clabconfig.GetNodeTemplate(node.Name, c.Mgmt.IPv4Subnet) clabNode = clabconfig.GetNodeTemplate(node.Name, c.Mgmt.IPv4Subnet)
if clabNode == nil { if clabNode == nil {
...@@ -306,6 +305,7 @@ func (r *RtdtManager) Run() error { ...@@ -306,6 +305,7 @@ func (r *RtdtManager) Run() error {
// Receive events from realnet VEnv // Receive events from realnet VEnv
func (r *RtdtManager) InitEventSystem() error { func (r *RtdtManager) InitEventSystem() error {
fmt.Println("Starting Event System for realnet!")
realnet_auth := r.realnet.GetAuth() realnet_auth := r.realnet.GetAuth()
ctx := realnet_auth.CreateContextWithAuthorization() ctx := realnet_auth.CreateContextWithAuthorization()
queueCredentials, err := registration.Register(ctx, realnet_auth.GetAddress(), "basic-interface-monitoring", "SecurePresharedToken") queueCredentials, err := registration.Register(ctx, realnet_auth.GetAddress(), "basic-interface-monitoring", "SecurePresharedToken")
......
...@@ -37,7 +37,7 @@ type VEnv struct { ...@@ -37,7 +37,7 @@ type VEnv struct {
conn *grpc.ClientConn // The connection to this specific environment's gosdn conn *grpc.ClientConn // The connection to this specific environment's gosdn
pnd *pnd.PrincipalNetworkDomain pnd *pnd.PrincipalNetworkDomain
clabData *clabconfig.ClabConfig // Represents yaml file that was used to deploy clabData *clabconfig.ClabConfig // Represents yaml file that was used to deploy
sdnConfig *sdnconfig.SdnConfig // Represents json config file for configuration grpc interface sdnConfig sdnconfig.SdnConfig // Represents json config file for configuration grpc interface
topology *rtdt_topology.Topology topology *rtdt_topology.Topology
clabFilename string // This is the name of the yaml file clabData is based on clabFilename string // This is the name of the yaml file clabData is based on
StopChan <-chan struct{} StopChan <-chan struct{}
...@@ -49,7 +49,7 @@ type VEnv struct { ...@@ -49,7 +49,7 @@ type VEnv struct {
// Accepts a yaml filename to deploy a container lab environment // Accepts a yaml filename to deploy a container lab environment
// TODO Split up into sub-functions // TODO Split up into sub-functions
// This takes FULL path name to clab config // This takes FULL path name to clab config
func NewVEnv(name string, clabFilename, user, pass string, wg *sync.WaitGroup) *VEnv { func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup) *VEnv {
fmt.Printf("[%s] - Creating new virtual environment\n", name) fmt.Printf("[%s] - Creating new virtual environment\n", name)
wg.Add(1) // Register the venv and run atleast until it calls wg.Done() wg.Add(1) // Register the venv and run atleast until it calls wg.Done()
var err error var err error
...@@ -125,6 +125,10 @@ func NewVEnv(name string, clabFilename, user, pass string, wg *sync.WaitGroup) * ...@@ -125,6 +125,10 @@ func NewVEnv(name string, clabFilename, user, pass string, wg *sync.WaitGroup) *
// Based on saved sdnconfig, create devices // Based on saved sdnconfig, create devices
func (v *VEnv) CreateDevices() error { func (v *VEnv) CreateDevices() error {
// Alternative (better) approach // Alternative (better) approach
fmt.Println("Creating devices now!")
if v.sdnConfig == nil {
return fmt.Errorf("Can't create devices without sdnConfig being set")
}
for _, mne := range v.sdnConfig.NetworkElements { for _, mne := range v.sdnConfig.NetworkElements {
fmt.Printf("[%s] - Found mne target: %s with addr: %s\n", v.Name, mne.Name, mne.TransportAddress) fmt.Printf("[%s] - Found mne target: %s with addr: %s\n", v.Name, mne.Name, mne.TransportAddress)
opt := &tpb.TransportOption{ opt := &tpb.TransportOption{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment