| Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 | # | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 3 | # lib/neutron | 
| Joe Gordon | 2394605 | 2014-01-15 21:42:32 +0000 | [diff] [blame] | 4 | # functions - functions specific to neutron | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 5 |  | 
|  | 6 | # Dependencies: | 
|  | 7 | # ``functions`` file | 
|  | 8 | # ``DEST`` must be defined | 
| Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 9 | # ``STACK_USER`` must be defined | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 10 |  | 
|  | 11 | # ``stack.sh`` calls the entry points in this order: | 
|  | 12 | # | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 13 | # - install_neutron_agent_packages | 
| YAMAMOTO Takashi | 1a669dc | 2015-02-05 11:54:12 +0900 | [diff] [blame] | 14 | # - install_neutronclient | 
|  | 15 | # - install_neutron | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 16 | # - install_neutron_third_party | 
|  | 17 | # - configure_neutron | 
|  | 18 | # - init_neutron | 
|  | 19 | # - configure_neutron_third_party | 
|  | 20 | # - init_neutron_third_party | 
|  | 21 | # - start_neutron_third_party | 
|  | 22 | # - create_nova_conf_neutron | 
|  | 23 | # - start_neutron_service_and_check | 
| YAMAMOTO Takashi | 1a669dc | 2015-02-05 11:54:12 +0900 | [diff] [blame] | 24 | # - check_neutron_third_party_integration | 
| yunhong jiang | 0d6e992 | 2014-10-10 06:12:47 -0700 | [diff] [blame] | 25 | # - start_neutron_agents | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 26 | # - create_neutron_initial_network | 
|  | 27 | # - setup_neutron_debug | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 28 | # | 
|  | 29 | # ``unstack.sh`` calls the entry points in this order: | 
|  | 30 | # | 
| YAMAMOTO Takashi | 1a669dc | 2015-02-05 11:54:12 +0900 | [diff] [blame] | 31 | # - teardown_neutron_debug | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 32 | # - stop_neutron | 
| yunhong jiang | 0d6e992 | 2014-10-10 06:12:47 -0700 | [diff] [blame] | 33 | # - stop_neutron_third_party | 
|  | 34 | # - cleanup_neutron | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 35 |  | 
|  | 36 | # Functions in lib/neutron are classified into the following categories: | 
|  | 37 | # | 
|  | 38 | # - entry points (called from stack.sh or unstack.sh) | 
|  | 39 | # - internal functions | 
|  | 40 | # - neutron exercises | 
|  | 41 | # - 3rd party programs | 
|  | 42 |  | 
|  | 43 |  | 
|  | 44 | # Neutron Networking | 
|  | 45 | # ------------------ | 
|  | 46 |  | 
|  | 47 | # Make sure that neutron is enabled in ``ENABLED_SERVICES``.  If you want | 
|  | 48 | # to run Neutron on this host, make sure that q-svc is also in | 
|  | 49 | # ``ENABLED_SERVICES``. | 
|  | 50 | # | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 51 | # See "Neutron Network Configuration" below for additional variables | 
|  | 52 | # that must be set in localrc for connectivity across hosts with | 
|  | 53 | # Neutron. | 
|  | 54 | # | 
|  | 55 | # With Neutron networking the NETWORK_MANAGER variable is ignored. | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 56 |  | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 57 | # Settings | 
|  | 58 | # -------- | 
|  | 59 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 60 |  | 
|  | 61 | # Neutron Network Configuration | 
|  | 62 | # ----------------------------- | 
|  | 63 |  | 
| Matthew Treinish | abde96a | 2016-05-12 19:26:20 -0400 | [diff] [blame] | 64 | deprecated "Using lib/neutron-legacy is deprecated, and it will be removed in the future" | 
| Armando Migliaccio | 7dbcfae | 2016-02-19 14:43:42 -0800 | [diff] [blame] | 65 |  | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 66 | if is_ssl_enabled_service "neutron" || is_service_enabled tls-proxy; then | 
|  | 67 | Q_PROTOCOL="https" | 
|  | 68 | fi | 
|  | 69 |  | 
|  | 70 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 71 | # Set up default directories | 
| Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 72 | GITDIR["python-neutronclient"]=$DEST/python-neutronclient | 
| Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 73 |  | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 74 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 75 | NEUTRON_DIR=$DEST/neutron | 
| Kyle Mestery | 20b839f | 2014-12-08 06:17:27 +0000 | [diff] [blame] | 76 | NEUTRON_FWAAS_DIR=$DEST/neutron-fwaas | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 77 | NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/var/cache/neutron} | 
|  | 78 |  | 
|  | 79 | # Support entry points installation of console scripts | 
|  | 80 | if [[ -d $NEUTRON_DIR/bin/neutron-server ]]; then | 
|  | 81 | NEUTRON_BIN_DIR=$NEUTRON_DIR/bin | 
| Sean Dague | 3bdb922 | 2013-10-22 08:36:16 -0400 | [diff] [blame] | 82 | else | 
|  | 83 | NEUTRON_BIN_DIR=$(get_python_exec_prefix) | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 84 | fi | 
|  | 85 |  | 
|  | 86 | NEUTRON_CONF_DIR=/etc/neutron | 
|  | 87 | NEUTRON_CONF=$NEUTRON_CONF_DIR/neutron.conf | 
|  | 88 | export NEUTRON_TEST_CONFIG_FILE=${NEUTRON_TEST_CONFIG_FILE:-"$NEUTRON_CONF_DIR/debug.ini"} | 
|  | 89 |  | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 90 | # Agent binaries.  Note, binary paths for other agents are set in per-service | 
|  | 91 | # scripts in lib/neutron_plugins/services/ | 
|  | 92 | AGENT_DHCP_BINARY="$NEUTRON_BIN_DIR/neutron-dhcp-agent" | 
|  | 93 | AGENT_L3_BINARY=${AGENT_L3_BINARY:-"$NEUTRON_BIN_DIR/neutron-l3-agent"} | 
|  | 94 | AGENT_META_BINARY="$NEUTRON_BIN_DIR/neutron-metadata-agent" | 
|  | 95 |  | 
|  | 96 | # Agent config files. Note, plugin-specific Q_PLUGIN_CONF_FILE is set and | 
|  | 97 | # loaded from per-plugin  scripts in lib/neutron_plugins/ | 
|  | 98 | Q_DHCP_CONF_FILE=$NEUTRON_CONF_DIR/dhcp_agent.ini | 
|  | 99 | Q_L3_CONF_FILE=$NEUTRON_CONF_DIR/l3_agent.ini | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 100 | Q_META_CONF_FILE=$NEUTRON_CONF_DIR/metadata_agent.ini | 
|  | 101 |  | 
| Henry Gessau | 0fc1cc2 | 2014-07-06 22:54:34 -0400 | [diff] [blame] | 102 | # Default name for Neutron database | 
|  | 103 | Q_DB_NAME=${Q_DB_NAME:-neutron} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 104 | # Default Neutron Plugin | 
| Kyle Mestery | 6d23500 | 2013-09-18 20:27:08 +0000 | [diff] [blame] | 105 | Q_PLUGIN=${Q_PLUGIN:-ml2} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 106 | # Default Neutron Port | 
|  | 107 | Q_PORT=${Q_PORT:-9696} | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 108 | # Default Neutron Internal Port when using TLS proxy | 
|  | 109 | Q_PORT_INT=${Q_PORT_INT:-19696} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 110 | # Default Neutron Host | 
|  | 111 | Q_HOST=${Q_HOST:-$SERVICE_HOST} | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 112 | # Default protocol | 
|  | 113 | Q_PROTOCOL=${Q_PROTOCOL:-$SERVICE_PROTOCOL} | 
| Brian Haley | 180f5eb | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 114 | # Default listen address | 
|  | 115 | Q_LISTEN_ADDRESS=${Q_LISTEN_ADDRESS:-$SERVICE_LISTEN_ADDRESS} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 116 | # Default admin username | 
|  | 117 | Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-neutron} | 
|  | 118 | # Default auth strategy | 
|  | 119 | Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 120 | # RHEL's support for namespaces requires using veths with ovs | 
|  | 121 | Q_OVS_USE_VETH=${Q_OVS_USE_VETH:-False} | 
|  | 122 | Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True} | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 123 | Q_USE_ROOTWRAP_DAEMON=$(trueorfalse True Q_USE_ROOTWRAP_DAEMON) | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 124 | # Meta data IP | 
|  | 125 | Q_META_DATA_IP=${Q_META_DATA_IP:-$SERVICE_HOST} | 
|  | 126 | # Allow Overlapping IP among subnets | 
|  | 127 | Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True} | 
| Terry Wilson | f06c443 | 2014-05-20 10:54:51 -0500 | [diff] [blame] | 128 | Q_NOTIFY_NOVA_PORT_STATUS_CHANGES=${Q_NOTIFY_NOVA_PORT_STATUS_CHANGES:-True} | 
|  | 129 | Q_NOTIFY_NOVA_PORT_DATA_CHANGES=${Q_NOTIFY_NOVA_PORT_DATA_CHANGES:-True} | 
| Aaron Rosen | cea32b1 | 2014-03-04 16:20:14 -0800 | [diff] [blame] | 130 | VIF_PLUGGING_IS_FATAL=${VIF_PLUGGING_IS_FATAL:-True} | 
|  | 131 | VIF_PLUGGING_TIMEOUT=${VIF_PLUGGING_TIMEOUT:-300} | 
| Aaron Rosen | 4540d00 | 2013-10-24 13:59:33 -0700 | [diff] [blame] | 132 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 133 | # List of config file names in addition to the main plugin config file | 
|  | 134 | # See _configure_neutron_common() for details about setting it up | 
|  | 135 | declare -a Q_PLUGIN_EXTRA_CONF_FILES | 
|  | 136 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 137 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 138 | Q_RR_CONF_FILE=$NEUTRON_CONF_DIR/rootwrap.conf | 
|  | 139 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
|  | 140 | Q_RR_COMMAND="sudo" | 
|  | 141 | else | 
|  | 142 | NEUTRON_ROOTWRAP=$(get_rootwrap_location neutron) | 
|  | 143 | Q_RR_COMMAND="sudo $NEUTRON_ROOTWRAP $Q_RR_CONF_FILE" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 144 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
|  | 145 | Q_RR_DAEMON_COMMAND="sudo $NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE" | 
|  | 146 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 147 | fi | 
|  | 148 |  | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 149 |  | 
|  | 150 | # Distributed Virtual Router (DVR) configuration | 
|  | 151 | # Can be: | 
| Dean Troyer | 3324f19 | 2014-09-18 09:26:39 -0500 | [diff] [blame] | 152 | # - ``legacy``   - No DVR functionality | 
|  | 153 | # - ``dvr_snat`` - Controller or single node DVR | 
|  | 154 | # - ``dvr``      - Compute node in multi-node DVR | 
|  | 155 | # | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 156 | Q_DVR_MODE=${Q_DVR_MODE:-legacy} | 
|  | 157 | if [[ "$Q_DVR_MODE" != "legacy" ]]; then | 
|  | 158 | Q_ML2_PLUGIN_MECHANISM_DRIVERS=openvswitch,linuxbridge,l2population | 
|  | 159 | fi | 
|  | 160 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 161 | # Provider Network Configurations | 
|  | 162 | # -------------------------------- | 
|  | 163 |  | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 164 | # The following variables control the Neutron ML2 plugins' allocation | 
|  | 165 | # of tenant networks and availability of provider networks. If these | 
|  | 166 | # are not configured in ``localrc``, tenant networks will be local to | 
|  | 167 | # the host (with no remote connectivity), and no physical resources | 
|  | 168 | # will be available for the allocation of provider networks. | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 169 |  | 
| Attila Fazekas | 8feaf6c | 2014-07-27 20:47:04 +0200 | [diff] [blame] | 170 | # To disable tunnels (GRE or VXLAN) for tenant networks, | 
|  | 171 | # set to False in ``local.conf``. | 
|  | 172 | # GRE tunnels are only supported by the openvswitch. | 
|  | 173 | ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-True} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 174 |  | 
| Richard Theis | 8906b48 | 2016-06-08 10:28:37 -0500 | [diff] [blame] | 175 | # If using GRE, VXLAN or GENEVE tunnels for tenant networks, | 
|  | 176 | # specify the range of IDs from which tenant networks are | 
|  | 177 | # allocated. Can be overridden in ``localrc`` if necessary. | 
| Anant Patil | 3827dc0 | 2014-07-03 21:38:16 +0530 | [diff] [blame] | 178 | TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGES:-1:1000} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 179 |  | 
|  | 180 | # To use VLANs for tenant networks, set to True in localrc. VLANs | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 181 | # are supported by the ML2 plugins, requiring additional configuration | 
|  | 182 | # described below. | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 183 | ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False} | 
|  | 184 |  | 
|  | 185 | # If using VLANs for tenant networks, set in ``localrc`` to specify | 
|  | 186 | # the range of VLAN VIDs from which tenant networks are | 
|  | 187 | # allocated. An external network switch must be configured to | 
|  | 188 | # trunk these VLANs between hosts for multi-host connectivity. | 
|  | 189 | # | 
|  | 190 | # Example: ``TENANT_VLAN_RANGE=1000:1999`` | 
|  | 191 | TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-} | 
|  | 192 |  | 
|  | 193 | # If using VLANs for tenant networks, or if using flat or VLAN | 
|  | 194 | # provider networks, set in ``localrc`` to the name of the physical | 
|  | 195 | # network, and also configure ``OVS_PHYSICAL_BRIDGE`` for the | 
|  | 196 | # openvswitch agent or ``LB_PHYSICAL_INTERFACE`` for the linuxbridge | 
|  | 197 | # agent, as described below. | 
|  | 198 | # | 
|  | 199 | # Example: ``PHYSICAL_NETWORK=default`` | 
| Kevin Benton | 1554ade | 2016-07-22 09:40:19 -0700 | [diff] [blame] | 200 | PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-public} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 201 |  | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 202 | # With the openvswitch agent, if using VLANs for tenant networks, | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 203 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
|  | 204 | # the name of the OVS bridge to use for the physical network. The | 
|  | 205 | # bridge will be created if it does not already exist, but a | 
|  | 206 | # physical interface must be manually added to the bridge as a | 
|  | 207 | # port for external connectivity. | 
|  | 208 | # | 
|  | 209 | # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1`` | 
| Kevin Benton | 1554ade | 2016-07-22 09:40:19 -0700 | [diff] [blame] | 210 | OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-br-ex} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 211 |  | 
| Clark Boylan | 9546903 | 2016-09-08 17:08:36 -0700 | [diff] [blame] | 212 | default_route_dev=$(ip route | grep ^default | awk '{print $5}') | 
|  | 213 | die_if_not_set $LINENO default_route_dev "Failure retrieving default route device" | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 214 | # With the linuxbridge agent, if using VLANs for tenant networks, | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 215 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
|  | 216 | # the name of the network interface to use for the physical | 
|  | 217 | # network. | 
|  | 218 | # | 
|  | 219 | # Example: ``LB_PHYSICAL_INTERFACE=eth1`` | 
| Clark Boylan | 9546903 | 2016-09-08 17:08:36 -0700 | [diff] [blame] | 220 | LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-$default_route_dev} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 221 |  | 
| Edgar Magana | 6f335b9 | 2014-07-10 15:42:44 -0700 | [diff] [blame] | 222 | # When Neutron tunnels are enabled it is needed to specify the | 
|  | 223 | # IP address of the end point in the local server. This IP is set | 
|  | 224 | # by default to the same IP address that the HOST IP. | 
|  | 225 | # This variable can be used to specify a different end point IP address | 
|  | 226 | # Example: ``TUNNEL_ENDPOINT_IP=1.1.1.1`` | 
|  | 227 | TUNNEL_ENDPOINT_IP=${TUNNEL_ENDPOINT_IP:-$HOST_IP} | 
|  | 228 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 229 | # With the openvswitch plugin, set to True in ``localrc`` to enable | 
|  | 230 | # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False. | 
|  | 231 | # | 
|  | 232 | # Example: ``OVS_ENABLE_TUNNELING=True`` | 
|  | 233 | OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS} | 
|  | 234 |  | 
| Tan Lin | 27a196e | 2014-10-31 15:44:34 +0800 | [diff] [blame] | 235 | # Use DHCP agent for providing metadata service in the case of | 
|  | 236 | # without L3 agent (No Route Agent), set to True in localrc. | 
|  | 237 | ENABLE_ISOLATED_METADATA=${ENABLE_ISOLATED_METADATA:-False} | 
|  | 238 |  | 
|  | 239 | # Add a static route as dhcp option, so the request to 169.254.169.254 | 
|  | 240 | # will be able to reach through a route(DHCP agent) | 
|  | 241 | # This option require ENABLE_ISOLATED_METADATA = True | 
|  | 242 | ENABLE_METADATA_NETWORK=${ENABLE_METADATA_NETWORK:-False} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 243 | # Neutron plugin specific functions | 
|  | 244 | # --------------------------------- | 
|  | 245 |  | 
|  | 246 | # Please refer to ``lib/neutron_plugins/README.md`` for details. | 
| Hirofumi Ichihara | 36daecd | 2015-07-23 17:50:40 +0900 | [diff] [blame] | 247 | if [ -f $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN ]; then | 
|  | 248 | source $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN | 
|  | 249 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 250 |  | 
| Emilien Macchi | 40546f7 | 2013-09-24 15:10:25 +0200 | [diff] [blame] | 251 | # Agent metering service plugin functions | 
|  | 252 | # ------------------------------------------- | 
|  | 253 |  | 
|  | 254 | # Hardcoding for 1 service plugin for now | 
|  | 255 | source $TOP_DIR/lib/neutron_plugins/services/metering | 
|  | 256 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 257 | # L3 Service functions | 
|  | 258 | source $TOP_DIR/lib/neutron_plugins/services/l3 | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 259 | # Use security group or not | 
|  | 260 | if has_neutron_plugin_security_group; then | 
|  | 261 | Q_USE_SECGROUP=${Q_USE_SECGROUP:-True} | 
|  | 262 | else | 
|  | 263 | Q_USE_SECGROUP=False | 
|  | 264 | fi | 
|  | 265 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 266 | # Save trace setting | 
| Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 267 | _XTRACE_NEUTRON=$(set +o | grep xtrace) | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 268 | set +o xtrace | 
|  | 269 |  | 
|  | 270 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 271 | # Functions | 
|  | 272 | # --------- | 
|  | 273 |  | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 274 | function _determine_config_server { | 
|  | 275 | local cfg_file | 
|  | 276 | local opts="--config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE" | 
|  | 277 | for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do | 
| Tom Patzig | 7346704 | 2016-04-19 17:02:34 +0200 | [diff] [blame] | 278 | opts+=" --config-file $cfg_file" | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 279 | done | 
|  | 280 | echo "$opts" | 
|  | 281 | } | 
|  | 282 |  | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 283 | function _determine_config_l3 { | 
| Angus Lees | a1c70f2 | 2016-05-31 14:43:14 +1000 | [diff] [blame] | 284 | local opts="--config-file $NEUTRON_CONF --config-file $Q_L3_CONF_FILE" | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 285 | echo "$opts" | 
|  | 286 | } | 
|  | 287 |  | 
|  | 288 | # For services and agents that require it, dynamically construct a list of | 
|  | 289 | # --config-file arguments that are passed to the binary. | 
|  | 290 | function determine_config_files { | 
|  | 291 | local opts="" | 
|  | 292 | case "$1" in | 
|  | 293 | "neutron-server") opts="$(_determine_config_server)" ;; | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 294 | "neutron-l3-agent") opts="$(_determine_config_l3)" ;; | 
|  | 295 | esac | 
|  | 296 | if [ -z "$opts" ] ; then | 
|  | 297 | die $LINENO "Could not determine config files for $1." | 
|  | 298 | fi | 
|  | 299 | echo "$opts" | 
|  | 300 | } | 
|  | 301 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 302 | # configure_mutnauq() | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 303 | # Set common config for all neutron server and agents. | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 304 | function configure_mutnauq { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 305 | _configure_neutron_common | 
| Brant Knudson | 2dd110c | 2015-03-14 12:39:14 -0500 | [diff] [blame] | 306 | iniset_rpc_backend neutron $NEUTRON_CONF | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 307 |  | 
|  | 308 | # goes before q-svc to init Q_SERVICE_PLUGIN_CLASSES | 
| Emilien Macchi | 40546f7 | 2013-09-24 15:10:25 +0200 | [diff] [blame] | 309 | if is_service_enabled q-metering; then | 
|  | 310 | _configure_neutron_metering | 
|  | 311 | fi | 
| Stephen Ma | 9b38eb2 | 2014-04-02 02:13:09 +0000 | [diff] [blame] | 312 | if is_service_enabled q-agt q-svc; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 313 | _configure_neutron_service | 
|  | 314 | fi | 
|  | 315 | if is_service_enabled q-agt; then | 
|  | 316 | _configure_neutron_plugin_agent | 
|  | 317 | fi | 
|  | 318 | if is_service_enabled q-dhcp; then | 
|  | 319 | _configure_neutron_dhcp_agent | 
|  | 320 | fi | 
|  | 321 | if is_service_enabled q-l3; then | 
|  | 322 | _configure_neutron_l3_agent | 
|  | 323 | fi | 
|  | 324 | if is_service_enabled q-meta; then | 
|  | 325 | _configure_neutron_metadata_agent | 
|  | 326 | fi | 
|  | 327 |  | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 328 | if [[ "$Q_DVR_MODE" != "legacy" ]]; then | 
|  | 329 | _configure_dvr | 
|  | 330 | fi | 
| Dina Belova | 58adaa6 | 2014-07-11 18:18:12 +0400 | [diff] [blame] | 331 | if is_service_enabled ceilometer; then | 
|  | 332 | _configure_neutron_ceilometer_notifications | 
|  | 333 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 334 |  | 
| armando-migliaccio | e155b89 | 2015-06-12 08:55:02 -0700 | [diff] [blame] | 335 | iniset $NEUTRON_CONF DEFAULT api_workers "$API_WORKERS" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 336 | } | 
|  | 337 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 338 | function create_nova_conf_neutron { | 
| Sean Dague | f21cc1f | 2016-03-04 11:08:32 -0500 | [diff] [blame] | 339 | iniset $NOVA_CONF DEFAULT use_neutron True | 
| Matthew Kassawara | 28af796 | 2016-02-10 19:04:08 +0000 | [diff] [blame] | 340 | iniset $NOVA_CONF neutron auth_type "password" | 
| Brant Knudson | e86b91b | 2016-05-03 15:21:47 -0500 | [diff] [blame] | 341 | iniset $NOVA_CONF neutron auth_url "$KEYSTONE_AUTH_URI/v3" | 
| Jamie Lennox | 394968f | 2015-08-28 09:18:26 +1000 | [diff] [blame] | 342 | iniset $NOVA_CONF neutron username "$Q_ADMIN_USERNAME" | 
|  | 343 | iniset $NOVA_CONF neutron password "$SERVICE_PASSWORD" | 
| Jamie Lennox | cbcbd8f | 2016-01-21 16:08:14 -0600 | [diff] [blame] | 344 | iniset $NOVA_CONF neutron user_domain_name "$SERVICE_DOMAIN_NAME" | 
| Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 345 | iniset $NOVA_CONF neutron project_name "$SERVICE_PROJECT_NAME" | 
| Jamie Lennox | cbcbd8f | 2016-01-21 16:08:14 -0600 | [diff] [blame] | 346 | iniset $NOVA_CONF neutron project_domain_name "$SERVICE_DOMAIN_NAME" | 
| Gary Kotton | 13d385e | 2014-06-17 23:24:53 -0700 | [diff] [blame] | 347 | iniset $NOVA_CONF neutron auth_strategy "$Q_AUTH_STRATEGY" | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 348 | iniset $NOVA_CONF neutron region_name "$REGION_NAME" | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 349 | iniset $NOVA_CONF neutron url "${Q_PROTOCOL}://$Q_HOST:$Q_PORT" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 350 |  | 
|  | 351 | if [[ "$Q_USE_SECGROUP" == "True" ]]; then | 
|  | 352 | LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver | 
| Jeff Peeler | 1143f7e | 2013-10-31 16:21:52 -0400 | [diff] [blame] | 353 | iniset $NOVA_CONF DEFAULT firewall_driver $LIBVIRT_FIREWALL_DRIVER | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 354 | fi | 
|  | 355 |  | 
| Matt Riedemann | 925c256 | 2015-08-25 13:40:25 -0700 | [diff] [blame] | 356 | # optionally set options in nova_conf | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 357 | neutron_plugin_create_nova_conf | 
|  | 358 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 359 | if is_service_enabled q-meta; then | 
| Gary Kotton | dd74550 | 2014-08-11 23:38:47 -0700 | [diff] [blame] | 360 | iniset $NOVA_CONF neutron service_metadata_proxy "True" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 361 | fi | 
| Aaron Rosen | cea32b1 | 2014-03-04 16:20:14 -0800 | [diff] [blame] | 362 |  | 
|  | 363 | iniset $NOVA_CONF DEFAULT vif_plugging_is_fatal "$VIF_PLUGGING_IS_FATAL" | 
|  | 364 | iniset $NOVA_CONF DEFAULT vif_plugging_timeout "$VIF_PLUGGING_TIMEOUT" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 365 | } | 
|  | 366 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 367 | # create_mutnauq_accounts() - Set up common required neutron accounts | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 368 |  | 
|  | 369 | # Tenant               User       Roles | 
|  | 370 | # ------------------------------------------------------------------ | 
|  | 371 | # service              neutron    admin        # if enabled | 
|  | 372 |  | 
|  | 373 | # Migrated from keystone_data.sh | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 374 | function create_mutnauq_accounts { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 375 | if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 376 |  | 
| Jamie Lennox | 85ff532 | 2015-01-28 14:28:01 +1000 | [diff] [blame] | 377 | create_service_user "neutron" | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 378 |  | 
| Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 379 | get_or_create_service "neutron" "network" "Neutron Service" | 
| Matt Riedemann | ae4578b | 2016-04-23 01:45:40 +0000 | [diff] [blame] | 380 | get_or_create_endpoint \ | 
| Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 381 | "network" \ | 
|  | 382 | "$REGION_NAME" \ | 
|  | 383 | "$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/" \ | 
|  | 384 | "$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/" \ | 
|  | 385 | "$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 386 | fi | 
|  | 387 | } | 
|  | 388 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 389 | # init_mutnauq() - Initialize databases, etc. | 
|  | 390 | function init_mutnauq { | 
| Ihar Hrachyshka | 157c84b | 2014-10-06 13:29:39 +0200 | [diff] [blame] | 391 | recreate_database $Q_DB_NAME | 
| Salvatore Orlando | dd64988 | 2013-08-05 08:56:17 -0700 | [diff] [blame] | 392 | # Run Neutron db migrations | 
|  | 393 | $NEUTRON_BIN_DIR/neutron-db-manage --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE upgrade head | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 394 | } | 
|  | 395 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 396 | # install_mutnauq() - Collect source and prepare | 
|  | 397 | function install_mutnauq { | 
| Doug Wiegley | 86561c3 | 2016-02-10 18:37:21 -0700 | [diff] [blame] | 398 | # Install neutron-lib from git so we make sure we're testing | 
|  | 399 | # the latest code. | 
|  | 400 | if use_library_from_git "neutron-lib"; then | 
|  | 401 | git_clone_by_name "neutron-lib" | 
|  | 402 | setup_dev_lib "neutron-lib" | 
|  | 403 | fi | 
|  | 404 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 405 | git_clone $NEUTRON_REPO $NEUTRON_DIR $NEUTRON_BRANCH | 
|  | 406 | setup_develop $NEUTRON_DIR | 
| Mate Lakat | 6df6489 | 2014-10-17 13:09:49 +0200 | [diff] [blame] | 407 |  | 
|  | 408 | if [ "$VIRT_DRIVER" == 'xenserver' ]; then | 
|  | 409 | local dom0_ip | 
|  | 410 | dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3-) | 
|  | 411 |  | 
|  | 412 | local ssh_dom0 | 
|  | 413 | ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip" | 
|  | 414 |  | 
|  | 415 | # Find where the plugins should go in dom0 | 
|  | 416 | local xen_functions | 
|  | 417 | xen_functions=$(cat $TOP_DIR/tools/xen/functions) | 
|  | 418 | local plugin_dir | 
|  | 419 | plugin_dir=$($ssh_dom0 "$xen_functions; set -eux; xapi_plugin_location") | 
|  | 420 |  | 
|  | 421 | # install neutron plugins to dom0 | 
| Huan Xie | 201e3c1 | 2015-08-27 12:34:24 +0100 | [diff] [blame] | 422 | tar -czf - -C $NEUTRON_DIR/neutron/plugins/ml2/drivers/openvswitch/agent/xenapi/etc/xapi.d/plugins/ ./ | | 
| Mate Lakat | 6df6489 | 2014-10-17 13:09:49 +0200 | [diff] [blame] | 423 | $ssh_dom0 "tar -xzf - -C $plugin_dir && chmod a+x $plugin_dir/*" | 
|  | 424 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 425 | } | 
|  | 426 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 427 | # install_neutron_agent_packages() - Collect source and prepare | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 428 | function install_neutron_agent_packages { | 
| Robert Li | 72b3e44 | 2014-07-17 15:04:52 -0400 | [diff] [blame] | 429 | # radvd doesn't come with the OS. Install it if the l3 service is enabled. | 
|  | 430 | if is_service_enabled q-l3; then | 
|  | 431 | install_package radvd | 
|  | 432 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 433 | # install packages that are specific to plugin agent(s) | 
|  | 434 | if is_service_enabled q-agt q-dhcp q-l3; then | 
|  | 435 | neutron_plugin_install_agent_packages | 
|  | 436 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 437 | } | 
|  | 438 |  | 
|  | 439 | # Start running processes, including screen | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 440 | function start_neutron_service_and_check { | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 441 | local service_port=$Q_PORT | 
|  | 442 | local service_protocol=$Q_PROTOCOL | 
| Ian Wienand | 7ae9729 | 2016-02-16 14:50:53 +1100 | [diff] [blame] | 443 | local cfg_file_options | 
|  | 444 |  | 
|  | 445 | cfg_file_options="$(determine_config_files neutron-server)" | 
|  | 446 |  | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 447 | if is_service_enabled tls-proxy; then | 
|  | 448 | service_port=$Q_PORT_INT | 
|  | 449 | service_protocol="http" | 
|  | 450 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 451 | # Start the Neutron service | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 452 | run_process q-svc "$NEUTRON_BIN_DIR/neutron-server $cfg_file_options" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 453 | echo "Waiting for Neutron to start..." | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 454 | if is_ssl_enabled_service "neutron"; then | 
|  | 455 | ssl_ca="--ca-certificate=${SSL_BUNDLE_FILE}" | 
|  | 456 | fi | 
| Sean Dague | 442e4e9 | 2015-06-24 13:24:02 -0400 | [diff] [blame] | 457 |  | 
|  | 458 | local testcmd="wget ${ssl_ca} --no-proxy -q -O- $service_protocol://$Q_HOST:$service_port" | 
|  | 459 | test_with_retry "$testcmd" "Neutron did not start" $SERVICE_TIMEOUT | 
|  | 460 |  | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 461 | # Start proxy if enabled | 
|  | 462 | if is_service_enabled tls-proxy; then | 
| Gregory Haynes | 4b49e40 | 2016-08-31 18:19:51 -0700 | [diff] [blame] | 463 | start_tls_proxy neutron '*' $Q_PORT $Q_HOST $Q_PORT_INT | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 464 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 465 | } | 
|  | 466 |  | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 467 | # Control of the l2 agent is separated out to make it easier to test partial | 
|  | 468 | # upgrades (everything upgraded except the L2 agent) | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 469 | function start_mutnauq_l2_agent { | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 470 | run_process q-agt "$AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE" | 
| Nachi Ueno | 584750f | 2013-07-15 18:22:21 -0700 | [diff] [blame] | 471 |  | 
| Kahou Lei | d663e29 | 2015-10-24 12:18:57 -0700 | [diff] [blame] | 472 | if is_provider_network && [[ $Q_AGENT == "openvswitch" ]]; then | 
| Zhongyue Luo | 56b7efb | 2014-12-16 11:36:49 +0800 | [diff] [blame] | 473 | sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_PHYSICAL_BRIDGE $PUBLIC_INTERFACE | 
| Sean M. Collins | 5ec6f8f | 2014-05-14 17:01:03 -0400 | [diff] [blame] | 474 | sudo ip link set $OVS_PHYSICAL_BRIDGE up | 
|  | 475 | sudo ip link set br-int up | 
|  | 476 | sudo ip link set $PUBLIC_INTERFACE up | 
| yunhong jiang | ae9ee6b | 2014-10-08 07:01:02 -0700 | [diff] [blame] | 477 | if is_ironic_hardware; then | 
|  | 478 | for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do | 
|  | 479 | sudo ip addr del $IP dev $PUBLIC_INTERFACE | 
|  | 480 | sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE | 
|  | 481 | done | 
| gong yong sheng | 348c6ac | 2015-06-23 14:03:47 +0800 | [diff] [blame] | 482 | sudo ip route replace $FIXED_RANGE via $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE | 
| yunhong jiang | ae9ee6b | 2014-10-08 07:01:02 -0700 | [diff] [blame] | 483 | fi | 
| Sean M. Collins | 5ec6f8f | 2014-05-14 17:01:03 -0400 | [diff] [blame] | 484 | fi | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 485 | } | 
|  | 486 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 487 | function start_mutnauq_other_agents { | 
| Angus Lees | a1c70f2 | 2016-05-31 14:43:14 +1000 | [diff] [blame] | 488 | run_process q-dhcp "$AGENT_DHCP_BINARY --config-file $NEUTRON_CONF --config-file $Q_DHCP_CONF_FILE" | 
| Sean M. Collins | 5ec6f8f | 2014-05-14 17:01:03 -0400 | [diff] [blame] | 489 |  | 
| Paul Michali | e4289c8 | 2015-08-14 11:49:27 -0400 | [diff] [blame] | 490 | if is_service_enabled neutron-vpnaas; then | 
|  | 491 | :  # Started by plugin | 
| Ravi Chunduru | 95c93e2 | 2013-07-16 04:18:47 -0700 | [diff] [blame] | 492 | else | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 493 | run_process q-l3 "$AGENT_L3_BINARY $(determine_config_files neutron-l3-agent)" | 
| Ravi Chunduru | 95c93e2 | 2013-07-16 04:18:47 -0700 | [diff] [blame] | 494 | fi | 
|  | 495 |  | 
| Angus Lees | a1c70f2 | 2016-05-31 14:43:14 +1000 | [diff] [blame] | 496 | run_process q-meta "$AGENT_META_BINARY --config-file $NEUTRON_CONF --config-file $Q_META_CONF_FILE" | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 497 | run_process q-metering "$AGENT_METERING_BINARY --config-file $NEUTRON_CONF --config-file $METERING_AGENT_CONF_FILENAME" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 498 |  | 
|  | 499 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then | 
|  | 500 | # For XenServer, start an agent for the domU openvswitch | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 501 | run_process q-domua "$AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE.domU" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 502 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 503 | } | 
|  | 504 |  | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 505 | # Start running processes, including screen | 
|  | 506 | function start_neutron_agents { | 
|  | 507 | # Start up the neutron agents if enabled | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 508 | start_mutnauq_l2_agent | 
|  | 509 | start_mutnauq_other_agents | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 510 | } | 
|  | 511 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 512 | function stop_mutnauq_l2_agent { | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 513 | stop_process q-agt | 
|  | 514 | } | 
|  | 515 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 516 | # stop_mutnauq_other() - Stop running processes (non-screen) | 
|  | 517 | function stop_mutnauq_other { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 518 | if is_service_enabled q-dhcp; then | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 519 | stop_process q-dhcp | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 520 | pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }') | 
|  | 521 | [ ! -z "$pid" ] && sudo kill -9 $pid | 
|  | 522 | fi | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 523 |  | 
|  | 524 | stop_process q-svc | 
| Li Ma | a15d9de | 2016-01-19 19:11:51 +0800 | [diff] [blame] | 525 |  | 
|  | 526 | if is_service_enabled q-l3; then | 
|  | 527 | sudo pkill -f "radvd -C $DATA_DIR/neutron/ra" | 
|  | 528 | stop_process q-l3 | 
|  | 529 | fi | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 530 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 531 | if is_service_enabled q-meta; then | 
| Jakub Libosvar | 1f76328 | 2014-01-28 23:01:38 +0100 | [diff] [blame] | 532 | sudo pkill -9 -f neutron-ns-metadata-proxy || : | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 533 | stop_process q-meta | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 534 | fi | 
| Akihiro Motoki | edddb1f | 2013-12-09 20:21:06 +0900 | [diff] [blame] | 535 |  | 
| Akihiro Motoki | edddb1f | 2013-12-09 20:21:06 +0900 | [diff] [blame] | 536 | if is_service_enabled q-metering; then | 
|  | 537 | neutron_metering_stop | 
|  | 538 | fi | 
| Li Ma | 50120fa | 2015-12-13 10:41:34 +0800 | [diff] [blame] | 539 |  | 
|  | 540 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
|  | 541 | sudo pkill -9 -f $NEUTRON_ROOTWRAP-daemon || : | 
|  | 542 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 543 | } | 
|  | 544 |  | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 545 | # stop_neutron() - Stop running processes (non-screen) | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 546 | function stop_mutnauq { | 
|  | 547 | stop_mutnauq_other | 
|  | 548 | stop_mutnauq_l2_agent | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 549 | } | 
|  | 550 |  | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 551 | # _move_neutron_addresses_route() - Move the primary IP to the OVS bridge | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 552 | # on startup, or back to the public interface on cleanup. If no IP is | 
|  | 553 | # configured on the interface, just add it as a port to the OVS bridge. | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 554 | function _move_neutron_addresses_route { | 
|  | 555 | local from_intf=$1 | 
|  | 556 | local to_intf=$2 | 
|  | 557 | local add_ovs_port=$3 | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 558 | local del_ovs_port=$4 | 
|  | 559 | local af=$5 | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 560 |  | 
|  | 561 | if [[ -n "$from_intf" && -n "$to_intf" ]]; then | 
|  | 562 | # Remove the primary IP address from $from_intf and add it to $to_intf, | 
|  | 563 | # along with the default route, if it exists.  Also, when called | 
|  | 564 | # on configure we will also add $from_intf as a port on $to_intf, | 
|  | 565 | # assuming it is an OVS bridge. | 
|  | 566 |  | 
| Matt McEuen | e24707b | 2016-07-11 08:37:59 -0500 | [diff] [blame] | 567 | local IP_REPLACE="" | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 568 | local IP_DEL="" | 
| Shinobu KINJO | f95315b | 2015-11-07 10:21:08 +0900 | [diff] [blame] | 569 | local IP_UP="" | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 570 | local DEFAULT_ROUTE_GW | 
| Sean M. Collins | 59e86a3 | 2015-11-09 11:06:39 -0500 | [diff] [blame] | 571 | DEFAULT_ROUTE_GW=$(ip -f $af r | awk "/default.+$from_intf/ { print \$3; exit }") | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 572 | local ADD_OVS_PORT="" | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 573 | local DEL_OVS_PORT="" | 
| Sean M. Collins | 17398a3 | 2016-05-11 18:24:46 +0000 | [diff] [blame] | 574 | local ARP_CMD="" | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 575 |  | 
| Brian Haley | bb9caea | 2015-11-16 17:18:42 -0500 | [diff] [blame] | 576 | IP_BRD=$(ip -f $af a s dev $from_intf scope global primary | grep inet | awk '{ print $2, $3, $4; exit }') | 
| Adam Kacmarsky | 11298a0 | 2015-06-26 14:49:47 -0600 | [diff] [blame] | 577 |  | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 578 | if [ "$DEFAULT_ROUTE_GW" != "" ]; then | 
| Sean M. Collins | 59e86a3 | 2015-11-09 11:06:39 -0500 | [diff] [blame] | 579 | ADD_DEFAULT_ROUTE="sudo ip -f $af r replace default via $DEFAULT_ROUTE_GW dev $to_intf" | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 580 | fi | 
|  | 581 |  | 
|  | 582 | if [[ "$add_ovs_port" == "True" ]]; then | 
| Raman Budny | db02bbf | 2015-03-31 13:09:09 +0300 | [diff] [blame] | 583 | ADD_OVS_PORT="sudo ovs-vsctl --may-exist add-port $to_intf $from_intf" | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 584 | fi | 
|  | 585 |  | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 586 | if [[ "$del_ovs_port" == "True" ]]; then | 
|  | 587 | DEL_OVS_PORT="sudo ovs-vsctl --if-exists del-port $from_intf $to_intf" | 
|  | 588 | fi | 
|  | 589 |  | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 590 | if [[ "$IP_BRD" != "" ]]; then | 
| Brian Haley | 9451021 | 2015-09-02 15:40:04 -0400 | [diff] [blame] | 591 | IP_DEL="sudo ip addr del $IP_BRD dev $from_intf" | 
| Matt McEuen | e24707b | 2016-07-11 08:37:59 -0500 | [diff] [blame] | 592 | IP_REPLACE="sudo ip addr replace $IP_BRD dev $to_intf" | 
| Shinobu KINJO | f95315b | 2015-11-07 10:21:08 +0900 | [diff] [blame] | 593 | IP_UP="sudo ip link set $to_intf up" | 
| Sean M. Collins | 6d4843e | 2016-05-12 16:14:26 -0400 | [diff] [blame] | 594 | if [[ "$af" == "inet" ]]; then | 
|  | 595 | IP=$(echo $IP_BRD | awk '{ print $1; exit }' | grep -o -E '(.*)/' | cut -d "/" -f1) | 
|  | 596 | ARP_CMD="arping -A -c 3 -w 4.5 -I $to_intf $IP " | 
|  | 597 | fi | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 598 | fi | 
|  | 599 |  | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 600 | # The add/del OVS port calls have to happen either before or | 
|  | 601 | # after the address is moved in order to not leave it orphaned. | 
| Matt McEuen | e24707b | 2016-07-11 08:37:59 -0500 | [diff] [blame] | 602 | $DEL_OVS_PORT; $IP_DEL; $IP_REPLACE; $IP_UP; $ADD_OVS_PORT; $ADD_DEFAULT_ROUTE; $ARP_CMD | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 603 | fi | 
|  | 604 | } | 
|  | 605 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 606 | # cleanup_mutnauq() - Remove residual data files, anything left over from previous | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 607 | # runs that a clean run would need to clean up | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 608 | function cleanup_mutnauq { | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 609 |  | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 610 | if [[ -n "$OVS_PHYSICAL_BRIDGE" ]]; then | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 611 | _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False True "inet" | 
| Adam Kacmarsky | 11298a0 | 2015-06-26 14:49:47 -0600 | [diff] [blame] | 612 |  | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 613 | if [[ $(ip -f inet6 a s dev "$OVS_PHYSICAL_BRIDGE" | grep -c 'global') != 0 ]]; then | 
| Sean M. Collins | 790266f | 2015-11-11 13:36:35 -0500 | [diff] [blame] | 614 | # ip(8) wants the prefix length when deleting | 
|  | 615 | local v6_gateway | 
|  | 616 | v6_gateway=$(ip -6 a s dev $OVS_PHYSICAL_BRIDGE | grep $IPV6_PUBLIC_NETWORK_GATEWAY | awk '{ print $2 }') | 
|  | 617 | sudo ip -6 addr del $v6_gateway dev $OVS_PHYSICAL_BRIDGE | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 618 | _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False False "inet6" | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 619 | fi | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 620 |  | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 621 | if is_provider_network && is_ironic_hardware; then | 
|  | 622 | for IP in $(ip addr show dev $OVS_PHYSICAL_BRIDGE | grep ' inet ' | awk '{print $2}'); do | 
|  | 623 | sudo ip addr del $IP dev $OVS_PHYSICAL_BRIDGE | 
|  | 624 | sudo ip addr add $IP dev $PUBLIC_INTERFACE | 
|  | 625 | done | 
|  | 626 | sudo route del -net $FIXED_RANGE gw $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE | 
|  | 627 | fi | 
| yunhong jiang | ae9ee6b | 2014-10-08 07:01:02 -0700 | [diff] [blame] | 628 | fi | 
|  | 629 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 630 | if is_neutron_ovs_base_plugin; then | 
|  | 631 | neutron_ovs_base_cleanup | 
|  | 632 | fi | 
|  | 633 |  | 
| Sean M. Collins | 7bc2af7 | 2015-06-08 12:36:30 -0400 | [diff] [blame] | 634 | if [[ $Q_AGENT == "linuxbridge" ]]; then | 
|  | 635 | neutron_lb_cleanup | 
|  | 636 | fi | 
|  | 637 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 638 | # delete all namespaces created by neutron | 
| Doug Wiegley | 7e40c64 | 2016-08-20 16:32:14 +0000 | [diff] [blame] | 639 | for ns in $(sudo ip netns list | grep -o -E '(qdhcp|qrouter|fip|snat)-[0-9a-f-]*'); do | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 640 | sudo ip netns delete ${ns} | 
|  | 641 | done | 
|  | 642 | } | 
|  | 643 |  | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 644 |  | 
| Maru Newby | 952fd90 | 2015-01-30 22:27:12 +0000 | [diff] [blame] | 645 | function _create_neutron_conf_dir { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 646 | # Put config files in ``NEUTRON_CONF_DIR`` for everyone to find | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 647 | sudo install -d -o $STACK_USER $NEUTRON_CONF_DIR | 
| Maru Newby | 952fd90 | 2015-01-30 22:27:12 +0000 | [diff] [blame] | 648 | } | 
|  | 649 |  | 
|  | 650 | # _configure_neutron_common() | 
|  | 651 | # Set common config for all neutron server and agents. | 
|  | 652 | # This MUST be called before other ``_configure_neutron_*`` functions. | 
|  | 653 | function _configure_neutron_common { | 
|  | 654 | _create_neutron_conf_dir | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 655 |  | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 656 | # Uses oslo config generator to generate core sample configuration files | 
|  | 657 | (cd $NEUTRON_DIR && exec ./tools/generate_config_file_samples.sh) | 
|  | 658 |  | 
|  | 659 | cp $NEUTRON_DIR/etc/neutron.conf.sample $NEUTRON_CONF | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 660 |  | 
| Jerry Zhao | 296c1e3 | 2015-08-07 20:43:54 -0400 | [diff] [blame] | 661 | Q_POLICY_FILE=$NEUTRON_CONF_DIR/policy.json | 
|  | 662 | cp $NEUTRON_DIR/etc/policy.json $Q_POLICY_FILE | 
|  | 663 |  | 
|  | 664 | # allow neutron user to administer neutron to match neutron account | 
|  | 665 | sed -i 's/"context_is_admin":  "role:admin"/"context_is_admin":  "role:admin or user_name:neutron"/g' $Q_POLICY_FILE | 
|  | 666 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 667 | # Set plugin-specific variables ``Q_DB_NAME``, ``Q_PLUGIN_CLASS``. | 
|  | 668 | # For main plugin config file, set ``Q_PLUGIN_CONF_PATH``, ``Q_PLUGIN_CONF_FILENAME``. | 
| Tom Patzig | 67223b0 | 2016-04-19 16:43:05 +0200 | [diff] [blame] | 669 | # For additional plugin config files, set ``Q_PLUGIN_EXTRA_CONF_PATH`` and | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 670 | # ``Q_PLUGIN_EXTRA_CONF_FILES``.  For example: | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 671 | # | 
| Tom Patzig | 67223b0 | 2016-04-19 16:43:05 +0200 | [diff] [blame] | 672 | #    ``Q_PLUGIN_EXTRA_CONF_PATH=/path/to/plugins`` | 
| Boden R | 82bca44 | 2016-04-15 10:56:09 -0600 | [diff] [blame] | 673 | #    ``Q_PLUGIN_EXTRA_CONF_FILES=(file1 file2)`` | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 674 | neutron_plugin_configure_common | 
|  | 675 |  | 
| sbauza | e2c4ee2 | 2013-08-29 17:29:46 +0200 | [diff] [blame] | 676 | if [[ "$Q_PLUGIN_CONF_PATH" == '' || "$Q_PLUGIN_CONF_FILENAME" == '' || "$Q_PLUGIN_CLASS" == '' ]]; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 677 | die $LINENO "Neutron plugin not set.. exiting" | 
|  | 678 | fi | 
|  | 679 |  | 
|  | 680 | # If needed, move config file from ``$NEUTRON_DIR/etc/neutron`` to ``NEUTRON_CONF_DIR`` | 
|  | 681 | mkdir -p /$Q_PLUGIN_CONF_PATH | 
|  | 682 | Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME | 
| Hirofumi Ichihara | 97cc85b | 2015-09-08 13:51:01 +0900 | [diff] [blame] | 683 | # NOTE(hichihara): Some neutron vendor plugins were already decomposed and | 
|  | 684 | # there is no config file in Neutron tree. They should prepare the file in each plugin. | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 685 | if [ -f "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" ]; then | 
|  | 686 | cp "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" /$Q_PLUGIN_CONF_FILE | 
|  | 687 | elif [ -f $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE ]; then | 
| Hirofumi Ichihara | 97cc85b | 2015-09-08 13:51:01 +0900 | [diff] [blame] | 688 | cp $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE | 
|  | 689 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 690 |  | 
| Ihar Hrachyshka | b816e5d | 2014-07-21 13:53:50 +0200 | [diff] [blame] | 691 | iniset $NEUTRON_CONF database connection `database_connection_url $Q_DB_NAME` | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 692 | iniset $NEUTRON_CONF DEFAULT state_path $DATA_DIR/neutron | 
| salvatore | e4e535b | 2014-10-29 18:22:46 +0100 | [diff] [blame] | 693 | iniset $NEUTRON_CONF DEFAULT use_syslog $SYSLOG | 
| Brian Haley | 180f5eb | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 694 | iniset $NEUTRON_CONF DEFAULT bind_host $Q_LISTEN_ADDRESS | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 695 | iniset $NEUTRON_CONF oslo_concurrency lock_path $DATA_DIR/neutron/lock | 
|  | 696 |  | 
| Victor Ryzhenkin | 878d7d8 | 2016-04-27 15:15:52 +0300 | [diff] [blame] | 697 | # NOTE(freerunner): Need to adjust Region Name for nova in multiregion installation | 
|  | 698 | iniset $NEUTRON_CONF nova region_name $REGION_NAME | 
|  | 699 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 700 | # If addition config files are set, make sure their path name is set as well | 
|  | 701 | if [[ ${#Q_PLUGIN_EXTRA_CONF_FILES[@]} > 0 && $Q_PLUGIN_EXTRA_CONF_PATH == '' ]]; then | 
|  | 702 | die $LINENO "Neutron additional plugin config not set.. exiting" | 
|  | 703 | fi | 
|  | 704 |  | 
|  | 705 | # If additional config files exist, copy them over to neutron configuration | 
|  | 706 | # directory | 
|  | 707 | if [[ $Q_PLUGIN_EXTRA_CONF_PATH != '' ]]; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 708 | local f | 
|  | 709 | for (( f=0; $f < ${#Q_PLUGIN_EXTRA_CONF_FILES[@]}; f+=1 )); do | 
|  | 710 | Q_PLUGIN_EXTRA_CONF_FILES[$f]=$Q_PLUGIN_EXTRA_CONF_PATH/${Q_PLUGIN_EXTRA_CONF_FILES[$f]} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 711 | done | 
|  | 712 | fi | 
|  | 713 |  | 
| Joe Gordon | bee5c50 | 2013-08-30 13:48:08 -0400 | [diff] [blame] | 714 | if [ "$VIRT_DRIVER" = 'fake' ]; then | 
|  | 715 | # Disable arbitrary limits | 
|  | 716 | iniset $NEUTRON_CONF quotas quota_network -1 | 
|  | 717 | iniset $NEUTRON_CONF quotas quota_subnet -1 | 
|  | 718 | iniset $NEUTRON_CONF quotas quota_port -1 | 
|  | 719 | iniset $NEUTRON_CONF quotas quota_security_group -1 | 
|  | 720 | iniset $NEUTRON_CONF quotas quota_security_group_rule -1 | 
|  | 721 | fi | 
|  | 722 |  | 
| Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 723 | # Format logging | 
|  | 724 | if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then | 
| Salvatore Orlando | bc7f643 | 2013-11-25 10:11:14 -0800 | [diff] [blame] | 725 | setup_colorized_logging $NEUTRON_CONF DEFAULT project_id | 
| venkata anil | 9b1df57 | 2015-01-15 07:38:22 +0000 | [diff] [blame] | 726 | else | 
|  | 727 | # Show user_name and project_name by default like in nova | 
| Ronald Bradford | e826490 | 2016-01-20 21:16:33 +0000 | [diff] [blame] | 728 | iniset $NEUTRON_CONF DEFAULT logging_user_identity_format "%(user_name)s %(project_name)s" | 
| Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 729 | fi | 
|  | 730 |  | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 731 | if is_service_enabled tls-proxy; then | 
|  | 732 | # Set the service port for a proxy to take the original | 
|  | 733 | iniset $NEUTRON_CONF DEFAULT bind_port "$Q_PORT_INT" | 
|  | 734 | fi | 
|  | 735 |  | 
|  | 736 | if is_ssl_enabled_service "nova"; then | 
| Jamie Lennox | dc757dd | 2015-03-09 14:48:09 +1100 | [diff] [blame] | 737 | iniset $NEUTRON_CONF nova cafile $SSL_BUNDLE_FILE | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 738 | fi | 
|  | 739 |  | 
|  | 740 | if is_ssl_enabled_service "neutron"; then | 
|  | 741 | ensure_certificates NEUTRON | 
|  | 742 |  | 
|  | 743 | iniset $NEUTRON_CONF DEFAULT use_ssl True | 
|  | 744 | iniset $NEUTRON_CONF DEFAULT ssl_cert_file "$NEUTRON_SSL_CERT" | 
|  | 745 | iniset $NEUTRON_CONF DEFAULT ssl_key_file "$NEUTRON_SSL_KEY" | 
|  | 746 | fi | 
|  | 747 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 748 | _neutron_setup_rootwrap | 
|  | 749 | } | 
|  | 750 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 751 | function _configure_neutron_dhcp_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 752 |  | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 753 | cp $NEUTRON_DIR/etc/dhcp_agent.ini.sample $Q_DHCP_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 754 |  | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 755 | iniset $Q_DHCP_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Sean Dague | 78801c1 | 2016-08-04 14:10:07 -0400 | [diff] [blame] | 756 | # make it so we have working DNS from guests | 
|  | 757 | iniset $Q_DHCP_CONF_FILE DEFAULT dnsmasq_local_resolv True | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 758 | iniset $Q_DHCP_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 759 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 760 | iniset $Q_DHCP_CONF_FILE AGENT root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 761 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 762 |  | 
| Tan Lin | 27a196e | 2014-10-31 15:44:34 +0800 | [diff] [blame] | 763 | if ! is_service_enabled q-l3; then | 
|  | 764 | if [[ "$ENABLE_ISOLATED_METADATA" = "True" ]]; then | 
|  | 765 | iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata $ENABLE_ISOLATED_METADATA | 
|  | 766 | iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network $ENABLE_METADATA_NETWORK | 
|  | 767 | else | 
|  | 768 | if [[ "$ENABLE_METADATA_NETWORK" = "True" ]]; then | 
|  | 769 | die "$LINENO" "Enable isolated metadata is a must for metadata network" | 
|  | 770 | fi | 
|  | 771 | fi | 
|  | 772 | fi | 
|  | 773 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 774 | _neutron_setup_interface_driver $Q_DHCP_CONF_FILE | 
|  | 775 |  | 
| xurong00037997 | 7ef31d0 | 2016-07-05 11:09:40 +0800 | [diff] [blame] | 776 | neutron_plugin_configure_dhcp_agent $Q_DHCP_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 777 | } | 
|  | 778 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 779 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 780 | function _configure_neutron_metadata_agent { | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 781 | cp $NEUTRON_DIR/etc/metadata_agent.ini.sample $Q_META_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 782 |  | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 783 | iniset $Q_META_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 784 | iniset $Q_META_CONF_FILE DEFAULT nova_metadata_ip $Q_META_DATA_IP | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 785 | iniset $Q_META_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 786 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 787 | iniset $Q_META_CONF_FILE AGENT root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 788 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 789 | } | 
|  | 790 |  | 
| Dina Belova | 58adaa6 | 2014-07-11 18:18:12 +0400 | [diff] [blame] | 791 | function _configure_neutron_ceilometer_notifications { | 
| Wanlong Gao | cf04a9a | 2016-01-16 17:46:35 +0800 | [diff] [blame] | 792 | iniset $NEUTRON_CONF oslo_messaging_notifications driver messaging | 
| Dina Belova | 58adaa6 | 2014-07-11 18:18:12 +0400 | [diff] [blame] | 793 | } | 
|  | 794 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 795 | function _configure_neutron_metering { | 
| Emilien Macchi | 40546f7 | 2013-09-24 15:10:25 +0200 | [diff] [blame] | 796 | neutron_agent_metering_configure_common | 
|  | 797 | neutron_agent_metering_configure_agent | 
|  | 798 | } | 
|  | 799 |  | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 800 | function _configure_dvr { | 
|  | 801 | iniset $NEUTRON_CONF DEFAULT router_distributed True | 
|  | 802 | iniset $Q_L3_CONF_FILE DEFAULT agent_mode $Q_DVR_MODE | 
|  | 803 | } | 
|  | 804 |  | 
|  | 805 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 806 | # _configure_neutron_plugin_agent() - Set config files for neutron plugin agent | 
|  | 807 | # It is called when q-agt is enabled. | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 808 | function _configure_neutron_plugin_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 809 | # Specify the default root helper prior to agent configuration to | 
|  | 810 | # ensure that an agent's configuration can override the default | 
|  | 811 | iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 812 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
|  | 813 | iniset /$Q_PLUGIN_CONF_FILE  agent root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
|  | 814 | fi | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 815 | iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 816 |  | 
|  | 817 | # Configure agent for plugin | 
|  | 818 | neutron_plugin_configure_plugin_agent | 
|  | 819 | } | 
|  | 820 |  | 
|  | 821 | # _configure_neutron_service() - Set config files for neutron service | 
|  | 822 | # It is called when q-svc is enabled. | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 823 | function _configure_neutron_service { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 824 | Q_API_PASTE_FILE=$NEUTRON_CONF_DIR/api-paste.ini | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 825 | cp $NEUTRON_DIR/etc/api-paste.ini $Q_API_PASTE_FILE | 
| Kevin Benton | 08a5fcc | 2014-07-18 16:06:12 -0700 | [diff] [blame] | 826 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 827 | # Update either configuration file with plugin | 
|  | 828 | iniset $NEUTRON_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS | 
|  | 829 |  | 
|  | 830 | if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then | 
|  | 831 | iniset $NEUTRON_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES | 
|  | 832 | fi | 
|  | 833 |  | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 834 | iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Chris Dent | 74a85b0 | 2015-04-22 18:02:39 +0000 | [diff] [blame] | 835 | iniset $NEUTRON_CONF oslo_policy policy_file $Q_POLICY_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 836 | iniset $NEUTRON_CONF DEFAULT allow_overlapping_ips $Q_ALLOW_OVERLAPPING_IP | 
|  | 837 |  | 
|  | 838 | iniset $NEUTRON_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY | 
|  | 839 | _neutron_setup_keystone $NEUTRON_CONF keystone_authtoken | 
|  | 840 |  | 
| Atsushi SAKAI | fe7b56c | 2015-11-13 17:06:16 +0900 | [diff] [blame] | 841 | # Configuration for neutron notifications to nova. | 
| Terry Wilson | f06c443 | 2014-05-20 10:54:51 -0500 | [diff] [blame] | 842 | iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_status_changes $Q_NOTIFY_NOVA_PORT_STATUS_CHANGES | 
|  | 843 | iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_data_changes $Q_NOTIFY_NOVA_PORT_DATA_CHANGES | 
| Jamie Lennox | dc757dd | 2015-03-09 14:48:09 +1100 | [diff] [blame] | 844 |  | 
| Thomas Bechtold | fb94891 | 2016-03-27 08:59:42 +0200 | [diff] [blame] | 845 | configure_auth_token_middleware $NEUTRON_CONF nova $NEUTRON_AUTH_CACHE_DIR nova | 
| Aaron Rosen | cea32b1 | 2014-03-04 16:20:14 -0800 | [diff] [blame] | 846 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 847 | # Configure plugin | 
|  | 848 | neutron_plugin_configure_service | 
|  | 849 | } | 
|  | 850 |  | 
|  | 851 | # Utility Functions | 
|  | 852 | #------------------ | 
|  | 853 |  | 
| Isaku Yamahata | 9e136b4 | 2013-12-16 15:52:03 +0900 | [diff] [blame] | 854 | # _neutron_service_plugin_class_add() - add service plugin class | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 855 | function _neutron_service_plugin_class_add { | 
| Isaku Yamahata | 9e136b4 | 2013-12-16 15:52:03 +0900 | [diff] [blame] | 856 | local service_plugin_class=$1 | 
|  | 857 | if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then | 
|  | 858 | Q_SERVICE_PLUGIN_CLASSES=$service_plugin_class | 
|  | 859 | elif [[ ! ,${Q_SERVICE_PLUGIN_CLASSES}, =~ ,${service_plugin_class}, ]]; then | 
|  | 860 | Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$service_plugin_class" | 
|  | 861 | fi | 
|  | 862 | } | 
|  | 863 |  | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 864 | # _neutron_deploy_rootwrap_filters() - deploy rootwrap filters to $Q_CONF_ROOTWRAP_D (owned by root). | 
|  | 865 | function _neutron_deploy_rootwrap_filters { | 
| gong yong sheng | 3d6eaae | 2015-09-15 15:00:29 +0800 | [diff] [blame] | 866 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
|  | 867 | return | 
|  | 868 | fi | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 869 | local srcdir=$1 | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 870 | sudo install -d -o root -m 755 $Q_CONF_ROOTWRAP_D | 
|  | 871 | sudo install -o root -m 644 $srcdir/etc/neutron/rootwrap.d/* $Q_CONF_ROOTWRAP_D/ | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 872 | } | 
|  | 873 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 874 | # _neutron_setup_rootwrap() - configure Neutron's rootwrap | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 875 | function _neutron_setup_rootwrap { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 876 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
|  | 877 | return | 
|  | 878 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 879 | # Wipe any existing ``rootwrap.d`` files first | 
|  | 880 | Q_CONF_ROOTWRAP_D=$NEUTRON_CONF_DIR/rootwrap.d | 
|  | 881 | if [[ -d $Q_CONF_ROOTWRAP_D ]]; then | 
|  | 882 | sudo rm -rf $Q_CONF_ROOTWRAP_D | 
|  | 883 | fi | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 884 |  | 
|  | 885 | _neutron_deploy_rootwrap_filters $NEUTRON_DIR | 
|  | 886 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 887 | # Set up ``rootwrap.conf``, pointing to ``$NEUTRON_CONF_DIR/rootwrap.d`` | 
|  | 888 | # location moved in newer versions, prefer new location | 
|  | 889 | if test -r $NEUTRON_DIR/etc/neutron/rootwrap.conf; then | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 890 | sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/neutron/rootwrap.conf $Q_RR_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 891 | else | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 892 | sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/rootwrap.conf $Q_RR_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 893 | fi | 
|  | 894 | sudo sed -e "s:^filters_path=.*$:filters_path=$Q_CONF_ROOTWRAP_D:" -i $Q_RR_CONF_FILE | 
| Robert Li | 2c5d462 | 2015-04-21 15:48:22 -0400 | [diff] [blame] | 895 | sudo sed -e 's:^exec_dirs=\(.*\)$:exec_dirs=\1,/usr/local/bin:' -i $Q_RR_CONF_FILE | 
|  | 896 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 897 | # Specify ``rootwrap.conf`` as first parameter to neutron-rootwrap | 
|  | 898 | ROOTWRAP_SUDOER_CMD="$NEUTRON_ROOTWRAP $Q_RR_CONF_FILE *" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 899 | ROOTWRAP_DAEMON_SUDOER_CMD="$NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 900 |  | 
|  | 901 | # Set up the rootwrap sudoers for neutron | 
|  | 902 | TEMPFILE=`mktemp` | 
| Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 903 | echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 904 | echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_DAEMON_SUDOER_CMD" >>$TEMPFILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 905 | chmod 0440 $TEMPFILE | 
|  | 906 | sudo chown root:root $TEMPFILE | 
|  | 907 | sudo mv $TEMPFILE /etc/sudoers.d/neutron-rootwrap | 
|  | 908 |  | 
|  | 909 | # Update the root_helper | 
|  | 910 | iniset $NEUTRON_CONF agent root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 911 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
|  | 912 | iniset $NEUTRON_CONF agent root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
|  | 913 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 914 | } | 
|  | 915 |  | 
| Ihar Hrachyshka | bb4654b | 2015-10-06 18:09:07 +0200 | [diff] [blame] | 916 | # Configures keystone integration for neutron service | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 917 | function _neutron_setup_keystone { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 918 | local conf_file=$1 | 
|  | 919 | local section=$2 | 
| Jamie Lennox | 3561d7f | 2014-05-21 17:18:43 +1000 | [diff] [blame] | 920 |  | 
| Brant Knudson | 0595237 | 2014-09-19 17:22:22 -0500 | [diff] [blame] | 921 | create_neutron_cache_dir | 
|  | 922 | configure_auth_token_middleware $conf_file $Q_ADMIN_USERNAME $NEUTRON_AUTH_CACHE_DIR $section | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 923 | } | 
|  | 924 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 925 | function _neutron_setup_interface_driver { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 926 |  | 
|  | 927 | # ovs_use_veth needs to be set before the plugin configuration | 
|  | 928 | # occurs to allow plugins to override the setting. | 
|  | 929 | iniset $1 DEFAULT ovs_use_veth $Q_OVS_USE_VETH | 
|  | 930 |  | 
|  | 931 | neutron_plugin_setup_interface_driver $1 | 
|  | 932 | } | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 933 | # Functions for Neutron Exercises | 
|  | 934 | #-------------------------------- | 
|  | 935 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 936 | function delete_probe { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 937 | local from_net="$1" | 
|  | 938 | net_id=`_get_net_id $from_net` | 
|  | 939 | probe_id=`neutron-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-list -c id -c network_id | grep $net_id | awk '{print $2}'` | 
|  | 940 | neutron-debug --os-tenant-name admin --os-username admin probe-delete $probe_id | 
|  | 941 | } | 
|  | 942 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 943 | function _get_net_id { | 
| Victor Ryzhenkin | 878d7d8 | 2016-04-27 15:15:52 +0300 | [diff] [blame] | 944 | neutron --os-cloud devstack-admin --os-region "$REGION_NAME" --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD net-list | grep $1 | awk '{print $2}' | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 945 | } | 
|  | 946 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 947 | function _get_probe_cmd_prefix { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 948 | local from_net="$1" | 
|  | 949 | net_id=`_get_net_id $from_net` | 
|  | 950 | probe_id=`neutron-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-list -c id -c network_id | grep $net_id | awk '{print $2}' | head -n 1` | 
|  | 951 | echo "$Q_RR_COMMAND ip netns exec qprobe-$probe_id" | 
|  | 952 | } | 
|  | 953 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 954 | # ssh check | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 955 | function _ssh_check_neutron { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 956 | local from_net=$1 | 
|  | 957 | local key_file=$2 | 
|  | 958 | local ip=$3 | 
|  | 959 | local user=$4 | 
|  | 960 | local timeout_sec=$5 | 
|  | 961 | local probe_cmd = "" | 
|  | 962 | probe_cmd=`_get_probe_cmd_prefix $from_net` | 
| Sean Dague | 442e4e9 | 2015-06-24 13:24:02 -0400 | [diff] [blame] | 963 | local testcmd="$probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success" | 
|  | 964 | test_with_retry "$testcmd" "server $ip didn't become ssh-able" $timeout_sec | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 965 | } | 
|  | 966 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 967 | # Restore xtrace | 
| Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 968 | $_XTRACE_NEUTRON | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 969 |  | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 970 | # Tell emacs to use shell-script-mode | 
|  | 971 | ## Local variables: | 
|  | 972 | ## mode: shell-script | 
|  | 973 | ## End: |