USER = 'openmanod'
-@when('openmano.installed')
-@when('openmano.available')
+@when('openmano.installed', 'openmano.available')
def openmano_available(openmano):
# TODO make this configurable via charm config
openmano.configure(port=9090)
-@when('openmano.installed')
-@when('db.available', 'db.installed')
-@when('openvim-controller.available')
-@when('openmano.running')
+@when('openvim-controller.available',
+ 'db.available',
+ 'db.installed',
+ 'openmano.installed',
+ 'openmano.running',
+ )
def openvim_available(openvim, db):
for service in openvim.services():
for endpoint in service['hosts']:
break
-@when('openmano.installed')
-@when('db.available', 'db.installed')
-@when('openvim-controller.available')
+@when('openmano.installed',
+ 'db.installed',
+ 'openvim-controller.available')
@when_not('openmano.running')
def start(*args):
# TODO: if the service fails to start, we should raise an error to the op
set_state('openmano.running')
-@when('openmano.installed')
-@when('db.available')
+@when('db.available', 'openmano.installed')
@when_not('db.installed')
def setup_db(db):
"""Setup the database
status_set('active', 'Database installed.')
set_state('db.installed')
+
@when_not('openvim-controller.available')
def need_openvim():
status_set('waiting', 'Waiting for OpenVIM')
export OPENMANO_TENANT=$4
OPENMANO_DATACENTER=`$OPENMANO datacenter-list myov`
-if [ $? -ne 0 ]; then
+if [ $? -eq 0 ]; then
+ # If the datacenter exists, the current approach is to delete the existing
+ # one and create a new one. We may want to change this behavior to retain
+ # the existing datacenter, but this script will also go away in favour of
+ # a python API to OpenMano
+
+ # If the datacenter exists, remove all traces of it before continuing
+ OPENMANO_DATACENTER=`echo $OPENMANO_DATACENTER |gawk '{print $1}'`
+
+ # Delete netmap
+ $OPENMANO datacenter-netmap-delete --all -f --datacenter $OPENMANO_DATACENTER
+
+ # detach
+ $OPENMANO datacenter-detach -a $OPENMANO_DATACENTER
+
# Make sure the datacenter is deleted
- $OPENMANO datacenter-delete myov
+ $OPENMANO datacenter-delete --force myov
+
OPENMANO_DATACENTER=`$OPENMANO datacenter-create myov http://$1:$2/openvim`
fi
-export OPENMANO_DATACENTER=`echo $OPENMANO_DATACENTER |gawk '{print $1}'`
+OPENMANO_DATACENTER=`echo $OPENMANO_DATACENTER |gawk '{print $1}'`
-#export OPENMANO_DATACENTER=`$OPENMANO datacenter-create myov http://$1:$2/openvim |gawk '{print $1}'`
-# FIXME: don't add this to .bashrc if it already exists.
-if ! grep -q "^export OPENMANO_DATACENTER" $HOME/.bashrc
-then
- echo "export OPENMANO_DATACENTER=$OPENMANO_DATACENTER " >> $HOME/.bashrc
-fi
-# TODO: Test idempotency. We may need to check and remove existing data
+# if ! grep -q "^export OPENMANO_DATACENTER" $HOME/.bashrc
+# then
+# echo "export OPENMANO_DATACENTER=$OPENMANO_DATACENTER " >> $HOME/.bashrc
+# fi
+
$OPENMANO datacenter-attach myov --vim-tenant-id $3
$OPENMANO datacenter-netmap-import -f --datacenter $OPENMANO_DATACENTER