Newer
Older
Sebastian Heiß
committed
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"sync"
"syscall"
Sebastian Heiß
committed
RtdtMan "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/rtdt-manager"
venv "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/venv"
Sebastian Heiß
committed
)
func main() {
// Global stop channel, should be passed to all venvs and App
stopChan := make(chan os.Signal, 1)
signal.Notify(stopChan, os.Interrupt, syscall.SIGTERM)
var wg sync.WaitGroup
var address string
Sebastian Heiß
committed
var pass string
var user string
var topology_file string
flag.StringVar(&address, "address", "172.100.0.5:55055", "Address of the gosdn controller")
flag.StringVar(&address, "a", "172.100.0.5:55055", "Address of the gosdn controller (shorthand)")
flag.StringVar(&pass, "password", "TestPassword", "Password for admin user")
flag.StringVar(&pass, "p", "TestPassword", "Password for admin user (shorthand)")
flag.StringVar(&user, "user", "admin", "Username")
flag.StringVar(&user, "u", "admin", "Username (shorthand)")
flag.BoolVar(&withTwin, "with-twin", false, "Whether to start a twin")
flag.StringVar(&topology_file, "topology", "data/clab.yaml", "Containerlab file on the basis of which to create topo")
flag.StringVar(&topology_file, "t", "data/clab.yaml", "Containerlab file on the basis of which to create topo (shorthand)")
flag.Usage = func() {
fmt.Println("--address, -a: Address of the gosdn controller (realnet)")
fmt.Println("--user, -u: User to log into realnet as")
fmt.Println("--password, -p: Password for the user to log into realnet as")
fmt.Println("--topology, -t: Topology .yaml file to use to generate realnet and twins")
S.H.
committed
fmt.Println("--with-twin: Whether to start the containerlab virtual environment for the twin")
Sebastian Heiß
committed
flag.Parse()
fmt.Println("Topology file path: ", topology_file)
S.H.
committed
// Start virtual environment for realnet
var realnet *venv.VEnv
S.H.
committed
realnet = venv.NewVEnv("REALNET", topology_file, user, pass, &wg)
if realnet == nil {
fmt.Println("ERROR: Couldn't deploy the physical network")
return
S.H.
committed
fmt.Println("Successfully deployed physical network")
Sebastian Heiß
committed
}
// Register realnet with rtdt-manager
rtdtMan := RtdtMan.NewRtdtManager(realnet, &wg, &stopChan)
if rtdtMan == nil {
fmt.Println("Couldn't initialize rtdt-manager, quitting!")
return
}
S.H.
committed
// err := rtdtMan.InitEventSystem()
// if err != nil {
// fmt.Printf("Error occured while initializing event system: %v", err)
// return
// }
S.H.
committed
rtdtMan.LaunchTwin("172.101.0.0/16", "2001:db9::/64", "TEST-TWIN")
if err := rtdtMan.Run(); err != nil {
fmt.Println("Program exited with errors: %w", err)