Merge "Prox vnf descriptor cleanup"
[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.name }}"
18     command: destroy
19   when: network_item.name in virt_nets.list_nets
20
21 # Ignoring erros 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.name }}"
27     command: undefine
28   when: network_item.name in virt_nets.list_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.name }}"
38   when: ovs_vsctl_present.rc == 0
39
40 - name: Check if linux bridge is present
41   stat: path="{{ '/sys/class/net/'+network_item.name+'/brif/' }}"
42   register: check_linux_bridge
43
44 - name: Remove linux bridge if it exists
45   shell: |
46     ifconfig "{{ network_item.name }}" down
47     brctl delbr "{{ network_item.name }}"
48   when: check_linux_bridge.stat.exists