| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 1 | #!/bin/bash | 
 | 2 | # | 
 | 3 | # lib/neutron | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 4 | # functions - functions specific to neutron | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 5 |  | 
 | 6 | # Dependencies: | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 7 | # ``functions`` file | 
 | 8 | # ``DEST`` must be defined | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 9 | # ``STACK_USER`` must be defined | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 10 |  | 
 | 11 | # ``stack.sh`` calls the entry points in this order: | 
 | 12 | # | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 13 | # - install_neutron_agent_packages | 
 | 14 | # - install_neutronclient | 
 | 15 | # - install_neutron | 
 | 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 | # - configure_neutron_after_post_config | 
 | 24 | # - start_neutron_service_and_check | 
 | 25 | # - check_neutron_third_party_integration | 
 | 26 | # - start_neutron_agents | 
 | 27 | # - create_neutron_initial_network | 
 | 28 | # | 
 | 29 | # ``unstack.sh`` calls the entry points in this order: | 
 | 30 | # | 
 | 31 | # - stop_neutron | 
 | 32 | # - stop_neutron_third_party | 
 | 33 | # - cleanup_neutron | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 34 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 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 | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 41 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 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 | # | 
 | 50 | # See "Neutron Network Configuration" below for additional variables | 
 | 51 | # that must be set in localrc for connectivity across hosts with | 
 | 52 | # Neutron. | 
 | 53 |  | 
 | 54 | # Settings | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 55 | # -------- | 
 | 56 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 57 |  | 
 | 58 | # Neutron Network Configuration | 
 | 59 | # ----------------------------- | 
 | 60 |  | 
 | 61 | if is_service_enabled tls-proxy; then | 
 | 62 |     Q_PROTOCOL="https" | 
 | 63 | fi | 
 | 64 |  | 
 | 65 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 66 | # Set up default directories | 
 | 67 | GITDIR["python-neutronclient"]=$DEST/python-neutronclient | 
 | 68 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 69 |  | 
 | 70 | NEUTRON_DIR=$DEST/neutron | 
 | 71 | NEUTRON_FWAAS_DIR=$DEST/neutron-fwaas | 
 | 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 | 
 | 76 | else | 
 | 77 |     NEUTRON_BIN_DIR=$(get_python_exec_prefix) | 
 | 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) | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 90 |  | 
| Stephen Finucane | 0cd8763 | 2024-04-19 12:12:16 +0100 | [diff] [blame] | 91 | NEUTRON_UWSGI=neutron.wsgi.api:application | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 92 | NEUTRON_UWSGI_CONF=$NEUTRON_CONF_DIR/neutron-api-uwsgi.ini | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 93 |  | 
| Slawek Kaplonski | 24b65ad | 2021-06-22 15:31:46 +0200 | [diff] [blame] | 94 | # If NEUTRON_ENFORCE_SCOPE == True, it will set "enforce_scope" | 
 | 95 | # and "enforce_new_defaults" to True in the Neutron's config to enforce usage | 
| Ghanshyam Mann | bacb840 | 2023-10-25 12:52:28 -0700 | [diff] [blame] | 96 | # of the new RBAC policies and scopes. Set it to False if you do not | 
 | 97 | # want to run Neutron with new RBAC. | 
 | 98 | NEUTRON_ENFORCE_SCOPE=$(trueorfalse True NEUTRON_ENFORCE_SCOPE) | 
| Slawek Kaplonski | 24b65ad | 2021-06-22 15:31:46 +0200 | [diff] [blame] | 99 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 100 | # Agent binaries.  Note, binary paths for other agents are set in per-service | 
 | 101 | # scripts in lib/neutron_plugins/services/ | 
 | 102 | AGENT_DHCP_BINARY="$NEUTRON_BIN_DIR/neutron-dhcp-agent" | 
 | 103 | AGENT_L3_BINARY=${AGENT_L3_BINARY:-"$NEUTRON_BIN_DIR/neutron-l3-agent"} | 
 | 104 | AGENT_META_BINARY="$NEUTRON_BIN_DIR/neutron-metadata-agent" | 
| Brian Haley | 9aaa529 | 2017-09-20 14:23:05 -0400 | [diff] [blame] | 105 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 106 | # Agent config files. Note, plugin-specific Q_PLUGIN_CONF_FILE is set and | 
 | 107 | # loaded from per-plugin  scripts in lib/neutron_plugins/ | 
 | 108 | Q_DHCP_CONF_FILE=$NEUTRON_CONF_DIR/dhcp_agent.ini | 
 | 109 | # NOTE(slaweq): NEUTRON_DHCP_CONF is used e.g. in neutron repository, | 
 | 110 | # it was previously defined in the lib/neutron module which is now deleted. | 
 | 111 | NEUTRON_DHCP_CONF=$Q_DHCP_CONF_FILE | 
 | 112 | Q_L3_CONF_FILE=$NEUTRON_CONF_DIR/l3_agent.ini | 
 | 113 | # NOTE(slaweq): NEUTRON_L3_CONF is used e.g. in neutron repository, | 
 | 114 | # it was previously defined in the lib/neutron module which is now deleted. | 
 | 115 | NEUTRON_L3_CONF=$Q_L3_CONF_FILE | 
 | 116 | Q_META_CONF_FILE=$NEUTRON_CONF_DIR/metadata_agent.ini | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 117 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 118 | # Default name for Neutron database | 
 | 119 | Q_DB_NAME=${Q_DB_NAME:-neutron} | 
 | 120 | # Default Neutron Plugin | 
 | 121 | Q_PLUGIN=${Q_PLUGIN:-ml2} | 
 | 122 | # Default Neutron Port | 
 | 123 | Q_PORT=${Q_PORT:-9696} | 
 | 124 | # Default Neutron Internal Port when using TLS proxy | 
 | 125 | Q_PORT_INT=${Q_PORT_INT:-19696} | 
 | 126 | # Default Neutron Host | 
 | 127 | Q_HOST=${Q_HOST:-$SERVICE_HOST} | 
 | 128 | # Default protocol | 
 | 129 | Q_PROTOCOL=${Q_PROTOCOL:-$SERVICE_PROTOCOL} | 
 | 130 | # Default listen address | 
 | 131 | Q_LISTEN_ADDRESS=${Q_LISTEN_ADDRESS:-$(ipv6_unquote $SERVICE_LISTEN_ADDRESS)} | 
 | 132 | # Default admin username | 
 | 133 | Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-neutron} | 
 | 134 | # Default auth strategy | 
 | 135 | Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone} | 
 | 136 | # RHEL's support for namespaces requires using veths with ovs | 
 | 137 | Q_OVS_USE_VETH=${Q_OVS_USE_VETH:-False} | 
 | 138 | Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True} | 
 | 139 | Q_USE_ROOTWRAP_DAEMON=$(trueorfalse True Q_USE_ROOTWRAP_DAEMON) | 
 | 140 | # Meta data IP | 
 | 141 | Q_META_DATA_IP=${Q_META_DATA_IP:-$(ipv6_unquote $SERVICE_HOST)} | 
 | 142 | # Allow Overlapping IP among subnets | 
 | 143 | Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True} | 
 | 144 | Q_NOTIFY_NOVA_PORT_STATUS_CHANGES=${Q_NOTIFY_NOVA_PORT_STATUS_CHANGES:-True} | 
 | 145 | Q_NOTIFY_NOVA_PORT_DATA_CHANGES=${Q_NOTIFY_NOVA_PORT_DATA_CHANGES:-True} | 
| Rodolfo Alonso Hernandez | aaaa037 | 2024-07-19 08:09:25 +0000 | [diff] [blame] | 146 | _Q_RUN_RPC_SERVER=True | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 147 | VIF_PLUGGING_IS_FATAL=${VIF_PLUGGING_IS_FATAL:-True} | 
 | 148 | VIF_PLUGGING_TIMEOUT=${VIF_PLUGGING_TIMEOUT:-300} | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 149 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 150 | # Allow to skip stopping of OVN services | 
 | 151 | SKIP_STOP_OVN=${SKIP_STOP_OVN:-False} | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 152 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 153 | # The directory which contains files for Q_PLUGIN_EXTRA_CONF_FILES. | 
 | 154 | # /etc/neutron is assumed by many of devstack plugins.  Do not change. | 
 | 155 | _Q_PLUGIN_EXTRA_CONF_PATH=/etc/neutron | 
| Julia Kreger | 6e5b138 | 2019-01-09 17:00:45 -0800 | [diff] [blame] | 156 |  | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 157 | # The name of the service in the endpoint URL | 
 | 158 | NEUTRON_ENDPOINT_SERVICE_NAME=${NEUTRON_ENDPOINT_SERVICE_NAME-"networking"} | 
 | 159 | if [[ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" && -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]]; then | 
 | 160 |     NEUTRON_ENDPOINT_SERVICE_NAME="networking" | 
 | 161 | fi | 
 | 162 |  | 
| elajkat | bb0c273 | 2023-11-16 11:30:04 +0100 | [diff] [blame] | 163 | # Source install libraries | 
 | 164 | ALEMBIC_REPO=${ALEMBIC_REPO:-https://github.com/sqlalchemy/alembic.git} | 
 | 165 | ALEMBIC_DIR=${ALEMBIC_DIR:-$DEST/alembic} | 
 | 166 | ALEMBIC_BRANCH=${ALEMBIC_BRANCH:-main} | 
 | 167 | SQLALCHEMY_REPO=${SQLALCHEMY_REPO:-https://github.com/sqlalchemy/sqlalchemy.git} | 
 | 168 | SQLALCHEMY_DIR=${SQLALCHEMY_DIR:-$DEST/sqlalchemy} | 
 | 169 | SQLALCHEMY_BRANCH=${SQLALCHEMY_BRANCH:-main} | 
 | 170 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 171 | # List of config file names in addition to the main plugin config file | 
 | 172 | # To add additional plugin config files, use ``neutron_server_config_add`` | 
 | 173 | # utility function.  For example: | 
 | 174 | # | 
 | 175 | #    ``neutron_server_config_add file1`` | 
 | 176 | # | 
 | 177 | # These config files are relative to ``/etc/neutron``.  The above | 
 | 178 | # example would specify ``--config-file /etc/neutron/file1`` for | 
 | 179 | # neutron server. | 
 | 180 | declare -a -g Q_PLUGIN_EXTRA_CONF_FILES | 
| Julia Kreger | 6e5b138 | 2019-01-09 17:00:45 -0800 | [diff] [blame] | 181 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 182 | # same as Q_PLUGIN_EXTRA_CONF_FILES, but with absolute path. | 
 | 183 | declare -a -g _Q_PLUGIN_EXTRA_CONF_FILES_ABS | 
 | 184 |  | 
 | 185 |  | 
 | 186 | Q_RR_CONF_FILE=$NEUTRON_CONF_DIR/rootwrap.conf | 
 | 187 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
 | 188 |     Q_RR_COMMAND="sudo" | 
 | 189 | else | 
 | 190 |     NEUTRON_ROOTWRAP=$(get_rootwrap_location neutron) | 
 | 191 |     Q_RR_COMMAND="sudo $NEUTRON_ROOTWRAP $Q_RR_CONF_FILE" | 
 | 192 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
 | 193 |         Q_RR_DAEMON_COMMAND="sudo $NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE" | 
 | 194 |     fi | 
 | 195 | fi | 
 | 196 |  | 
 | 197 |  | 
 | 198 | # Distributed Virtual Router (DVR) configuration | 
 | 199 | # Can be: | 
 | 200 | # - ``legacy``   - No DVR functionality | 
 | 201 | # - ``dvr_snat`` - Controller or single node DVR | 
 | 202 | # - ``dvr``      - Compute node in multi-node DVR | 
 | 203 | # - ``dvr_no_external`` - Compute node in multi-node DVR, no external network | 
 | 204 | # | 
 | 205 | Q_DVR_MODE=${Q_DVR_MODE:-legacy} | 
 | 206 | if [[ "$Q_DVR_MODE" != "legacy" ]]; then | 
 | 207 |     Q_ML2_PLUGIN_MECHANISM_DRIVERS=openvswitch,l2population | 
 | 208 | fi | 
 | 209 |  | 
 | 210 | # Provider Network Configurations | 
 | 211 | # -------------------------------- | 
 | 212 |  | 
 | 213 | # The following variables control the Neutron ML2 plugins' allocation | 
 | 214 | # of tenant networks and availability of provider networks. If these | 
 | 215 | # are not configured in ``localrc``, tenant networks will be local to | 
 | 216 | # the host (with no remote connectivity), and no physical resources | 
 | 217 | # will be available for the allocation of provider networks. | 
 | 218 |  | 
 | 219 | # To disable tunnels (GRE or VXLAN) for tenant networks, | 
 | 220 | # set to False in ``local.conf``. | 
 | 221 | # GRE tunnels are only supported by the openvswitch. | 
 | 222 | ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-True} | 
 | 223 |  | 
 | 224 | # If using GRE, VXLAN or GENEVE tunnels for tenant networks, | 
 | 225 | # specify the range of IDs from which tenant networks are | 
 | 226 | # allocated. Can be overridden in ``localrc`` if necessary. | 
 | 227 | TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGES:-1:1000} | 
 | 228 |  | 
 | 229 | # To use VLANs for tenant networks, set to True in localrc. VLANs | 
 | 230 | # are supported by the ML2 plugins, requiring additional configuration | 
 | 231 | # described below. | 
 | 232 | ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False} | 
 | 233 |  | 
 | 234 | # If using VLANs for tenant networks, set in ``localrc`` to specify | 
 | 235 | # the range of VLAN VIDs from which tenant networks are | 
 | 236 | # allocated. An external network switch must be configured to | 
 | 237 | # trunk these VLANs between hosts for multi-host connectivity. | 
 | 238 | # | 
 | 239 | # Example: ``TENANT_VLAN_RANGE=1000:1999`` | 
 | 240 | TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-} | 
 | 241 |  | 
 | 242 | # If using VLANs for tenant networks, or if using flat or VLAN | 
 | 243 | # provider networks, set in ``localrc`` to the name of the physical | 
 | 244 | # network, and also configure ``OVS_PHYSICAL_BRIDGE`` for the | 
 | 245 | # openvswitch agent or ``LB_PHYSICAL_INTERFACE`` for the linuxbridge | 
 | 246 | # agent, as described below. | 
 | 247 | # | 
 | 248 | # Example: ``PHYSICAL_NETWORK=default`` | 
 | 249 | PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-public} | 
 | 250 |  | 
 | 251 | # With the openvswitch agent, if using VLANs for tenant networks, | 
 | 252 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
 | 253 | # the name of the OVS bridge to use for the physical network. The | 
 | 254 | # bridge will be created if it does not already exist, but a | 
 | 255 | # physical interface must be manually added to the bridge as a | 
 | 256 | # port for external connectivity. | 
 | 257 | # | 
 | 258 | # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1`` | 
 | 259 | OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-br-ex} | 
 | 260 |  | 
 | 261 | # With the linuxbridge agent, if using VLANs for tenant networks, | 
 | 262 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
 | 263 | # the name of the network interface to use for the physical | 
 | 264 | # network. | 
 | 265 | # | 
 | 266 | # Example: ``LB_PHYSICAL_INTERFACE=eth1`` | 
 | 267 | if [[ $Q_AGENT == "linuxbridge" && -z ${LB_PHYSICAL_INTERFACE} ]]; then | 
 | 268 |     default_route_dev=$( (ip route; ip -6 route) | grep ^default | head -n 1 | awk '{print $5}') | 
 | 269 |     die_if_not_set $LINENO default_route_dev "Failure retrieving default route device" | 
 | 270 |     LB_PHYSICAL_INTERFACE=$default_route_dev | 
 | 271 | fi | 
 | 272 |  | 
 | 273 | # With the openvswitch plugin, set to True in ``localrc`` to enable | 
 | 274 | # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False. | 
 | 275 | # | 
 | 276 | # Example: ``OVS_ENABLE_TUNNELING=True`` | 
 | 277 | OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS} | 
 | 278 |  | 
 | 279 | # Use DHCP agent for providing metadata service in the case of | 
 | 280 | # without L3 agent (No Route Agent), set to True in localrc. | 
 | 281 | ENABLE_ISOLATED_METADATA=${ENABLE_ISOLATED_METADATA:-False} | 
 | 282 |  | 
 | 283 | # Add a static route as dhcp option, so the request to 169.254.169.254 | 
 | 284 | # will be able to reach through a route(DHCP agent) | 
 | 285 | # This option require ENABLE_ISOLATED_METADATA = True | 
 | 286 | ENABLE_METADATA_NETWORK=${ENABLE_METADATA_NETWORK:-False} | 
 | 287 | # Neutron plugin specific functions | 
 | 288 | # --------------------------------- | 
 | 289 |  | 
 | 290 | # Please refer to ``lib/neutron_plugins/README.md`` for details. | 
 | 291 | if [ -f $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN ]; then | 
 | 292 |     source $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN | 
 | 293 | fi | 
 | 294 |  | 
 | 295 | # Agent metering service plugin functions | 
 | 296 | # ------------------------------------------- | 
 | 297 |  | 
 | 298 | # Hardcoding for 1 service plugin for now | 
 | 299 | source $TOP_DIR/lib/neutron_plugins/services/metering | 
 | 300 |  | 
 | 301 | # L3 Service functions | 
 | 302 | source $TOP_DIR/lib/neutron_plugins/services/l3 | 
 | 303 |  | 
 | 304 | # Additional Neutron service plugins | 
 | 305 | source $TOP_DIR/lib/neutron_plugins/services/placement | 
 | 306 | source $TOP_DIR/lib/neutron_plugins/services/trunk | 
 | 307 | source $TOP_DIR/lib/neutron_plugins/services/qos | 
| elajkat | a84b209 | 2021-11-17 11:52:56 +0100 | [diff] [blame] | 308 | source $TOP_DIR/lib/neutron_plugins/services/segments | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 309 |  | 
 | 310 | # Use security group or not | 
 | 311 | if has_neutron_plugin_security_group; then | 
 | 312 |     Q_USE_SECGROUP=${Q_USE_SECGROUP:-True} | 
 | 313 | else | 
 | 314 |     Q_USE_SECGROUP=False | 
 | 315 | fi | 
 | 316 |  | 
| Harald Jensås | 16ac21f | 2023-08-31 15:06:52 +0200 | [diff] [blame] | 317 | # OVN_BRIDGE_MAPPINGS - ovn-bridge-mappings | 
 | 318 | # NOTE(hjensas): Initialize after sourcing neutron_plugins/services/l3 | 
 | 319 | # which initialize PUBLIC_BRIDGE. | 
 | 320 | OVN_BRIDGE_MAPPINGS=${OVN_BRIDGE_MAPPINGS:-$PHYSICAL_NETWORK:$PUBLIC_BRIDGE} | 
 | 321 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 322 | # Save trace setting | 
 | 323 | _XTRACE_NEUTRON=$(set +o | grep xtrace) | 
 | 324 | set +o xtrace | 
 | 325 |  | 
| YAMAMOTO Takashi | eede9dd | 2016-07-15 10:27:53 +0900 | [diff] [blame] | 326 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 327 | # Functions | 
 | 328 | # --------- | 
 | 329 |  | 
 | 330 | # Test if any Neutron services are enabled | 
 | 331 | # is_neutron_enabled | 
 | 332 | function is_neutron_enabled { | 
| Clark Boylan | 902158b | 2017-05-30 14:11:09 -0700 | [diff] [blame] | 333 |     [[ ,${DISABLED_SERVICES} =~ ,"neutron" ]] && return 1 | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 334 |     [[ ,${ENABLED_SERVICES} =~ ,"neutron-" || ,${ENABLED_SERVICES} =~ ,"q-" ]] && return 0 | 
 | 335 |     return 1 | 
 | 336 | } | 
 | 337 |  | 
 | 338 | # Test if any Neutron services are enabled | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 339 | # TODO(slaweq): this is not really needed now and we should remove it as soon | 
 | 340 | # as it will not be called from any other Devstack plugins, like e.g. Neutron | 
 | 341 | # plugin | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 342 | function is_neutron_legacy_enabled { | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 343 |     return 0 | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 344 | } | 
 | 345 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 346 | function _determine_config_server { | 
 | 347 |     if [[ "$Q_PLUGIN_EXTRA_CONF_PATH" != '' ]]; then | 
 | 348 |         if [[ "$Q_PLUGIN_EXTRA_CONF_PATH" = "$_Q_PLUGIN_EXTRA_CONF_PATH" ]]; then | 
 | 349 |             deprecated "Q_PLUGIN_EXTRA_CONF_PATH is deprecated" | 
 | 350 |         else | 
 | 351 |             die $LINENO "Q_PLUGIN_EXTRA_CONF_PATH is deprecated" | 
 | 352 |         fi | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 353 |     fi | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 354 |     if [[ ${#Q_PLUGIN_EXTRA_CONF_FILES[@]} > 0 ]]; then | 
 | 355 |         deprecated "Q_PLUGIN_EXTRA_CONF_FILES is deprecated.  Use neutron_server_config_add instead." | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 356 |     fi | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 357 |     for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do | 
 | 358 |         _Q_PLUGIN_EXTRA_CONF_FILES_ABS+=($_Q_PLUGIN_EXTRA_CONF_PATH/$cfg_file) | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 359 |     done | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 360 |  | 
 | 361 |     local cfg_file | 
 | 362 |     local opts="--config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE" | 
 | 363 |     for cfg_file in ${_Q_PLUGIN_EXTRA_CONF_FILES_ABS[@]}; do | 
 | 364 |         opts+=" --config-file $cfg_file" | 
 | 365 |     done | 
 | 366 |     echo "$opts" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 367 | } | 
 | 368 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 369 | function _determine_config_l3 { | 
 | 370 |     local opts="--config-file $NEUTRON_CONF --config-file $Q_L3_CONF_FILE" | 
 | 371 |     echo "$opts" | 
| Ihar Hrachyshka | e65ab4a | 2017-02-24 17:47:55 +0000 | [diff] [blame] | 372 | } | 
 | 373 |  | 
| Rodolfo Alonso Hernandez | 3a0c0b9 | 2024-06-24 11:09:34 +0000 | [diff] [blame] | 374 | function _enable_ovn_maintenance { | 
 | 375 |     if [[ $Q_AGENT == "ovn" ]]; then | 
 | 376 |         enable_service neutron-ovn-maintenance-worker | 
 | 377 |     fi | 
 | 378 | } | 
 | 379 |  | 
 | 380 | function _run_ovn_maintenance { | 
 | 381 |     if [[ $Q_AGENT == "ovn" ]]; then | 
 | 382 |         run_process neutron-ovn-maintenance-worker "$NEUTRON_BIN_DIR/neutron-ovn-maintenance-worker $cfg_file_options" | 
 | 383 |     fi | 
 | 384 | } | 
 | 385 |  | 
 | 386 | function _stop_ovn_maintenance { | 
 | 387 |     if [[ $Q_AGENT == "ovn" ]]; then | 
 | 388 |         stop_process neutron-ovn-maintenance-worker | 
 | 389 |     fi | 
 | 390 | } | 
 | 391 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 392 | # For services and agents that require it, dynamically construct a list of | 
 | 393 | # --config-file arguments that are passed to the binary. | 
 | 394 | function determine_config_files { | 
 | 395 |     local opts="" | 
 | 396 |     case "$1" in | 
 | 397 |         "neutron-server") opts="$(_determine_config_server)" ;; | 
 | 398 |         "neutron-l3-agent") opts="$(_determine_config_l3)" ;; | 
 | 399 |     esac | 
 | 400 |     if [ -z "$opts" ] ; then | 
 | 401 |         die $LINENO "Could not determine config files for $1." | 
| YAMAMOTO Takashi | 1df17c9 | 2017-05-01 17:00:42 +0900 | [diff] [blame] | 402 |     fi | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 403 |     echo "$opts" | 
 | 404 | } | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 405 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 406 | # configure_neutron() | 
 | 407 | # Set common config for all neutron server and agents. | 
 | 408 | function configure_neutron { | 
 | 409 |     _configure_neutron_common | 
| Sean M. Collins | 5394cc1 | 2016-05-11 15:03:38 -0400 | [diff] [blame] | 410 |     iniset_rpc_backend neutron $NEUTRON_CONF | 
 | 411 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 412 |     if is_service_enabled q-metering neutron-metering; then | 
 | 413 |         _configure_neutron_metering | 
 | 414 |     fi | 
 | 415 |     if is_service_enabled q-agt neutron-agent; then | 
 | 416 |         _configure_neutron_plugin_agent | 
 | 417 |     fi | 
 | 418 |     if is_service_enabled q-dhcp neutron-dhcp; then | 
 | 419 |         _configure_neutron_dhcp_agent | 
 | 420 |     fi | 
 | 421 |     if is_service_enabled q-l3 neutron-l3; then | 
 | 422 |         _configure_neutron_l3_agent | 
 | 423 |     fi | 
 | 424 |     if is_service_enabled q-meta neutron-metadata-agent; then | 
 | 425 |         _configure_neutron_metadata_agent | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 426 |     fi | 
 | 427 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 428 |     if [[ "$Q_DVR_MODE" != "legacy" ]]; then | 
 | 429 |         _configure_dvr | 
 | 430 |     fi | 
 | 431 |     if is_service_enabled ceilometer; then | 
 | 432 |         _configure_neutron_ceilometer_notifications | 
 | 433 |     fi | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 434 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 435 |     if [[ $Q_AGENT == "ovn" ]]; then | 
 | 436 |         configure_ovn | 
 | 437 |         configure_ovn_plugin | 
 | 438 |     fi | 
| Brian Haley | 9aaa529 | 2017-09-20 14:23:05 -0400 | [diff] [blame] | 439 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 440 |     # Configure Neutron's advanced services | 
 | 441 |     if is_service_enabled q-placement neutron-placement; then | 
 | 442 |         configure_placement_extension | 
 | 443 |     fi | 
 | 444 |     if is_service_enabled q-trunk neutron-trunk; then | 
 | 445 |         configure_trunk_extension | 
 | 446 |     fi | 
 | 447 |     if is_service_enabled q-qos neutron-qos; then | 
 | 448 |         configure_qos | 
 | 449 |         if is_service_enabled q-l3 neutron-l3; then | 
 | 450 |             configure_l3_agent_extension_fip_qos | 
 | 451 |             configure_l3_agent_extension_gateway_ip_qos | 
| Denis Buliga | 0bf75a4 | 2017-02-06 16:56:46 +0200 | [diff] [blame] | 452 |         fi | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 453 |     fi | 
| elajkat | a84b209 | 2021-11-17 11:52:56 +0100 | [diff] [blame] | 454 |     if is_service_enabled neutron-segments; then | 
 | 455 |         configure_placement_neutron | 
 | 456 |         configure_segments_extension | 
 | 457 |     fi | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 458 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 459 |     # Finally configure Neutron server and core plugin | 
 | 460 |     if is_service_enabled q-agt neutron-agent q-svc neutron-api; then | 
 | 461 |         _configure_neutron_service | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 462 |     fi | 
 | 463 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 464 |     iniset $NEUTRON_CONF DEFAULT api_workers "$API_WORKERS" | 
 | 465 |     # devstack is not a tool for running uber scale OpenStack | 
 | 466 |     # clouds, therefore running without a dedicated RPC worker | 
 | 467 |     # for state reports is more than adequate. | 
 | 468 |     iniset $NEUTRON_CONF DEFAULT rpc_state_report_workers 0 | 
| Rodolfo Alonso Hernandez | aaaa037 | 2024-07-19 08:09:25 +0000 | [diff] [blame] | 469 |     # The default value of "rpc_workers" is None (not defined). If | 
 | 470 |     # "rpc_workers" is explicitly set to 0, the RPC workers process should not | 
 | 471 |     # be executed. NOTE: this service is only executed when WSGI is enabled | 
 | 472 |     # (NEUTRON_DEPLOY_MOD_WSGI=True) for the Neutron server. | 
 | 473 |     local rpc_workers | 
 | 474 |     rpc_workers=$(iniget_multiline /etc/neutron/neutron.conf DEFAULT rpc_workers) | 
| Rodolfo Alonso Hernandez | 13888a3 | 2024-07-20 15:50:30 +0000 | [diff] [blame] | 475 |     if [ "$rpc_workers" == "0" ]; then | 
| Rodolfo Alonso Hernandez | aaaa037 | 2024-07-19 08:09:25 +0000 | [diff] [blame] | 476 |         _Q_RUN_RPC_SERVER=False | 
 | 477 |     fi | 
| Ihar Hrachyshka | e391593 | 2017-02-24 06:24:47 +0000 | [diff] [blame] | 478 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 479 |     if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then | 
| Stephen Finucane | 0cd8763 | 2024-04-19 12:12:16 +0100 | [diff] [blame] | 480 |         write_uwsgi_config "$NEUTRON_UWSGI_CONF" "$NEUTRON_UWSGI" "/networking" "" "neutron-api" | 
| Sean M. Collins | 8063fee | 2016-05-24 11:27:36 -0700 | [diff] [blame] | 481 |     fi | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 482 | } | 
 | 483 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 484 | function configure_neutron_nova { | 
 | 485 |     create_nova_conf_neutron $NOVA_CONF | 
 | 486 |     if [[ "${CELLSV2_SETUP}" == "superconductor" ]]; then | 
 | 487 |         for i in $(seq 1 $NOVA_NUM_CELLS); do | 
 | 488 |             local conf | 
 | 489 |             conf=$(conductor_conf $i) | 
 | 490 |             create_nova_conf_neutron $conf | 
 | 491 |         done | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 492 |     fi | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 493 | } | 
 | 494 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 495 | function create_nova_conf_neutron { | 
| Lucas Alvares Gomes | e638593 | 2018-06-28 11:00:28 +0100 | [diff] [blame] | 496 |     local conf=${1:-$NOVA_CONF} | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 497 |     iniset $conf neutron auth_type "password" | 
 | 498 |     iniset $conf neutron auth_url "$KEYSTONE_SERVICE_URI" | 
| Dr. Jens Harbott | 696dbdf | 2024-07-09 16:36:37 +0200 | [diff] [blame] | 499 |     iniset $conf neutron username nova | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 500 |     iniset $conf neutron password "$SERVICE_PASSWORD" | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 501 |     iniset $conf neutron user_domain_name "$SERVICE_DOMAIN_NAME" | 
 | 502 |     iniset $conf neutron project_name "$SERVICE_PROJECT_NAME" | 
 | 503 |     iniset $conf neutron project_domain_name "$SERVICE_DOMAIN_NAME" | 
 | 504 |     iniset $conf neutron auth_strategy "$Q_AUTH_STRATEGY" | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 505 |     iniset $conf neutron region_name "$REGION_NAME" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 506 |  | 
| Gary Kotton | 88f8558 | 2016-08-14 06:55:42 -0700 | [diff] [blame] | 507 |     # optionally set options in nova_conf | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 508 |     neutron_plugin_create_nova_conf $conf | 
| Gary Kotton | 88f8558 | 2016-08-14 06:55:42 -0700 | [diff] [blame] | 509 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 510 |     if is_service_enabled q-meta neutron-metadata-agent; then | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 511 |         iniset $conf neutron service_metadata_proxy "True" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 512 |     fi | 
 | 513 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 514 |     iniset $conf DEFAULT vif_plugging_is_fatal "$VIF_PLUGGING_IS_FATAL" | 
 | 515 |     iniset $conf DEFAULT vif_plugging_timeout "$VIF_PLUGGING_TIMEOUT" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 516 | } | 
 | 517 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 518 | # create_neutron_accounts() - Set up common required neutron accounts | 
 | 519 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 520 | # Tenant               User       Roles | 
 | 521 | # ------------------------------------------------------------------ | 
 | 522 | # service              neutron    admin        # if enabled | 
 | 523 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 524 | # Migrated from keystone_data.sh | 
 | 525 | function create_neutron_accounts { | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 526 |     local neutron_url | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 527 |     if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 528 |         neutron_url=$Q_PROTOCOL://$SERVICE_HOST/ | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 529 |     else | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 530 |         neutron_url=$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/ | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 531 |     fi | 
| Slawek Kaplonski | 1a21ccb | 2022-07-08 21:57:45 +0200 | [diff] [blame] | 532 |     if [ ! -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]; then | 
 | 533 |         neutron_url=$neutron_url$NEUTRON_ENDPOINT_SERVICE_NAME | 
 | 534 |     fi | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 535 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 536 |     if is_service_enabled q-svc neutron-api; then | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 537 |  | 
 | 538 |         create_service_user "neutron" | 
 | 539 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 540 |         get_or_create_service "neutron" "network" "Neutron Service" | 
 | 541 |         get_or_create_endpoint \ | 
 | 542 |             "network" \ | 
| Kevin Benton | 66b361b | 2017-06-13 00:31:01 -0700 | [diff] [blame] | 543 |             "$REGION_NAME" "$neutron_url" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 544 |     fi | 
 | 545 | } | 
 | 546 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 547 | # init_neutron() - Initialize databases, etc. | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 548 | function init_neutron { | 
 | 549 |     recreate_database $Q_DB_NAME | 
| Clark Boylan | 633dbc3 | 2017-06-14 12:09:21 -0700 | [diff] [blame] | 550 |     time_start "dbsync" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 551 |     # Run Neutron db migrations | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 552 |     $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] | 553 |     time_stop "dbsync" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 554 | } | 
 | 555 |  | 
 | 556 | # install_neutron() - Collect source and prepare | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 557 | function install_neutron { | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 558 |     # Install neutron-lib from git so we make sure we're testing | 
 | 559 |     # the latest code. | 
 | 560 |     if use_library_from_git "neutron-lib"; then | 
 | 561 |         git_clone_by_name "neutron-lib" | 
 | 562 |         setup_dev_lib "neutron-lib" | 
 | 563 |     fi | 
 | 564 |  | 
| elajkat | bb0c273 | 2023-11-16 11:30:04 +0100 | [diff] [blame] | 565 |     # Install SQLAlchemy and alembic from git when these are required | 
 | 566 |     # see https://bugs.launchpad.net/neutron/+bug/2042941 | 
 | 567 |     if use_library_from_git "sqlalchemy"; then | 
 | 568 |         git_clone $SQLALCHEMY_REPO $SQLALCHEMY_DIR $SQLALCHEMY_BRANCH | 
 | 569 |         setup_develop $SQLALCHEMY_DIR | 
 | 570 |     fi | 
 | 571 |     if use_library_from_git "alembic"; then | 
 | 572 |         git_clone $ALEMBIC_REPO $ALEMBIC_DIR $ALEMBIC_BRANCH | 
 | 573 |         setup_develop $ALEMBIC_DIR | 
 | 574 |     fi | 
 | 575 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 576 |     git_clone $NEUTRON_REPO $NEUTRON_DIR $NEUTRON_BRANCH | 
 | 577 |     setup_develop $NEUTRON_DIR | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 578 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 579 |     if [[ $Q_AGENT == "ovn" ]]; then | 
 | 580 |         install_ovn | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 581 |     fi | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 582 | } | 
 | 583 |  | 
 | 584 | # install_neutronclient() - Collect source and prepare | 
 | 585 | function install_neutronclient { | 
 | 586 |     if use_library_from_git "python-neutronclient"; then | 
 | 587 |         git_clone_by_name "python-neutronclient" | 
 | 588 |         setup_dev_lib "python-neutronclient" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 589 |     fi | 
 | 590 | } | 
 | 591 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 592 | # install_neutron_agent_packages() - Collect source and prepare | 
 | 593 | function install_neutron_agent_packages { | 
 | 594 |     # radvd doesn't come with the OS. Install it if the l3 service is enabled. | 
 | 595 |     if is_service_enabled q-l3 neutron-l3; then | 
 | 596 |         install_package radvd | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 597 |     fi | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 598 |     # install packages that are specific to plugin agent(s) | 
 | 599 |     if is_service_enabled q-agt neutron-agent q-dhcp neutron-dhcp q-l3 neutron-l3; then | 
 | 600 |         neutron_plugin_install_agent_packages | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 601 |     fi | 
 | 602 | } | 
 | 603 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 604 | # Finish neutron configuration | 
 | 605 | function configure_neutron_after_post_config { | 
 | 606 |     if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then | 
 | 607 |         iniset $NEUTRON_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 608 |     fi | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 609 |     configure_rbac_policies | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 610 | } | 
 | 611 |  | 
| Slawek Kaplonski | 24b65ad | 2021-06-22 15:31:46 +0200 | [diff] [blame] | 612 | # configure_rbac_policies() - Configure Neutron to enforce new RBAC | 
 | 613 | # policies and scopes if NEUTRON_ENFORCE_SCOPE == True | 
 | 614 | function configure_rbac_policies { | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 615 |     if [[ "$NEUTRON_ENFORCE_SCOPE" == "True" || "$ENFORCE_SCOPE" == True ]]; then | 
| Slawek Kaplonski | 24b65ad | 2021-06-22 15:31:46 +0200 | [diff] [blame] | 616 |         iniset $NEUTRON_CONF oslo_policy enforce_new_defaults True | 
 | 617 |         iniset $NEUTRON_CONF oslo_policy enforce_scope True | 
 | 618 |     else | 
 | 619 |         iniset $NEUTRON_CONF oslo_policy enforce_new_defaults False | 
 | 620 |         iniset $NEUTRON_CONF oslo_policy enforce_scope False | 
 | 621 |     fi | 
 | 622 | } | 
 | 623 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 624 | # Start running OVN processes | 
 | 625 | function start_ovn_services { | 
 | 626 |     if [[ $Q_AGENT == "ovn" ]]; then | 
| Lucas Alvares Gomes | a389128 | 2023-07-18 16:31:28 +0100 | [diff] [blame] | 627 |         if [ "$VIRT_DRIVER" != 'ironic' ]; then | 
 | 628 |             # NOTE(TheJulia): Ironic's devstack plugin needs to perform | 
 | 629 |             # additional networking configuration to setup a working test | 
 | 630 |             # environment with test virtual machines to emulate baremetal, | 
 | 631 |             # which requires OVN to be up and running earlier to complete | 
 | 632 |             # that base configuration. | 
 | 633 |             init_ovn | 
 | 634 |             start_ovn | 
 | 635 |         fi | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 636 |         if [[ "$OVN_L3_CREATE_PUBLIC_NETWORK" == "True" ]]; then | 
 | 637 |             if [[ "$NEUTRON_CREATE_INITIAL_NETWORKS" != "True" ]]; then | 
 | 638 |                 echo "OVN_L3_CREATE_PUBLIC_NETWORK=True is being ignored " | 
 | 639 |                 echo "because NEUTRON_CREATE_INITIAL_NETWORKS is set to False" | 
 | 640 |             else | 
 | 641 |                 create_public_bridge | 
 | 642 |             fi | 
| Matt Riedemann | e95f2a3 | 2018-06-18 16:17:29 -0400 | [diff] [blame] | 643 |         fi | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 644 |     fi | 
 | 645 | } | 
 | 646 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 647 | # Start running processes | 
 | 648 | function start_neutron_service_and_check { | 
 | 649 |     local service_port=$Q_PORT | 
 | 650 |     local service_protocol=$Q_PROTOCOL | 
 | 651 |     local cfg_file_options | 
 | 652 |     local neutron_url | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 653 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 654 |     cfg_file_options="$(determine_config_files neutron-server)" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 655 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 656 |     if is_service_enabled tls-proxy; then | 
 | 657 |         service_port=$Q_PORT_INT | 
 | 658 |         service_protocol="http" | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 659 |     fi | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 660 |     # Start the Neutron service | 
 | 661 |     if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then | 
 | 662 |         enable_service neutron-api | 
 | 663 |         run_process neutron-api "$(which uwsgi) --procname-prefix neutron-api --ini $NEUTRON_UWSGI_CONF" | 
 | 664 |         neutron_url=$Q_PROTOCOL://$Q_HOST/ | 
| Rodolfo Alonso Hernandez | aaaa037 | 2024-07-19 08:09:25 +0000 | [diff] [blame] | 665 |         if [[ "$_Q_RUN_RPC_SERVER" = True ]]; then | 
 | 666 |             enable_service neutron-rpc-server | 
 | 667 |         fi | 
| Rodolfo Alonso Hernandez | 56368c2 | 2024-06-17 15:10:40 +0000 | [diff] [blame] | 668 |         enable_service neutron-periodic-workers | 
| Rodolfo Alonso Hernandez | 3a0c0b9 | 2024-06-24 11:09:34 +0000 | [diff] [blame] | 669 |         _enable_ovn_maintenance | 
| Rodolfo Alonso Hernandez | aaaa037 | 2024-07-19 08:09:25 +0000 | [diff] [blame] | 670 |         if [[ "$_Q_RUN_RPC_SERVER" = True ]]; then | 
 | 671 |             run_process neutron-rpc-server "$NEUTRON_BIN_DIR/neutron-rpc-server $cfg_file_options" | 
 | 672 |         fi | 
| Rodolfo Alonso Hernandez | 56368c2 | 2024-06-17 15:10:40 +0000 | [diff] [blame] | 673 |         run_process neutron-periodic-workers "$NEUTRON_BIN_DIR/neutron-periodic-workers $cfg_file_options" | 
| Rodolfo Alonso Hernandez | 3a0c0b9 | 2024-06-24 11:09:34 +0000 | [diff] [blame] | 674 |         _run_ovn_maintenance | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 675 |     else | 
 | 676 |         run_process q-svc "$NEUTRON_BIN_DIR/neutron-server $cfg_file_options" | 
 | 677 |         neutron_url=$service_protocol://$Q_HOST:$service_port/ | 
 | 678 |         # Start proxy if enabled | 
 | 679 |         if is_service_enabled tls-proxy; then | 
 | 680 |             start_tls_proxy neutron '*' $Q_PORT $Q_HOST $Q_PORT_INT | 
 | 681 |         fi | 
 | 682 |     fi | 
 | 683 |     if [ ! -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]; then | 
 | 684 |         neutron_url=$neutron_url$NEUTRON_ENDPOINT_SERVICE_NAME | 
 | 685 |     fi | 
 | 686 |     echo "Waiting for Neutron to start..." | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 687 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 688 |     local testcmd="wget ${ssl_ca} --no-proxy -q -O- $neutron_url" | 
 | 689 |     test_with_retry "$testcmd" "Neutron did not start" $SERVICE_TIMEOUT | 
| YAMAMOTO Takashi | eede9dd | 2016-07-15 10:27:53 +0900 | [diff] [blame] | 690 | } | 
 | 691 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 692 | function start_neutron { | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 693 |     start_l2_agent "$@" | 
 | 694 |     start_other_agents "$@" | 
 | 695 | } | 
 | 696 |  | 
 | 697 | # Control of the l2 agent is separated out to make it easier to test partial | 
 | 698 | # upgrades (everything upgraded except the L2 agent) | 
 | 699 | function start_l2_agent { | 
 | 700 |     run_process q-agt "$AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE" | 
 | 701 |  | 
 | 702 |     if is_provider_network && [[ $Q_AGENT == "openvswitch" ]]; then | 
 | 703 |         sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_PHYSICAL_BRIDGE $PUBLIC_INTERFACE | 
 | 704 |         sudo ip link set $OVS_PHYSICAL_BRIDGE up | 
 | 705 |         sudo ip link set br-int up | 
 | 706 |         sudo ip link set $PUBLIC_INTERFACE up | 
 | 707 |         if is_ironic_hardware; then | 
 | 708 |             for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do | 
 | 709 |                 sudo ip addr del $IP dev $PUBLIC_INTERFACE | 
 | 710 |                 sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE | 
 | 711 |             done | 
 | 712 |             sudo ip route replace $FIXED_RANGE via $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE | 
 | 713 |         fi | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 714 |     fi | 
 | 715 | } | 
 | 716 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 717 | function start_other_agents { | 
 | 718 |     run_process q-dhcp "$AGENT_DHCP_BINARY --config-file $NEUTRON_CONF --config-file $Q_DHCP_CONF_FILE" | 
 | 719 |  | 
 | 720 |     run_process q-l3 "$AGENT_L3_BINARY $(determine_config_files neutron-l3-agent)" | 
 | 721 |  | 
 | 722 |     run_process q-meta "$AGENT_META_BINARY --config-file $NEUTRON_CONF --config-file $Q_META_CONF_FILE" | 
 | 723 |     run_process q-metering "$AGENT_METERING_BINARY --config-file $NEUTRON_CONF --config-file $METERING_AGENT_CONF_FILENAME" | 
 | 724 | } | 
 | 725 |  | 
 | 726 | # Start running processes, including screen | 
 | 727 | function start_neutron_agents { | 
 | 728 |     # NOTE(slaweq): it's now just a wrapper for start_neutron function | 
 | 729 |     start_neutron "$@" | 
 | 730 | } | 
 | 731 |  | 
 | 732 | function stop_l2_agent { | 
 | 733 |     stop_process q-agt | 
 | 734 | } | 
 | 735 |  | 
 | 736 | # stop_other() - Stop running processes | 
 | 737 | function stop_other { | 
 | 738 |     if is_service_enabled q-dhcp neutron-dhcp; then | 
 | 739 |         stop_process q-dhcp | 
 | 740 |         pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }') | 
 | 741 |         [ ! -z "$pid" ] && sudo kill -9 $pid | 
 | 742 |     fi | 
 | 743 |  | 
 | 744 |     if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then | 
 | 745 |         stop_process neutron-rpc-server | 
| Rodolfo Alonso Hernandez | 56368c2 | 2024-06-17 15:10:40 +0000 | [diff] [blame] | 746 |         stop_process neutron-periodic-workers | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 747 |         stop_process neutron-api | 
| Rodolfo Alonso Hernandez | 3a0c0b9 | 2024-06-24 11:09:34 +0000 | [diff] [blame] | 748 |         _stop_ovn_maintenance | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 749 |     else | 
 | 750 |         stop_process q-svc | 
 | 751 |     fi | 
 | 752 |  | 
 | 753 |     if is_service_enabled q-l3 neutron-l3; then | 
 | 754 |         sudo pkill -f "radvd -C $DATA_DIR/neutron/ra" | 
 | 755 |         stop_process q-l3 | 
 | 756 |     fi | 
 | 757 |  | 
 | 758 |     if is_service_enabled q-meta neutron-metadata-agent; then | 
 | 759 |         stop_process q-meta | 
 | 760 |     fi | 
 | 761 |  | 
 | 762 |     if is_service_enabled q-metering neutron-metering; then | 
 | 763 |         neutron_metering_stop | 
 | 764 |     fi | 
 | 765 |  | 
 | 766 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
| Bence Romsics | 71c3c40 | 2022-12-21 13:50:54 +0100 | [diff] [blame] | 767 |         # pkill takes care not to kill itself, but it may kill its parent | 
 | 768 |         # sudo unless we use the "ps | grep [f]oo" trick | 
 | 769 |         sudo pkill -9 -f "$NEUTRON_ROOTWRAP-[d]aemon" || : | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 770 |     fi | 
 | 771 | } | 
 | 772 |  | 
 | 773 | # stop_neutron() - Stop running processes (non-screen) | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 774 | function stop_neutron { | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 775 |     stop_other | 
 | 776 |     stop_l2_agent | 
 | 777 |  | 
 | 778 |     if [[ $Q_AGENT == "ovn" && $SKIP_STOP_OVN != "True" ]]; then | 
 | 779 |         stop_ovn | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 780 |     fi | 
 | 781 | } | 
 | 782 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 783 | # _move_neutron_addresses_route() - Move the primary IP to the OVS bridge | 
 | 784 | # on startup, or back to the public interface on cleanup. If no IP is | 
 | 785 | # configured on the interface, just add it as a port to the OVS bridge. | 
 | 786 | function _move_neutron_addresses_route { | 
 | 787 |     local from_intf=$1 | 
 | 788 |     local to_intf=$2 | 
 | 789 |     local add_ovs_port=$3 | 
 | 790 |     local del_ovs_port=$4 | 
 | 791 |     local af=$5 | 
 | 792 |  | 
 | 793 |     if [[ -n "$from_intf" && -n "$to_intf" ]]; then | 
 | 794 |         # Remove the primary IP address from $from_intf and add it to $to_intf, | 
 | 795 |         # along with the default route, if it exists.  Also, when called | 
 | 796 |         # on configure we will also add $from_intf as a port on $to_intf, | 
 | 797 |         # assuming it is an OVS bridge. | 
 | 798 |  | 
 | 799 |         local IP_REPLACE="" | 
 | 800 |         local IP_DEL="" | 
 | 801 |         local IP_UP="" | 
 | 802 |         local DEFAULT_ROUTE_GW | 
 | 803 |         DEFAULT_ROUTE_GW=$(ip -f $af r | awk "/default.+$from_intf\s/ { print \$3; exit }") | 
 | 804 |         local ADD_OVS_PORT="" | 
 | 805 |         local DEL_OVS_PORT="" | 
 | 806 |         local ARP_CMD="" | 
 | 807 |  | 
 | 808 |         IP_BRD=$(ip -f $af a s dev $from_intf scope global primary | grep inet | awk '{ print $2, $3, $4; exit }') | 
 | 809 |  | 
 | 810 |         if [ "$DEFAULT_ROUTE_GW" != "" ]; then | 
 | 811 |             ADD_DEFAULT_ROUTE="sudo ip -f $af r replace default via $DEFAULT_ROUTE_GW dev $to_intf" | 
 | 812 |         fi | 
 | 813 |  | 
 | 814 |         if [[ "$add_ovs_port" == "True" ]]; then | 
 | 815 |             ADD_OVS_PORT="sudo ovs-vsctl --may-exist add-port $to_intf $from_intf" | 
 | 816 |         fi | 
 | 817 |  | 
 | 818 |         if [[ "$del_ovs_port" == "True" ]]; then | 
 | 819 |             DEL_OVS_PORT="sudo ovs-vsctl --if-exists del-port $from_intf $to_intf" | 
 | 820 |         fi | 
 | 821 |  | 
 | 822 |         if [[ "$IP_BRD" != "" ]]; then | 
 | 823 |             IP_DEL="sudo ip addr del $IP_BRD dev $from_intf" | 
 | 824 |             IP_REPLACE="sudo ip addr replace $IP_BRD dev $to_intf" | 
 | 825 |             IP_UP="sudo ip link set $to_intf up" | 
 | 826 |             if [[ "$af" == "inet" ]]; then | 
 | 827 |                 IP=$(echo $IP_BRD | awk '{ print $1; exit }' | grep -o -E '(.*)/' | cut -d "/" -f1) | 
 | 828 |                 ARP_CMD="sudo arping -A -c 3 -w 5 -I $to_intf $IP " | 
 | 829 |             fi | 
 | 830 |         fi | 
 | 831 |  | 
 | 832 |         # The add/del OVS port calls have to happen either before or | 
 | 833 |         # after the address is moved in order to not leave it orphaned. | 
 | 834 |         $DEL_OVS_PORT; $IP_DEL; $IP_REPLACE; $IP_UP; $ADD_OVS_PORT; $ADD_DEFAULT_ROUTE; $ARP_CMD | 
 | 835 |     fi | 
 | 836 | } | 
 | 837 |  | 
 | 838 | # _configure_public_network_connectivity() - Configures connectivity to the | 
 | 839 | # external network using $PUBLIC_INTERFACE or NAT on the single interface | 
 | 840 | # machines | 
 | 841 | function _configure_public_network_connectivity { | 
 | 842 |     # If we've given a PUBLIC_INTERFACE to take over, then we assume | 
 | 843 |     # that we can own the whole thing, and privot it into the OVS | 
 | 844 |     # bridge. If we are not, we're probably on a single interface | 
 | 845 |     # machine, and we just setup NAT so that fixed guests can get out. | 
 | 846 |     if [[ -n "$PUBLIC_INTERFACE" ]]; then | 
 | 847 |         _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True False "inet" | 
 | 848 |  | 
 | 849 |         if [[ $(ip -f inet6 a s dev "$PUBLIC_INTERFACE" | grep -c 'global') != 0 ]]; then | 
 | 850 |             _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" False False "inet6" | 
 | 851 |         fi | 
| YAMAMOTO Takashi | c043b6f | 2017-02-23 22:30:08 -0500 | [diff] [blame] | 852 |     else | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 853 |         for d in $default_v4_route_devs; do | 
 | 854 |             sudo iptables -t nat -A POSTROUTING -o $d -s $FLOATING_RANGE -j MASQUERADE | 
 | 855 |         done | 
 | 856 |     fi | 
 | 857 | } | 
 | 858 |  | 
 | 859 | # cleanup_neutron() - Remove residual data files, anything left over from previous | 
 | 860 | # runs that a clean run would need to clean up | 
 | 861 | function cleanup_neutron { | 
 | 862 |     if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then | 
 | 863 |         stop_process neutron-api | 
 | 864 |         stop_process neutron-rpc-server | 
| Rodolfo Alonso Hernandez | 56368c2 | 2024-06-17 15:10:40 +0000 | [diff] [blame] | 865 |         stop_process neutron-periodic-workers | 
| Rodolfo Alonso Hernandez | 3a0c0b9 | 2024-06-24 11:09:34 +0000 | [diff] [blame] | 866 |         _stop_ovn_maintenance | 
| Stephen Finucane | d5182ce | 2024-04-19 12:27:14 +0100 | [diff] [blame] | 867 |         remove_uwsgi_config "$NEUTRON_UWSGI_CONF" "neutron-api" | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 868 |         sudo rm -f $(apache_site_config_for neutron-api) | 
 | 869 |     fi | 
 | 870 |  | 
 | 871 |     if [[ -n "$OVS_PHYSICAL_BRIDGE" ]]; then | 
 | 872 |         _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False True "inet" | 
 | 873 |  | 
 | 874 |         if [[ $(ip -f inet6 a s dev "$OVS_PHYSICAL_BRIDGE" | grep -c 'global') != 0 ]]; then | 
 | 875 |             # ip(8) wants the prefix length when deleting | 
 | 876 |             local v6_gateway | 
 | 877 |             v6_gateway=$(ip -6 a s dev $OVS_PHYSICAL_BRIDGE | grep $IPV6_PUBLIC_NETWORK_GATEWAY | awk '{ print $2 }') | 
 | 878 |             sudo ip -6 addr del $v6_gateway dev $OVS_PHYSICAL_BRIDGE | 
 | 879 |             _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False False "inet6" | 
 | 880 |         fi | 
 | 881 |  | 
 | 882 |         if is_provider_network && is_ironic_hardware; then | 
 | 883 |             for IP in $(ip addr show dev $OVS_PHYSICAL_BRIDGE | grep ' inet ' | awk '{print $2}'); do | 
 | 884 |                 sudo ip addr del $IP dev $OVS_PHYSICAL_BRIDGE | 
 | 885 |                 sudo ip addr add $IP dev $PUBLIC_INTERFACE | 
 | 886 |             done | 
 | 887 |             sudo route del -net $FIXED_RANGE gw $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE | 
 | 888 |         fi | 
 | 889 |     fi | 
 | 890 |  | 
 | 891 |     if is_neutron_ovs_base_plugin; then | 
 | 892 |         neutron_ovs_base_cleanup | 
 | 893 |     fi | 
 | 894 |  | 
 | 895 |     if [[ $Q_AGENT == "linuxbridge" ]]; then | 
 | 896 |         neutron_lb_cleanup | 
 | 897 |     fi | 
 | 898 |  | 
 | 899 |     # delete all namespaces created by neutron | 
 | 900 |     for ns in $(sudo ip netns list | grep -o -E '(qdhcp|qrouter|fip|snat)-[0-9a-f-]*'); do | 
 | 901 |         sudo ip netns delete ${ns} | 
 | 902 |     done | 
 | 903 |  | 
 | 904 |     if [[ $Q_AGENT == "ovn" ]]; then | 
 | 905 |         cleanup_ovn | 
 | 906 |     fi | 
 | 907 | } | 
 | 908 |  | 
 | 909 |  | 
 | 910 | function _create_neutron_conf_dir { | 
 | 911 |     # Put config files in ``NEUTRON_CONF_DIR`` for everyone to find | 
 | 912 |     sudo install -d -o $STACK_USER $NEUTRON_CONF_DIR | 
 | 913 | } | 
 | 914 |  | 
 | 915 | # _configure_neutron_common() | 
 | 916 | # Set common config for all neutron server and agents. | 
 | 917 | # This MUST be called before other ``_configure_neutron_*`` functions. | 
 | 918 | function _configure_neutron_common { | 
 | 919 |     _create_neutron_conf_dir | 
 | 920 |  | 
 | 921 |     # Uses oslo config generator to generate core sample configuration files | 
 | 922 |     (cd $NEUTRON_DIR && exec ./tools/generate_config_file_samples.sh) | 
 | 923 |  | 
 | 924 |     cp $NEUTRON_DIR/etc/neutron.conf.sample $NEUTRON_CONF | 
 | 925 |  | 
 | 926 |     Q_POLICY_FILE=$NEUTRON_CONF_DIR/policy.json | 
 | 927 |  | 
 | 928 |     # allow neutron user to administer neutron to match neutron account | 
 | 929 |     # NOTE(amotoki): This is required for nova works correctly with neutron. | 
 | 930 |     if [ -f $NEUTRON_DIR/etc/policy.json ]; then | 
 | 931 |         cp $NEUTRON_DIR/etc/policy.json $Q_POLICY_FILE | 
 | 932 |         sed -i 's/"context_is_admin":  "role:admin"/"context_is_admin":  "role:admin or user_name:neutron"/g' $Q_POLICY_FILE | 
 | 933 |     else | 
 | 934 |         echo '{"context_is_admin":  "role:admin or user_name:neutron"}' > $Q_POLICY_FILE | 
 | 935 |     fi | 
 | 936 |  | 
 | 937 |     # Set plugin-specific variables ``Q_DB_NAME``, ``Q_PLUGIN_CLASS``. | 
 | 938 |     # For main plugin config file, set ``Q_PLUGIN_CONF_PATH``, ``Q_PLUGIN_CONF_FILENAME``. | 
 | 939 |     neutron_plugin_configure_common | 
 | 940 |  | 
 | 941 |     if [[ "$Q_PLUGIN_CONF_PATH" == '' || "$Q_PLUGIN_CONF_FILENAME" == '' || "$Q_PLUGIN_CLASS" == '' ]]; then | 
 | 942 |         die $LINENO "Neutron plugin not set.. exiting" | 
 | 943 |     fi | 
 | 944 |  | 
 | 945 |     # If needed, move config file from ``$NEUTRON_DIR/etc/neutron`` to ``NEUTRON_CONF_DIR`` | 
 | 946 |     mkdir -p /$Q_PLUGIN_CONF_PATH | 
 | 947 |     Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME | 
 | 948 |     # NOTE(slaweq): NEUTRON_CORE_PLUGIN_CONF is used e.g. in neutron repository, | 
 | 949 |     # it was previously defined in the lib/neutron module which is now deleted. | 
 | 950 |     NEUTRON_CORE_PLUGIN_CONF=$Q_PLUGIN_CONF_FILE | 
 | 951 |     # NOTE(hichihara): Some neutron vendor plugins were already decomposed and | 
 | 952 |     # there is no config file in Neutron tree. They should prepare the file in each plugin. | 
 | 953 |     if [ -f "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" ]; then | 
 | 954 |         cp "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" /$Q_PLUGIN_CONF_FILE | 
 | 955 |     elif [ -f $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE ]; then | 
 | 956 |         cp $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE | 
 | 957 |     fi | 
 | 958 |  | 
 | 959 |     iniset $NEUTRON_CONF database connection `database_connection_url $Q_DB_NAME` | 
 | 960 |     iniset $NEUTRON_CONF DEFAULT state_path $DATA_DIR/neutron | 
 | 961 |     iniset $NEUTRON_CONF DEFAULT use_syslog $SYSLOG | 
 | 962 |     iniset $NEUTRON_CONF DEFAULT bind_host $Q_LISTEN_ADDRESS | 
 | 963 |     iniset $NEUTRON_CONF oslo_concurrency lock_path $DATA_DIR/neutron/lock | 
 | 964 |  | 
 | 965 |     # NOTE(freerunner): Need to adjust Region Name for nova in multiregion installation | 
 | 966 |     iniset $NEUTRON_CONF nova region_name $REGION_NAME | 
 | 967 |  | 
 | 968 |     if [ "$VIRT_DRIVER" = 'fake' ]; then | 
 | 969 |         # Disable arbitrary limits | 
 | 970 |         iniset $NEUTRON_CONF quotas quota_network -1 | 
 | 971 |         iniset $NEUTRON_CONF quotas quota_subnet -1 | 
 | 972 |         iniset $NEUTRON_CONF quotas quota_port -1 | 
 | 973 |         iniset $NEUTRON_CONF quotas quota_security_group -1 | 
 | 974 |         iniset $NEUTRON_CONF quotas quota_security_group_rule -1 | 
 | 975 |     fi | 
 | 976 |  | 
 | 977 |     # Format logging | 
 | 978 |     setup_logging $NEUTRON_CONF | 
 | 979 |  | 
 | 980 |     if is_service_enabled tls-proxy && [ "$NEUTRON_DEPLOY_MOD_WSGI" == "False" ]; then | 
 | 981 |         # Set the service port for a proxy to take the original | 
 | 982 |         iniset $NEUTRON_CONF DEFAULT bind_port "$Q_PORT_INT" | 
 | 983 |         iniset $NEUTRON_CONF oslo_middleware enable_proxy_headers_parsing True | 
 | 984 |     fi | 
 | 985 |  | 
 | 986 |     _neutron_setup_rootwrap | 
 | 987 | } | 
 | 988 |  | 
 | 989 | function _configure_neutron_dhcp_agent { | 
 | 990 |  | 
 | 991 |     cp $NEUTRON_DIR/etc/dhcp_agent.ini.sample $Q_DHCP_CONF_FILE | 
 | 992 |  | 
 | 993 |     iniset $Q_DHCP_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
 | 994 |     # make it so we have working DNS from guests | 
 | 995 |     iniset $Q_DHCP_CONF_FILE DEFAULT dnsmasq_local_resolv True | 
 | 996 |     configure_root_helper_options $Q_DHCP_CONF_FILE | 
 | 997 |  | 
 | 998 |     if ! is_service_enabled q-l3 neutron-l3; then | 
 | 999 |         if [[ "$ENABLE_ISOLATED_METADATA" = "True" ]]; then | 
 | 1000 |             iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata $ENABLE_ISOLATED_METADATA | 
 | 1001 |             iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network $ENABLE_METADATA_NETWORK | 
 | 1002 |         else | 
 | 1003 |             if [[ "$ENABLE_METADATA_NETWORK" = "True" ]]; then | 
 | 1004 |                 die "$LINENO" "Enable isolated metadata is a must for metadata network" | 
 | 1005 |             fi | 
 | 1006 |         fi | 
 | 1007 |     fi | 
 | 1008 |  | 
 | 1009 |     _neutron_setup_interface_driver $Q_DHCP_CONF_FILE | 
 | 1010 |  | 
 | 1011 |     neutron_plugin_configure_dhcp_agent $Q_DHCP_CONF_FILE | 
 | 1012 | } | 
 | 1013 |  | 
 | 1014 |  | 
 | 1015 | function _configure_neutron_metadata_agent { | 
 | 1016 |     cp $NEUTRON_DIR/etc/metadata_agent.ini.sample $Q_META_CONF_FILE | 
 | 1017 |  | 
 | 1018 |     iniset $Q_META_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
 | 1019 |     iniset $Q_META_CONF_FILE DEFAULT nova_metadata_host $Q_META_DATA_IP | 
 | 1020 |     iniset $Q_META_CONF_FILE DEFAULT metadata_workers $API_WORKERS | 
 | 1021 |     configure_root_helper_options $Q_META_CONF_FILE | 
 | 1022 | } | 
 | 1023 |  | 
 | 1024 | function _configure_neutron_ceilometer_notifications { | 
 | 1025 |     iniset $NEUTRON_CONF oslo_messaging_notifications driver messagingv2 | 
 | 1026 | } | 
 | 1027 |  | 
 | 1028 | function _configure_neutron_metering { | 
 | 1029 |     neutron_agent_metering_configure_common | 
 | 1030 |     neutron_agent_metering_configure_agent | 
 | 1031 | } | 
 | 1032 |  | 
 | 1033 | function _configure_dvr { | 
 | 1034 |     iniset $NEUTRON_CONF DEFAULT router_distributed True | 
 | 1035 |     iniset $Q_L3_CONF_FILE DEFAULT agent_mode $Q_DVR_MODE | 
 | 1036 | } | 
 | 1037 |  | 
 | 1038 |  | 
 | 1039 | # _configure_neutron_plugin_agent() - Set config files for neutron plugin agent | 
 | 1040 | # It is called when q-agt is enabled. | 
 | 1041 | function _configure_neutron_plugin_agent { | 
 | 1042 |     # Specify the default root helper prior to agent configuration to | 
 | 1043 |     # ensure that an agent's configuration can override the default | 
 | 1044 |     configure_root_helper_options /$Q_PLUGIN_CONF_FILE | 
 | 1045 |     iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
 | 1046 |  | 
 | 1047 |     # Configure agent for plugin | 
 | 1048 |     neutron_plugin_configure_plugin_agent | 
 | 1049 | } | 
 | 1050 |  | 
 | 1051 | function _replace_api_paste_composite { | 
 | 1052 |     local sep | 
 | 1053 |     sep=$(echo -ne "\x01") | 
 | 1054 |     # Replace it | 
 | 1055 |     $sudo sed -i -e "s/\/\: neutronversions_composite/\/"${NEUTRON_ENDPOINT_SERVICE_NAME}"\/\: neutronversions_composite/" "$Q_API_PASTE_FILE" | 
 | 1056 |     $sudo sed -i -e "s/\/healthcheck\: healthcheck/\/"${NEUTRON_ENDPOINT_SERVICE_NAME}"\/healthcheck\: healthcheck/" "$Q_API_PASTE_FILE" | 
 | 1057 |     $sudo sed -i -e "s/\/v2.0\: neutronapi_v2_0/\/"${NEUTRON_ENDPOINT_SERVICE_NAME}"\/v2.0\: neutronapi_v2_0/" "$Q_API_PASTE_FILE" | 
 | 1058 | } | 
 | 1059 |  | 
 | 1060 | # _configure_neutron_service() - Set config files for neutron service | 
 | 1061 | # It is called when q-svc is enabled. | 
 | 1062 | function _configure_neutron_service { | 
 | 1063 |     Q_API_PASTE_FILE=$NEUTRON_CONF_DIR/api-paste.ini | 
 | 1064 |     cp $NEUTRON_DIR/etc/api-paste.ini $Q_API_PASTE_FILE | 
 | 1065 |  | 
| Slawek Kaplonski | b500d80 | 2024-06-14 12:58:58 +0200 | [diff] [blame] | 1066 |     if [[ "$NEUTRON_DEPLOY_MOD_WSGI" == "False" && -n "$NEUTRON_ENDPOINT_SERVICE_NAME" ]]; then | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 1067 |         _replace_api_paste_composite | 
 | 1068 |     fi | 
 | 1069 |  | 
 | 1070 |     # Update either configuration file with plugin | 
 | 1071 |     iniset $NEUTRON_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS | 
 | 1072 |  | 
 | 1073 |     iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
 | 1074 |     iniset $NEUTRON_CONF oslo_policy policy_file $Q_POLICY_FILE | 
 | 1075 |  | 
 | 1076 |     iniset $NEUTRON_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY | 
 | 1077 |     configure_keystone_authtoken_middleware $NEUTRON_CONF $Q_ADMIN_USERNAME | 
 | 1078 |  | 
 | 1079 |     # Configuration for neutron notifications to nova. | 
 | 1080 |     iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_status_changes $Q_NOTIFY_NOVA_PORT_STATUS_CHANGES | 
 | 1081 |     iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_data_changes $Q_NOTIFY_NOVA_PORT_DATA_CHANGES | 
 | 1082 |  | 
 | 1083 |     configure_keystone_authtoken_middleware $NEUTRON_CONF nova nova | 
 | 1084 |  | 
 | 1085 |     # Configuration for placement client | 
 | 1086 |     configure_keystone_authtoken_middleware $NEUTRON_CONF placement placement | 
 | 1087 |  | 
 | 1088 |     # Configure plugin | 
 | 1089 |     neutron_plugin_configure_service | 
 | 1090 | } | 
 | 1091 |  | 
 | 1092 | # Utility Functions | 
 | 1093 | #------------------ | 
 | 1094 |  | 
 | 1095 | # neutron_service_plugin_class_add() - add service plugin class | 
 | 1096 | function neutron_service_plugin_class_add { | 
 | 1097 |     local service_plugin_class=$1 | 
 | 1098 |     if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then | 
 | 1099 |         Q_SERVICE_PLUGIN_CLASSES=$service_plugin_class | 
 | 1100 |     elif [[ ! ,${Q_SERVICE_PLUGIN_CLASSES}, =~ ,${service_plugin_class}, ]]; then | 
 | 1101 |         Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$service_plugin_class" | 
 | 1102 |     fi | 
 | 1103 | } | 
 | 1104 |  | 
 | 1105 | # neutron_ml2_extension_driver_add() - add ML2 extension driver | 
 | 1106 | function neutron_ml2_extension_driver_add { | 
 | 1107 |     local extension=$1 | 
 | 1108 |     if [[ $Q_ML2_PLUGIN_EXT_DRIVERS == '' ]]; then | 
 | 1109 |         Q_ML2_PLUGIN_EXT_DRIVERS=$extension | 
 | 1110 |     elif [[ ! ,${Q_ML2_PLUGIN_EXT_DRIVERS}, =~ ,${extension}, ]]; then | 
 | 1111 |         Q_ML2_PLUGIN_EXT_DRIVERS="$Q_ML2_PLUGIN_EXT_DRIVERS,$extension" | 
 | 1112 |     fi | 
 | 1113 | } | 
 | 1114 |  | 
 | 1115 | # neutron_server_config_add() - add server config file | 
 | 1116 | function neutron_server_config_add { | 
 | 1117 |     _Q_PLUGIN_EXTRA_CONF_FILES_ABS+=($1) | 
 | 1118 | } | 
 | 1119 |  | 
 | 1120 | # neutron_deploy_rootwrap_filters() - deploy rootwrap filters to $Q_CONF_ROOTWRAP_D (owned by root). | 
 | 1121 | function neutron_deploy_rootwrap_filters { | 
 | 1122 |     if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
 | 1123 |         return | 
 | 1124 |     fi | 
 | 1125 |     local srcdir=$1 | 
 | 1126 |     sudo install -d -o root -m 755 $Q_CONF_ROOTWRAP_D | 
 | 1127 |     sudo install -o root -m 644 $srcdir/etc/neutron/rootwrap.d/* $Q_CONF_ROOTWRAP_D/ | 
 | 1128 | } | 
 | 1129 |  | 
 | 1130 | # _neutron_setup_rootwrap() - configure Neutron's rootwrap | 
 | 1131 | function _neutron_setup_rootwrap { | 
 | 1132 |     if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
 | 1133 |         return | 
 | 1134 |     fi | 
 | 1135 |     # Wipe any existing ``rootwrap.d`` files first | 
 | 1136 |     Q_CONF_ROOTWRAP_D=$NEUTRON_CONF_DIR/rootwrap.d | 
 | 1137 |     if [[ -d $Q_CONF_ROOTWRAP_D ]]; then | 
 | 1138 |         sudo rm -rf $Q_CONF_ROOTWRAP_D | 
 | 1139 |     fi | 
 | 1140 |  | 
 | 1141 |     neutron_deploy_rootwrap_filters $NEUTRON_DIR | 
 | 1142 |  | 
 | 1143 |     # Set up ``rootwrap.conf``, pointing to ``$NEUTRON_CONF_DIR/rootwrap.d`` | 
 | 1144 |     # location moved in newer versions, prefer new location | 
 | 1145 |     if test -r $NEUTRON_DIR/etc/neutron/rootwrap.conf; then | 
 | 1146 |         sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/neutron/rootwrap.conf $Q_RR_CONF_FILE | 
 | 1147 |     else | 
 | 1148 |         sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/rootwrap.conf $Q_RR_CONF_FILE | 
 | 1149 |     fi | 
 | 1150 |     sudo sed -e "s:^filters_path=.*$:filters_path=$Q_CONF_ROOTWRAP_D:" -i $Q_RR_CONF_FILE | 
| yatinkarel | ffc1b76 | 2023-08-28 10:52:26 +0530 | [diff] [blame] | 1151 |     # Rely on $PATH set by devstack to determine what is safe to execute | 
 | 1152 |     # by rootwrap rather than use explicit whitelist of paths in | 
 | 1153 |     # rootwrap.conf | 
 | 1154 |     sudo sed -e 's/^exec_dirs=.*/#&/' -i $Q_RR_CONF_FILE | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 1155 |  | 
 | 1156 |     # Specify ``rootwrap.conf`` as first parameter to neutron-rootwrap | 
 | 1157 |     ROOTWRAP_SUDOER_CMD="$NEUTRON_ROOTWRAP $Q_RR_CONF_FILE *" | 
 | 1158 |     ROOTWRAP_DAEMON_SUDOER_CMD="$NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE" | 
 | 1159 |  | 
 | 1160 |     # Set up the rootwrap sudoers for neutron | 
 | 1161 |     TEMPFILE=`mktemp` | 
 | 1162 |     echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE | 
 | 1163 |     echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_DAEMON_SUDOER_CMD" >>$TEMPFILE | 
 | 1164 |     chmod 0440 $TEMPFILE | 
 | 1165 |     sudo chown root:root $TEMPFILE | 
 | 1166 |     sudo mv $TEMPFILE /etc/sudoers.d/neutron-rootwrap | 
 | 1167 |  | 
 | 1168 |     # Update the root_helper | 
 | 1169 |     configure_root_helper_options $NEUTRON_CONF | 
 | 1170 | } | 
 | 1171 |  | 
 | 1172 | function configure_root_helper_options { | 
 | 1173 |     local conffile=$1 | 
 | 1174 |     iniset $conffile agent root_helper "$Q_RR_COMMAND" | 
 | 1175 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
 | 1176 |         iniset $conffile agent root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
 | 1177 |     fi | 
 | 1178 | } | 
 | 1179 |  | 
 | 1180 | function _neutron_setup_interface_driver { | 
 | 1181 |  | 
 | 1182 |     # ovs_use_veth needs to be set before the plugin configuration | 
 | 1183 |     # occurs to allow plugins to override the setting. | 
 | 1184 |     iniset $1 DEFAULT ovs_use_veth $Q_OVS_USE_VETH | 
 | 1185 |  | 
 | 1186 |     neutron_plugin_setup_interface_driver $1 | 
 | 1187 | } | 
 | 1188 | # Functions for Neutron Exercises | 
 | 1189 | #-------------------------------- | 
 | 1190 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 1191 | # ssh check | 
 | 1192 | function _ssh_check_neutron { | 
 | 1193 |     local from_net=$1 | 
 | 1194 |     local key_file=$2 | 
 | 1195 |     local ip=$3 | 
 | 1196 |     local user=$4 | 
 | 1197 |     local timeout_sec=$5 | 
 | 1198 |     local probe_cmd = "" | 
 | 1199 |     probe_cmd=`_get_probe_cmd_prefix $from_net` | 
 | 1200 |     local testcmd="$probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success" | 
 | 1201 |     test_with_retry "$testcmd" "server $ip didn't become ssh-able" $timeout_sec | 
 | 1202 | } | 
 | 1203 |  | 
 | 1204 | function plugin_agent_add_l2_agent_extension { | 
 | 1205 |     local l2_agent_extension=$1 | 
 | 1206 |     if [[ -z "$L2_AGENT_EXTENSIONS" ]]; then | 
 | 1207 |         L2_AGENT_EXTENSIONS=$l2_agent_extension | 
 | 1208 |     elif [[ ! ,${L2_AGENT_EXTENSIONS}, =~ ,${l2_agent_extension}, ]]; then | 
 | 1209 |         L2_AGENT_EXTENSIONS+=",$l2_agent_extension" | 
| YAMAMOTO Takashi | c043b6f | 2017-02-23 22:30:08 -0500 | [diff] [blame] | 1210 |     fi | 
 | 1211 | } | 
 | 1212 |  | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 1213 | # Restore xtrace | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 1214 | $_XTRACE_NEUTRON | 
 | 1215 |  | 
 | 1216 | # Tell emacs to use shell-script-mode | 
 | 1217 | ## Local variables: | 
 | 1218 | ## mode: shell-script | 
 | 1219 | ## End: |