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

Fix name not being set properly in venv, add support for uint8, add advisory to README.md

parent 454a5d3d
Branches
No related tags found
No related merge requests found
Pipeline #270903 failed
...@@ -34,7 +34,9 @@ $ ./artifacts/rtdt-manager -u admin -a 172.100.0.5:55055 -p TestPassword -c appl ...@@ -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. 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. 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. 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 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. ...@@ -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 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. 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 ### 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 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. The Makefile in this branch was modified to build this image.
......
...@@ -16,7 +16,6 @@ func main() { ...@@ -16,7 +16,6 @@ func main() {
var pass string var pass string
var user string var user string
var clabConfigName string var clabConfigName string
var withTwin bool
var benchmark bool var benchmark bool
var sdnConfigPath string var sdnConfigPath string
...@@ -26,7 +25,6 @@ func main() { ...@@ -26,7 +25,6 @@ func main() {
flag.StringVar(&pass, "p", "TestPassword", "Password for admin user (shorthand)") flag.StringVar(&pass, "p", "TestPassword", "Password for admin user (shorthand)")
flag.StringVar(&user, "user", "admin", "Username") flag.StringVar(&user, "user", "admin", "Username")
flag.StringVar(&user, "u", "admin", "Username (shorthand)") 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, "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.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, "benchmark", false, "Run performance tests (measure propagation delay)")
...@@ -35,10 +33,9 @@ func main() { ...@@ -35,10 +33,9 @@ func main() {
flag.Usage = func() { flag.Usage = func() {
fmt.Println("--address, -a: Address of the gosdn controller (realnet)") fmt.Println("--address, -a: Address of the gosdn controller (realnet)")
fmt.Println("--user, -u: User to log into realnet as") 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") fmt.Println("--password, -p: Password for the user to log into realnet as (Try 'TestPassword')")
fmt.Println("--topology, -t: Topology .yaml file to use to generate realnet and twins") fmt.Println("--topology, -t: Topology .yaml file with entries for the goSDN environment. Used to generate realnet and twins")
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") fmt.Println("--sdnconfig: Path to the sdnconfig .json file that contains information about network elements and links")
} }
flag.Parse() flag.Parse()
......
...@@ -14,14 +14,10 @@ import ( ...@@ -14,14 +14,10 @@ import (
"sync" "sync"
"time" "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/event"
//"code.fbi.h-da.de/danet/gosdn/application-framework/registration"
clabconfig "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/clab-config" 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/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/benchmark"
"code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/venv" "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/venv"
) )
...@@ -62,7 +58,7 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig ...@@ -62,7 +58,7 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig
return fmt.Errorf("Error in LaunchRealnet(): %w", err) return fmt.Errorf("Error in LaunchRealnet(): %w", err)
} }
fmt.Println("Produced realnet ClabConfig file from sdnconfig and base config") 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() realnetClabPath, err := clabconfig.ClabConfigPath()
if err != nil { if err != nil {
return fmt.Errorf("Error in LaunchRealnet() %w", err) return fmt.Errorf("Error in LaunchRealnet() %w", err)
...@@ -97,7 +93,6 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig ...@@ -97,7 +93,6 @@ func (r *RtdtManager) LaunchRealnetVEnv(realnetName string, sdnConfig *sdnconfig
// takes a prepared sdnconfig to produce a clabConfig struct based on it // 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) { func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnConfig, baseClab *clabconfig.ClabConfig) (*clabconfig.ClabConfig, error) {
// Test abort conditions
if sdnConfig == nil { if sdnConfig == nil {
return nil, fmt.Errorf("Can't produce clab config without loading sdnconfig\n") 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 ...@@ -109,14 +104,12 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon
pluginRegistryAddress := clabConfig.Topology.Nodes["plugin-registry"].MgmtIPv4 pluginRegistryAddress := clabConfig.Topology.Nodes["plugin-registry"].MgmtIPv4
mongodbAddress := clabConfig.Topology.Nodes["mongodb"].MgmtIPv4 mongodbAddress := clabConfig.Topology.Nodes["mongodb"].MgmtIPv4
// Replace the nodes on the basis of base config // Replace the nodes on the basis of base config
// var NewNodes map[string]clabconfig.Node
for nodename, node := range clabConfig.Topology.Nodes { for nodename, node := range clabConfig.Topology.Nodes {
// newName := fmt.Sprintf("%s-%s", nodename, name)
if strings.HasPrefix(nodename, "gosdn") { if strings.HasPrefix(nodename, "gosdn") {
node.Binds = []string{"../../../../artifacts/ssl/gosdn:/app/ssl"} node.Binds = []string{"../../../../artifacts/ssl/gosdn:/app/ssl"}
if name != "realnet" { // if name != "realnet" {
node.Binds = append(node.Binds, "gosdn_share:/app/gosdn_share") // node.Binds = append(node.Binds, "gosdn_share:/app/gosdn_share")
} // }
pluginRegistryAddress := fmt.Sprintf("%s:55057", pluginRegistryAddress) pluginRegistryAddress := fmt.Sprintf("%s:55057", pluginRegistryAddress)
dbAddress := fmt.Sprintf("mongodb://root:example@%s:27017", mongodbAddress) dbAddress := fmt.Sprintf("mongodb://root:example@%s:27017", mongodbAddress)
node.Cmd = fmt.Sprintf("%s --plugin-registry %s -d %s", node.Cmd, pluginRegistryAddress, dbAddress) 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 ...@@ -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) fmt.Printf("ProduceClabConfig(): Warning: No MNE entry for node: %s\n", node.Name)
} }
if node.Name == "gnmi-target-switch0-test-twin" { // if node.Name == "gnmi-target-switch0-test-twin" {
clabNode.Binds = append(clabNode.Binds, "mne_share:/etc/gnmi-target/mne_share") // place tests here // clabNode.Binds = append(clabNode.Binds, "mne_share:/etc/gnmi-target/mne_share") // place tests here
} // }
clabConfig.Topology.Nodes[node.Name] = *clabNode clabConfig.Topology.Nodes[node.Name] = *clabNode
} }
for _, link := range sdnConfig.Links { for _, link := range sdnConfig.Links {
...@@ -156,7 +149,8 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon ...@@ -156,7 +149,8 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon
} }
// To launch a new twin, this runs through the following steps: // 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 // - Derive the config we need for twin
// - Write the config to disk // - Write the config to disk
// - Use that config to call "containerlab deploy" // - Use that config to call "containerlab deploy"
......
...@@ -102,7 +102,7 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi ...@@ -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) fmt.Printf("[%s] - Couldn't log in to gosdn, quitting!\n", name)
return nil return nil
} else { } 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 // Get PND of gosdn in created venv
var gosdn_pnd *pnd.PrincipalNetworkDomain var gosdn_pnd *pnd.PrincipalNetworkDomain
...@@ -119,6 +119,7 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi ...@@ -119,6 +119,7 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi
// load topo into DB via API // load topo into DB via API
return &VEnv{ return &VEnv{
Name: name,
auth: gosdnauth, auth: gosdnauth,
pnd: gosdn_pnd, pnd: gosdn_pnd,
conn: gosdnconn, conn: gosdnconn,
...@@ -280,7 +281,7 @@ func getTypedValue(value, ytype string) (*gnmi.TypedValue, error) { ...@@ -280,7 +281,7 @@ func getTypedValue(value, ytype string) (*gnmi.TypedValue, error) {
return nil, err return nil, err
} }
} }
case "uint16", "uint32", "uint64": case "uint8", "uint16", "uint32", "uint64":
{ {
uintVal, err := strconv.ParseUint(value, 10, 64) uintVal, err := strconv.ParseUint(value, 10, 64)
if err == nil { if err == nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment