summaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
authorRyota MIBU <r-mibu@cq.jp.nec.com>2017-01-27 04:44:48 +0000
committerRyota MIBU <r-mibu@cq.jp.nec.com>2017-01-27 04:48:17 +0000
commit50e1c44f64585abe63bd40982cb379412045fa33 (patch)
tree885484b9ccf27f0e0a18fc208e1d769c989df7e2 /ci
parent59f0f3aa4b49425e19369b2d5fe7b55688b23f7f (diff)
improvements for default virtual pod creation
This patch includes the following improvements: - deprecate ci/00-maasdeploy.sh - refactor cleaner sctipts - fix MAAS_IP in default configs Change-Id: I60f77e18ce41573a744d79b8cf468c23a7dd3385 Signed-off-by: Ryota MIBU <r-mibu@cq.jp.nec.com>
Diffstat (limited to 'ci')
-rwxr-xr-xci/00-maasdeploy.sh6
-rwxr-xr-xci/03-maasdeploy.sh13
-rwxr-xr-xci/clean.sh3
-rwxr-xr-xci/cleanmaas.sh11
-rwxr-xr-xci/cleanvm.sh33
5 files changed, 33 insertions, 33 deletions
diff --git a/ci/00-maasdeploy.sh b/ci/00-maasdeploy.sh
index f87e2d3d..38bf3537 100755
--- a/ci/00-maasdeploy.sh
+++ b/ci/00-maasdeploy.sh
@@ -2,6 +2,12 @@
#placeholder for deployment script.
set -ex
+echo "Note: This script is deprecated. Use 03-maasdeploy.sh instead."
+echo "Are you sure you want to execute this script? [y/N] "
+read a
+[[ "$a" = "y" ]] || exit
+
+
virtinstall=0
labname=$1
diff --git a/ci/03-maasdeploy.sh b/ci/03-maasdeploy.sh
index 8bafea5b..2dd0c269 100755
--- a/ci/03-maasdeploy.sh
+++ b/ci/03-maasdeploy.sh
@@ -2,14 +2,6 @@
#placeholder for deployment script.
set -ex
-maasver=`apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/ //'`
-
-if [[ "$maasver" > "2" ]]; then
- echo "removing existing maas ..."
- #sudo apt-get purge maas maas-cli maas-common maas-dhcp maas-dns maas-proxy maas-rack-controller maas-region-api maas-region-controller -y
- #sudo rm -rf /var/lib/maas
-fi
-
virtinstall=0
labname=$1
@@ -182,7 +174,10 @@ fi
if [ ! -e ~maas/.ssh/id_rsa.pub ]; then
- sudo su - $USER -c "echo |ssh-keygen -t rsa -f $HOME/id_rsa_maas"
+ if [ ! -e $HOME/id_rsa_maas.pub ]; then
+ [ -e $HOME/id_rsa_maas ] && rm -f $HOME/id_rsa_maas
+ sudo su - $USER -c "echo |ssh-keygen -t rsa -f $HOME/id_rsa_maas"
+ fi
sudo -u maas mkdir ~maas/.ssh/ || true
sudo cp $HOME/id_rsa_maas ~maas/.ssh/id_rsa
sudo cp $HOME/id_rsa_maas.pub ~maas/.ssh/id_rsa.pub
diff --git a/ci/clean.sh b/ci/clean.sh
index 3b0ab34f..aa14fe76 100755
--- a/ci/clean.sh
+++ b/ci/clean.sh
@@ -46,6 +46,3 @@ elif [ -d $HOME/.juju/environments ]; then
rm -rf $HOME/.juju/ssh
sudo sysctl -w vm.drop_caches=3
fi
-
-#sudo apt-get purge maas maas-cli maas-common maas-dhcp maas-dns maas-proxy maas-rack-controller maas-region-api maas-region-controller -y
-#sudo rm -rf /var/lib/maas
diff --git a/ci/cleanmaas.sh b/ci/cleanmaas.sh
new file mode 100755
index 00000000..40961359
--- /dev/null
+++ b/ci/cleanmaas.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -ex
+
+maasver=$(apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/^.*: //')
+
+if [[ "$maasver" > "2" ]]; then
+ echo "removing existing maas ..."
+ sudo apt-get purge maas maas-cli maas-common maas-dhcp maas-dns maas-proxy maas-rack-controller maas-region-api maas-region-controller -y
+ sudo rm -rf /var/lib/maas
+fi
diff --git a/ci/cleanvm.sh b/ci/cleanvm.sh
index 73c61c4b..d4f1f3bd 100755
--- a/ci/cleanvm.sh
+++ b/ci/cleanvm.sh
@@ -2,30 +2,21 @@
set -ex
+echo " Cleanup Started ..."
+
#use the below commands if you needs to delete the virtual machine
# also along with envuronment destroy.
-
-echo " Cleanup Started ..."
./clean.sh || true
-
-maasver=`apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/ //'`
-sudo virsh destroy node1-control || true
-sudo virsh destroy node3-control || true
-sudo virsh destroy node4-control || true
-sudo virsh destroy node2-compute || true
-sudo virsh destroy node5-compute || true
-sudo virsh undefine node1-control || true
-sudo virsh undefine node3-control || true
-sudo virsh undefine node4-control || true
-sudo virsh undefine node2-compute || true
-sudo virsh undefine node5-compute || true
-sudo rm -rf /var/lib/libvirt/images/node1-control.qcow2 /var/lib/libvirt/images/node2-compute.qcow2 /var/lib/libvirt/images/node3-control.qcow2 /var/lib/libvirt/images/node4-control.qcow2 /var/lib/libvirt/images/node5-compute.qcow2 || true
-
-if [[ "$maasver" > "2" ]]; then
- sudo virsh destroy bootstrap || true
- sudo virsh undefine bootstrap || true
- sudo rm -rf /var/lib/libvirt/images/bootstrap.qcow2 || true
-fi
+vm_list=$(sudo virsh list --all)
+
+for vm in node1-control node2-compute node3-control node4-control \
+ node5-compute bootstrap
+do
+ echo "$vm_list" | grep -q " $vm " || continue
+ sudo virsh destroy $vm
+ sudo virsh undefine $vm
+ sudo rm -f /var/lib/libvirt/images/${vm}.qcow2
+done
echo " Cleanup Finished ..."