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