diff --git a/applications/rtdt-manager/README.md b/applications/rtdt-manager/README.md index 481a416686a9ddf9688a4a6f640be4bafe0070b7..b2daf92fe10b249ac9f8a90756b422c3ab6751b7 100644 --- a/applications/rtdt-manager/README.md +++ b/applications/rtdt-manager/README.md @@ -34,7 +34,9 @@ $ ./artifacts/rtdt-manager -u admin -a 172.100.0.5:55055 -p TestPassword -c appl ``` The application expects a .yaml containerlab topology file which specifies the base gosdn environment that should be used. +An example can be found in the data folder. It also takes a .json SDN configuration file which mirrors the Topology MongoDB collection. This specifies how the physical network looks. +For this, the file `downloaded-config.json` could be used. It contains a pre-defined SDN configuration with subscriptions to hostname and the interfaces path. In a use-case with an actual physical network that uses e.g. arista EOS-based switches, this would be assumed to be just retrievable from the database directly. When starting up, the application first creates the physical network automatically. It does this by first taking the base Containerlab .yaml file to configure the physical network and to @@ -49,6 +51,10 @@ instances of RabbitMQ, MongoDB, etc. The rtdt-manager subscribes to specific events in the physical network and a callback is triggered when these events occur. In this callback, the YANG path of the data that experienced a change as well as the new value can be retrieved and are applied to the NDT. +Right now there are some bugs in the event system/controller. Changing the hostname works reliably (`/system/config/hostname`), +the interfaces handler in the gNMI-target often triggers many unwanted events, so it's dangerous to subscribe to `interfaces/` +on its own. + ### Additional Changes to Code The code expects there to be a local Docker image for gnmi-target called `gnmi-target-local`. For this, you can clone the gnmi-target repo (see Section [#Building](#building)) and checkout the `interface-enabled-test`. The Makefile in this branch was modified to build this image. diff --git a/applications/rtdt-manager/main.go b/applications/rtdt-manager/main.go index 1983201e222d4628713fb62321b375e773e74a07..f95d64666e7c90a3ca5e065d2a5208e493ba58b9 100644 --- a/applications/rtdt-manager/main.go +++ b/applications/rtdt-manager/main.go @@ -16,7 +16,6 @@ func main() { var pass string var user string var clabConfigName string - var withTwin bool var benchmark bool var sdnConfigPath string @@ -26,7 +25,6 @@ func main() { 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)") @@ -35,10 +33,9 @@ func main() { 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") - fmt.Println("--with-twin: Whether to start the containerlab virtual environment for the twin") + fmt.Println("--user, -u: User to log into realnet as (Try admin)") + fmt.Println("--password, -p: Password for the user to log into realnet as (Try 'TestPassword')") + fmt.Println("--topology, -t: Topology .yaml file with entries for the goSDN environment. Used to generate realnet and twins") fmt.Println("--sdnconfig: Path to the sdnconfig .json file that contains information about network elements and links") } flag.Parse() diff --git a/applications/rtdt-manager/rtdt-manager/rtdt-manager.go b/applications/rtdt-manager/rtdt-manager/rtdt-manager.go index d08f800f64f180558ce73575eacf58221be96b84..3fcf1e822ce3fbb1dc900e451922771d92f76750 100644 --- a/applications/rtdt-manager/rtdt-manager/rtdt-manager.go +++ b/applications/rtdt-manager/rtdt-manager/rtdt-manager.go @@ -14,14 +14,10 @@ import ( "sync" "time" - // "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/networkelement" - // submanagement "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/subscriptionmanagement" "code.fbi.h-da.de/danet/gosdn/application-framework/event" - //"code.fbi.h-da.de/danet/gosdn/application-framework/registration" clabconfig "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/clab-config" "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/sdnconfig" - // "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/util" "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/benchmark" "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/venv" ) @@ -62,7 +58,7 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig return fmt.Errorf("Error in LaunchRealnet(): %w", err) } fmt.Println("Produced realnet ClabConfig file from sdnconfig and base config") - // Need to write the clab struct to disk: + // Write the clab struct to disk: realnetClabPath, err := clabconfig.ClabConfigPath() if err != nil { return fmt.Errorf("Error in LaunchRealnet() %w", err) @@ -97,7 +93,6 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig // takes a prepared sdnconfig to produce a clabConfig struct based on it func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnConfig, baseClab *clabconfig.ClabConfig) (*clabconfig.ClabConfig, error) { - // Test abort conditions if sdnConfig == nil { return nil, fmt.Errorf("Can't produce clab config without loading sdnconfig\n") } @@ -109,14 +104,12 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon pluginRegistryAddress := clabConfig.Topology.Nodes["plugin-registry"].MgmtIPv4 mongodbAddress := clabConfig.Topology.Nodes["mongodb"].MgmtIPv4 // Replace the nodes on the basis of base config - // var NewNodes map[string]clabconfig.Node for nodename, node := range clabConfig.Topology.Nodes { - // newName := fmt.Sprintf("%s-%s", nodename, name) if strings.HasPrefix(nodename, "gosdn") { node.Binds = []string{"../../../../artifacts/ssl/gosdn:/app/ssl"} - if name != "realnet" { - node.Binds = append(node.Binds, "gosdn_share:/app/gosdn_share") - } + // if name != "realnet" { + // node.Binds = append(node.Binds, "gosdn_share:/app/gosdn_share") + // } pluginRegistryAddress := fmt.Sprintf("%s:55057", pluginRegistryAddress) dbAddress := fmt.Sprintf("mongodb://root:example@%s:27017", mongodbAddress) node.Cmd = fmt.Sprintf("%s --plugin-registry %s -d %s", node.Cmd, pluginRegistryAddress, dbAddress) @@ -139,9 +132,9 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon fmt.Printf("ProduceClabConfig(): Warning: No MNE entry for node: %s\n", node.Name) } - if node.Name == "gnmi-target-switch0-test-twin" { - clabNode.Binds = append(clabNode.Binds, "mne_share:/etc/gnmi-target/mne_share") // place tests here - } + // if node.Name == "gnmi-target-switch0-test-twin" { + // clabNode.Binds = append(clabNode.Binds, "mne_share:/etc/gnmi-target/mne_share") // place tests here + // } clabConfig.Topology.Nodes[node.Name] = *clabNode } for _, link := range sdnConfig.Links { @@ -156,7 +149,8 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon } // To launch a new twin, this runs through the following steps: -// - Load the clab config for current realnet gosdn (passed on cli) +// - Retrieve the sdn topology from DB +// - Transpose topology // - Derive the config we need for twin // - Write the config to disk // - Use that config to call "containerlab deploy" diff --git a/applications/rtdt-manager/venv/venv.go b/applications/rtdt-manager/venv/venv.go index b0373a382965313aa147bcd0fe7e0363df294b8a..aaea188f9e33a49c031567756ea88b4f57ebaaff 100644 --- a/applications/rtdt-manager/venv/venv.go +++ b/applications/rtdt-manager/venv/venv.go @@ -102,7 +102,7 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi fmt.Printf("[%s] - Couldn't log in to gosdn, quitting!\n", name) return nil } else { - fmt.Printf("[%s] - Successfully logged into gosdn as user: %s, with password: %s, session token: %v\n", name, gosdnauth.GetUsername(), gosdnauth.GetPassword(), gosdnauth.GetSessionToken()) + fmt.Printf("[%s] - Successfully logged into gosdn as user: %s\n", name, gosdnauth.GetUsername()) } // Get PND of gosdn in created venv var gosdn_pnd *pnd.PrincipalNetworkDomain @@ -119,6 +119,7 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi // load topo into DB via API return &VEnv{ + Name: name, auth: gosdnauth, pnd: gosdn_pnd, conn: gosdnconn, @@ -280,7 +281,7 @@ func getTypedValue(value, ytype string) (*gnmi.TypedValue, error) { return nil, err } } - case "uint16", "uint32", "uint64": + case "uint8", "uint16", "uint32", "uint64": { uintVal, err := strconv.ParseUint(value, 10, 64) if err == nil {