From a9ccba4771acb599877ed5870778cac5ed998bfc Mon Sep 17 00:00:00 2001
From: Malte Bauch <malte.bauch@tbnet.works>
Date: Fri, 8 Apr 2022 13:24:51 +0000
Subject: [PATCH] The controllers docker did not start because of missing
 config files

See merge request danet/gosdn!277

Co-authored-by: Malte Bauch <malte.bauch@extern.h-da.de>
---
 .gitignore                                    |  1 +
 README.md                                     | 28 +++++++++++++------
 controller/Dockerfile                         |  5 +---
 controller/cmd/root.go                        |  4 +--
 controller/configs/clients.toml               |  5 ----
 .../configs/containerlab-gosdn.toml.example   | 13 +++++++++
 .../configs/development-gosdn.toml.example    |  3 +-
 controller/configs/gosdn.toml                 |  3 +-
 gosdn.clab.yaml                               |  8 +++---
 9 files changed, 42 insertions(+), 28 deletions(-)
 delete mode 100644 controller/configs/clients.toml
 create mode 100644 controller/configs/containerlab-gosdn.toml.example

diff --git a/.gitignore b/.gitignore
index ffb1b7e2d..406add7d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,4 @@ cli/gosdnc
 # testing and configs
 controller/configs/testing-gosdn.toml
 controller/configs/development-gosdn.toml
+controller/configs/containerlab-gosdn.toml
diff --git a/README.md b/README.md
index 2156d1c98..68ef7d0b2 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,8 @@
 
 # Overview
 
-`goSDN` is also an application that will allow you to manage your multi-vendor network using one unified controller.
+`goSDN` is also an application that will allow you to manage your multi-vendor
+network using one unified controller.
 
 `goSDN` provides:
 * Model driven device representation
@@ -25,7 +26,8 @@
 * Multi controller environments
 
 ## Example
-A simple showcase how the controller can be adressed after `make containerlab-start` is shown below:
+A simple showcase how the controller can be adressed after
+`make containerlab-start` is shown below:
 
 ![](gosdn-cli-showcase.webm)
 
@@ -42,9 +44,9 @@ A simple showcase how the controller can be adressed after `make containerlab-st
 
 # Concepts
 
-The `goSDN` controllers core - also called `nucleus` - is a lightweight library that
-manages principal network domains and provides southbound interface operations
-for orchestrated networking devices.
+The `goSDN` controllers core - also called `nucleus` - is a lightweight library
+that manages principal network domains and provides southbound interface
+operations for orchestrated networking devices.
 
 In addition we provide a simple Northbound-API for the controller ()
 
@@ -74,8 +76,9 @@ running `./gosdn` from the shell.
 
 # Getting Started
 
-If you want to use the the [playground](#playground) you have to make sure you have
-[containerlab](https://containerlab.dev/install/) installed on your system.
+If you want to use the the [playground](#playground) you have to make sure you
+have [containerlab](https://containerlab.dev/install/) installed on your
+system.
 
 ## Playground
 
@@ -86,9 +89,16 @@ The environment contains two [Arista
 cEOS](https://www.arista.com/en/products/software-controlled-container-networking),
 a goSDN, a cSBI orchestrator and a gNMI target.
 
-> If you're a member of the danet group you should have access to the containers repo. Don't forget to `docker login registry.code.fbi.h-da.de`
+> If you're a member of the danet group you should have access to the
+> containers repo. Don't forget to `sudo docker login
+> registry.code.fbi.h-da.de` (`sudo` is necessary since `containerlab` has to
+> be run with it and therefore a normal `docker login` wouldn't be recognized
+> by it.)
 >
-> If you're no member of the danet group you have to [create an account](https://www.arista.com/en/login) at Arista and download the Arista cEOS image by yourself. Don't forget to change the image name (line `11` in the `gosdn.clab.yml` file) to the local one you've downloaded.
+> If you're no member of the danet group you have to [create an
+> account](https://www.arista.com/en/login) at Arista and download the Arista
+> cEOS image by yourself. Don't forget to change the image name (line `11` in
+> the `gosdn.clab.yml` file) to the local one you've downloaded.
 
 ```sh
 # starts the containerlab topology which contains two Arista cEOS, an cSBI orchestrator, a goSDN controller and gNMI target.
diff --git a/controller/Dockerfile b/controller/Dockerfile
index 27f73f92a..0dd6c8756 100644
--- a/controller/Dockerfile
+++ b/controller/Dockerfile
@@ -12,10 +12,7 @@ FROM installer as builder
 COPY . .
 RUN make build
 
-#FROM scratch as gosdn
-#COPY --from=builder  /gosdn/artifacts/gosdn /
-#ENTRYPOINT ["/gosdn"]
-
 FROM builder as gosdn
 COPY controller/configs/development-gosdn.toml.example /gosdn/configs/development-gosdn.toml
+COPY controller/configs/containerlab-gosdn.toml.example /gosdn/configs/containerlab-gosdn.toml
 ENTRYPOINT ["/gosdn/artifacts/gosdn"]
diff --git a/controller/cmd/root.go b/controller/cmd/root.go
index d56e963cf..c1dad9408 100644
--- a/controller/cmd/root.go
+++ b/controller/cmd/root.go
@@ -47,7 +47,7 @@ import (
 
 var cfgFile string
 var loglevel string
-var grpcPort string
+var socket string
 var csbiOrchestrator string
 var pluginFolder string
 var security string
@@ -80,7 +80,7 @@ func init() {
 	rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./configs/gosdn.toml)")
 	rootCmd.PersistentFlags().StringVarP(&loglevel, "log-level", "l", "", "log level 'debug' or 'trace'")
 
-	rootCmd.Flags().StringVar(&grpcPort, "grpc-port", "", "port for gRPC NBI")
+	rootCmd.Flags().StringVar(&socket, "socket", "", "port for the controllers gRPC northbound interface")
 	rootCmd.Flags().StringVar(&csbiOrchestrator, "csbi-orchestrator", "", "csbi orchestrator address")
 	rootCmd.Flags().StringVar(&pluginFolder, "plugin-folder", "", "folder holding all goSDN specific plugins")
 	rootCmd.Flags().StringVarP(&security, "security", "s", "", "security level 'secure' or 'insecure'")
diff --git a/controller/configs/clients.toml b/controller/configs/clients.toml
deleted file mode 100644
index ef551bf2e..000000000
--- a/controller/configs/clients.toml
+++ /dev/null
@@ -1,5 +0,0 @@
-[[client]]
-identifier = "ciena-mcp"
-endpoint = "172.17.0.3:8080"
-gjsonDefaultPath = "data.#.object_data.tapi-object-data"
-gjsonConnectionsPath = "data.#.object_data"
diff --git a/controller/configs/containerlab-gosdn.toml.example b/controller/configs/containerlab-gosdn.toml.example
new file mode 100644
index 000000000..0a7a31bfe
--- /dev/null
+++ b/controller/configs/containerlab-gosdn.toml.example
@@ -0,0 +1,13 @@
+basepnduuid = "5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d"
+basesouthboundtype = 1
+basesouthbounduuid = "ca29311a-3b17-4385-96f8-515b602a97ac"
+cli_pnd = "0455b241-5863-4660-ad15-dfde7617738e"
+cli_sbi = "a249f2d2-f7da-481d-8a99-b7f11471e0af"
+csbi-orchestrator = "clab-gosdn_csbi_arista_base-csbi-orchestrator:55056"
+help = false
+plugin-folder = "plugins"
+log-level = "debug"
+pnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec"
+socket = ":55055"
+databaseConnection = "mongodb://root:example@clab-gosdn_csbi_arista_base-mongodb:27017"
+
diff --git a/controller/configs/development-gosdn.toml.example b/controller/configs/development-gosdn.toml.example
index a59052974..60f125602 100644
--- a/controller/configs/development-gosdn.toml.example
+++ b/controller/configs/development-gosdn.toml.example
@@ -3,10 +3,9 @@ basesouthboundtype = 1
 basesouthbounduuid = "ca29311a-3b17-4385-96f8-515b602a97ac"
 cli_pnd = "0455b241-5863-4660-ad15-dfde7617738e"
 cli_sbi = "a249f2d2-f7da-481d-8a99-b7f11471e0af"
-config = ""
 csbi-orchestrator = "localhost:55056"
-grpc-port = ""
 help = false
+plugin-folder = "plugins"
 log-level = "debug"
 pnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec"
 socket = ":55055"
diff --git a/controller/configs/gosdn.toml b/controller/configs/gosdn.toml
index ee5117006..dc3060edb 100644
--- a/controller/configs/gosdn.toml
+++ b/controller/configs/gosdn.toml
@@ -3,10 +3,9 @@ basesouthboundtype = 1
 basesouthbounduuid = "ca29311a-3b17-4385-96f8-515b602a97ac"
 cli_pnd = "0455b241-5863-4660-ad15-dfde7617738e"
 cli_sbi = "a249f2d2-f7da-481d-8a99-b7f11471e0af"
-config = ""
 csbi-orchestrator = "localhost:55056"
-grpc-port = ""
 help = false
+plugin-folder = "plugins"
 log-level = "debug"
 pnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec"
 socket = ":55055"
diff --git a/gosdn.clab.yaml b/gosdn.clab.yaml
index 8a4e239d8..407f9d8cc 100644
--- a/gosdn.clab.yaml
+++ b/gosdn.clab.yaml
@@ -36,8 +36,7 @@ topology:
         - 8080:8080
         - 40000:40000
       cmd:
-        --config /gosdn/configs/development-gosdn.toml
-        --csbi-orchestrator clab-gosdn_csbi_arista_base-csbi-orchestrator:55056
+        --config /gosdn/configs/containerlab-gosdn.toml
       mgmt_ipv4: 172.100.0.5
     gnmi-target:
       kind: linux
@@ -88,8 +87,9 @@ topology:
       ports:
         - 8081:8081
       env:
-        MONGO_INITDB_ROOT_USERNAME: root
-        MONGO_INITDB_ROOT_PASSWORD: example
+        ME_CONFIG_MONGODB_ADMINUSERNAME: root
+        ME_CONFIG_MONGODB_ADMINPASSWORD: example
+        ME_CONFIG_MONGODB_SERVER: mongodb
       mgmt_ipv4: 172.100.0.14
 
   links:
-- 
GitLab