CORD-2522 Delete VMs in ERROR state
Change-Id: I3befe68f1e8b896225d7dc67159c5c5fa1338bb8
diff --git a/roles/test-mcord-base/tasks/main.yml b/roles/test-mcord-base/tasks/main.yml
index aa5ae9a..111e019 100644
--- a/roles/test-mcord-base/tasks/main.yml
+++ b/roles/test-mcord-base/tasks/main.yml
@@ -17,7 +17,9 @@
# Run tests to check that the base elements of M-CORD are present
- name: Wait for networks to be synchronized
- shell: bash -c "source /opt/cord_profile/admin-openrc.sh; neutron net-list|grep '{{ item }}' > /dev/null"
+ shell: source /opt/cord_profile/admin-openrc.sh; neutron net-list|grep '{{ item }}' > /dev/null
+ args:
+ executable: /bin/bash
register: result
until: result | success
retries: 10
@@ -26,8 +28,29 @@
tags:
- skip_ansible_lint # running a sub job
+- name: Wait for VMs to appear in Nova
+ shell: source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item }}' > /dev/null
+ args:
+ executable: /bin/bash
+ register: result
+ until: result | success
+ retries: 10
+ delay: 60
+ with_items: "{{ test_services }}"
+ tags:
+ - skip_ansible_lint # running a sub job
+
+- name: Delete any VMs that are in ERROR state (XOS will re-create them)
+ shell: source /opt/cord_profile/admin-openrc.sh; for vm in $(nova list --all-tenants|grep 'ERROR'|awk '{ print $2 }'); do nova delete $vm; done
+ args:
+ executable: /bin/bash
+ tags:
+ - skip_ansible_lint # running a sub job
+
- name: Wait for VMs to come up
- shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item }}.*ACTIVE' > /dev/null"
+ shell: source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item }}.*ACTIVE' > /dev/null
+ args:
+ executable: /bin/bash
register: result
until: result | success
retries: 10
@@ -37,7 +60,9 @@
- skip_ansible_lint # running a sub job
- name: Verify that VMs are properly networked
- shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item.vm }}.*ACTIVE.*{{ item.network }}' > /dev/null"
+ shell: source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item.vm }}.*ACTIVE.*{{ item.network }}' > /dev/null
+ args:
+ executable: /bin/bash
with_items: "{{ test_ports }}"
tags:
- skip_ansible_lint # running a sub job