| 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 | 
| YAMAMOTO Takashi | a1875b1 | 2017-02-23 05:44:22 +0900 | [diff] [blame] | 23 | # - configure_neutron_after_post_config | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 24 | # - start_neutron_service_and_check | 
| YAMAMOTO Takashi | 1a669dc | 2015-02-05 11:54:12 +0900 | [diff] [blame] | 25 | # - check_neutron_third_party_integration | 
| yunhong jiang | 0d6e992 | 2014-10-10 06:12:47 -0700 | [diff] [blame] | 26 | # - start_neutron_agents | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 27 | # - create_neutron_initial_network | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 28 | # | 
|  | 29 | # ``unstack.sh`` calls the entry points in this order: | 
|  | 30 | # | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 31 | # - stop_neutron | 
| yunhong jiang | 0d6e992 | 2014-10-10 06:12:47 -0700 | [diff] [blame] | 32 | # - stop_neutron_third_party | 
|  | 33 | # - cleanup_neutron | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 34 |  | 
|  | 35 | # Functions in lib/neutron are classified into the following categories: | 
|  | 36 | # | 
|  | 37 | # - entry points (called from stack.sh or unstack.sh) | 
|  | 38 | # - internal functions | 
|  | 39 | # - neutron exercises | 
|  | 40 | # - 3rd party programs | 
|  | 41 |  | 
|  | 42 |  | 
|  | 43 | # Neutron Networking | 
|  | 44 | # ------------------ | 
|  | 45 |  | 
|  | 46 | # Make sure that neutron is enabled in ``ENABLED_SERVICES``.  If you want | 
|  | 47 | # to run Neutron on this host, make sure that q-svc is also in | 
|  | 48 | # ``ENABLED_SERVICES``. | 
|  | 49 | # | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 50 | # See "Neutron Network Configuration" below for additional variables | 
|  | 51 | # that must be set in localrc for connectivity across hosts with | 
|  | 52 | # Neutron. | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 53 |  | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 54 | # Settings | 
|  | 55 | # -------- | 
|  | 56 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 57 |  | 
|  | 58 | # Neutron Network Configuration | 
|  | 59 | # ----------------------------- | 
|  | 60 |  | 
| Sean Dague | f3b2f4c | 2017-04-13 10:11:48 -0400 | [diff] [blame] | 61 | if is_service_enabled tls-proxy; then | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 62 | Q_PROTOCOL="https" | 
|  | 63 | fi | 
|  | 64 |  | 
|  | 65 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 66 | # Set up default directories | 
| Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 67 | GITDIR["python-neutronclient"]=$DEST/python-neutronclient | 
| Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 68 |  | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 69 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 70 | NEUTRON_DIR=$DEST/neutron | 
| Kyle Mestery | 20b839f | 2014-12-08 06:17:27 +0000 | [diff] [blame] | 71 | NEUTRON_FWAAS_DIR=$DEST/neutron-fwaas | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 72 |  | 
|  | 73 | # Support entry points installation of console scripts | 
|  | 74 | if [[ -d $NEUTRON_DIR/bin/neutron-server ]]; then | 
|  | 75 | NEUTRON_BIN_DIR=$NEUTRON_DIR/bin | 
| Sean Dague | 3bdb922 | 2013-10-22 08:36:16 -0400 | [diff] [blame] | 76 | else | 
|  | 77 | NEUTRON_BIN_DIR=$(get_python_exec_prefix) | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 78 | fi | 
|  | 79 |  | 
|  | 80 | NEUTRON_CONF_DIR=/etc/neutron | 
|  | 81 | NEUTRON_CONF=$NEUTRON_CONF_DIR/neutron.conf | 
|  | 82 | export NEUTRON_TEST_CONFIG_FILE=${NEUTRON_TEST_CONFIG_FILE:-"$NEUTRON_CONF_DIR/debug.ini"} | 
|  | 83 |  | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 84 | # NEUTRON_DEPLOY_MOD_WSGI defines how neutron is deployed, allowed values: | 
|  | 85 | # - False (default) : Run neutron under Eventlet | 
|  | 86 | # - True : Run neutron under uwsgi | 
|  | 87 | # TODO(annp): Switching to uwsgi in next cycle if things turn out to be stable | 
|  | 88 | # enough | 
| Jens Harbott | 3492fee | 2018-11-30 13:57:17 +0000 | [diff] [blame] | 89 | NEUTRON_DEPLOY_MOD_WSGI=$(trueorfalse False NEUTRON_DEPLOY_MOD_WSGI) | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 90 |  | 
|  | 91 | NEUTRON_UWSGI_CONF=$NEUTRON_CONF_DIR/neutron-api-uwsgi.ini | 
|  | 92 |  | 
| Slawek Kaplonski | 24b65ad | 2021-06-22 15:31:46 +0200 | [diff] [blame] | 93 | # If NEUTRON_ENFORCE_SCOPE == True, it will set "enforce_scope" | 
|  | 94 | # and "enforce_new_defaults" to True in the Neutron's config to enforce usage | 
|  | 95 | # of the new RBAC policies and scopes. | 
|  | 96 | NEUTRON_ENFORCE_SCOPE=$(trueorfalse False NEUTRON_ENFORCE_SCOPE) | 
|  | 97 |  | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 98 | # Agent binaries.  Note, binary paths for other agents are set in per-service | 
|  | 99 | # scripts in lib/neutron_plugins/services/ | 
|  | 100 | AGENT_DHCP_BINARY="$NEUTRON_BIN_DIR/neutron-dhcp-agent" | 
|  | 101 | AGENT_L3_BINARY=${AGENT_L3_BINARY:-"$NEUTRON_BIN_DIR/neutron-l3-agent"} | 
|  | 102 | AGENT_META_BINARY="$NEUTRON_BIN_DIR/neutron-metadata-agent" | 
|  | 103 |  | 
|  | 104 | # Agent config files. Note, plugin-specific Q_PLUGIN_CONF_FILE is set and | 
|  | 105 | # loaded from per-plugin  scripts in lib/neutron_plugins/ | 
|  | 106 | Q_DHCP_CONF_FILE=$NEUTRON_CONF_DIR/dhcp_agent.ini | 
|  | 107 | Q_L3_CONF_FILE=$NEUTRON_CONF_DIR/l3_agent.ini | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 108 | Q_META_CONF_FILE=$NEUTRON_CONF_DIR/metadata_agent.ini | 
|  | 109 |  | 
| Henry Gessau | 0fc1cc2 | 2014-07-06 22:54:34 -0400 | [diff] [blame] | 110 | # Default name for Neutron database | 
|  | 111 | Q_DB_NAME=${Q_DB_NAME:-neutron} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 112 | # Default Neutron Plugin | 
| Kyle Mestery | 6d23500 | 2013-09-18 20:27:08 +0000 | [diff] [blame] | 113 | Q_PLUGIN=${Q_PLUGIN:-ml2} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 114 | # Default Neutron Port | 
|  | 115 | Q_PORT=${Q_PORT:-9696} | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 116 | # Default Neutron Internal Port when using TLS proxy | 
|  | 117 | Q_PORT_INT=${Q_PORT_INT:-19696} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 118 | # Default Neutron Host | 
|  | 119 | Q_HOST=${Q_HOST:-$SERVICE_HOST} | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 120 | # Default protocol | 
|  | 121 | Q_PROTOCOL=${Q_PROTOCOL:-$SERVICE_PROTOCOL} | 
| Brian Haley | 180f5eb | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 122 | # Default listen address | 
| Jens Harbott | dc7b429 | 2017-09-19 10:52:32 +0000 | [diff] [blame] | 123 | Q_LISTEN_ADDRESS=${Q_LISTEN_ADDRESS:-$(ipv6_unquote $SERVICE_LISTEN_ADDRESS)} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 124 | # Default admin username | 
|  | 125 | Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-neutron} | 
|  | 126 | # Default auth strategy | 
|  | 127 | Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 128 | # RHEL's support for namespaces requires using veths with ovs | 
|  | 129 | Q_OVS_USE_VETH=${Q_OVS_USE_VETH:-False} | 
|  | 130 | Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True} | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 131 | Q_USE_ROOTWRAP_DAEMON=$(trueorfalse True Q_USE_ROOTWRAP_DAEMON) | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 132 | # Meta data IP | 
| Jens Harbott | dc7b429 | 2017-09-19 10:52:32 +0000 | [diff] [blame] | 133 | Q_META_DATA_IP=${Q_META_DATA_IP:-$(ipv6_unquote $SERVICE_HOST)} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 134 | # Allow Overlapping IP among subnets | 
|  | 135 | Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True} | 
| Terry Wilson | f06c443 | 2014-05-20 10:54:51 -0500 | [diff] [blame] | 136 | Q_NOTIFY_NOVA_PORT_STATUS_CHANGES=${Q_NOTIFY_NOVA_PORT_STATUS_CHANGES:-True} | 
|  | 137 | 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] | 138 | VIF_PLUGGING_IS_FATAL=${VIF_PLUGGING_IS_FATAL:-True} | 
|  | 139 | VIF_PLUGGING_TIMEOUT=${VIF_PLUGGING_TIMEOUT:-300} | 
| Aaron Rosen | 4540d00 | 2013-10-24 13:59:33 -0700 | [diff] [blame] | 140 |  | 
| yatinkarel | 6dd896f | 2022-04-26 16:37:07 +0530 | [diff] [blame] | 141 | # Allow to skip stopping of OVN services | 
|  | 142 | SKIP_STOP_OVN=${SKIP_STOP_OVN:-False} | 
|  | 143 |  | 
| YAMAMOTO Takashi | eede9dd | 2016-07-15 10:27:53 +0900 | [diff] [blame] | 144 | # The directory which contains files for Q_PLUGIN_EXTRA_CONF_FILES. | 
|  | 145 | # /etc/neutron is assumed by many of devstack plugins.  Do not change. | 
|  | 146 | _Q_PLUGIN_EXTRA_CONF_PATH=/etc/neutron | 
|  | 147 |  | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 148 | # The name of the service in the endpoint URL | 
|  | 149 | NEUTRON_ENDPOINT_SERVICE_NAME=${NEUTRON_ENDPOINT_SERVICE_NAME-"networking"} | 
|  | 150 | if [[ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" && -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]]; then | 
|  | 151 | NEUTRON_ENDPOINT_SERVICE_NAME="networking" | 
|  | 152 | fi | 
|  | 153 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 154 | # List of config file names in addition to the main plugin config file | 
| YAMAMOTO Takashi | eede9dd | 2016-07-15 10:27:53 +0900 | [diff] [blame] | 155 | # To add additional plugin config files, use ``neutron_server_config_add`` | 
|  | 156 | # utility function.  For example: | 
|  | 157 | # | 
|  | 158 | #    ``neutron_server_config_add file1`` | 
|  | 159 | # | 
|  | 160 | # These config files are relative to ``/etc/neutron``.  The above | 
|  | 161 | # example would specify ``--config-file /etc/neutron/file1`` for | 
|  | 162 | # neutron server. | 
| Sean Dague | afef8bf | 2017-03-06 14:07:23 -0500 | [diff] [blame] | 163 | declare -a -g Q_PLUGIN_EXTRA_CONF_FILES | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 164 |  | 
| YAMAMOTO Takashi | eede9dd | 2016-07-15 10:27:53 +0900 | [diff] [blame] | 165 | # same as Q_PLUGIN_EXTRA_CONF_FILES, but with absolute path. | 
| Sean Dague | afef8bf | 2017-03-06 14:07:23 -0500 | [diff] [blame] | 166 | declare -a -g _Q_PLUGIN_EXTRA_CONF_FILES_ABS | 
| YAMAMOTO Takashi | eede9dd | 2016-07-15 10:27:53 +0900 | [diff] [blame] | 167 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 168 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 169 | Q_RR_CONF_FILE=$NEUTRON_CONF_DIR/rootwrap.conf | 
|  | 170 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
|  | 171 | Q_RR_COMMAND="sudo" | 
|  | 172 | else | 
|  | 173 | NEUTRON_ROOTWRAP=$(get_rootwrap_location neutron) | 
|  | 174 | Q_RR_COMMAND="sudo $NEUTRON_ROOTWRAP $Q_RR_CONF_FILE" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 175 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
|  | 176 | Q_RR_DAEMON_COMMAND="sudo $NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE" | 
|  | 177 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 178 | fi | 
|  | 179 |  | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 180 |  | 
|  | 181 | # Distributed Virtual Router (DVR) configuration | 
|  | 182 | # Can be: | 
| Dean Troyer | 3324f19 | 2014-09-18 09:26:39 -0500 | [diff] [blame] | 183 | # - ``legacy``   - No DVR functionality | 
|  | 184 | # - ``dvr_snat`` - Controller or single node DVR | 
|  | 185 | # - ``dvr``      - Compute node in multi-node DVR | 
|  | 186 | # | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 187 | Q_DVR_MODE=${Q_DVR_MODE:-legacy} | 
|  | 188 | if [[ "$Q_DVR_MODE" != "legacy" ]]; then | 
| Brian Haley | e43dfdd | 2017-09-12 16:13:26 -0600 | [diff] [blame] | 189 | Q_ML2_PLUGIN_MECHANISM_DRIVERS=openvswitch,l2population | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 190 | fi | 
|  | 191 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 192 | # Provider Network Configurations | 
|  | 193 | # -------------------------------- | 
|  | 194 |  | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 195 | # The following variables control the Neutron ML2 plugins' allocation | 
|  | 196 | # of tenant networks and availability of provider networks. If these | 
|  | 197 | # are not configured in ``localrc``, tenant networks will be local to | 
|  | 198 | # the host (with no remote connectivity), and no physical resources | 
|  | 199 | # will be available for the allocation of provider networks. | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 200 |  | 
| Attila Fazekas | 8feaf6c | 2014-07-27 20:47:04 +0200 | [diff] [blame] | 201 | # To disable tunnels (GRE or VXLAN) for tenant networks, | 
|  | 202 | # set to False in ``local.conf``. | 
|  | 203 | # GRE tunnels are only supported by the openvswitch. | 
|  | 204 | ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-True} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 205 |  | 
| Richard Theis | 8906b48 | 2016-06-08 10:28:37 -0500 | [diff] [blame] | 206 | # If using GRE, VXLAN or GENEVE tunnels for tenant networks, | 
|  | 207 | # specify the range of IDs from which tenant networks are | 
|  | 208 | # allocated. Can be overridden in ``localrc`` if necessary. | 
| Anant Patil | 3827dc0 | 2014-07-03 21:38:16 +0530 | [diff] [blame] | 209 | TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGES:-1:1000} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 210 |  | 
|  | 211 | # To use VLANs for tenant networks, set to True in localrc. VLANs | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 212 | # are supported by the ML2 plugins, requiring additional configuration | 
|  | 213 | # described below. | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 214 | ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False} | 
|  | 215 |  | 
|  | 216 | # If using VLANs for tenant networks, set in ``localrc`` to specify | 
|  | 217 | # the range of VLAN VIDs from which tenant networks are | 
|  | 218 | # allocated. An external network switch must be configured to | 
|  | 219 | # trunk these VLANs between hosts for multi-host connectivity. | 
|  | 220 | # | 
|  | 221 | # Example: ``TENANT_VLAN_RANGE=1000:1999`` | 
|  | 222 | TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-} | 
|  | 223 |  | 
|  | 224 | # If using VLANs for tenant networks, or if using flat or VLAN | 
|  | 225 | # provider networks, set in ``localrc`` to the name of the physical | 
|  | 226 | # network, and also configure ``OVS_PHYSICAL_BRIDGE`` for the | 
|  | 227 | # openvswitch agent or ``LB_PHYSICAL_INTERFACE`` for the linuxbridge | 
|  | 228 | # agent, as described below. | 
|  | 229 | # | 
|  | 230 | # Example: ``PHYSICAL_NETWORK=default`` | 
| Kevin Benton | 1554ade | 2016-07-22 09:40:19 -0700 | [diff] [blame] | 231 | PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-public} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 232 |  | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 233 | # With the openvswitch agent, if using VLANs for tenant networks, | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 234 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
|  | 235 | # the name of the OVS bridge to use for the physical network. The | 
|  | 236 | # bridge will be created if it does not already exist, but a | 
|  | 237 | # physical interface must be manually added to the bridge as a | 
|  | 238 | # port for external connectivity. | 
|  | 239 | # | 
|  | 240 | # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1`` | 
| Kevin Benton | 1554ade | 2016-07-22 09:40:19 -0700 | [diff] [blame] | 241 | OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-br-ex} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 242 |  | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 243 | # With the linuxbridge agent, if using VLANs for tenant networks, | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 244 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
|  | 245 | # the name of the network interface to use for the physical | 
|  | 246 | # network. | 
|  | 247 | # | 
|  | 248 | # Example: ``LB_PHYSICAL_INTERFACE=eth1`` | 
| Jens Harbott | 47f76ac | 2020-10-29 10:42:38 +0000 | [diff] [blame] | 249 | if [[ $Q_AGENT == "linuxbridge" && -z ${LB_PHYSICAL_INTERFACE} ]]; then | 
| Nate Johnston | efc04ee | 2020-11-03 10:04:26 -0500 | [diff] [blame] | 250 | default_route_dev=$( (ip route; ip -6 route) | grep ^default | head -n 1 | awk '{print $5}') | 
| Jens Harbott | 47f76ac | 2020-10-29 10:42:38 +0000 | [diff] [blame] | 251 | die_if_not_set $LINENO default_route_dev "Failure retrieving default route device" | 
|  | 252 | LB_PHYSICAL_INTERFACE=$default_route_dev | 
|  | 253 | fi | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 254 |  | 
|  | 255 | # With the openvswitch plugin, set to True in ``localrc`` to enable | 
|  | 256 | # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False. | 
|  | 257 | # | 
|  | 258 | # Example: ``OVS_ENABLE_TUNNELING=True`` | 
|  | 259 | OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS} | 
|  | 260 |  | 
| Tan Lin | 27a196e | 2014-10-31 15:44:34 +0800 | [diff] [blame] | 261 | # Use DHCP agent for providing metadata service in the case of | 
|  | 262 | # without L3 agent (No Route Agent), set to True in localrc. | 
|  | 263 | ENABLE_ISOLATED_METADATA=${ENABLE_ISOLATED_METADATA:-False} | 
|  | 264 |  | 
|  | 265 | # Add a static route as dhcp option, so the request to 169.254.169.254 | 
|  | 266 | # will be able to reach through a route(DHCP agent) | 
|  | 267 | # This option require ENABLE_ISOLATED_METADATA = True | 
|  | 268 | ENABLE_METADATA_NETWORK=${ENABLE_METADATA_NETWORK:-False} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 269 | # Neutron plugin specific functions | 
|  | 270 | # --------------------------------- | 
|  | 271 |  | 
|  | 272 | # Please refer to ``lib/neutron_plugins/README.md`` for details. | 
| Hirofumi Ichihara | 36daecd | 2015-07-23 17:50:40 +0900 | [diff] [blame] | 273 | if [ -f $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN ]; then | 
|  | 274 | source $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN | 
|  | 275 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 276 |  | 
| Emilien Macchi | 40546f7 | 2013-09-24 15:10:25 +0200 | [diff] [blame] | 277 | # Agent metering service plugin functions | 
|  | 278 | # ------------------------------------------- | 
|  | 279 |  | 
|  | 280 | # Hardcoding for 1 service plugin for now | 
|  | 281 | source $TOP_DIR/lib/neutron_plugins/services/metering | 
|  | 282 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 283 | # L3 Service functions | 
|  | 284 | source $TOP_DIR/lib/neutron_plugins/services/l3 | 
| Slawek Kaplonski | f758b60 | 2021-10-06 12:02:22 +0200 | [diff] [blame] | 285 |  | 
|  | 286 | # Additional Neutron service plugins | 
| Slawek Kaplonski | 7f6d928 | 2021-10-27 16:40:30 +0200 | [diff] [blame] | 287 | source $TOP_DIR/lib/neutron_plugins/services/placement | 
| Slawek Kaplonski | f758b60 | 2021-10-06 12:02:22 +0200 | [diff] [blame] | 288 | source $TOP_DIR/lib/neutron_plugins/services/trunk | 
| Slawek Kaplonski | f9a896c | 2021-10-27 16:50:11 +0200 | [diff] [blame] | 289 | source $TOP_DIR/lib/neutron_plugins/services/qos | 
| Slawek Kaplonski | f758b60 | 2021-10-06 12:02:22 +0200 | [diff] [blame] | 290 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 291 | # Use security group or not | 
|  | 292 | if has_neutron_plugin_security_group; then | 
|  | 293 | Q_USE_SECGROUP=${Q_USE_SECGROUP:-True} | 
|  | 294 | else | 
|  | 295 | Q_USE_SECGROUP=False | 
|  | 296 | fi | 
|  | 297 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 298 | # Save trace setting | 
| Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 299 | _XTRACE_NEUTRON=$(set +o | grep xtrace) | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 300 | set +o xtrace | 
|  | 301 |  | 
|  | 302 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 303 | # Functions | 
|  | 304 | # --------- | 
|  | 305 |  | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 306 | function _determine_config_server { | 
| YAMAMOTO Takashi | eede9dd | 2016-07-15 10:27:53 +0900 | [diff] [blame] | 307 | if [[ "$Q_PLUGIN_EXTRA_CONF_PATH" != '' ]]; then | 
|  | 308 | if [[ "$Q_PLUGIN_EXTRA_CONF_PATH" = "$_Q_PLUGIN_EXTRA_CONF_PATH" ]]; then | 
|  | 309 | deprecated "Q_PLUGIN_EXTRA_CONF_PATH is deprecated" | 
|  | 310 | else | 
|  | 311 | die $LINENO "Q_PLUGIN_EXTRA_CONF_PATH is deprecated" | 
|  | 312 | fi | 
|  | 313 | fi | 
|  | 314 | if [[ ${#Q_PLUGIN_EXTRA_CONF_FILES[@]} > 0 ]]; then | 
|  | 315 | deprecated "Q_PLUGIN_EXTRA_CONF_FILES is deprecated.  Use neutron_server_config_add instead." | 
|  | 316 | fi | 
|  | 317 | for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do | 
|  | 318 | _Q_PLUGIN_EXTRA_CONF_FILES_ABS+=($_Q_PLUGIN_EXTRA_CONF_PATH/$cfg_file) | 
|  | 319 | done | 
|  | 320 |  | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 321 | local cfg_file | 
|  | 322 | local opts="--config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE" | 
| YAMAMOTO Takashi | eede9dd | 2016-07-15 10:27:53 +0900 | [diff] [blame] | 323 | for cfg_file in ${_Q_PLUGIN_EXTRA_CONF_FILES_ABS[@]}; do | 
| Tom Patzig | 7346704 | 2016-04-19 17:02:34 +0200 | [diff] [blame] | 324 | opts+=" --config-file $cfg_file" | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 325 | done | 
|  | 326 | echo "$opts" | 
|  | 327 | } | 
|  | 328 |  | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 329 | function _determine_config_l3 { | 
| Angus Lees | a1c70f2 | 2016-05-31 14:43:14 +1000 | [diff] [blame] | 330 | local opts="--config-file $NEUTRON_CONF --config-file $Q_L3_CONF_FILE" | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 331 | echo "$opts" | 
|  | 332 | } | 
|  | 333 |  | 
|  | 334 | # For services and agents that require it, dynamically construct a list of | 
|  | 335 | # --config-file arguments that are passed to the binary. | 
|  | 336 | function determine_config_files { | 
|  | 337 | local opts="" | 
|  | 338 | case "$1" in | 
|  | 339 | "neutron-server") opts="$(_determine_config_server)" ;; | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 340 | "neutron-l3-agent") opts="$(_determine_config_l3)" ;; | 
|  | 341 | esac | 
|  | 342 | if [ -z "$opts" ] ; then | 
|  | 343 | die $LINENO "Could not determine config files for $1." | 
|  | 344 | fi | 
|  | 345 | echo "$opts" | 
|  | 346 | } | 
|  | 347 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 348 | # configure_mutnauq() | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 349 | # Set common config for all neutron server and agents. | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 350 | function configure_mutnauq { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 351 | _configure_neutron_common | 
| Brant Knudson | 2dd110c | 2015-03-14 12:39:14 -0500 | [diff] [blame] | 352 | iniset_rpc_backend neutron $NEUTRON_CONF | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 353 |  | 
| Emilien Macchi | 40546f7 | 2013-09-24 15:10:25 +0200 | [diff] [blame] | 354 | if is_service_enabled q-metering; then | 
|  | 355 | _configure_neutron_metering | 
|  | 356 | fi | 
| Stephen Ma | 9b38eb2 | 2014-04-02 02:13:09 +0000 | [diff] [blame] | 357 | if is_service_enabled q-agt q-svc; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 358 | _configure_neutron_service | 
|  | 359 | fi | 
|  | 360 | if is_service_enabled q-agt; then | 
|  | 361 | _configure_neutron_plugin_agent | 
|  | 362 | fi | 
|  | 363 | if is_service_enabled q-dhcp; then | 
|  | 364 | _configure_neutron_dhcp_agent | 
|  | 365 | fi | 
|  | 366 | if is_service_enabled q-l3; then | 
|  | 367 | _configure_neutron_l3_agent | 
|  | 368 | fi | 
|  | 369 | if is_service_enabled q-meta; then | 
|  | 370 | _configure_neutron_metadata_agent | 
|  | 371 | fi | 
|  | 372 |  | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 373 | if [[ "$Q_DVR_MODE" != "legacy" ]]; then | 
|  | 374 | _configure_dvr | 
|  | 375 | fi | 
| Dina Belova | 58adaa6 | 2014-07-11 18:18:12 +0400 | [diff] [blame] | 376 | if is_service_enabled ceilometer; then | 
|  | 377 | _configure_neutron_ceilometer_notifications | 
|  | 378 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 379 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 380 | if [[ $Q_AGENT == "ovn" ]]; then | 
|  | 381 | configure_ovn | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 382 | configure_ovn_plugin | 
|  | 383 | fi | 
|  | 384 |  | 
| Slawek Kaplonski | f758b60 | 2021-10-06 12:02:22 +0200 | [diff] [blame] | 385 | # Configure Neutron's advanced services | 
| Slawek Kaplonski | 7f6d928 | 2021-10-27 16:40:30 +0200 | [diff] [blame] | 386 | if is_service_enabled q-placement neutron-placement; then | 
|  | 387 | configure_placement_extension | 
|  | 388 | fi | 
| Slawek Kaplonski | f758b60 | 2021-10-06 12:02:22 +0200 | [diff] [blame] | 389 | if is_service_enabled q-trunk neutron-trunk; then | 
|  | 390 | configure_trunk_extension | 
|  | 391 | fi | 
| Slawek Kaplonski | f9a896c | 2021-10-27 16:50:11 +0200 | [diff] [blame] | 392 | if is_service_enabled q-qos neutron-qos; then | 
|  | 393 | configure_qos | 
|  | 394 | if is_service_enabled q-l3 neutron-l3; then | 
|  | 395 | configure_l3_agent_extension_fip_qos | 
|  | 396 | configure_l3_agent_extension_gateway_ip_qos | 
|  | 397 | fi | 
|  | 398 | fi | 
| Slawek Kaplonski | f758b60 | 2021-10-06 12:02:22 +0200 | [diff] [blame] | 399 |  | 
| armando-migliaccio | e155b89 | 2015-06-12 08:55:02 -0700 | [diff] [blame] | 400 | iniset $NEUTRON_CONF DEFAULT api_workers "$API_WORKERS" | 
| Armando Migliaccio | 06f2ea2 | 2017-02-02 16:47:00 -0800 | [diff] [blame] | 401 | # devstack is not a tool for running uber scale OpenStack | 
|  | 402 | # clouds, therefore running without a dedicated RPC worker | 
|  | 403 | # for state reports is more than adequate. | 
|  | 404 | iniset $NEUTRON_CONF DEFAULT rpc_state_report_workers 0 | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 405 | } | 
|  | 406 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 407 | function create_nova_conf_neutron { | 
| Lucas Alvares Gomes | e638593 | 2018-06-28 11:00:28 +0100 | [diff] [blame] | 408 | local conf=${1:-$NOVA_CONF} | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 409 | iniset $conf neutron auth_type "password" | 
| Jens Harbott | 32c0089 | 2019-04-10 10:33:39 +0000 | [diff] [blame] | 410 | iniset $conf neutron auth_url "$KEYSTONE_SERVICE_URI" | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 411 | iniset $conf neutron username "$Q_ADMIN_USERNAME" | 
|  | 412 | iniset $conf neutron password "$SERVICE_PASSWORD" | 
|  | 413 | iniset $conf neutron user_domain_name "$SERVICE_DOMAIN_NAME" | 
|  | 414 | iniset $conf neutron project_name "$SERVICE_PROJECT_NAME" | 
|  | 415 | iniset $conf neutron project_domain_name "$SERVICE_DOMAIN_NAME" | 
|  | 416 | iniset $conf neutron auth_strategy "$Q_AUTH_STRATEGY" | 
|  | 417 | iniset $conf neutron region_name "$REGION_NAME" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 418 |  | 
| Matt Riedemann | 925c256 | 2015-08-25 13:40:25 -0700 | [diff] [blame] | 419 | # optionally set options in nova_conf | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 420 | neutron_plugin_create_nova_conf $conf | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 421 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 422 | if is_service_enabled q-meta; then | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 423 | iniset $conf neutron service_metadata_proxy "True" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 424 | fi | 
| Aaron Rosen | cea32b1 | 2014-03-04 16:20:14 -0800 | [diff] [blame] | 425 |  | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 426 | iniset $conf DEFAULT vif_plugging_is_fatal "$VIF_PLUGGING_IS_FATAL" | 
|  | 427 | iniset $conf DEFAULT vif_plugging_timeout "$VIF_PLUGGING_TIMEOUT" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 428 | } | 
|  | 429 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 430 | # create_mutnauq_accounts() - Set up common required neutron accounts | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 431 |  | 
|  | 432 | # Tenant               User       Roles | 
|  | 433 | # ------------------------------------------------------------------ | 
|  | 434 | # service              neutron    admin        # if enabled | 
|  | 435 |  | 
|  | 436 | # Migrated from keystone_data.sh | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 437 | function create_mutnauq_accounts { | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 438 | local neutron_url | 
|  | 439 | if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 440 | neutron_url=$Q_PROTOCOL://$SERVICE_HOST/ | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 441 | else | 
|  | 442 | neutron_url=$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/ | 
|  | 443 | fi | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 444 | if [ ! -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]; then | 
|  | 445 | neutron_url=$neutron_url$NEUTRON_ENDPOINT_SERVICE_NAME | 
|  | 446 | fi | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 447 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 448 | if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 449 |  | 
| Jamie Lennox | 85ff532 | 2015-01-28 14:28:01 +1000 | [diff] [blame] | 450 | create_service_user "neutron" | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 451 |  | 
| Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 452 | get_or_create_service "neutron" "network" "Neutron Service" | 
| Matt Riedemann | ae4578b | 2016-04-23 01:45:40 +0000 | [diff] [blame] | 453 | get_or_create_endpoint \ | 
| Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 454 | "network" \ | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 455 | "$REGION_NAME" "$neutron_url" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 456 | fi | 
|  | 457 | } | 
|  | 458 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 459 | # init_mutnauq() - Initialize databases, etc. | 
|  | 460 | function init_mutnauq { | 
| Ihar Hrachyshka | 157c84b | 2014-10-06 13:29:39 +0200 | [diff] [blame] | 461 | recreate_database $Q_DB_NAME | 
| Clark Boylan | 633dbc3 | 2017-06-14 12:09:21 -0700 | [diff] [blame] | 462 | time_start "dbsync" | 
| Salvatore Orlando | dd64988 | 2013-08-05 08:56:17 -0700 | [diff] [blame] | 463 | # Run Neutron db migrations | 
|  | 464 | $NEUTRON_BIN_DIR/neutron-db-manage --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE upgrade head | 
| Clark Boylan | 633dbc3 | 2017-06-14 12:09:21 -0700 | [diff] [blame] | 465 | time_stop "dbsync" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 466 | } | 
|  | 467 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 468 | # install_mutnauq() - Collect source and prepare | 
|  | 469 | function install_mutnauq { | 
| Doug Wiegley | 86561c3 | 2016-02-10 18:37:21 -0700 | [diff] [blame] | 470 | # Install neutron-lib from git so we make sure we're testing | 
|  | 471 | # the latest code. | 
|  | 472 | if use_library_from_git "neutron-lib"; then | 
|  | 473 | git_clone_by_name "neutron-lib" | 
|  | 474 | setup_dev_lib "neutron-lib" | 
|  | 475 | fi | 
|  | 476 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 477 | git_clone $NEUTRON_REPO $NEUTRON_DIR $NEUTRON_BRANCH | 
|  | 478 | setup_develop $NEUTRON_DIR | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 479 |  | 
|  | 480 | if [[ $Q_AGENT == "ovn" ]]; then | 
|  | 481 | install_ovn | 
|  | 482 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 483 | } | 
|  | 484 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 485 | # install_neutron_agent_packages() - Collect source and prepare | 
| YAMAMOTO Takashi | c74315e | 2016-07-21 17:49:43 +0900 | [diff] [blame] | 486 | function install_neutron_agent_packages_mutnauq { | 
| Robert Li | 72b3e44 | 2014-07-17 15:04:52 -0400 | [diff] [blame] | 487 | # radvd doesn't come with the OS. Install it if the l3 service is enabled. | 
|  | 488 | if is_service_enabled q-l3; then | 
|  | 489 | install_package radvd | 
|  | 490 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 491 | # install packages that are specific to plugin agent(s) | 
|  | 492 | if is_service_enabled q-agt q-dhcp q-l3; then | 
|  | 493 | neutron_plugin_install_agent_packages | 
|  | 494 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 495 | } | 
|  | 496 |  | 
| YAMAMOTO Takashi | a1875b1 | 2017-02-23 05:44:22 +0900 | [diff] [blame] | 497 | # Finish neutron configuration | 
|  | 498 | function configure_neutron_after_post_config { | 
|  | 499 | if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then | 
|  | 500 | iniset $NEUTRON_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES | 
|  | 501 | fi | 
| Slawek Kaplonski | 24b65ad | 2021-06-22 15:31:46 +0200 | [diff] [blame] | 502 | configure_rbac_policies | 
|  | 503 | } | 
|  | 504 |  | 
|  | 505 | # configure_rbac_policies() - Configure Neutron to enforce new RBAC | 
|  | 506 | # policies and scopes if NEUTRON_ENFORCE_SCOPE == True | 
|  | 507 | function configure_rbac_policies { | 
| Grzegorz Grasza | 8615563 | 2021-10-18 16:52:06 +0200 | [diff] [blame] | 508 | if [[ "$NEUTRON_ENFORCE_SCOPE" == "True" || "$ENFORCE_SCOPE" == True ]]; then | 
| Slawek Kaplonski | 24b65ad | 2021-06-22 15:31:46 +0200 | [diff] [blame] | 509 | iniset $NEUTRON_CONF oslo_policy enforce_new_defaults True | 
|  | 510 | iniset $NEUTRON_CONF oslo_policy enforce_scope True | 
|  | 511 | else | 
|  | 512 | iniset $NEUTRON_CONF oslo_policy enforce_new_defaults False | 
|  | 513 | iniset $NEUTRON_CONF oslo_policy enforce_scope False | 
|  | 514 | fi | 
| YAMAMOTO Takashi | a1875b1 | 2017-02-23 05:44:22 +0900 | [diff] [blame] | 515 | } | 
|  | 516 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 517 | # Start running OVN processes | 
|  | 518 | function start_ovn_services { | 
|  | 519 | if [[ $Q_AGENT == "ovn" ]]; then | 
|  | 520 | init_ovn | 
|  | 521 | start_ovn | 
|  | 522 | if [[ "$OVN_L3_CREATE_PUBLIC_NETWORK" == "True" ]]; then | 
|  | 523 | if [[ "$NEUTRON_CREATE_INITIAL_NETWORKS" != "True" ]]; then | 
|  | 524 | echo "OVN_L3_CREATE_PUBLIC_NETWORK=True is being ignored " | 
|  | 525 | echo "because NEUTRON_CREATE_INITIAL_NETWORKS is set to False" | 
|  | 526 | else | 
|  | 527 | create_public_bridge | 
|  | 528 | fi | 
|  | 529 | fi | 
|  | 530 | fi | 
|  | 531 | } | 
|  | 532 |  | 
| Sean Dague | 0eebeb4 | 2017-08-30 14:16:58 -0400 | [diff] [blame] | 533 | # Start running processes | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 534 | function start_neutron_service_and_check { | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 535 | local service_port=$Q_PORT | 
|  | 536 | local service_protocol=$Q_PROTOCOL | 
| Ian Wienand | 7ae9729 | 2016-02-16 14:50:53 +1100 | [diff] [blame] | 537 | local cfg_file_options | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 538 | local neutron_url | 
| Ian Wienand | 7ae9729 | 2016-02-16 14:50:53 +1100 | [diff] [blame] | 539 |  | 
|  | 540 | cfg_file_options="$(determine_config_files neutron-server)" | 
|  | 541 |  | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 542 | if is_service_enabled tls-proxy; then | 
|  | 543 | service_port=$Q_PORT_INT | 
|  | 544 | service_protocol="http" | 
|  | 545 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 546 | # Start the Neutron service | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 547 | if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then | 
|  | 548 | enable_service neutron-api | 
| Ian Wienand | 312517d | 2018-06-22 22:23:29 +1000 | [diff] [blame] | 549 | run_process neutron-api "$(which uwsgi) --procname-prefix neutron-api --ini $NEUTRON_UWSGI_CONF" | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 550 | neutron_url=$Q_PROTOCOL://$Q_HOST/ | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 551 | enable_service neutron-rpc-server | 
|  | 552 | run_process neutron-rpc-server "$NEUTRON_BIN_DIR/neutron-rpc-server $cfg_file_options" | 
|  | 553 | else | 
|  | 554 | run_process q-svc "$NEUTRON_BIN_DIR/neutron-server $cfg_file_options" | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 555 | neutron_url=$service_protocol://$Q_HOST:$service_port/ | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 556 | # Start proxy if enabled | 
|  | 557 | if is_service_enabled tls-proxy; then | 
|  | 558 | start_tls_proxy neutron '*' $Q_PORT $Q_HOST $Q_PORT_INT | 
|  | 559 | fi | 
|  | 560 | fi | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 561 | if [ ! -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]; then | 
|  | 562 | neutron_url=$neutron_url$NEUTRON_ENDPOINT_SERVICE_NAME | 
|  | 563 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 564 | echo "Waiting for Neutron to start..." | 
| Sean Dague | 442e4e9 | 2015-06-24 13:24:02 -0400 | [diff] [blame] | 565 |  | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 566 | local testcmd="wget ${ssl_ca} --no-proxy -q -O- $neutron_url" | 
| Sean Dague | 442e4e9 | 2015-06-24 13:24:02 -0400 | [diff] [blame] | 567 | test_with_retry "$testcmd" "Neutron did not start" $SERVICE_TIMEOUT | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 568 | } | 
|  | 569 |  | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 570 | # Control of the l2 agent is separated out to make it easier to test partial | 
|  | 571 | # upgrades (everything upgraded except the L2 agent) | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 572 | function start_mutnauq_l2_agent { | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 573 | 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] | 574 |  | 
| Kahou Lei | d663e29 | 2015-10-24 12:18:57 -0700 | [diff] [blame] | 575 | if is_provider_network && [[ $Q_AGENT == "openvswitch" ]]; then | 
| Zhongyue Luo | 56b7efb | 2014-12-16 11:36:49 +0800 | [diff] [blame] | 576 | 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] | 577 | sudo ip link set $OVS_PHYSICAL_BRIDGE up | 
|  | 578 | sudo ip link set br-int up | 
|  | 579 | sudo ip link set $PUBLIC_INTERFACE up | 
| yunhong jiang | ae9ee6b | 2014-10-08 07:01:02 -0700 | [diff] [blame] | 580 | if is_ironic_hardware; then | 
|  | 581 | for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do | 
|  | 582 | sudo ip addr del $IP dev $PUBLIC_INTERFACE | 
|  | 583 | sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE | 
|  | 584 | done | 
| gong yong sheng | 348c6ac | 2015-06-23 14:03:47 +0800 | [diff] [blame] | 585 | 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] | 586 | fi | 
| Sean M. Collins | 5ec6f8f | 2014-05-14 17:01:03 -0400 | [diff] [blame] | 587 | fi | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 588 | } | 
|  | 589 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 590 | function start_mutnauq_other_agents { | 
| Angus Lees | a1c70f2 | 2016-05-31 14:43:14 +1000 | [diff] [blame] | 591 | 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] | 592 |  | 
| YAMAMOTO Takashi | 6839d42 | 2017-10-17 12:58:18 +0900 | [diff] [blame] | 593 | 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] | 594 |  | 
| Angus Lees | a1c70f2 | 2016-05-31 14:43:14 +1000 | [diff] [blame] | 595 | 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] | 596 | 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] | 597 | } | 
|  | 598 |  | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 599 | # Start running processes, including screen | 
|  | 600 | function start_neutron_agents { | 
|  | 601 | # Start up the neutron agents if enabled | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 602 | start_mutnauq_l2_agent | 
|  | 603 | start_mutnauq_other_agents | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 604 | } | 
|  | 605 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 606 | function stop_mutnauq_l2_agent { | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 607 | stop_process q-agt | 
|  | 608 | } | 
|  | 609 |  | 
| Sean Dague | 0eebeb4 | 2017-08-30 14:16:58 -0400 | [diff] [blame] | 610 | # stop_mutnauq_other() - Stop running processes | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 611 | function stop_mutnauq_other { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 612 | if is_service_enabled q-dhcp; then | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 613 | stop_process q-dhcp | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 614 | pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }') | 
|  | 615 | [ ! -z "$pid" ] && sudo kill -9 $pid | 
|  | 616 | fi | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 617 |  | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 618 | if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then | 
|  | 619 | stop_process neutron-rpc-server | 
|  | 620 | stop_process neutron-api | 
|  | 621 | else | 
|  | 622 | stop_process q-svc | 
|  | 623 | fi | 
| Li Ma | a15d9de | 2016-01-19 19:11:51 +0800 | [diff] [blame] | 624 |  | 
|  | 625 | if is_service_enabled q-l3; then | 
|  | 626 | sudo pkill -f "radvd -C $DATA_DIR/neutron/ra" | 
|  | 627 | stop_process q-l3 | 
|  | 628 | fi | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 629 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 630 | if is_service_enabled q-meta; then | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 631 | stop_process q-meta | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 632 | fi | 
| Akihiro Motoki | edddb1f | 2013-12-09 20:21:06 +0900 | [diff] [blame] | 633 |  | 
| Akihiro Motoki | edddb1f | 2013-12-09 20:21:06 +0900 | [diff] [blame] | 634 | if is_service_enabled q-metering; then | 
|  | 635 | neutron_metering_stop | 
|  | 636 | fi | 
| Li Ma | 50120fa | 2015-12-13 10:41:34 +0800 | [diff] [blame] | 637 |  | 
|  | 638 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
|  | 639 | sudo pkill -9 -f $NEUTRON_ROOTWRAP-daemon || : | 
|  | 640 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 641 | } | 
|  | 642 |  | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 643 | # stop_neutron() - Stop running processes (non-screen) | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 644 | function stop_mutnauq { | 
|  | 645 | stop_mutnauq_other | 
|  | 646 | stop_mutnauq_l2_agent | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 647 |  | 
| yatinkarel | 6dd896f | 2022-04-26 16:37:07 +0530 | [diff] [blame] | 648 | if [[ $Q_AGENT == "ovn" && $SKIP_STOP_OVN != "True" ]]; then | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 649 | stop_ovn | 
|  | 650 | fi | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 651 | } | 
|  | 652 |  | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 653 | # _move_neutron_addresses_route() - Move the primary IP to the OVS bridge | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 654 | # on startup, or back to the public interface on cleanup. If no IP is | 
|  | 655 | # 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] | 656 | function _move_neutron_addresses_route { | 
|  | 657 | local from_intf=$1 | 
|  | 658 | local to_intf=$2 | 
|  | 659 | local add_ovs_port=$3 | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 660 | local del_ovs_port=$4 | 
|  | 661 | local af=$5 | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 662 |  | 
|  | 663 | if [[ -n "$from_intf" && -n "$to_intf" ]]; then | 
|  | 664 | # Remove the primary IP address from $from_intf and add it to $to_intf, | 
|  | 665 | # along with the default route, if it exists.  Also, when called | 
|  | 666 | # on configure we will also add $from_intf as a port on $to_intf, | 
|  | 667 | # assuming it is an OVS bridge. | 
|  | 668 |  | 
| Matt McEuen | e24707b | 2016-07-11 08:37:59 -0500 | [diff] [blame] | 669 | local IP_REPLACE="" | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 670 | local IP_DEL="" | 
| Shinobu KINJO | f95315b | 2015-11-07 10:21:08 +0900 | [diff] [blame] | 671 | local IP_UP="" | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 672 | local DEFAULT_ROUTE_GW | 
| Andreas Scheuring | 92e6b1a | 2017-04-26 13:40:42 +0200 | [diff] [blame] | 673 | DEFAULT_ROUTE_GW=$(ip -f $af r | awk "/default.+$from_intf\s/ { print \$3; exit }") | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 674 | local ADD_OVS_PORT="" | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 675 | local DEL_OVS_PORT="" | 
| Sean M. Collins | 17398a3 | 2016-05-11 18:24:46 +0000 | [diff] [blame] | 676 | local ARP_CMD="" | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 677 |  | 
| Brian Haley | bb9caea | 2015-11-16 17:18:42 -0500 | [diff] [blame] | 678 | 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] | 679 |  | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 680 | if [ "$DEFAULT_ROUTE_GW" != "" ]; then | 
| Sean M. Collins | 59e86a3 | 2015-11-09 11:06:39 -0500 | [diff] [blame] | 681 | 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] | 682 | fi | 
|  | 683 |  | 
|  | 684 | if [[ "$add_ovs_port" == "True" ]]; then | 
| Raman Budny | db02bbf | 2015-03-31 13:09:09 +0300 | [diff] [blame] | 685 | 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] | 686 | fi | 
|  | 687 |  | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 688 | if [[ "$del_ovs_port" == "True" ]]; then | 
|  | 689 | DEL_OVS_PORT="sudo ovs-vsctl --if-exists del-port $from_intf $to_intf" | 
|  | 690 | fi | 
|  | 691 |  | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 692 | if [[ "$IP_BRD" != "" ]]; then | 
| Brian Haley | 9451021 | 2015-09-02 15:40:04 -0400 | [diff] [blame] | 693 | IP_DEL="sudo ip addr del $IP_BRD dev $from_intf" | 
| Matt McEuen | e24707b | 2016-07-11 08:37:59 -0500 | [diff] [blame] | 694 | IP_REPLACE="sudo ip addr replace $IP_BRD dev $to_intf" | 
| Shinobu KINJO | f95315b | 2015-11-07 10:21:08 +0900 | [diff] [blame] | 695 | IP_UP="sudo ip link set $to_intf up" | 
| Sean M. Collins | 6d4843e | 2016-05-12 16:14:26 -0400 | [diff] [blame] | 696 | if [[ "$af" == "inet" ]]; then | 
|  | 697 | IP=$(echo $IP_BRD | awk '{ print $1; exit }' | grep -o -E '(.*)/' | cut -d "/" -f1) | 
| Rodolfo Alonso Hernandez | ca486c5 | 2020-06-25 18:22:28 +0000 | [diff] [blame] | 698 | ARP_CMD="sudo arping -A -c 3 -w 5 -I $to_intf $IP " | 
| Sean M. Collins | 6d4843e | 2016-05-12 16:14:26 -0400 | [diff] [blame] | 699 | fi | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 700 | fi | 
|  | 701 |  | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 702 | # The add/del OVS port calls have to happen either before or | 
|  | 703 | # after the address is moved in order to not leave it orphaned. | 
| Matt McEuen | e24707b | 2016-07-11 08:37:59 -0500 | [diff] [blame] | 704 | $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] | 705 | fi | 
|  | 706 | } | 
|  | 707 |  | 
| Slawek Kaplonski | b1a89eb | 2021-08-26 21:42:32 +0200 | [diff] [blame] | 708 | # _configure_public_network_connectivity() - Configures connectivity to the | 
|  | 709 | # external network using $PUBLIC_INTERFACE or NAT on the single interface | 
|  | 710 | # machines | 
|  | 711 | function _configure_public_network_connectivity { | 
|  | 712 | # If we've given a PUBLIC_INTERFACE to take over, then we assume | 
|  | 713 | # that we can own the whole thing, and privot it into the OVS | 
|  | 714 | # bridge. If we are not, we're probably on a single interface | 
|  | 715 | # machine, and we just setup NAT so that fixed guests can get out. | 
|  | 716 | if [[ -n "$PUBLIC_INTERFACE" ]]; then | 
|  | 717 | _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True False "inet" | 
|  | 718 |  | 
|  | 719 | if [[ $(ip -f inet6 a s dev "$PUBLIC_INTERFACE" | grep -c 'global') != 0 ]]; then | 
|  | 720 | _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" False False "inet6" | 
|  | 721 | fi | 
|  | 722 | else | 
|  | 723 | for d in $default_v4_route_devs; do | 
|  | 724 | sudo iptables -t nat -A POSTROUTING -o $d -s $FLOATING_RANGE -j MASQUERADE | 
|  | 725 | done | 
|  | 726 | fi | 
|  | 727 | } | 
|  | 728 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 729 | # cleanup_mutnauq() - Remove residual data files, anything left over from previous | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 730 | # runs that a clean run would need to clean up | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 731 | function cleanup_mutnauq { | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 732 |  | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 733 | if [[ -n "$OVS_PHYSICAL_BRIDGE" ]]; then | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 734 | _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False True "inet" | 
| Adam Kacmarsky | 11298a0 | 2015-06-26 14:49:47 -0600 | [diff] [blame] | 735 |  | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 736 | 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] | 737 | # ip(8) wants the prefix length when deleting | 
|  | 738 | local v6_gateway | 
|  | 739 | v6_gateway=$(ip -6 a s dev $OVS_PHYSICAL_BRIDGE | grep $IPV6_PUBLIC_NETWORK_GATEWAY | awk '{ print $2 }') | 
|  | 740 | sudo ip -6 addr del $v6_gateway dev $OVS_PHYSICAL_BRIDGE | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 741 | _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False False "inet6" | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 742 | fi | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 743 |  | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 744 | if is_provider_network && is_ironic_hardware; then | 
|  | 745 | for IP in $(ip addr show dev $OVS_PHYSICAL_BRIDGE | grep ' inet ' | awk '{print $2}'); do | 
|  | 746 | sudo ip addr del $IP dev $OVS_PHYSICAL_BRIDGE | 
|  | 747 | sudo ip addr add $IP dev $PUBLIC_INTERFACE | 
|  | 748 | done | 
|  | 749 | sudo route del -net $FIXED_RANGE gw $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE | 
|  | 750 | fi | 
| yunhong jiang | ae9ee6b | 2014-10-08 07:01:02 -0700 | [diff] [blame] | 751 | fi | 
|  | 752 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 753 | if is_neutron_ovs_base_plugin; then | 
|  | 754 | neutron_ovs_base_cleanup | 
|  | 755 | fi | 
|  | 756 |  | 
| Sean M. Collins | 7bc2af7 | 2015-06-08 12:36:30 -0400 | [diff] [blame] | 757 | if [[ $Q_AGENT == "linuxbridge" ]]; then | 
|  | 758 | neutron_lb_cleanup | 
|  | 759 | fi | 
|  | 760 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 761 | # delete all namespaces created by neutron | 
| Doug Wiegley | 7e40c64 | 2016-08-20 16:32:14 +0000 | [diff] [blame] | 762 | 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] | 763 | sudo ip netns delete ${ns} | 
|  | 764 | done | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 765 |  | 
|  | 766 | if [[ $Q_AGENT == "ovn" ]]; then | 
|  | 767 | cleanup_ovn | 
|  | 768 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 769 | } | 
|  | 770 |  | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 771 |  | 
| Maru Newby | 952fd90 | 2015-01-30 22:27:12 +0000 | [diff] [blame] | 772 | function _create_neutron_conf_dir { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 773 | # Put config files in ``NEUTRON_CONF_DIR`` for everyone to find | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 774 | sudo install -d -o $STACK_USER $NEUTRON_CONF_DIR | 
| Maru Newby | 952fd90 | 2015-01-30 22:27:12 +0000 | [diff] [blame] | 775 | } | 
|  | 776 |  | 
|  | 777 | # _configure_neutron_common() | 
|  | 778 | # Set common config for all neutron server and agents. | 
|  | 779 | # This MUST be called before other ``_configure_neutron_*`` functions. | 
|  | 780 | function _configure_neutron_common { | 
|  | 781 | _create_neutron_conf_dir | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 782 |  | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 783 | # Uses oslo config generator to generate core sample configuration files | 
|  | 784 | (cd $NEUTRON_DIR && exec ./tools/generate_config_file_samples.sh) | 
|  | 785 |  | 
|  | 786 | cp $NEUTRON_DIR/etc/neutron.conf.sample $NEUTRON_CONF | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 787 |  | 
| Jerry Zhao | 296c1e3 | 2015-08-07 20:43:54 -0400 | [diff] [blame] | 788 | Q_POLICY_FILE=$NEUTRON_CONF_DIR/policy.json | 
| Jerry Zhao | 296c1e3 | 2015-08-07 20:43:54 -0400 | [diff] [blame] | 789 |  | 
|  | 790 | # allow neutron user to administer neutron to match neutron account | 
| Akihiro Motoki | 80769c5 | 2018-11-23 05:18:40 +0900 | [diff] [blame] | 791 | # NOTE(amotoki): This is required for nova works correctly with neutron. | 
|  | 792 | if [ -f $NEUTRON_DIR/etc/policy.json ]; then | 
|  | 793 | cp $NEUTRON_DIR/etc/policy.json $Q_POLICY_FILE | 
|  | 794 | sed -i 's/"context_is_admin":  "role:admin"/"context_is_admin":  "role:admin or user_name:neutron"/g' $Q_POLICY_FILE | 
|  | 795 | else | 
|  | 796 | echo '{"context_is_admin":  "role:admin or user_name:neutron"}' > $Q_POLICY_FILE | 
|  | 797 | fi | 
| Jerry Zhao | 296c1e3 | 2015-08-07 20:43:54 -0400 | [diff] [blame] | 798 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 799 | # Set plugin-specific variables ``Q_DB_NAME``, ``Q_PLUGIN_CLASS``. | 
|  | 800 | # For main plugin config file, set ``Q_PLUGIN_CONF_PATH``, ``Q_PLUGIN_CONF_FILENAME``. | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 801 | neutron_plugin_configure_common | 
|  | 802 |  | 
| sbauza | e2c4ee2 | 2013-08-29 17:29:46 +0200 | [diff] [blame] | 803 | 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] | 804 | die $LINENO "Neutron plugin not set.. exiting" | 
|  | 805 | fi | 
|  | 806 |  | 
|  | 807 | # If needed, move config file from ``$NEUTRON_DIR/etc/neutron`` to ``NEUTRON_CONF_DIR`` | 
|  | 808 | mkdir -p /$Q_PLUGIN_CONF_PATH | 
|  | 809 | Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME | 
| Hirofumi Ichihara | 97cc85b | 2015-09-08 13:51:01 +0900 | [diff] [blame] | 810 | # NOTE(hichihara): Some neutron vendor plugins were already decomposed and | 
|  | 811 | # 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] | 812 | if [ -f "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" ]; then | 
|  | 813 | cp "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" /$Q_PLUGIN_CONF_FILE | 
|  | 814 | elif [ -f $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE ]; then | 
| Hirofumi Ichihara | 97cc85b | 2015-09-08 13:51:01 +0900 | [diff] [blame] | 815 | cp $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE | 
|  | 816 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 817 |  | 
| Ihar Hrachyshka | b816e5d | 2014-07-21 13:53:50 +0200 | [diff] [blame] | 818 | iniset $NEUTRON_CONF database connection `database_connection_url $Q_DB_NAME` | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 819 | iniset $NEUTRON_CONF DEFAULT state_path $DATA_DIR/neutron | 
| salvatore | e4e535b | 2014-10-29 18:22:46 +0100 | [diff] [blame] | 820 | iniset $NEUTRON_CONF DEFAULT use_syslog $SYSLOG | 
| Brian Haley | 180f5eb | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 821 | iniset $NEUTRON_CONF DEFAULT bind_host $Q_LISTEN_ADDRESS | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 822 | iniset $NEUTRON_CONF oslo_concurrency lock_path $DATA_DIR/neutron/lock | 
|  | 823 |  | 
| Victor Ryzhenkin | 878d7d8 | 2016-04-27 15:15:52 +0300 | [diff] [blame] | 824 | # NOTE(freerunner): Need to adjust Region Name for nova in multiregion installation | 
|  | 825 | iniset $NEUTRON_CONF nova region_name $REGION_NAME | 
|  | 826 |  | 
| Joe Gordon | bee5c50 | 2013-08-30 13:48:08 -0400 | [diff] [blame] | 827 | if [ "$VIRT_DRIVER" = 'fake' ]; then | 
|  | 828 | # Disable arbitrary limits | 
|  | 829 | iniset $NEUTRON_CONF quotas quota_network -1 | 
|  | 830 | iniset $NEUTRON_CONF quotas quota_subnet -1 | 
|  | 831 | iniset $NEUTRON_CONF quotas quota_port -1 | 
|  | 832 | iniset $NEUTRON_CONF quotas quota_security_group -1 | 
|  | 833 | iniset $NEUTRON_CONF quotas quota_security_group_rule -1 | 
|  | 834 | fi | 
|  | 835 |  | 
| Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 836 | # Format logging | 
| Sean Dague | 9751be6 | 2016-04-05 12:08:57 -0400 | [diff] [blame] | 837 | setup_logging $NEUTRON_CONF | 
| Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 838 |  | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 839 | if is_service_enabled tls-proxy && [ "$NEUTRON_DEPLOY_MOD_WSGI" == "False" ]; then | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 840 | # Set the service port for a proxy to take the original | 
|  | 841 | iniset $NEUTRON_CONF DEFAULT bind_port "$Q_PORT_INT" | 
| Jens Harbott | 411c34d | 2017-08-29 14:40:26 +0000 | [diff] [blame] | 842 | iniset $NEUTRON_CONF oslo_middleware enable_proxy_headers_parsing True | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 843 | fi | 
|  | 844 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 845 | _neutron_setup_rootwrap | 
|  | 846 | } | 
|  | 847 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 848 | function _configure_neutron_dhcp_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 849 |  | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 850 | cp $NEUTRON_DIR/etc/dhcp_agent.ini.sample $Q_DHCP_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 851 |  | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 852 | iniset $Q_DHCP_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Sean Dague | 78801c1 | 2016-08-04 14:10:07 -0400 | [diff] [blame] | 853 | # make it so we have working DNS from guests | 
|  | 854 | iniset $Q_DHCP_CONF_FILE DEFAULT dnsmasq_local_resolv True | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 855 | iniset $Q_DHCP_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 856 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 857 | 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] | 858 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 859 |  | 
| Tan Lin | 27a196e | 2014-10-31 15:44:34 +0800 | [diff] [blame] | 860 | if ! is_service_enabled q-l3; then | 
|  | 861 | if [[ "$ENABLE_ISOLATED_METADATA" = "True" ]]; then | 
|  | 862 | iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata $ENABLE_ISOLATED_METADATA | 
|  | 863 | iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network $ENABLE_METADATA_NETWORK | 
|  | 864 | else | 
|  | 865 | if [[ "$ENABLE_METADATA_NETWORK" = "True" ]]; then | 
|  | 866 | die "$LINENO" "Enable isolated metadata is a must for metadata network" | 
|  | 867 | fi | 
|  | 868 | fi | 
|  | 869 | fi | 
|  | 870 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 871 | _neutron_setup_interface_driver $Q_DHCP_CONF_FILE | 
|  | 872 |  | 
| xurong00037997 | 7ef31d0 | 2016-07-05 11:09:40 +0800 | [diff] [blame] | 873 | neutron_plugin_configure_dhcp_agent $Q_DHCP_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 874 | } | 
|  | 875 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 876 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 877 | function _configure_neutron_metadata_agent { | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 878 | cp $NEUTRON_DIR/etc/metadata_agent.ini.sample $Q_META_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 879 |  | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 880 | iniset $Q_META_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Brian Haley | efc5168 | 2017-11-10 00:50:48 -0500 | [diff] [blame] | 881 | iniset $Q_META_CONF_FILE DEFAULT nova_metadata_host $Q_META_DATA_IP | 
| Armando Migliaccio | 06f2ea2 | 2017-02-02 16:47:00 -0800 | [diff] [blame] | 882 | iniset $Q_META_CONF_FILE DEFAULT metadata_workers $API_WORKERS | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 883 | iniset $Q_META_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 884 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 885 | 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] | 886 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 887 | } | 
|  | 888 |  | 
| Dina Belova | 58adaa6 | 2014-07-11 18:18:12 +0400 | [diff] [blame] | 889 | function _configure_neutron_ceilometer_notifications { | 
| Matt Riedemann | 45da777 | 2017-03-05 13:07:39 -0500 | [diff] [blame] | 890 | iniset $NEUTRON_CONF oslo_messaging_notifications driver messagingv2 | 
| Dina Belova | 58adaa6 | 2014-07-11 18:18:12 +0400 | [diff] [blame] | 891 | } | 
|  | 892 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 893 | function _configure_neutron_metering { | 
| Emilien Macchi | 40546f7 | 2013-09-24 15:10:25 +0200 | [diff] [blame] | 894 | neutron_agent_metering_configure_common | 
|  | 895 | neutron_agent_metering_configure_agent | 
|  | 896 | } | 
|  | 897 |  | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 898 | function _configure_dvr { | 
|  | 899 | iniset $NEUTRON_CONF DEFAULT router_distributed True | 
|  | 900 | iniset $Q_L3_CONF_FILE DEFAULT agent_mode $Q_DVR_MODE | 
|  | 901 | } | 
|  | 902 |  | 
|  | 903 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 904 | # _configure_neutron_plugin_agent() - Set config files for neutron plugin agent | 
|  | 905 | # It is called when q-agt is enabled. | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 906 | function _configure_neutron_plugin_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 907 | # Specify the default root helper prior to agent configuration to | 
|  | 908 | # ensure that an agent's configuration can override the default | 
|  | 909 | iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 910 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
|  | 911 | iniset /$Q_PLUGIN_CONF_FILE  agent root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
|  | 912 | fi | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 913 | iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 914 |  | 
|  | 915 | # Configure agent for plugin | 
|  | 916 | neutron_plugin_configure_plugin_agent | 
|  | 917 | } | 
|  | 918 |  | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 919 | function _replace_api_paste_composite { | 
|  | 920 | local sep | 
|  | 921 | sep=$(echo -ne "\x01") | 
|  | 922 | # Replace it | 
|  | 923 | $sudo sed -i -e "s/\/\: neutronversions_composite/\/"${NEUTRON_ENDPOINT_SERVICE_NAME}"\/\: neutronversions_composite/" "$Q_API_PASTE_FILE" | 
|  | 924 | $sudo sed -i -e "s/\/healthcheck\: healthcheck/\/"${NEUTRON_ENDPOINT_SERVICE_NAME}"\/healthcheck\: healthcheck/" "$Q_API_PASTE_FILE" | 
|  | 925 | $sudo sed -i -e "s/\/v2.0\: neutronapi_v2_0/\/"${NEUTRON_ENDPOINT_SERVICE_NAME}"\/v2.0\: neutronapi_v2_0/" "$Q_API_PASTE_FILE" | 
|  | 926 | } | 
|  | 927 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 928 | # _configure_neutron_service() - Set config files for neutron service | 
|  | 929 | # It is called when q-svc is enabled. | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 930 | function _configure_neutron_service { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 931 | Q_API_PASTE_FILE=$NEUTRON_CONF_DIR/api-paste.ini | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 932 | cp $NEUTRON_DIR/etc/api-paste.ini $Q_API_PASTE_FILE | 
| Kevin Benton | 08a5fcc | 2014-07-18 16:06:12 -0700 | [diff] [blame] | 933 |  | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 934 | if [[ -n "$NEUTRON_ENDPOINT_SERVICE_NAME" ]]; then | 
|  | 935 | _replace_api_paste_composite | 
|  | 936 | fi | 
|  | 937 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 938 | # Update either configuration file with plugin | 
|  | 939 | iniset $NEUTRON_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS | 
|  | 940 |  | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 941 | iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Chris Dent | 74a85b0 | 2015-04-22 18:02:39 +0000 | [diff] [blame] | 942 | iniset $NEUTRON_CONF oslo_policy policy_file $Q_POLICY_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 943 |  | 
|  | 944 | iniset $NEUTRON_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY | 
| Dirk Mueller | 8ab64b3 | 2017-11-17 19:52:29 +0100 | [diff] [blame] | 945 | configure_keystone_authtoken_middleware $NEUTRON_CONF $Q_ADMIN_USERNAME | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 946 |  | 
| Atsushi SAKAI | fe7b56c | 2015-11-13 17:06:16 +0900 | [diff] [blame] | 947 | # Configuration for neutron notifications to nova. | 
| Terry Wilson | f06c443 | 2014-05-20 10:54:51 -0500 | [diff] [blame] | 948 | iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_status_changes $Q_NOTIFY_NOVA_PORT_STATUS_CHANGES | 
|  | 949 | 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] | 950 |  | 
| Dirk Mueller | 8ab64b3 | 2017-11-17 19:52:29 +0100 | [diff] [blame] | 951 | configure_keystone_authtoken_middleware $NEUTRON_CONF nova nova | 
| Aaron Rosen | cea32b1 | 2014-03-04 16:20:14 -0800 | [diff] [blame] | 952 |  | 
| yatinkarel | 92a34db | 2022-05-17 20:10:48 +0530 | [diff] [blame] | 953 | # Configuration for placement client | 
|  | 954 | configure_keystone_authtoken_middleware $NEUTRON_CONF placement placement | 
|  | 955 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 956 | # Configure plugin | 
|  | 957 | neutron_plugin_configure_service | 
|  | 958 | } | 
|  | 959 |  | 
|  | 960 | # Utility Functions | 
|  | 961 | #------------------ | 
|  | 962 |  | 
| Isaku Yamahata | 9e136b4 | 2013-12-16 15:52:03 +0900 | [diff] [blame] | 963 | # _neutron_service_plugin_class_add() - add service plugin class | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 964 | function _neutron_service_plugin_class_add { | 
| Isaku Yamahata | 9e136b4 | 2013-12-16 15:52:03 +0900 | [diff] [blame] | 965 | local service_plugin_class=$1 | 
|  | 966 | if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then | 
|  | 967 | Q_SERVICE_PLUGIN_CLASSES=$service_plugin_class | 
|  | 968 | elif [[ ! ,${Q_SERVICE_PLUGIN_CLASSES}, =~ ,${service_plugin_class}, ]]; then | 
|  | 969 | Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$service_plugin_class" | 
|  | 970 | fi | 
|  | 971 | } | 
|  | 972 |  | 
| Ihar Hrachyshka | f511c36 | 2017-03-07 06:31:49 +0000 | [diff] [blame] | 973 | # _neutron_ml2_extension_driver_add_old() - add ML2 extension driver | 
|  | 974 | function _neutron_ml2_extension_driver_add_old { | 
|  | 975 | local extension=$1 | 
|  | 976 | if [[ $Q_ML2_PLUGIN_EXT_DRIVERS == '' ]]; then | 
|  | 977 | Q_ML2_PLUGIN_EXT_DRIVERS=$extension | 
|  | 978 | elif [[ ! ,${Q_ML2_PLUGIN_EXT_DRIVERS}, =~ ,${extension}, ]]; then | 
|  | 979 | Q_ML2_PLUGIN_EXT_DRIVERS="$Q_ML2_PLUGIN_EXT_DRIVERS,$extension" | 
|  | 980 | fi | 
|  | 981 | } | 
|  | 982 |  | 
| YAMAMOTO Takashi | eede9dd | 2016-07-15 10:27:53 +0900 | [diff] [blame] | 983 | # mutnauq_server_config_add() - add server config file | 
|  | 984 | function mutnauq_server_config_add { | 
|  | 985 | _Q_PLUGIN_EXTRA_CONF_FILES_ABS+=($1) | 
|  | 986 | } | 
|  | 987 |  | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 988 | # _neutron_deploy_rootwrap_filters() - deploy rootwrap filters to $Q_CONF_ROOTWRAP_D (owned by root). | 
|  | 989 | function _neutron_deploy_rootwrap_filters { | 
| gong yong sheng | 3d6eaae | 2015-09-15 15:00:29 +0800 | [diff] [blame] | 990 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
|  | 991 | return | 
|  | 992 | fi | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 993 | local srcdir=$1 | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 994 | sudo install -d -o root -m 755 $Q_CONF_ROOTWRAP_D | 
|  | 995 | 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] | 996 | } | 
|  | 997 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 998 | # _neutron_setup_rootwrap() - configure Neutron's rootwrap | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 999 | function _neutron_setup_rootwrap { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1000 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
|  | 1001 | return | 
|  | 1002 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1003 | # Wipe any existing ``rootwrap.d`` files first | 
|  | 1004 | Q_CONF_ROOTWRAP_D=$NEUTRON_CONF_DIR/rootwrap.d | 
|  | 1005 | if [[ -d $Q_CONF_ROOTWRAP_D ]]; then | 
|  | 1006 | sudo rm -rf $Q_CONF_ROOTWRAP_D | 
|  | 1007 | fi | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 1008 |  | 
|  | 1009 | _neutron_deploy_rootwrap_filters $NEUTRON_DIR | 
|  | 1010 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1011 | # Set up ``rootwrap.conf``, pointing to ``$NEUTRON_CONF_DIR/rootwrap.d`` | 
|  | 1012 | # location moved in newer versions, prefer new location | 
|  | 1013 | if test -r $NEUTRON_DIR/etc/neutron/rootwrap.conf; then | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 1014 | 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] | 1015 | else | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 1016 | 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] | 1017 | fi | 
|  | 1018 | 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] | 1019 | sudo sed -e 's:^exec_dirs=\(.*\)$:exec_dirs=\1,/usr/local/bin:' -i $Q_RR_CONF_FILE | 
|  | 1020 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1021 | # Specify ``rootwrap.conf`` as first parameter to neutron-rootwrap | 
|  | 1022 | ROOTWRAP_SUDOER_CMD="$NEUTRON_ROOTWRAP $Q_RR_CONF_FILE *" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1023 | ROOTWRAP_DAEMON_SUDOER_CMD="$NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1024 |  | 
|  | 1025 | # Set up the rootwrap sudoers for neutron | 
|  | 1026 | TEMPFILE=`mktemp` | 
| Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 1027 | echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1028 | echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_DAEMON_SUDOER_CMD" >>$TEMPFILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1029 | chmod 0440 $TEMPFILE | 
|  | 1030 | sudo chown root:root $TEMPFILE | 
|  | 1031 | sudo mv $TEMPFILE /etc/sudoers.d/neutron-rootwrap | 
|  | 1032 |  | 
|  | 1033 | # Update the root_helper | 
|  | 1034 | iniset $NEUTRON_CONF agent root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1035 | if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
|  | 1036 | iniset $NEUTRON_CONF agent root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
|  | 1037 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1038 | } | 
|  | 1039 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1040 | function _neutron_setup_interface_driver { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1041 |  | 
|  | 1042 | # ovs_use_veth needs to be set before the plugin configuration | 
|  | 1043 | # occurs to allow plugins to override the setting. | 
|  | 1044 | iniset $1 DEFAULT ovs_use_veth $Q_OVS_USE_VETH | 
|  | 1045 |  | 
|  | 1046 | neutron_plugin_setup_interface_driver $1 | 
|  | 1047 | } | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1048 | # Functions for Neutron Exercises | 
|  | 1049 | #-------------------------------- | 
|  | 1050 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1051 | function delete_probe { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1052 | local from_net="$1" | 
|  | 1053 | net_id=`_get_net_id $from_net` | 
|  | 1054 | 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}'` | 
|  | 1055 | neutron-debug --os-tenant-name admin --os-username admin probe-delete $probe_id | 
|  | 1056 | } | 
|  | 1057 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1058 | function _get_net_id { | 
| Brian Haley | 4bc42c7 | 2017-11-07 15:22:00 -0500 | [diff] [blame] | 1059 | openstack --os-cloud devstack-admin --os-region-name="$REGION_NAME" --os-project-name admin --os-username admin --os-password $ADMIN_PASSWORD network list | grep $1 | awk '{print $2}' | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1060 | } | 
|  | 1061 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1062 | function _get_probe_cmd_prefix { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1063 | local from_net="$1" | 
|  | 1064 | net_id=`_get_net_id $from_net` | 
|  | 1065 | 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` | 
|  | 1066 | echo "$Q_RR_COMMAND ip netns exec qprobe-$probe_id" | 
|  | 1067 | } | 
|  | 1068 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1069 | # ssh check | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1070 | function _ssh_check_neutron { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1071 | local from_net=$1 | 
|  | 1072 | local key_file=$2 | 
|  | 1073 | local ip=$3 | 
|  | 1074 | local user=$4 | 
|  | 1075 | local timeout_sec=$5 | 
|  | 1076 | local probe_cmd = "" | 
|  | 1077 | probe_cmd=`_get_probe_cmd_prefix $from_net` | 
| Sean Dague | 442e4e9 | 2015-06-24 13:24:02 -0400 | [diff] [blame] | 1078 | local testcmd="$probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success" | 
|  | 1079 | 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] | 1080 | } | 
|  | 1081 |  | 
| Slawek Kaplonski | faed11d | 2021-11-18 10:36:57 +0100 | [diff] [blame] | 1082 | function plugin_agent_add_l2_agent_extension { | 
|  | 1083 | local l2_agent_extension=$1 | 
|  | 1084 | if [[ -z "$L2_AGENT_EXTENSIONS" ]]; then | 
|  | 1085 | L2_AGENT_EXTENSIONS=$l2_agent_extension | 
|  | 1086 | elif [[ ! ,${L2_AGENT_EXTENSIONS}, =~ ,${l2_agent_extension}, ]]; then | 
|  | 1087 | L2_AGENT_EXTENSIONS+=",$l2_agent_extension" | 
|  | 1088 | fi | 
|  | 1089 | } | 
|  | 1090 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1091 | # Restore xtrace | 
| Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 1092 | $_XTRACE_NEUTRON | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1093 |  | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 1094 | # Tell emacs to use shell-script-mode | 
|  | 1095 | ## Local variables: | 
|  | 1096 | ## mode: shell-script | 
|  | 1097 | ## End: |