modified to download precise images also as part of MAAS install.
[joid.git] / ci / 02-maasdeploy.sh
index 2df7c0a..c90a4eb 100755 (executable)
@@ -18,18 +18,16 @@ case "$1" in
 esac
 
 echo "... Deployment of maas Started ...."
-sudo apt-add-repository ppa:maas-deployers/stable -y
-sudo apt-get update -y
-sudo apt-get install maas-deployer -y
 
-if [ ! -e /home/ubuntu/.ssh/id_rsa ]; then
-    ssh-keygen -N '' -f /home/ubuntu/.ssh/id_rsa
+if [ ! -e $HOME/.ssh/id_rsa ]; then
+    ssh-keygen -N '' -f $HOME/.ssh/id_rsa
 fi
-sudo adduser ubuntu libvirtd
 
-if [ ! 'virsh pool-list | grep default' ]; then
+if [ ! -e /var/lib/libvirt/images ]; then
 
-    virsh pool-define /dev/stdin <<EOF
+    sudo apt-get install libvirt-bin -y
+    sudo adduser ubuntu libvirtd
+    sudo virsh pool-define /dev/stdin <<EOF
 <pool type='dir'>
   <name>default</name>
   <target>
@@ -38,18 +36,30 @@ if [ ! 'virsh pool-list | grep default' ]; then
 </pool>
 EOF
 
-    virsh pool-start default
-    virsh pool-autostart default
+    sudo virsh pool-start default
+    sudo virsh pool-autostart default
 
 fi
 
-cat /home/ubuntu/.ssh/id_rsa.pub >> /home/ubuntu/.ssh/authorized_keys
+sudo apt-add-repository ppa:maas-deployers/stable -y
+sudo apt-add-repository ppa:juju/stable -y
+sudo apt-add-repository ppa:maas/stable -y
+sudo apt-get update -y
+sudo apt-get install git maas-deployer juju juju-deployer maas-cli -y
+juju init -f
+
+cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
 maas-deployer -c deployment.yaml -d --force
+
 echo "... Deployment of maas finish ...."
 
-maas_ip=`grep " ip_address" deployment.yaml | cut -d ":"  -f 2`
+maas_ip=`grep " ip_address" deployment.yaml | cut -d " "  -f 10`
+apikey=`grep maas-oauth: environments.yaml | cut -d "'" -f 2`
+maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey}
+maas maas boot-source-selections create 1 os="ubuntu" release="trusty" arches="amd64" subarches="*" labels="*"
+maas maas boot-resources import
 
 #echo "... Deployment of opnfv release Started ...."
-python deploy.py $maas_ip
+#python deploy.py $maas_ip
 #echo "... Deployment of opnfv release finished ...."