Skip to content
Snippets Groups Projects
Commit 31b12c0e authored by Neil-Jocelyn Schark's avatar Neil-Jocelyn Schark Committed by Malte Bauch
Browse files

Improve dev setup to have a solid way to create a dev environment

See merge request !418
parent 85d411a9
No related branches found
No related tags found
2 merge requests!442Develop,!418Improve dev setup to have a solid way to create a dev environment
Pipeline #136020 failed
......@@ -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)
......@@ -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
......
......@@ -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
......
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'
This diff is collapsed.
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment