include the cleanupvm to remove the virtual machines also. 67/4467/2
authorNarinder Gupta <narinder.gupta@canonical.com>
Mon, 14 Dec 2015 21:13:14 +0000 (15:13 -0600)
committerNarinder Gupta <narinder.gupta@canonical.com>
Mon, 14 Dec 2015 23:28:25 +0000 (17:28 -0600)
modified maasdeploy.sh to include current user in no password list.

Change-Id: I3087f3a73e719686a9d4e0f58c1ada1850fc7b61

ci/02-maasdeploy.sh
ci/cleanvm.sh [new file with mode: 0644]

index 0fb88bb..fb72ccd 100755 (executable)
@@ -26,6 +26,20 @@ case "$1" in
         ;;
 esac
 
+#make sure no password asked during the deployment. 
+
+echo "$USER ALL=(ALL) NOPASSWD:ALL" > 90-joid-init
+
+if [ -e /etc/sudoers.d/90-joid-init ]; then
+    cp /etc/sudoers.d/90-joid-init 91-joid-init
+    cat 90-joid-init >> 91-joid-init
+    sudo chown root:root 90-joid-init
+    sudo mv 91-joid-init /etc/sudoers.d/
+else
+    sudo chown root:root 90-joid-init
+    sudo mv 90-joid-init /etc/sudoers.d/
+fi
+
 echo "... Deployment of maas Started ...."
 
 if [ ! -e $HOME/.ssh/id_rsa ]; then
@@ -90,11 +104,11 @@ if [ $virtinstall ]; then
     maas maas tags new name='control'
     maas maas tags new name='compute'
 
-    controlnodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node1-control' tags='control' hostname='node1-control' power_type='virsh' mac_addresses=$node1controlmac power_parameters_power_address='qemu+ssh://ubuntu@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node1-control' | grep system_id | cut -d '"' -f 4 `
+    controlnodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node1-control' tags='control' hostname='node1-control' power_type='virsh' mac_addresses=$node1controlmac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node1-control' | grep system_id | cut -d '"' -f 4 `
 
     maas maas tag update-nodes control add=$controlnodeid
 
-    computenodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node2-compute' tags='compute' hostname='node2-compute' power_type='virsh' mac_addresses=$node2computemac power_parameters_power_address='qemu+ssh://ubuntu@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node2-compute' | grep system_id | cut -d '"' -f 4 `
+    computenodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node2-compute' tags='compute' hostname='node2-compute' power_type='virsh' mac_addresses=$node2computemac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node2-compute' | grep system_id | cut -d '"' -f 4 `
 
     maas maas tag update-nodes compute add=$computenodeid
 
diff --git a/ci/cleanvm.sh b/ci/cleanvm.sh
new file mode 100644 (file)
index 0000000..0cb513e
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -ex
+
+#use the below commands if you needs to delete the virtual machine
+# also along with envuronment destroy.
+
+echo " Cleanup Started ..."
+./clean.sh
+virsh destroy opnfv-maas || true
+virsh destroy bootstrap || true
+virsh destroy node1-control || true
+virsh destroy node2-compute || true
+virsh undefine opnfv-maas || true
+virsh undefine bootstrap || true
+virsh undefine node1-control || true
+virsh undefine node2-compute || true
+sudo rm -rf  /var/lib/libvirt/images/bootstrap.img /var/lib/libvirt/images/node1-control.img /var/lib/libvirt/images/node2-compute.img || true
+
+echo " Cleanup Finished ..."