Merge "Document for Euphrates test case results"
[yardstick.git] / ansible / roles / infra_destroy_previous_configuration / tasks / delete_network.yml
index 314ee30..5e61633 100644 (file)
 ---
 - name: Destroy old networks created by virt
   virt_net:
-    name: "{{ network_item.name }}"
+    name: "{{ network_item }}"
     command: destroy
-  when: network_item.name in virt_nets.list_nets
+  when: clean_up | bool or network_item in deploy_nets
 
-# Ignoring erros as network can be created without being defined.
+# Ignoring errors as network can be created without being defined.
 # This can happen if a user manually creates a network using the virsh command.
 # If the network is not defined the undefine code will throw an error.
 - name: Undefine old networks defined by virt
   virt_net:
-    name: "{{ network_item.name }}"
+    name: "{{ network_item }}"
     command: undefine
-  when: network_item.name in virt_nets.list_nets
+  when: clean_up | bool or network_item in deploy_nets
   ignore_errors: yes
 
 - name: Check if "ovs-vsctl" command is present
   ignore_errors: yes
 
 - name: Destroy OVS bridge if it exists
-  command: ovs-vsctl --if-exists -- del-br "{{ network_item.name }}"
-  when: ovs_vsctl_present.rc == 0
+  command: ovs-vsctl --if-exists -- del-br "{{ network_item }}"
+  when:
+    - ovs_vsctl_present.rc == 0
+    - clean_up | bool or network_item in deploy_nets
+  ignore_errors: yes
 
 - name: Check if linux bridge is present
-  stat: path="{{ '/sys/class/net/'+network_item.name+'/brif/' }}"
+  stat: path="{{ '/sys/class/net/' + network_item + '/brif/' }}"
   register: check_linux_bridge
 
 - name: Remove linux bridge if it exists
   shell: |
-    ifconfig "{{ network_item.name }}" down
-    brctl delbr "{{ network_item.name }}"
-  when: check_linux_bridge.stat.exists
+    ifconfig "{{ network_item }}" down
+    brctl delbr "{{ network_item }}"
+  when:
+    - check_linux_bridge.stat.exists
+    - clean_up | bool or network_item in deploy_nets