From 31b12c0ee5fe4902674bc7b6ba63d9edb51fff9a Mon Sep 17 00:00:00 2001 From: Neil-Jocelyn Schark <neil-jocelyn.schark@stud.h-da.de> Date: Thu, 16 Mar 2023 14:51:57 +0000 Subject: [PATCH] Improve dev setup to have a solid way to create a dev environment See merge request danet/gosdn!418 --- Makefile | 6 + README.md | 22 ++- controller/Makefile | 2 +- .../configs/development-gosdn.toml.example | 35 ++-- ...basic.clab.yaml => basic_two_aristas.yaml} | 0 dev_env_data/sdn/.gitkeep | 0 dev_env_data/sdn/basic_two_aristas.json | 175 ++++++++++++++++++ scripts/manage_virt_env.sh | 74 ++++++++ 8 files changed, 297 insertions(+), 17 deletions(-) rename dev_env_data/clab/{sts_demo_basic.clab.yaml => basic_two_aristas.yaml} (100%) delete mode 100644 dev_env_data/sdn/.gitkeep create mode 100644 dev_env_data/sdn/basic_two_aristas.json create mode 100755 scripts/manage_virt_env.sh diff --git a/Makefile b/Makefile index 6041223cb..75828fb17 100644 --- a/Makefile +++ b/Makefile @@ -135,6 +135,12 @@ shell-orchestrator: start: build-gosdn ./$(BUILD_ARTIFACTS_PATH)/gosdn -l debug --config ./controller/configs/gosdn.toml +start-dev-env: build + ./scripts/manage_virt_env.sh --mode start --topology dev_env_data/clab/basic_two_aristas.yaml --sdnconfig dev_env_data/sdn/basic_two_aristas.json + +stop-dev-env: + ./scripts/manage_virt_env.sh --mode stop --topology dev_env_data/clab/basic_two_aristas.yaml + clean: $(GOCLEAN) rm -rf $(BUILD_ARTIFACTS_PATH) diff --git a/README.md b/README.md index c4017ce74..17426aa69 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,27 @@ Information about how to use the CLI is provided in the `cli` folder, see [here] # Development Tutorial -TBD +To help with developing there is a small script available, which helps to create the complete dev environment. +For it to work, you need `go`, `docker`, `docker compose` and `containerlab`. + +For a quick start simply use `make start-dev-env` to start everything. This can take a while. Afterwards, you see the output of goSDN, to stop it hit Ctrl+C. To stop everything else use `make stop-dev-env`. + +If you want more control over your environment, you can use the `manage_virt_env.sh` script directly. + +It works like this, if you are in the projects root folder: + +`./scripts/manage_virt_env.sh --mode $(start || stop) --topology $PATH_TO_TOPOLOGY --SDNCONFIG $PATH_TO_SDNCONFIG --keepdb (optional)` + +`mode` defines if it should start or stop the environment, while the two commands `--topology` and `--sdnconfig` are used to provide the desired files. +The optional flag `keepdb` is used if you want to create the environment without reloading the SDN config file, which is handy if you just want to restart the environment. For every command there is a shortcut available (e.g. -t for --topology, etc.). + +Example usages: + +`./scripts/manage_virt_env.sh --mode start --topology dev_env_data/clab/basic_two_aristas.yaml --sdnconfig dev_env_data/sdn/basic_two_aristas.json` + +`./scripts/manage_virt_env.sh --mode start --topology dev_env_data/clab/basic_two_aristas.yaml --keepdb` + +`./scripts/manage_virt_env.sh --mode stop --topology dev_env_data/clab/basic_two_aristas.yaml` ## Backup and restore your mongodb diff --git a/controller/Makefile b/controller/Makefile index 6e9b91496..0c94ce65b 100644 --- a/controller/Makefile +++ b/controller/Makefile @@ -31,7 +31,7 @@ clean: rm -f $(BINARY_NAME) start: clean build - ENVIRONMENT=development ./$(BINARY_NAME) -l debug + GOSDN_ADMIN_PASSWORD="admin" ENVIRONMENT=development ./$(BINARY_NAME) -l debug start-insecure: clean build ENVIRONMENT=development ./$(BINARY_NAME) -l debug -s insecure diff --git a/controller/configs/development-gosdn.toml.example b/controller/configs/development-gosdn.toml.example index 74d196f15..1ff882325 100644 --- a/controller/configs/development-gosdn.toml.example +++ b/controller/configs/development-gosdn.toml.example @@ -1,17 +1,22 @@ -basepnduuid = "5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" +amqphost = 'localhost' +amqppassword = 'guest' +amqpport = '5672' +amqpprefix = 'amqp://' +amqpuser = 'guest' +basepnduuid = '5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d' basesouthboundtype = 1 -basesouthbounduuid = "ca29311a-3b17-4385-96f8-515b602a97ac" -csbi-orchestrator = "localhost:55056" +basesouthbounduuid = 'ca29311a-3b17-4385-96f8-515b602a97ac' +cli_pnd = '0455b241-5863-4660-ad15-dfde7617738e' +cli_sbi = 'a249f2d2-f7da-481d-8a99-b7f11471e0af' +config = '/home/neil/code/gosdn/controller/configs/development-gosdn.toml' +csbi-orchestrator = 'localhost:55056' +databaseconnection = 'mongodb://root:example@localhost:27017' +defaultjwtduration = 24 +filesystempathtostores = 'stores' +gnmisubscriptionspath = 'configs/gNMISubscriptions.txt' help = false -plugin-folder = "plugins" -log-level = "debug" -socket = ":55055" -databaseConnection = "mongodb://root:example@localhost:27017" -filesystemPathToStores = "stores" -gNMISubscriptionsPath = "controller/configs/gNMISubscriptions.txt" - -amqpPrefix = "amqp://" -amqpUser = "guest" -amqpPassword = "guest" -amqpHost = "localhost" -amqpPort = "5672" +log-level = 'debug' +plugin-folder = 'plugins' +pnduuid = 'bf8160d4-4659-4a1b-98fd-f409a04111ec' +security = 'insecure' +socket = ':55055' diff --git a/dev_env_data/clab/sts_demo_basic.clab.yaml b/dev_env_data/clab/basic_two_aristas.yaml similarity index 100% rename from dev_env_data/clab/sts_demo_basic.clab.yaml rename to dev_env_data/clab/basic_two_aristas.yaml diff --git a/dev_env_data/sdn/.gitkeep b/dev_env_data/sdn/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/dev_env_data/sdn/basic_two_aristas.json b/dev_env_data/sdn/basic_two_aristas.json new file mode 100644 index 000000000..501025964 --- /dev/null +++ b/dev_env_data/sdn/basic_two_aristas.json @@ -0,0 +1,175 @@ +{ + "pndID": "5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d", + "nodes": [ + { + "ID": "95a28ee8-4553-4a7b-af1f-bdd5670b43d8", + "Metadata": { + "last_updated": "2023-01-24T12:18:51.248Z", + "created_at": "2023-01-24T12:18:51.248Z" + }, + "Name": "ceos0" + }, + { + "ID": "56f265dc-092e-44f9-afb0-dd891bdc8f4b", + "Metadata": { + "last_updated": "2023-01-24T12:18:51.355Z", + "created_at": "2023-01-24T12:18:51.355Z" + }, + "Name": "ceos1" + } + ], + "ports": [ + { + "ID": "1fa479e7-d393-4d45-822d-485cc1f05fcb", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "eth2", + "Configuration": { + "IP": "0.0.0.0", + "PrefixLength": 24 + } + }, + { + "ID": "1fa479e7-d393-4d45-822d-485cc1f05fca", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "eth1", + "Configuration": { + "IP": "0.0.0.0", + "PrefixLength": 24 + } + } + ], + "links": [ + { + "ID": "82d993c3-6667-4952-b422-90ed9e6e4a26", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "test", + "SourceNode": { + "ID": "95a28ee8-4553-4a7b-af1f-bdd5670b43d8", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "ceos0" + }, + "TargetNode": { + "ID": "56f265dc-092e-44f9-afb0-dd891bdc8f4b", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "ceos1" + }, + "SourcePort": { + "ID": "1fa479e7-d393-4d45-822d-485cc1f05fcb", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "eth2", + "Configuration": { + "IP": "0.0.0.0", + "PrefixLength": 24 + } + }, + "TargetPort": { + "ID": "1fa479e7-d393-4d45-822d-485cc1f05fcb", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "eth2", + "Configuration": { + "IP": "0.0.0.0", + "PrefixLength": 24 + } + } + }, + { + "ID": "34ec541b-355a-418b-aabf-639a547b5953", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "test", + "SourceNode": { + "ID": "95a28ee8-4553-4a7b-af1f-bdd5670b43d8", + "Metadata": { + "last_updated": "2023-01-24T12:18:51.248Z", + "created_at": "2023-01-24T12:18:51.248Z" + }, + "Name": "ceos0" + }, + "TargetNode": { + "ID": "56f265dc-092e-44f9-afb0-dd891bdc8f4b", + "Metadata": { + "last_updated": "2023-01-24T12:18:51.355Z", + "created_at": "2023-01-24T12:18:51.355Z" + }, + "Name": "ceos1" + }, + "SourcePort": { + "ID": "1fa479e7-d393-4d45-822d-485cc1f05fca", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "eth1", + "Configuration": { + "IP": "0.0.0.0", + "PrefixLength": 24 + } + }, + "TargetPort": { + "ID": "1fa479e7-d393-4d45-822d-485cc1f05fca", + "Metadata": { + "last_updated": "0001-01-01T00:00:00Z", + "created_at": "0001-01-01T00:00:00Z" + }, + "Name": "eth1", + "Configuration": { + "IP": "0.0.0.0", + "PrefixLength": 24 + } + } + } + ], + "sbis": [ + { + "_id": "33028183-06bc-4b1f-b440-f40ed390a309", + "type": 1 + } + ], + "networkelements": [ + { + "id": "95a28ee8-4553-4a7b-af1f-bdd5670b43d8", + "name": "ceos0", + "transport_type": "gnmi", + "transport_address": "172.100.0.11:6030", + "transport_username": "admin", + "transport_password": "admin", + "transport_option": 1, + "sbi": "33028183-06bc-4b1f-b440-f40ed390a309", + "Model": "{\n \"openconfig-interfaces:interfaces\": {\n \"interface\": [\n {\n \"config\": {\n \"enabled\": true,\n \"loopback-mode\": false,\n \"mtu\": 0,\n \"name\": \"Ethernet1\",\n \"openconfig-vlan:tpid\": \"openconfig-vlan-types:TPID_0X8100\",\n \"type\": \"iana-if-type:ethernetCsmacd\"\n },\n \"name\": \"Ethernet1\",\n \"openconfig-if-ethernet:ethernet\": {\n \"config\": {\n \"mac-address\": \"00:00:00:00:00:00\",\n \"port-speed\": \"openconfig-if-ethernet:SPEED_UNKNOWN\"\n }\n },\n \"subinterfaces\": {\n \"subinterface\": [\n {\n \"config\": {\n \"enabled\": true,\n \"index\": 0\n },\n \"index\": 0,\n \"openconfig-if-ip:ipv4\": {\n \"addresses\": {\n \"address\": [\n {\n \"config\": {\n \"ip\": \"10.13.37.1\",\n \"prefix-length\": 24\n },\n \"ip\": \"10.13.37.1\"\n }\n ]\n },\n \"config\": {\n \"enabled\": true\n }\n }\n }\n ]\n }\n },\n {\n \"config\": {\n \"enabled\": true,\n \"loopback-mode\": false,\n \"mtu\": 0,\n \"name\": \"Ethernet2\",\n \"openconfig-vlan:tpid\": \"openconfig-vlan-types:TPID_0X8100\",\n \"type\": \"iana-if-type:ethernetCsmacd\"\n },\n \"name\": \"Ethernet2\",\n \"openconfig-if-ethernet:ethernet\": {\n \"config\": {\n \"mac-address\": \"00:00:00:00:00:00\",\n \"port-speed\": \"openconfig-if-ethernet:SPEED_UNKNOWN\"\n }\n },\n \"subinterfaces\": {\n \"subinterface\": [\n {\n \"config\": {\n \"enabled\": true,\n \"index\": 0\n },\n \"index\": 0,\n \"openconfig-if-ip:ipv4\": {\n \"addresses\": {\n \"address\": [\n {\n \"config\": {\n \"ip\": \"10.0.23.1\",\n \"prefix-length\": 24\n },\n \"ip\": \"10.0.23.1\"\n }\n ]\n },\n \"config\": {\n \"enabled\": true\n }\n }\n }\n ]\n }\n },\n {\n \"config\": {\n \"mtu\": 0,\n \"name\": \"Management0\",\n \"type\": \"iana-if-type:ethernetCsmacd\"\n },\n \"name\": \"Management0\",\n \"openconfig-if-ethernet:ethernet\": {\n \"config\": {\n \"mac-address\": \"00:00:00:00:00:00\",\n \"port-speed\": \"openconfig-if-ethernet:SPEED_UNKNOWN\"\n }\n },\n \"subinterfaces\": {\n \"subinterface\": [\n {\n \"index\": 0,\n \"openconfig-if-ip:ipv4\": {\n \"addresses\": {\n \"address\": [\n {\n \"config\": {\n \"ip\": \"172.100.0.11\",\n \"prefix-length\": 16\n },\n \"ip\": \"172.100.0.11\"\n }\n ]\n },\n \"neighbors\": {\n \"neighbor\": [\n {\n \"config\": {\n \"ip\": \"172.100.0.1\"\n },\n \"ip\": \"172.100.0.1\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n },\n \"openconfig-lldp:lldp\": {\n \"config\": {\n \"arista-lldp-augments:management-address\": {\n \"interface\": \"\",\n \"network-instance\": \"default\",\n \"transmit-mode\": \"BEST\"\n },\n \"hello-timer\": \"30\",\n \"system-description\": \"Arista Networks EOS version 4.28.2F-28369039.4282F (engineering build) running on an Arista cEOSLab\",\n \"system-name\": \"ceos0\"\n },\n \"interfaces\": {\n \"interface\": [\n {\n \"config\": {\n \"name\": \"Ethernet1\"\n },\n \"name\": \"Ethernet1\"\n },\n {\n \"config\": {\n \"name\": \"Ethernet2\"\n },\n \"name\": \"Ethernet2\"\n },\n {\n \"config\": {\n \"name\": \"Management0\"\n },\n \"name\": \"Management0\"\n }\n ]\n }\n },\n \"openconfig-network-instance:network-instances\": {\n \"network-instance\": [\n {\n \"config\": {\n \"enabled\": true,\n \"name\": \"default\",\n \"type\": \"openconfig-network-instance-types:DEFAULT_INSTANCE\"\n },\n \"mpls\": {\n \"global\": {\n \"reserved-label-blocks\": {\n \"reserved-label-block\": [\n {\n \"config\": {\n \"local-id\": \"bgp-sr\",\n \"lower-bound\": 900000,\n \"upper-bound\": 965535\n },\n \"local-id\": \"bgp-sr\"\n },\n {\n \"config\": {\n \"local-id\": \"dynamic\",\n \"lower-bound\": 100000,\n \"upper-bound\": 362143\n },\n \"local-id\": \"dynamic\"\n },\n {\n \"config\": {\n \"local-id\": \"isis-sr\",\n \"lower-bound\": 900000,\n \"upper-bound\": 965535\n },\n \"local-id\": \"isis-sr\"\n },\n {\n \"config\": {\n \"local-id\": \"l2evpn\",\n \"lower-bound\": 1036288,\n \"upper-bound\": 1048575\n },\n \"local-id\": \"l2evpn\"\n },\n {\n \"config\": {\n \"local-id\": \"l2evpnSharedEs\",\n \"lower-bound\": 1031072,\n \"upper-bound\": 1032095\n },\n \"local-id\": \"l2evpnSharedEs\"\n },\n {\n \"config\": {\n \"local-id\": \"srlb\",\n \"lower-bound\": 965536,\n \"upper-bound\": 1031071\n },\n \"local-id\": \"srlb\"\n },\n {\n \"config\": {\n \"local-id\": \"static\",\n \"lower-bound\": 16,\n \"upper-bound\": 99999\n },\n \"local-id\": \"static\"\n }\n ]\n }\n },\n \"signaling-protocols\": {\n \"rsvp-te\": {\n \"global\": {\n \"hellos\": {\n \"config\": {\n \"hello-interval\": 10000\n }\n },\n \"soft-preemption\": {\n \"config\": {\n \"enable\": true\n }\n }\n }\n }\n }\n },\n \"name\": \"default\",\n \"protocols\": {\n \"protocol\": [\n {\n \"bgp\": {\n \"global\": {\n \"afi-safis\": {\n \"afi-safi\": [\n {\n \"afi-safi-name\": \"openconfig-bgp-types:IPV4_UNICAST\",\n \"config\": {\n \"afi-safi-name\": \"openconfig-bgp-types:IPV4_UNICAST\"\n }\n },\n {\n \"afi-safi-name\": \"openconfig-bgp-types:IPV6_UNICAST\",\n \"config\": {\n \"afi-safi-name\": \"openconfig-bgp-types:IPV6_UNICAST\"\n }\n }\n ]\n }\n }\n },\n \"config\": {\n \"identifier\": \"openconfig-policy-types:BGP\",\n \"name\": \"BGP\"\n },\n \"identifier\": \"openconfig-policy-types:BGP\",\n \"name\": \"BGP\"\n },\n {\n \"config\": {\n \"identifier\": \"openconfig-policy-types:DIRECTLY_CONNECTED\",\n \"name\": \"DIRECTLY_CONNECTED\"\n },\n \"identifier\": \"openconfig-policy-types:DIRECTLY_CONNECTED\",\n \"name\": \"DIRECTLY_CONNECTED\"\n },\n {\n \"config\": {\n \"identifier\": \"openconfig-policy-types:STATIC\",\n \"name\": \"STATIC\"\n },\n \"identifier\": \"openconfig-policy-types:STATIC\",\n \"name\": \"STATIC\",\n \"static-routes\": {\n \"static\": [\n {\n \"config\": {\n \"prefix\": \"0.0.0.0/0\"\n },\n \"next-hops\": {\n \"next-hop\": [\n {\n \"config\": {\n \"index\": \"AUTO_1_172-100-0-1\",\n \"metric\": 1,\n \"next-hop\": \"172.100.0.1\"\n },\n \"index\": \"AUTO_1_172-100-0-1\"\n }\n ]\n },\n \"prefix\": \"0.0.0.0/0\"\n }\n ]\n }\n }\n ]\n },\n \"segment-routing\": {\n \"srgbs\": {\n \"srgb\": [\n {\n \"config\": {\n \"dataplane-type\": \"MPLS\",\n \"local-id\": \"isis-sr\",\n \"mpls-label-blocks\": [\n \"isis-sr\"\n ]\n },\n \"local-id\": \"isis-sr\"\n }\n ]\n },\n \"srlbs\": {\n \"srlb\": [\n {\n \"config\": {\n \"dataplane-type\": \"MPLS\",\n \"local-id\": \"srlb\",\n \"mpls-label-block\": \"srlb\"\n },\n \"local-id\": \"srlb\"\n }\n ]\n }\n },\n \"tables\": {\n \"table\": [\n {\n \"address-family\": \"openconfig-types:IPV4\",\n \"config\": {\n \"address-family\": \"openconfig-types:IPV4\",\n \"protocol\": \"openconfig-policy-types:DIRECTLY_CONNECTED\"\n },\n \"protocol\": \"openconfig-policy-types:DIRECTLY_CONNECTED\"\n },\n {\n \"address-family\": \"openconfig-types:IPV6\",\n \"config\": {\n \"address-family\": \"openconfig-types:IPV6\",\n \"protocol\": \"openconfig-policy-types:DIRECTLY_CONNECTED\"\n },\n \"protocol\": \"openconfig-policy-types:DIRECTLY_CONNECTED\"\n },\n {\n \"address-family\": \"openconfig-types:IPV4\",\n \"config\": {\n \"address-family\": \"openconfig-types:IPV4\",\n \"protocol\": \"openconfig-policy-types:STATIC\"\n },\n \"protocol\": \"openconfig-policy-types:STATIC\"\n },\n {\n \"address-family\": \"openconfig-types:IPV6\",\n \"config\": {\n \"address-family\": \"openconfig-types:IPV6\",\n \"protocol\": \"openconfig-policy-types:STATIC\"\n },\n \"protocol\": \"openconfig-policy-types:STATIC\"\n }\n ]\n },\n \"vlans\": {\n \"vlan\": [\n {\n \"config\": {\n \"name\": \"default\",\n \"vlan-id\": 1\n },\n \"vlan-id\": 1\n }\n ]\n }\n }\n ]\n },\n \"openconfig-platform:components\": {\n \"component\": [\n {\n \"config\": {\n \"name\": \"Aboot\"\n },\n \"name\": \"Aboot\"\n },\n {\n \"config\": {\n \"name\": \"BIOS\"\n },\n \"name\": \"BIOS\"\n },\n {\n \"config\": {\n \"name\": \"CPU0\"\n },\n \"name\": \"CPU0\"\n },\n {\n \"config\": {\n \"name\": \"CPU1\"\n },\n \"name\": \"CPU1\"\n },\n {\n \"config\": {\n \"name\": \"CPU10\"\n },\n \"name\": \"CPU10\"\n },\n {\n \"config\": {\n \"name\": \"CPU11\"\n },\n \"name\": \"CPU11\"\n },\n {\n \"config\": {\n \"name\": \"CPU12\"\n },\n \"name\": \"CPU12\"\n },\n {\n \"config\": {\n \"name\": \"CPU13\"\n },\n \"name\": \"CPU13\"\n },\n {\n \"config\": {\n \"name\": \"CPU14\"\n },\n \"name\": \"CPU14\"\n },\n {\n \"config\": {\n \"name\": \"CPU15\"\n },\n \"name\": \"CPU15\"\n },\n {\n \"config\": {\n \"name\": \"CPU2\"\n },\n \"name\": \"CPU2\"\n },\n {\n \"config\": {\n \"name\": \"CPU3\"\n },\n \"name\": \"CPU3\"\n },\n {\n \"config\": {\n \"name\": \"CPU4\"\n },\n \"name\": \"CPU4\"\n },\n {\n \"config\": {\n \"name\": \"CPU5\"\n },\n \"name\": \"CPU5\"\n },\n {\n \"config\": {\n \"name\": \"CPU6\"\n },\n \"name\": \"CPU6\"\n },\n {\n \"config\": {\n \"name\": \"CPU7\"\n },\n \"name\": \"CPU7\"\n },\n {\n \"config\": {\n \"name\": \"CPU8\"\n },\n \"name\": \"CPU8\"\n },\n {\n \"config\": {\n \"name\": \"CPU9\"\n },\n \"name\": \"CPU9\"\n },\n {\n \"config\": {\n \"name\": \"Chassis\"\n },\n \"name\": \"Chassis\",\n \"subcomponents\": {\n \"subcomponent\": [\n {\n \"config\": {\n \"name\": \"SwitchChip0\"\n },\n \"name\": \"SwitchChip0\"\n }\n ]\n }\n },\n {\n \"config\": {\n \"name\": \"EOS\"\n },\n \"name\": \"EOS\"\n },\n {\n \"config\": {\n \"name\": \"Ethernet1\"\n },\n \"name\": \"Ethernet1\"\n },\n {\n \"config\": {\n \"name\": \"Ethernet2\"\n },\n \"name\": \"Ethernet2\"\n },\n {\n \"config\": {\n \"name\": \"Port1\"\n },\n \"name\": \"Port1\"\n },\n {\n \"config\": {\n \"name\": \"Port2\"\n },\n \"name\": \"Port2\"\n },\n {\n \"config\": {\n \"name\": \"SwitchChip0\"\n },\n \"name\": \"SwitchChip0\",\n \"subcomponents\": {\n \"subcomponent\": [\n {\n \"config\": {\n \"name\": \"Ethernet1\"\n },\n \"name\": \"Ethernet1\"\n },\n {\n \"config\": {\n \"name\": \"Ethernet2\"\n },\n \"name\": \"Ethernet2\"\n }\n ]\n }\n },\n {\n \"config\": {\n \"name\": \"chassis-hostName\"\n },\n \"name\": \"chassis-hostName\"\n }\n ]\n },\n \"openconfig-system:system\": {\n \"aaa\": {\n \"authentication\": {\n \"config\": {\n \"authentication-method\": [\n \"openconfig-aaa-types:LOCAL\"\n ]\n },\n \"users\": {\n \"user\": [\n {\n \"config\": {\n \"password-hashed\": \"$6$/LyOizqW1THikBge$5sda5Pgj55Z20dazbvrzpc6UgRkPX6rungn.CW40peXNNQpdY8WJdczEFaSuP4XYTa.NnxEFs6Eyptfdki9ak1\",\n \"role\": \"openconfig-aaa-types:SYSTEM_ROLE_ADMIN\",\n \"username\": \"admin\"\n },\n \"username\": \"admin\"\n }\n ]\n }\n }\n },\n \"clock\": {\n \"config\": {\n \"timezone-name\": \"UTC\"\n }\n },\n \"config\": {\n \"hostname\": \"ceos0\"\n },\n \"ssh-server\": {\n \"config\": {\n \"session-limit\": 50,\n \"timeout\": 0\n }\n }\n }\n}" + }, + { + "id": "56f265dc-092e-44f9-afb0-dd891bdc8f4b", + "name": "ceos1", + "transport_type": "gnmi", + "transport_address": "172.100.0.12:6030", + "transport_username": "admin", + "transport_password": "admin", + "transport_option": 1, + "sbi": "33028183-06bc-4b1f-b440-f40ed390a309", + "Model": "{\n \"openconfig-interfaces:interfaces\": {\n \"interface\": [\n {\n \"config\": {\n \"enabled\": true,\n \"loopback-mode\": false,\n \"mtu\": 0,\n \"name\": \"Ethernet1\",\n \"openconfig-vlan:tpid\": \"openconfig-vlan-types:TPID_0X8100\",\n \"type\": \"iana-if-type:ethernetCsmacd\"\n },\n \"name\": \"Ethernet1\",\n \"openconfig-if-ethernet:ethernet\": {\n \"config\": {\n \"mac-address\": \"00:00:00:00:00:00\",\n \"port-speed\": \"openconfig-if-ethernet:SPEED_UNKNOWN\"\n }\n },\n \"subinterfaces\": {\n \"subinterface\": [\n {\n \"config\": {\n \"enabled\": true,\n \"index\": 0\n },\n \"index\": 0,\n \"openconfig-if-ip:ipv4\": {\n \"addresses\": {\n \"address\": [\n {\n \"config\": {\n \"ip\": \"10.13.37.2\",\n \"prefix-length\": 24\n },\n \"ip\": \"10.13.37.2\"\n }\n ]\n },\n \"config\": {\n \"enabled\": true\n }\n }\n }\n ]\n }\n },\n {\n \"config\": {\n \"mtu\": 0,\n \"name\": \"Ethernet2\",\n \"type\": \"iana-if-type:ethernetCsmacd\"\n },\n \"name\": \"Ethernet2\",\n \"openconfig-if-ethernet:ethernet\": {\n \"config\": {\n \"mac-address\": \"00:00:00:00:00:00\",\n \"port-speed\": \"openconfig-if-ethernet:SPEED_UNKNOWN\"\n }\n },\n \"subinterfaces\": {\n \"subinterface\": [\n {\n \"index\": 0\n }\n ]\n }\n },\n {\n \"config\": {\n \"mtu\": 0,\n \"name\": \"Management0\",\n \"type\": \"iana-if-type:ethernetCsmacd\"\n },\n \"name\": \"Management0\",\n \"openconfig-if-ethernet:ethernet\": {\n \"config\": {\n \"mac-address\": \"00:00:00:00:00:00\",\n \"port-speed\": \"openconfig-if-ethernet:SPEED_UNKNOWN\"\n }\n },\n \"subinterfaces\": {\n \"subinterface\": [\n {\n \"index\": 0,\n \"openconfig-if-ip:ipv4\": {\n \"addresses\": {\n \"address\": [\n {\n \"config\": {\n \"ip\": \"172.100.0.12\",\n \"prefix-length\": 16\n },\n \"ip\": \"172.100.0.12\"\n }\n ]\n },\n \"neighbors\": {\n \"neighbor\": [\n {\n \"config\": {\n \"ip\": \"172.100.0.1\"\n },\n \"ip\": \"172.100.0.1\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n },\n \"openconfig-lldp:lldp\": {\n \"config\": {\n \"arista-lldp-augments:management-address\": {\n \"interface\": \"\",\n \"network-instance\": \"default\",\n \"transmit-mode\": \"BEST\"\n },\n \"hello-timer\": \"30\",\n \"system-description\": \"Arista Networks EOS version 4.28.2F-28369039.4282F (engineering build) running on an Arista cEOSLab\",\n \"system-name\": \"ceos1\"\n },\n \"interfaces\": {\n \"interface\": [\n {\n \"config\": {\n \"name\": \"Ethernet1\"\n },\n \"name\": \"Ethernet1\"\n },\n {\n \"config\": {\n \"name\": \"Ethernet2\"\n },\n \"name\": \"Ethernet2\"\n },\n {\n \"config\": {\n \"name\": \"Management0\"\n },\n \"name\": \"Management0\"\n }\n ]\n }\n },\n \"openconfig-network-instance:network-instances\": {\n \"network-instance\": [\n {\n \"config\": {\n \"enabled\": true,\n \"name\": \"default\",\n \"type\": \"openconfig-network-instance-types:DEFAULT_INSTANCE\"\n },\n \"mpls\": {\n \"global\": {\n \"reserved-label-blocks\": {\n \"reserved-label-block\": [\n {\n \"config\": {\n \"local-id\": \"bgp-sr\",\n \"lower-bound\": 900000,\n \"upper-bound\": 965535\n },\n \"local-id\": \"bgp-sr\"\n },\n {\n \"config\": {\n \"local-id\": \"dynamic\",\n \"lower-bound\": 100000,\n \"upper-bound\": 362143\n },\n \"local-id\": \"dynamic\"\n },\n {\n \"config\": {\n \"local-id\": \"isis-sr\",\n \"lower-bound\": 900000,\n \"upper-bound\": 965535\n },\n \"local-id\": \"isis-sr\"\n },\n {\n \"config\": {\n \"local-id\": \"l2evpn\",\n \"lower-bound\": 1036288,\n \"upper-bound\": 1048575\n },\n \"local-id\": \"l2evpn\"\n },\n {\n \"config\": {\n \"local-id\": \"l2evpnSharedEs\",\n \"lower-bound\": 1031072,\n \"upper-bound\": 1032095\n },\n \"local-id\": \"l2evpnSharedEs\"\n },\n {\n \"config\": {\n \"local-id\": \"srlb\",\n \"lower-bound\": 965536,\n \"upper-bound\": 1031071\n },\n \"local-id\": \"srlb\"\n },\n {\n \"config\": {\n \"local-id\": \"static\",\n \"lower-bound\": 16,\n \"upper-bound\": 99999\n },\n \"local-id\": \"static\"\n }\n ]\n }\n },\n \"signaling-protocols\": {\n \"rsvp-te\": {\n \"global\": {\n \"hellos\": {\n \"config\": {\n \"hello-interval\": 10000\n }\n },\n \"soft-preemption\": {\n \"config\": {\n \"enable\": true\n }\n }\n }\n }\n }\n },\n \"name\": \"default\",\n \"protocols\": {\n \"protocol\": [\n {\n \"bgp\": {\n \"global\": {\n \"afi-safis\": {\n \"afi-safi\": [\n {\n \"afi-safi-name\": \"openconfig-bgp-types:IPV4_UNICAST\",\n \"config\": {\n \"afi-safi-name\": \"openconfig-bgp-types:IPV4_UNICAST\"\n }\n },\n {\n \"afi-safi-name\": \"openconfig-bgp-types:IPV6_UNICAST\",\n \"config\": {\n \"afi-safi-name\": \"openconfig-bgp-types:IPV6_UNICAST\"\n }\n }\n ]\n }\n }\n },\n \"config\": {\n \"identifier\": \"openconfig-policy-types:BGP\",\n \"name\": \"BGP\"\n },\n \"identifier\": \"openconfig-policy-types:BGP\",\n \"name\": \"BGP\"\n },\n {\n \"config\": {\n \"identifier\": \"openconfig-policy-types:DIRECTLY_CONNECTED\",\n \"name\": \"DIRECTLY_CONNECTED\"\n },\n \"identifier\": \"openconfig-policy-types:DIRECTLY_CONNECTED\",\n \"name\": \"DIRECTLY_CONNECTED\"\n },\n {\n \"config\": {\n \"identifier\": \"openconfig-policy-types:STATIC\",\n \"name\": \"STATIC\"\n },\n \"identifier\": \"openconfig-policy-types:STATIC\",\n \"name\": \"STATIC\",\n \"static-routes\": {\n \"static\": [\n {\n \"config\": {\n \"prefix\": \"0.0.0.0/0\"\n },\n \"next-hops\": {\n \"next-hop\": [\n {\n \"config\": {\n \"index\": \"AUTO_1_172-100-0-1\",\n \"metric\": 1,\n \"next-hop\": \"172.100.0.1\"\n },\n \"index\": \"AUTO_1_172-100-0-1\"\n }\n ]\n },\n \"prefix\": \"0.0.0.0/0\"\n }\n ]\n }\n }\n ]\n },\n \"segment-routing\": {\n \"srgbs\": {\n \"srgb\": [\n {\n \"config\": {\n \"dataplane-type\": \"MPLS\",\n \"local-id\": \"isis-sr\",\n \"mpls-label-blocks\": [\n \"isis-sr\"\n ]\n },\n \"local-id\": \"isis-sr\"\n }\n ]\n },\n \"srlbs\": {\n \"srlb\": [\n {\n \"config\": {\n \"dataplane-type\": \"MPLS\",\n \"local-id\": \"srlb\",\n \"mpls-label-block\": \"srlb\"\n },\n \"local-id\": \"srlb\"\n }\n ]\n }\n },\n \"tables\": {\n \"table\": [\n {\n \"address-family\": \"openconfig-types:IPV4\",\n \"config\": {\n \"address-family\": \"openconfig-types:IPV4\",\n \"protocol\": \"openconfig-policy-types:DIRECTLY_CONNECTED\"\n },\n \"protocol\": \"openconfig-policy-types:DIRECTLY_CONNECTED\"\n },\n {\n \"address-family\": \"openconfig-types:IPV6\",\n \"config\": {\n \"address-family\": \"openconfig-types:IPV6\",\n \"protocol\": \"openconfig-policy-types:DIRECTLY_CONNECTED\"\n },\n \"protocol\": \"openconfig-policy-types:DIRECTLY_CONNECTED\"\n },\n {\n \"address-family\": \"openconfig-types:IPV4\",\n \"config\": {\n \"address-family\": \"openconfig-types:IPV4\",\n \"protocol\": \"openconfig-policy-types:STATIC\"\n },\n \"protocol\": \"openconfig-policy-types:STATIC\"\n },\n {\n \"address-family\": \"openconfig-types:IPV6\",\n \"config\": {\n \"address-family\": \"openconfig-types:IPV6\",\n \"protocol\": \"openconfig-policy-types:STATIC\"\n },\n \"protocol\": \"openconfig-policy-types:STATIC\"\n }\n ]\n },\n \"vlans\": {\n \"vlan\": [\n {\n \"config\": {\n \"name\": \"default\",\n \"vlan-id\": 1\n },\n \"vlan-id\": 1\n }\n ]\n }\n }\n ]\n },\n \"openconfig-platform:components\": {\n \"component\": [\n {\n \"config\": {\n \"name\": \"Aboot\"\n },\n \"name\": \"Aboot\"\n },\n {\n \"config\": {\n \"name\": \"BIOS\"\n },\n \"name\": \"BIOS\"\n },\n {\n \"config\": {\n \"name\": \"CPU0\"\n },\n \"name\": \"CPU0\"\n },\n {\n \"config\": {\n \"name\": \"CPU1\"\n },\n \"name\": \"CPU1\"\n },\n {\n \"config\": {\n \"name\": \"CPU10\"\n },\n \"name\": \"CPU10\"\n },\n {\n \"config\": {\n \"name\": \"CPU11\"\n },\n \"name\": \"CPU11\"\n },\n {\n \"config\": {\n \"name\": \"CPU12\"\n },\n \"name\": \"CPU12\"\n },\n {\n \"config\": {\n \"name\": \"CPU13\"\n },\n \"name\": \"CPU13\"\n },\n {\n \"config\": {\n \"name\": \"CPU14\"\n },\n \"name\": \"CPU14\"\n },\n {\n \"config\": {\n \"name\": \"CPU15\"\n },\n \"name\": \"CPU15\"\n },\n {\n \"config\": {\n \"name\": \"CPU2\"\n },\n \"name\": \"CPU2\"\n },\n {\n \"config\": {\n \"name\": \"CPU3\"\n },\n \"name\": \"CPU3\"\n },\n {\n \"config\": {\n \"name\": \"CPU4\"\n },\n \"name\": \"CPU4\"\n },\n {\n \"config\": {\n \"name\": \"CPU5\"\n },\n \"name\": \"CPU5\"\n },\n {\n \"config\": {\n \"name\": \"CPU6\"\n },\n \"name\": \"CPU6\"\n },\n {\n \"config\": {\n \"name\": \"CPU7\"\n },\n \"name\": \"CPU7\"\n },\n {\n \"config\": {\n \"name\": \"CPU8\"\n },\n \"name\": \"CPU8\"\n },\n {\n \"config\": {\n \"name\": \"CPU9\"\n },\n \"name\": \"CPU9\"\n },\n {\n \"config\": {\n \"name\": \"Chassis\"\n },\n \"name\": \"Chassis\",\n \"subcomponents\": {\n \"subcomponent\": [\n {\n \"config\": {\n \"name\": \"SwitchChip0\"\n },\n \"name\": \"SwitchChip0\"\n }\n ]\n }\n },\n {\n \"config\": {\n \"name\": \"EOS\"\n },\n \"name\": \"EOS\"\n },\n {\n \"config\": {\n \"name\": \"Ethernet1\"\n },\n \"name\": \"Ethernet1\"\n },\n {\n \"config\": {\n \"name\": \"Ethernet2\"\n },\n \"name\": \"Ethernet2\"\n },\n {\n \"config\": {\n \"name\": \"Port1\"\n },\n \"name\": \"Port1\"\n },\n {\n \"config\": {\n \"name\": \"Port2\"\n },\n \"name\": \"Port2\"\n },\n {\n \"config\": {\n \"name\": \"SwitchChip0\"\n },\n \"name\": \"SwitchChip0\",\n \"subcomponents\": {\n \"subcomponent\": [\n {\n \"config\": {\n \"name\": \"Ethernet1\"\n },\n \"name\": \"Ethernet1\"\n },\n {\n \"config\": {\n \"name\": \"Ethernet2\"\n },\n \"name\": \"Ethernet2\"\n }\n ]\n }\n },\n {\n \"config\": {\n \"name\": \"chassis-hostName\"\n },\n \"name\": \"chassis-hostName\"\n }\n ]\n },\n \"openconfig-system:system\": {\n \"aaa\": {\n \"authentication\": {\n \"config\": {\n \"authentication-method\": [\n \"openconfig-aaa-types:LOCAL\"\n ]\n },\n \"users\": {\n \"user\": [\n {\n \"config\": {\n \"password-hashed\": \"$6$DPYiFBoPj.OoxQ/m$5Utr2c4LTYNAgzbUuTQb0OJo2zCJanOT7uTo6/0Ss0jU1dvqysxBNl.zFJU9TYO.PIEA0fhjTdWXtJ5aLuOtx.\",\n \"role\": \"openconfig-aaa-types:SYSTEM_ROLE_ADMIN\",\n \"username\": \"admin\"\n },\n \"username\": \"admin\"\n }\n ]\n }\n }\n },\n \"clock\": {\n \"config\": {\n \"timezone-name\": \"UTC\"\n }\n },\n \"config\": {\n \"hostname\": \"ceos1\"\n },\n \"ssh-server\": {\n \"config\": {\n \"session-limit\": 50,\n \"timeout\": 0\n }\n }\n }\n}" + } + ] +} \ No newline at end of file diff --git a/scripts/manage_virt_env.sh b/scripts/manage_virt_env.sh new file mode 100755 index 000000000..d5dec194a --- /dev/null +++ b/scripts/manage_virt_env.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +POSITIONAL_ARGS=() +KEEPDB='false' + +while [[ $# -gt 0 ]]; do + case $1 in + -m|--mode) + MODE="$2" + shift # past argument + shift # past value + ;; + -t|--topology) + TOPOLOGY="$2" + shift # past argument + shift # past value + ;; + -s|--sdnconfig) + SDNCONFIG="$2" + shift # past argument + shift # past value + ;; + --keepdb) + KEEPDB="true" + shift # past argument + ;; + -*|--*) + echo "Unknown option $1" + exit 1 + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift # past argument + ;; + esac +done + +start_gosdn () { + # Start controller + cd controller + GOSDN_ADMIN_PASSWORD="admin" make start & + pid=$! + cd .. +} + +if [ $MODE = 'start' ]; +then + echo "Need sudo rights." + sudo echo "sudo rights granted" + # Start databases, etc. + docker compose up -d + + # Start clab topology + if [ $KEEPDB = 'true' ]; + then + sudo containerlab deploy -t $TOPOLOGY + start_gosdn + else + sleep 5 + start_gosdn + ./artifacts/venv-manager --mode deploy --topology $TOPOLOGY --sdnconfig $SDNCONFIG + fi + + echo "#########################################################################################" + echo "Initialisation finished. You will now see the output of goSDN. Press Ctrl+C to stop it." + wait $pid +fi + +if [ $MODE = 'stop' ]; +then + docker compose down + sudo containerlab destroy -t $TOPOLOGY -c + rm -f dev_env_data/clab/.*.bak +fi -- GitLab