-#read the value from deployment.yaml
-if [ -e ~/.juju/deployment.yaml ]; then
- cp ~/.juju/deployment.yaml ./deployment.yaml
- if [ -e ~/.juju/deployconfig.yaml ]; then
- cp ~/.juju/deployconfig.yaml ./deployconfig.yaml
- extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
- datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
- admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
- cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
- osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
- fi
-
- workmutiple=`maas maas nodes list | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`
+#read the value from deployconfig.yaml
+
+PROFILE=maas
+MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
+API_SERVERMAAS="http://$MAAS_IP:5240/MAAS/"
+API_KEY=`sudo maas-region apikey --username=ubuntu || true`
+
+if [[ "$API_KEY" = "" ]]; then
+ API_KEY=`sshpass -p ubuntu ssh ubuntu@$MAAS_IP 'sudo maas-region apikey --username=ubuntu'`
+fi
+
+maas login $PROFILE $API_SERVERMAAS $API_KEY
+
+if [[ "$opnfvmodel" = "openstack" ]]; then
+ if [ -e ./deployconfig.yaml ]; then
+ extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
+ datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
+ cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
+ admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
+ osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
+ fi
+
+ workmutiple=`maas maas nodes read | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`