#!/bin/sh

## Note: This script does not clean up network elements already existing in the storage. Running it repeatedly will
## create a garbage storage.

GOSDNC_PATH="./gosdnc"
GOSDN_ADDRESS="172.100.20.2:55055"
ADMINPW="TestPassword"
KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d"
PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d"
## Adjust this if timer is to short.
SLEEP_TIMER=20


echo 'Logging in via gosdnc and setting up KMS in controller...'

## Sleep is needed to give gosdn some time to start correctly.
sleep $SLEEP_TIMER

# TODO: Add --tls when adding certs to this!

## Call login and create entries for all the network elements.
## Could be a bit more automated in the future, but fine for now.
$GOSDNC_PATH login --controller $GOSDN_ADDRESS --u admin --p $ADMINPW
$GOSDNC_PATH pnd use $PND_UUID
$GOSDNC_PATH mne create --address 172.100.20.10:7030 --name kms01 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 0ff33c82-7fe1-482b-a0ca-67565806ee4b
$GOSDNC_PATH mne create --address 172.100.20.11:7030 --name kms02 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 5e41c291-6121-4335-84f6-41e04b8bdaa2
$GOSDNC_PATH mne create --address 172.100.20.12:7030 --name kms03 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid f80db2c0-2480-46b9-b7d1-b63f954e8227
$GOSDNC_PATH mne create --address 172.100.20.13:7030 --name kms04 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 968fd594-b0e7-41f0-ba4b-de259047a933
