Merge "Replace nova attach volume to server with shade client."
[yardstick.git] / ansible / roles / infra_destroy_previous_configuration / tasks / delete_network.yml
1 # Copyright (c) 2017-2018 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15 - name: Destroy old networks created by virt
16   virt_net:
17     name: "{{ network_item }}"
18     command: destroy
19   when: clean_up | bool or network_item in deploy_nets
20
21 # Ignoring errors as network can be created without being defined.
22 # This can happen if a user manually creates a network using the virsh command.
23 # If the network is not defined the undefine code will throw an error.
24 - name: Undefine old networks defined by virt
25   virt_net:
26     name: "{{ network_item }}"
27     command: undefine
28   when: clean_up | bool or network_item in deploy_nets
29   ignore_errors: yes
30
31 - name: Check if "ovs-vsctl" command is present
32   command: which ovs-vsctl
33   register: ovs_vsctl_present
34   ignore_errors: yes
35
36 - name: Destroy OVS bridge if it exists
37   command: ovs-vsctl --if-exists -- del-br "{{ network_item }}"
38   when:
39     - ovs_vsctl_present.rc == 0
40     - clean_up | bool or network_item in deploy_nets
41   ignore_errors: yes
42
43 - name: Check if linux bridge is present
44   stat: path="{{ '/sys/class/net/' + network_item + '/brif/' }}"
45   register: check_linux_bridge
46
47 - name: Remove linux bridge if it exists
48   shell: |
49     ifconfig "{{ network_item }}" down
50     brctl delbr "{{ network_item }}"
51   when:
52     - check_linux_bridge.stat.exists
53     - clean_up | bool or network_item in deploy_nets