Browse Source

Post Fuel deployment, remove default OpenStack network configuration which doesn't work with Calico.

Change-Id: I843cc94d787efe43f86ab73120b0c4ab4ed42a72
Emma Gordon 3 years ago
parent
commit
21cc049030
2 changed files with 53 additions and 0 deletions
  1. 45
    0
      deployment_scripts/remove_default_networks.sh
  2. 8
    0
      tasks.yaml

+ 45
- 0
deployment_scripts/remove_default_networks.sh View File

@@ -0,0 +1,45 @@
1
+#!/bin/bash
2
+# This script removes default network config created in OpenStack as part of a
3
+# Fuel deployment. These networks do not work for instance creation with
4
+# Calico, so need to be removed.
5
+
6
+# OpenStack authentication and authorization requires environment variables
7
+# contained in the openrc file, this will allow us to issue commands via the 
8
+# neutron API.
9
+source /root/openrc
10
+
11
+# Details of the default networks/routers created on Fuel deployment of a
12
+# Mirantis OpenStack environment.
13
+DEFAULT_NET=net04
14
+DEFAULT_NET_EXT=net04_ext
15
+DEFAULT_ROUTER=router04
16
+
17
+# DEFAULT_NET_EXT is set as the gateway for DEFAULT_ROUTER, we must clear that
18
+# before we can delete the network.
19
+neutron router-gateway-clear $DEFAULT_ROUTER
20
+neutron net-delete $DEFAULT_NET_EXT
21
+
22
+# DEFAULT_NET cannot be deleted until all ports configured on the network have 
23
+# been removed. We get details of the configured ports from the "neutron port-list"
24
+# command, whose output is of the form:
25
+# +-----+------+-------------------+-----------------------------------------------+
26
+# | id  | name | mac_address       | fixed_ips                                     |
27
+# +-----+------+-------------------+-----------------------------------------------+
28
+# | foo |      | fa:16:3e:ae:70:4e | {"subnet_id": "bar", "ip_address": "a.b.c.d"} |
29
+# +-----+------+-------------------+-----------------------------------------------+
30
+port_ids=$(neutron port-list | grep "|" | grep -v "fixed_ips" | cut -d " " -f 2)
31
+for port_id in "${port_ids[@]}"
32
+do
33
+  neutron port-delete $port_id
34
+  if [[ $? != 0 ]]; then
35
+    # One of the ports is associated with the interface for the default router.
36
+    # This causes port deletion to fail. So we delete the interface on the
37
+    # router (this also removes the port).
38
+    neutron router-interface-delete $DEFAULT_ROUTER port=$port_id
39
+  fi
40
+done
41
+
42
+# We can now delete the default router and the default network.
43
+neutron router-delete $DEFAULT_ROUTER
44
+neutron net-delete $DEFAULT_NET
45
+

+ 8
- 0
tasks.yaml View File

@@ -16,6 +16,14 @@
16 16
     cmd: ./calico_route_reflector.sh
17 17
     timeout: 60
18 18
 
19
+# Remove default OpenStack network configuration which doesn't work with Calico.
20
+- role: ['primary-controller']
21
+  stage: post_deployment/150
22
+  type: shell
23
+  parameters:
24
+    cmd: ./remove_default_networks.sh
25
+    timeout: 60
26
+
19 27
 # Install/configure calico on the compute nodes after cluster deployment.
20 28
 - role: ['compute']
21 29
   stage: post_deployment

Loading…
Cancel
Save