Newer
Older
Sebastian Heiß
committed
package main
import (
clabconfig "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/clab-config"
Sebastian Heiß
committed
RtdtMan "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/rtdt-manager"
"code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/sdnconfig"
//"code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/sdnconfig"
Sebastian Heiß
committed
)
func main() {
var err error
var address string
Sebastian Heiß
committed
var pass string
var user string
var clabConfigName string
var benchmark bool
var sdnConfigPath 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(&clabConfigName, "clabfile", "data/clab.yaml", "Containerlab file with basic gosdn environment")
flag.StringVar(&clabConfigName, "c", "data/clab.yaml", "Containerlab file with basic gosdn environment (shorthand)")
flag.BoolVar(&benchmark, "benchmark", false, "Run performance tests (measure propagation delay)")
flag.BoolVar(&benchmark, "b", false, "Run performance tests (measure propagation delay)")
flag.StringVar(&sdnConfigPath, "sdnconfig", "applications/rtdt-manager/data/sample_venv_sdnconfig.json", "SdnConfig file (json)")
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")
fmt.Println("--sdnconfig: Path to the sdnconfig .json file that contains information about network elements and links")
Sebastian Heiß
committed
flag.Parse()
// Register new RtdtManager
rtdtMan := RtdtMan.NewRtdtManager()
if rtdtMan == nil {
fmt.Println("Couldn't initialize rtdt-manager, quitting!")
return
}
// Load the sdnconfig .json file that contain network elements and topology information
// of the physical network first as a starting point. In a deployed physical network, this information
// would also be retrievable, making this as realistic as it can be.
sdnConfig := sdnconfig.NewSdnConfig()
err = sdnConfig.LoadSdnConfig(sdnConfigPath)
if err != nil {
fmt.Printf("In main(): %v\n", err)
return
}
// This loads the base containerlab config file that contains information on how to start
// gosdn, rabbitmq, pluginregistry and mongodb+mongodbexpress as containers
clabBaseConfig, err := clabconfig.LoadConfig(clabConfigName)
if err != nil {
fmt.Printf("In main(): %v\n", err)
return
}
// Start virtual environment for physical network. This can be skipped in an environment
// where an actual physical network is already running.
err = rtdtMan.LaunchRealnetVEnv("realnet", sdnConfig, clabBaseConfig)
if err != nil {
fmt.Printf("In main(): %v\n", err)
return
}
err = rtdtMan.InitEventSystemRealnet()
if err != nil {
fmt.Printf("In main(): %v\n", err)
return
}
// Runs the main loop
if err := rtdtMan.Run(); err != nil {
fmt.Println("Program exited with errors: %w", err)