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