Change-Id: If268a5ae1f0a103314f1ab742b495de3ffdb5efc
Signed-off-by: Narinder Gupta <narinder.gupta@canonical.com>
PROFILE=maas
MAAS_IP=$(grep " ip_address" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //')
API_SERVERMAAS="http://$MAAS_IP/MAAS/"
-API_KEY=`sudo maas-region apikey --username=ubuntu`
+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
sudo apt-get dist-upgrade -y
sudo apt-get install openssh-server bzr git juju virtinst qemu-kvm libvirt-bin \
maas maas-region-controller python-pip python-psutil python-openstackclient \
- python-congressclient gsutil charm-tools pastebinit python-jinja2 -y
+ python-congressclient gsutil charm-tools pastebinit python-jinja2 sshpass -y
sudo pip install --upgrade pip