| 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 |  | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 64 | # Subnet IP version | 
| Sean M. Collins | 645114b | 2015-03-03 10:56:03 -0500 | [diff] [blame] | 65 | IP_VERSION=${IP_VERSION:-"4+6"} | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 66 | # Validate IP_VERSION | 
 | 67 | if [[ $IP_VERSION != "4" ]] && [[ $IP_VERSION != "6" ]] && [[ $IP_VERSION != "4+6" ]]; then | 
 | 68 |     die $LINENO "IP_VERSION must be either 4, 6, or 4+6" | 
 | 69 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 70 | # Gateway and subnet defaults, in case they are not customized in localrc | 
 | 71 | NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1} | 
| Salvatore Orlando | 90234ac | 2013-11-25 05:44:10 -0800 | [diff] [blame] | 72 | PUBLIC_NETWORK_GATEWAY=${PUBLIC_NETWORK_GATEWAY:-172.24.4.1} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 73 | PRIVATE_SUBNET_NAME=${PRIVATE_SUBNET_NAME:-"private-subnet"} | 
 | 74 | PUBLIC_SUBNET_NAME=${PUBLIC_SUBNET_NAME:-"public-subnet"} | 
 | 75 |  | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 76 | if is_ssl_enabled_service "neutron" || is_service_enabled tls-proxy; then | 
 | 77 |     Q_PROTOCOL="https" | 
 | 78 | fi | 
 | 79 |  | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 80 | # Generate 40-bit IPv6 Global ID to comply with RFC 4193 | 
 | 81 | IPV6_GLOBAL_ID=`uuidgen | sed s/-//g | cut -c 23- | sed -e "s/\(..\)\(....\)\(....\)/\1:\2:\3/"` | 
 | 82 |  | 
 | 83 | # IPv6 gateway and subnet defaults, in case they are not customized in localrc | 
 | 84 | IPV6_RA_MODE=${IPV6_RA_MODE:-slaac} | 
 | 85 | IPV6_ADDRESS_MODE=${IPV6_ADDRESS_MODE:-slaac} | 
 | 86 | IPV6_PUBLIC_SUBNET_NAME=${IPV6_PUBLIC_SUBNET_NAME:-ipv6-public-subnet} | 
 | 87 | IPV6_PRIVATE_SUBNET_NAME=${IPV6_PRIVATE_SUBNET_NAME:-ipv6-private-subnet} | 
 | 88 | FIXED_RANGE_V6=${FIXED_RANGE_V6:-fd$IPV6_GLOBAL_ID::/64} | 
 | 89 | IPV6_PRIVATE_NETWORK_GATEWAY=${IPV6_PRIVATE_NETWORK_GATEWAY:-fd$IPV6_GLOBAL_ID::1} | 
| Dane LeBlanc | a79e101 | 2015-03-26 14:48:07 -0400 | [diff] [blame] | 90 | IPV6_PUBLIC_RANGE=${IPV6_PUBLIC_RANGE:-2001:db8::/64} | 
 | 91 | IPV6_PUBLIC_NETWORK_GATEWAY=${IPV6_PUBLIC_NETWORK_GATEWAY:-2001:db8::2} | 
 | 92 | IPV6_ROUTER_GW_IP=${IPV6_ROUTER_GW_IP:-2001:db8::1} | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 93 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 94 | # Set up default directories | 
| Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 95 | GITDIR["python-neutronclient"]=$DEST/python-neutronclient | 
| Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 96 |  | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 97 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 98 | NEUTRON_DIR=$DEST/neutron | 
| Kyle Mestery | 20b839f | 2014-12-08 06:17:27 +0000 | [diff] [blame] | 99 | NEUTRON_FWAAS_DIR=$DEST/neutron-fwaas | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 100 | NEUTRON_LBAAS_DIR=$DEST/neutron-lbaas | 
| Kyle Mestery | 20b839f | 2014-12-08 06:17:27 +0000 | [diff] [blame] | 101 | NEUTRON_VPNAAS_DIR=$DEST/neutron-vpnaas | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 102 | NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/var/cache/neutron} | 
 | 103 |  | 
 | 104 | # Support entry points installation of console scripts | 
 | 105 | if [[ -d $NEUTRON_DIR/bin/neutron-server ]]; then | 
 | 106 |     NEUTRON_BIN_DIR=$NEUTRON_DIR/bin | 
| Sean Dague | 3bdb922 | 2013-10-22 08:36:16 -0400 | [diff] [blame] | 107 | else | 
 | 108 |     NEUTRON_BIN_DIR=$(get_python_exec_prefix) | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 109 | fi | 
 | 110 |  | 
 | 111 | NEUTRON_CONF_DIR=/etc/neutron | 
 | 112 | NEUTRON_CONF=$NEUTRON_CONF_DIR/neutron.conf | 
 | 113 | export NEUTRON_TEST_CONFIG_FILE=${NEUTRON_TEST_CONFIG_FILE:-"$NEUTRON_CONF_DIR/debug.ini"} | 
 | 114 |  | 
| Martin Hickey | 10bff0e | 2015-12-03 15:18:10 +0000 | [diff] [blame] | 115 | # Default provider for load balancer service | 
 | 116 | DEFAULT_LB_PROVIDER=LOADBALANCER:Haproxy:neutron_lbaas.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default | 
 | 117 |  | 
| Martin Hickey | 47115b0 | 2015-12-18 11:08:38 +0000 | [diff] [blame] | 118 | # Default provider for VPN service | 
 | 119 | DEFAULT_VPN_PROVIDER=VPN:openswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default | 
 | 120 |  | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 121 | # Agent binaries.  Note, binary paths for other agents are set in per-service | 
 | 122 | # scripts in lib/neutron_plugins/services/ | 
 | 123 | AGENT_DHCP_BINARY="$NEUTRON_BIN_DIR/neutron-dhcp-agent" | 
 | 124 | AGENT_L3_BINARY=${AGENT_L3_BINARY:-"$NEUTRON_BIN_DIR/neutron-l3-agent"} | 
 | 125 | AGENT_META_BINARY="$NEUTRON_BIN_DIR/neutron-metadata-agent" | 
 | 126 |  | 
 | 127 | # Agent config files. Note, plugin-specific Q_PLUGIN_CONF_FILE is set and | 
 | 128 | # loaded from per-plugin  scripts in lib/neutron_plugins/ | 
 | 129 | Q_DHCP_CONF_FILE=$NEUTRON_CONF_DIR/dhcp_agent.ini | 
 | 130 | Q_L3_CONF_FILE=$NEUTRON_CONF_DIR/l3_agent.ini | 
 | 131 | Q_FWAAS_CONF_FILE=$NEUTRON_CONF_DIR/fwaas_driver.ini | 
 | 132 | Q_VPN_CONF_FILE=$NEUTRON_CONF_DIR/vpn_agent.ini | 
 | 133 | Q_META_CONF_FILE=$NEUTRON_CONF_DIR/metadata_agent.ini | 
 | 134 |  | 
| Henry Gessau | 0fc1cc2 | 2014-07-06 22:54:34 -0400 | [diff] [blame] | 135 | # Default name for Neutron database | 
 | 136 | Q_DB_NAME=${Q_DB_NAME:-neutron} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 137 | # Default Neutron Plugin | 
| Kyle Mestery | 6d23500 | 2013-09-18 20:27:08 +0000 | [diff] [blame] | 138 | Q_PLUGIN=${Q_PLUGIN:-ml2} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 139 | # Default Neutron Port | 
 | 140 | Q_PORT=${Q_PORT:-9696} | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 141 | # Default Neutron Internal Port when using TLS proxy | 
 | 142 | Q_PORT_INT=${Q_PORT_INT:-19696} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 143 | # Default Neutron Host | 
 | 144 | Q_HOST=${Q_HOST:-$SERVICE_HOST} | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 145 | # Default protocol | 
 | 146 | Q_PROTOCOL=${Q_PROTOCOL:-$SERVICE_PROTOCOL} | 
| Brian Haley | 180f5eb | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 147 | # Default listen address | 
 | 148 | Q_LISTEN_ADDRESS=${Q_LISTEN_ADDRESS:-$SERVICE_LISTEN_ADDRESS} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 149 | # Default admin username | 
 | 150 | Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-neutron} | 
 | 151 | # Default auth strategy | 
 | 152 | Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 153 | # RHEL's support for namespaces requires using veths with ovs | 
 | 154 | Q_OVS_USE_VETH=${Q_OVS_USE_VETH:-False} | 
 | 155 | Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True} | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 156 | Q_USE_ROOTWRAP_DAEMON=$(trueorfalse True Q_USE_ROOTWRAP_DAEMON) | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 157 | # Meta data IP | 
 | 158 | Q_META_DATA_IP=${Q_META_DATA_IP:-$SERVICE_HOST} | 
 | 159 | # Allow Overlapping IP among subnets | 
 | 160 | Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True} | 
 | 161 | # Use neutron-debug command | 
 | 162 | Q_USE_DEBUG_COMMAND=${Q_USE_DEBUG_COMMAND:-False} | 
 | 163 | # The name of the default q-l3 router | 
 | 164 | Q_ROUTER_NAME=${Q_ROUTER_NAME:-router1} | 
| Terry Wilson | f06c443 | 2014-05-20 10:54:51 -0500 | [diff] [blame] | 165 | Q_NOTIFY_NOVA_PORT_STATUS_CHANGES=${Q_NOTIFY_NOVA_PORT_STATUS_CHANGES:-True} | 
 | 166 | 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] | 167 | VIF_PLUGGING_IS_FATAL=${VIF_PLUGGING_IS_FATAL:-True} | 
 | 168 | VIF_PLUGGING_TIMEOUT=${VIF_PLUGGING_TIMEOUT:-300} | 
| Edgar Magana | 7bce8fa | 2014-11-04 17:32:54 +0100 | [diff] [blame] | 169 | # Specify if the initial private and external networks should be created | 
 | 170 | NEUTRON_CREATE_INITIAL_NETWORKS=${NEUTRON_CREATE_INITIAL_NETWORKS:-True} | 
| Aaron Rosen | 4540d00 | 2013-10-24 13:59:33 -0700 | [diff] [blame] | 171 |  | 
| Sean M. Collins | 5ec6f8f | 2014-05-14 17:01:03 -0400 | [diff] [blame] | 172 | ## Provider Network Information | 
 | 173 | PROVIDER_SUBNET_NAME=${PROVIDER_SUBNET_NAME:-"provider_net"} | 
| John Kasperski | 50ce626 | 2015-11-23 15:47:45 -0600 | [diff] [blame] | 174 | IPV6_PROVIDER_SUBNET_NAME=${IPV6_PROVIDER_SUBNET_NAME:-"provider_net_v6"} | 
 | 175 | IPV6_PROVIDER_FIXED_RANGE=${IPV6_PROVIDER_FIXED_RANGE:-} | 
 | 176 | IPV6_PROVIDER_NETWORK_GATEWAY=${IPV6_PROVIDER_NETWORK_GATEWAY:-} | 
| Sean M. Collins | 5ec6f8f | 2014-05-14 17:01:03 -0400 | [diff] [blame] | 177 |  | 
| Sean M. Collins | 64d5ecf | 2015-06-01 14:13:41 -0400 | [diff] [blame] | 178 | # Define the public bridge that will transmit traffic from VMs to the | 
 | 179 | # physical network - used by both the OVS and Linux Bridge drivers. | 
 | 180 | PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex} | 
 | 181 |  | 
| YAMAMOTO Takashi | 6a633fd | 2014-07-23 12:02:18 +0900 | [diff] [blame] | 182 | # Use flat providernet for public network | 
 | 183 | # | 
 | 184 | # If Q_USE_PROVIDERNET_FOR_PUBLIC=True, use a flat provider network | 
 | 185 | # for external interface of neutron l3-agent.  In that case, | 
 | 186 | # PUBLIC_PHYSICAL_NETWORK specifies provider:physical_network value | 
| YAMAMOTO Takashi | 0f18c23 | 2014-09-12 23:44:58 +0900 | [diff] [blame] | 187 | # used for the network.  In case of ofagent, you should add the | 
 | 188 | # corresponding entry to your OFAGENT_PHYSICAL_INTERFACE_MAPPINGS. | 
 | 189 | # For openvswitch agent, you should add the corresponding entry to | 
 | 190 | # your OVS_BRIDGE_MAPPINGS. | 
| YAMAMOTO Takashi | 6a633fd | 2014-07-23 12:02:18 +0900 | [diff] [blame] | 191 | # | 
| YAMAMOTO Takashi | 0f18c23 | 2014-09-12 23:44:58 +0900 | [diff] [blame] | 192 | # eg.  (ofagent) | 
 | 193 | #    Q_USE_PROVIDERNET_FOR_PUBLIC=True | 
 | 194 | #    Q_USE_PUBLIC_VETH=True | 
 | 195 | #    PUBLIC_PHYSICAL_NETWORK=public | 
 | 196 | #    OFAGENT_PHYSICAL_INTERFACE_MAPPINGS=public:veth-pub-int | 
 | 197 | # | 
 | 198 | # eg.  (openvswitch agent) | 
| YAMAMOTO Takashi | 6a633fd | 2014-07-23 12:02:18 +0900 | [diff] [blame] | 199 | #    Q_USE_PROVIDERNET_FOR_PUBLIC=True | 
 | 200 | #    PUBLIC_PHYSICAL_NETWORK=public | 
 | 201 | #    OVS_BRIDGE_MAPPINGS=public:br-ex | 
 | 202 | Q_USE_PROVIDERNET_FOR_PUBLIC=${Q_USE_PROVIDERNET_FOR_PUBLIC:-False} | 
 | 203 | PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK:-public} | 
 | 204 |  | 
| YAMAMOTO Takashi | 0f18c23 | 2014-09-12 23:44:58 +0900 | [diff] [blame] | 205 | # If Q_USE_PUBLIC_VETH=True, create and use a veth pair instead of | 
 | 206 | # PUBLIC_BRIDGE.  This is intended to be used with | 
 | 207 | # Q_USE_PROVIDERNET_FOR_PUBLIC=True. | 
 | 208 | Q_USE_PUBLIC_VETH=${Q_USE_PUBLIC_VETH:-False} | 
 | 209 | Q_PUBLIC_VETH_EX=${Q_PUBLIC_VETH_EX:-veth-pub-ex} | 
 | 210 | Q_PUBLIC_VETH_INT=${Q_PUBLIC_VETH_INT:-veth-pub-int} | 
 | 211 |  | 
| Tomoe Sugihara | afbc631 | 2013-11-14 20:02:47 +0000 | [diff] [blame] | 212 | # The next two variables are configured by plugin | 
 | 213 | # e.g.  _configure_neutron_l3_agent or lib/neutron_plugins/* | 
 | 214 | # | 
 | 215 | # The plugin supports L3. | 
 | 216 | Q_L3_ENABLED=${Q_L3_ENABLED:-False} | 
 | 217 | # L3 routers exist per tenant | 
| Cedric Brandily | b814b53 | 2015-10-22 22:25:45 +0200 | [diff] [blame] | 218 | Q_L3_ROUTER_PER_TENANT=${Q_L3_ROUTER_PER_TENANT:-True} | 
| Aaron Rosen | 4540d00 | 2013-10-24 13:59:33 -0700 | [diff] [blame] | 219 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 220 | # List of config file names in addition to the main plugin config file | 
 | 221 | # See _configure_neutron_common() for details about setting it up | 
 | 222 | declare -a Q_PLUGIN_EXTRA_CONF_FILES | 
 | 223 |  | 
| Paul Michali | 746dcee | 2014-04-02 19:12:22 +0000 | [diff] [blame] | 224 | # List of (optional) config files for VPN device drivers to use with | 
 | 225 | # the neutron-q-vpn agent | 
 | 226 | declare -a Q_VPN_EXTRA_CONF_FILES | 
 | 227 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 228 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 229 | Q_RR_CONF_FILE=$NEUTRON_CONF_DIR/rootwrap.conf | 
 | 230 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
 | 231 |     Q_RR_COMMAND="sudo" | 
 | 232 | else | 
 | 233 |     NEUTRON_ROOTWRAP=$(get_rootwrap_location neutron) | 
 | 234 |     Q_RR_COMMAND="sudo $NEUTRON_ROOTWRAP $Q_RR_CONF_FILE" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 235 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
 | 236 |         Q_RR_DAEMON_COMMAND="sudo $NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE" | 
 | 237 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 238 | fi | 
 | 239 |  | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 240 |  | 
 | 241 | # Distributed Virtual Router (DVR) configuration | 
 | 242 | # Can be: | 
| Dean Troyer | 3324f19 | 2014-09-18 09:26:39 -0500 | [diff] [blame] | 243 | # - ``legacy``   - No DVR functionality | 
 | 244 | # - ``dvr_snat`` - Controller or single node DVR | 
 | 245 | # - ``dvr``      - Compute node in multi-node DVR | 
 | 246 | # | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 247 | Q_DVR_MODE=${Q_DVR_MODE:-legacy} | 
 | 248 | if [[ "$Q_DVR_MODE" != "legacy" ]]; then | 
 | 249 |     Q_ML2_PLUGIN_MECHANISM_DRIVERS=openvswitch,linuxbridge,l2population | 
 | 250 | fi | 
 | 251 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 252 | # Provider Network Configurations | 
 | 253 | # -------------------------------- | 
 | 254 |  | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 255 | # The following variables control the Neutron ML2 plugins' allocation | 
 | 256 | # of tenant networks and availability of provider networks. If these | 
 | 257 | # are not configured in ``localrc``, tenant networks will be local to | 
 | 258 | # the host (with no remote connectivity), and no physical resources | 
 | 259 | # will be available for the allocation of provider networks. | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 260 |  | 
| Attila Fazekas | 8feaf6c | 2014-07-27 20:47:04 +0200 | [diff] [blame] | 261 | # To disable tunnels (GRE or VXLAN) for tenant networks, | 
 | 262 | # set to False in ``local.conf``. | 
 | 263 | # GRE tunnels are only supported by the openvswitch. | 
 | 264 | ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-True} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 265 |  | 
 | 266 | # If using GRE tunnels for tenant networks, specify the range of | 
 | 267 | # tunnel IDs from which tenant networks are allocated. Can be | 
| Atsushi SAKAI | fe7b56c | 2015-11-13 17:06:16 +0900 | [diff] [blame] | 268 | # overridden in ``localrc`` in necessary. | 
| Anant Patil | 3827dc0 | 2014-07-03 21:38:16 +0530 | [diff] [blame] | 269 | TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGES:-1:1000} | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 270 |  | 
 | 271 | # To use VLANs for tenant networks, set to True in localrc. VLANs | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 272 | # are supported by the ML2 plugins, requiring additional configuration | 
 | 273 | # described below. | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 274 | ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False} | 
 | 275 |  | 
 | 276 | # If using VLANs for tenant networks, set in ``localrc`` to specify | 
 | 277 | # the range of VLAN VIDs from which tenant networks are | 
 | 278 | # allocated. An external network switch must be configured to | 
 | 279 | # trunk these VLANs between hosts for multi-host connectivity. | 
 | 280 | # | 
 | 281 | # Example: ``TENANT_VLAN_RANGE=1000:1999`` | 
 | 282 | TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-} | 
 | 283 |  | 
 | 284 | # If using VLANs for tenant networks, or if using flat or VLAN | 
 | 285 | # provider networks, set in ``localrc`` to the name of the physical | 
 | 286 | # network, and also configure ``OVS_PHYSICAL_BRIDGE`` for the | 
 | 287 | # openvswitch agent or ``LB_PHYSICAL_INTERFACE`` for the linuxbridge | 
 | 288 | # agent, as described below. | 
 | 289 | # | 
 | 290 | # Example: ``PHYSICAL_NETWORK=default`` | 
 | 291 | PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-} | 
 | 292 |  | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 293 | # With the openvswitch agent, if using VLANs for tenant networks, | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 294 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
 | 295 | # the name of the OVS bridge to use for the physical network. The | 
 | 296 | # bridge will be created if it does not already exist, but a | 
 | 297 | # physical interface must be manually added to the bridge as a | 
 | 298 | # port for external connectivity. | 
 | 299 | # | 
 | 300 | # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1`` | 
 | 301 | OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-} | 
 | 302 |  | 
| YAMAMOTO Takashi | 15130cd | 2014-10-28 11:49:58 +0900 | [diff] [blame] | 303 | # With the linuxbridge agent, if using VLANs for tenant networks, | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 304 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
 | 305 | # the name of the network interface to use for the physical | 
 | 306 | # network. | 
 | 307 | # | 
 | 308 | # Example: ``LB_PHYSICAL_INTERFACE=eth1`` | 
 | 309 | LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-} | 
 | 310 |  | 
| Edgar Magana | 6f335b9 | 2014-07-10 15:42:44 -0700 | [diff] [blame] | 311 | # When Neutron tunnels are enabled it is needed to specify the | 
 | 312 | # IP address of the end point in the local server. This IP is set | 
 | 313 | # by default to the same IP address that the HOST IP. | 
 | 314 | # This variable can be used to specify a different end point IP address | 
 | 315 | # Example: ``TUNNEL_ENDPOINT_IP=1.1.1.1`` | 
 | 316 | TUNNEL_ENDPOINT_IP=${TUNNEL_ENDPOINT_IP:-$HOST_IP} | 
 | 317 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 318 | # With the openvswitch plugin, set to True in ``localrc`` to enable | 
 | 319 | # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False. | 
 | 320 | # | 
 | 321 | # Example: ``OVS_ENABLE_TUNNELING=True`` | 
 | 322 | OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS} | 
 | 323 |  | 
| Tan Lin | 27a196e | 2014-10-31 15:44:34 +0800 | [diff] [blame] | 324 | # Use DHCP agent for providing metadata service in the case of | 
 | 325 | # without L3 agent (No Route Agent), set to True in localrc. | 
 | 326 | ENABLE_ISOLATED_METADATA=${ENABLE_ISOLATED_METADATA:-False} | 
 | 327 |  | 
 | 328 | # Add a static route as dhcp option, so the request to 169.254.169.254 | 
 | 329 | # will be able to reach through a route(DHCP agent) | 
 | 330 | # This option require ENABLE_ISOLATED_METADATA = True | 
 | 331 | ENABLE_METADATA_NETWORK=${ENABLE_METADATA_NETWORK:-False} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 332 | # Neutron plugin specific functions | 
 | 333 | # --------------------------------- | 
 | 334 |  | 
 | 335 | # Please refer to ``lib/neutron_plugins/README.md`` for details. | 
| Hirofumi Ichihara | 36daecd | 2015-07-23 17:50:40 +0900 | [diff] [blame] | 336 | if [ -f $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN ]; then | 
 | 337 |     source $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN | 
 | 338 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 339 |  | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 340 | # Agent loadbalancer service plugin functions | 
 | 341 | # ------------------------------------------- | 
 | 342 |  | 
 | 343 | # Hardcoding for 1 service plugin for now | 
 | 344 | source $TOP_DIR/lib/neutron_plugins/services/loadbalancer | 
 | 345 |  | 
| Emilien Macchi | 40546f7 | 2013-09-24 15:10:25 +0200 | [diff] [blame] | 346 | # Agent metering service plugin functions | 
 | 347 | # ------------------------------------------- | 
 | 348 |  | 
 | 349 | # Hardcoding for 1 service plugin for now | 
 | 350 | source $TOP_DIR/lib/neutron_plugins/services/metering | 
 | 351 |  | 
| Nachi Ueno | 69b3ff6 | 2013-06-07 10:28:33 -0700 | [diff] [blame] | 352 | # VPN service plugin functions | 
 | 353 | # ------------------------------------------- | 
 | 354 | # Hardcoding for 1 service plugin for now | 
 | 355 | source $TOP_DIR/lib/neutron_plugins/services/vpn | 
 | 356 |  | 
| Ravi Chunduru | 95c93e2 | 2013-07-16 04:18:47 -0700 | [diff] [blame] | 357 | # Firewall Service Plugin functions | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 358 | # --------------------------------- | 
| Ravi Chunduru | 95c93e2 | 2013-07-16 04:18:47 -0700 | [diff] [blame] | 359 | source $TOP_DIR/lib/neutron_plugins/services/firewall | 
 | 360 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 361 | # Use security group or not | 
 | 362 | if has_neutron_plugin_security_group; then | 
 | 363 |     Q_USE_SECGROUP=${Q_USE_SECGROUP:-True} | 
 | 364 | else | 
 | 365 |     Q_USE_SECGROUP=False | 
 | 366 | fi | 
 | 367 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 368 | # Save trace setting | 
| Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 369 | _XTRACE_NEUTRON=$(set +o | grep xtrace) | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 370 | set +o xtrace | 
 | 371 |  | 
 | 372 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 373 | # Functions | 
 | 374 | # --------- | 
 | 375 |  | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 376 | function _determine_config_server { | 
 | 377 |     local cfg_file | 
 | 378 |     local opts="--config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE" | 
 | 379 |     for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do | 
 | 380 |         opts+=" --config-file /$cfg_file" | 
 | 381 |     done | 
 | 382 |     echo "$opts" | 
 | 383 | } | 
 | 384 |  | 
 | 385 | function _determine_config_vpn { | 
 | 386 |     local cfg_file | 
 | 387 |     local opts="--config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE --config-file=$Q_VPN_CONF_FILE" | 
 | 388 |     if is_service_enabled q-fwaas; then | 
 | 389 |         opts+=" --config-file $Q_FWAAS_CONF_FILE" | 
 | 390 |     fi | 
 | 391 |     for cfg_file in ${Q_VPN_EXTRA_CONF_FILES[@]}; do | 
 | 392 |         opts+=" --config-file $cfg_file" | 
 | 393 |     done | 
 | 394 |     echo "$opts" | 
 | 395 |  | 
 | 396 | } | 
 | 397 |  | 
 | 398 | function _determine_config_l3 { | 
 | 399 |     local opts="--config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE" | 
 | 400 |     if is_service_enabled q-fwaas; then | 
 | 401 |         opts+=" --config-file $Q_FWAAS_CONF_FILE" | 
 | 402 |     fi | 
 | 403 |     echo "$opts" | 
 | 404 | } | 
 | 405 |  | 
 | 406 | # For services and agents that require it, dynamically construct a list of | 
 | 407 | # --config-file arguments that are passed to the binary. | 
 | 408 | function determine_config_files { | 
 | 409 |     local opts="" | 
 | 410 |     case "$1" in | 
 | 411 |         "neutron-server") opts="$(_determine_config_server)" ;; | 
 | 412 |         "neutron-vpn-agent") opts="$(_determine_config_vpn)" ;; | 
 | 413 |         "neutron-l3-agent") opts="$(_determine_config_l3)" ;; | 
 | 414 |     esac | 
 | 415 |     if [ -z "$opts" ] ; then | 
 | 416 |         die $LINENO "Could not determine config files for $1." | 
 | 417 |     fi | 
 | 418 |     echo "$opts" | 
 | 419 | } | 
 | 420 |  | 
| Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 421 | # Test if any Neutron services are enabled | 
 | 422 | # is_neutron_enabled | 
 | 423 | function is_neutron_enabled { | 
 | 424 |     [[ ,${ENABLED_SERVICES} =~ ,"q-" ]] && return 0 | 
 | 425 |     return 1 | 
 | 426 | } | 
 | 427 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 428 | # configure_neutron() | 
 | 429 | # Set common config for all neutron server and agents. | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 430 | function configure_neutron { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 431 |     _configure_neutron_common | 
| Brant Knudson | 2dd110c | 2015-03-14 12:39:14 -0500 | [diff] [blame] | 432 |     iniset_rpc_backend neutron $NEUTRON_CONF | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 433 |  | 
 | 434 |     # goes before q-svc to init Q_SERVICE_PLUGIN_CLASSES | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 435 |     if is_service_enabled q-lbaas; then | 
 | 436 |         _configure_neutron_lbaas | 
 | 437 |     fi | 
| Emilien Macchi | 40546f7 | 2013-09-24 15:10:25 +0200 | [diff] [blame] | 438 |     if is_service_enabled q-metering; then | 
 | 439 |         _configure_neutron_metering | 
 | 440 |     fi | 
| Nachi Ueno | 69b3ff6 | 2013-06-07 10:28:33 -0700 | [diff] [blame] | 441 |     if is_service_enabled q-vpn; then | 
 | 442 |         _configure_neutron_vpn | 
 | 443 |     fi | 
| Ravi Chunduru | 95c93e2 | 2013-07-16 04:18:47 -0700 | [diff] [blame] | 444 |     if is_service_enabled q-fwaas; then | 
 | 445 |         _configure_neutron_fwaas | 
 | 446 |     fi | 
| Stephen Ma | 9b38eb2 | 2014-04-02 02:13:09 +0000 | [diff] [blame] | 447 |     if is_service_enabled q-agt q-svc; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 448 |         _configure_neutron_service | 
 | 449 |     fi | 
 | 450 |     if is_service_enabled q-agt; then | 
 | 451 |         _configure_neutron_plugin_agent | 
 | 452 |     fi | 
 | 453 |     if is_service_enabled q-dhcp; then | 
 | 454 |         _configure_neutron_dhcp_agent | 
 | 455 |     fi | 
 | 456 |     if is_service_enabled q-l3; then | 
 | 457 |         _configure_neutron_l3_agent | 
 | 458 |     fi | 
 | 459 |     if is_service_enabled q-meta; then | 
 | 460 |         _configure_neutron_metadata_agent | 
 | 461 |     fi | 
 | 462 |  | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 463 |     if [[ "$Q_DVR_MODE" != "legacy" ]]; then | 
 | 464 |         _configure_dvr | 
 | 465 |     fi | 
| Dina Belova | 58adaa6 | 2014-07-11 18:18:12 +0400 | [diff] [blame] | 466 |     if is_service_enabled ceilometer; then | 
 | 467 |         _configure_neutron_ceilometer_notifications | 
 | 468 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 469 |  | 
 | 470 |     _configure_neutron_debug_command | 
| armando-migliaccio | e155b89 | 2015-06-12 08:55:02 -0700 | [diff] [blame] | 471 |  | 
 | 472 |     iniset $NEUTRON_CONF DEFAULT api_workers "$API_WORKERS" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 473 | } | 
 | 474 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 475 | function create_nova_conf_neutron { | 
| Yong Sheng Gong | 032e454 | 2013-08-25 10:21:10 +0800 | [diff] [blame] | 476 |     iniset $NOVA_CONF DEFAULT network_api_class "nova.network.neutronv2.api.API" | 
| Davanum Srinivas | d6456e6 | 2015-08-19 10:33:23 -0400 | [diff] [blame] | 477 |  | 
| Jamie Lennox | 394968f | 2015-08-28 09:18:26 +1000 | [diff] [blame] | 478 |     iniset $NOVA_CONF neutron auth_plugin "v3password" | 
 | 479 |     iniset $NOVA_CONF neutron auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v3" | 
 | 480 |     iniset $NOVA_CONF neutron username "$Q_ADMIN_USERNAME" | 
 | 481 |     iniset $NOVA_CONF neutron password "$SERVICE_PASSWORD" | 
 | 482 |     iniset $NOVA_CONF neutron user_domain_name "Default" | 
 | 483 |     iniset $NOVA_CONF neutron project_name "$SERVICE_TENANT_NAME" | 
 | 484 |     iniset $NOVA_CONF neutron project_domain_name "Default" | 
| Gary Kotton | 13d385e | 2014-06-17 23:24:53 -0700 | [diff] [blame] | 485 |     iniset $NOVA_CONF neutron auth_strategy "$Q_AUTH_STRATEGY" | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 486 |     iniset $NOVA_CONF neutron region_name "$REGION_NAME" | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 487 |     iniset $NOVA_CONF neutron url "${Q_PROTOCOL}://$Q_HOST:$Q_PORT" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 488 |  | 
 | 489 |     if [[ "$Q_USE_SECGROUP" == "True" ]]; then | 
 | 490 |         LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver | 
| Jeff Peeler | 1143f7e | 2013-10-31 16:21:52 -0400 | [diff] [blame] | 491 |         iniset $NOVA_CONF DEFAULT firewall_driver $LIBVIRT_FIREWALL_DRIVER | 
| Yong Sheng Gong | 032e454 | 2013-08-25 10:21:10 +0800 | [diff] [blame] | 492 |         iniset $NOVA_CONF DEFAULT security_group_api neutron | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 493 |     fi | 
 | 494 |  | 
| Matt Riedemann | 925c256 | 2015-08-25 13:40:25 -0700 | [diff] [blame] | 495 |     # optionally set options in nova_conf | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 496 |     neutron_plugin_create_nova_conf | 
 | 497 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 498 |     if is_service_enabled q-meta; then | 
| Gary Kotton | dd74550 | 2014-08-11 23:38:47 -0700 | [diff] [blame] | 499 |         iniset $NOVA_CONF neutron service_metadata_proxy "True" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 500 |     fi | 
| Aaron Rosen | cea32b1 | 2014-03-04 16:20:14 -0800 | [diff] [blame] | 501 |  | 
 | 502 |     iniset $NOVA_CONF DEFAULT vif_plugging_is_fatal "$VIF_PLUGGING_IS_FATAL" | 
 | 503 |     iniset $NOVA_CONF DEFAULT vif_plugging_timeout "$VIF_PLUGGING_TIMEOUT" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 504 | } | 
 | 505 |  | 
| Emilien Macchi | a677b7f | 2013-11-25 23:40:20 +0100 | [diff] [blame] | 506 | # create_neutron_cache_dir() - Part of the _neutron_setup_keystone() process | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 507 | function create_neutron_cache_dir { | 
| Emilien Macchi | a677b7f | 2013-11-25 23:40:20 +0100 | [diff] [blame] | 508 |     # Create cache dir | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 509 |     sudo install -d -o $STACK_USER $NEUTRON_AUTH_CACHE_DIR | 
| Emilien Macchi | a677b7f | 2013-11-25 23:40:20 +0100 | [diff] [blame] | 510 |     rm -f $NEUTRON_AUTH_CACHE_DIR/* | 
 | 511 | } | 
 | 512 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 513 | # create_neutron_accounts() - Set up common required neutron accounts | 
 | 514 |  | 
 | 515 | # Tenant               User       Roles | 
 | 516 | # ------------------------------------------------------------------ | 
 | 517 | # service              neutron    admin        # if enabled | 
 | 518 |  | 
 | 519 | # Migrated from keystone_data.sh | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 520 | function create_neutron_accounts { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 521 |     if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 522 |  | 
| Jamie Lennox | 85ff532 | 2015-01-28 14:28:01 +1000 | [diff] [blame] | 523 |         create_service_user "neutron" | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 524 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 525 |         if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 526 |  | 
| Jamie Lennox | b17ad75 | 2015-05-29 06:04:47 +0000 | [diff] [blame] | 527 |             get_or_create_service "neutron" "network" "Neutron Service" | 
 | 528 |             get_or_create_endpoint "network" \ | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 529 |                 "$REGION_NAME" \ | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 530 |                 "$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/" \ | 
 | 531 |                 "$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/" \ | 
 | 532 |                 "$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 533 |         fi | 
 | 534 |     fi | 
 | 535 | } | 
 | 536 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 537 | function create_neutron_initial_network { | 
| Steve Martinelli | 1968542 | 2014-01-24 13:02:26 -0600 | [diff] [blame] | 538 |     TENANT_ID=$(openstack project list | grep " demo " | get_field 1) | 
| DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 539 |     die_if_not_set $LINENO TENANT_ID "Failure retrieving TENANT_ID for demo" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 540 |  | 
| Rob | d06a6d9 | 2014-12-04 20:32:22 +0000 | [diff] [blame] | 541 |     # Allow drivers that need to create an initial network to do so here | 
 | 542 |     if type -p neutron_plugin_create_initial_network_profile > /dev/null; then | 
 | 543 |         neutron_plugin_create_initial_network_profile $PHYSICAL_NETWORK | 
 | 544 |     fi | 
 | 545 |  | 
| Sean Dague | 2f8e08b | 2014-12-05 08:31:16 -0500 | [diff] [blame] | 546 |     if is_provider_network; then | 
| Satoru Moriya | af9b251 | 2014-09-01 20:43:08 +0900 | [diff] [blame] | 547 |         die_if_not_set $LINENO PHYSICAL_NETWORK "You must specify the PHYSICAL_NETWORK" | 
| Atsushi SAKAI | fe7b56c | 2015-11-13 17:06:16 +0900 | [diff] [blame] | 548 |         die_if_not_set $LINENO PROVIDER_NETWORK_TYPE "You must specify the PROVIDER_NETWORK_TYPE" | 
| Satoru Moriya | af9b251 | 2014-09-01 20:43:08 +0900 | [diff] [blame] | 549 |         NET_ID=$(neutron net-create $PHYSICAL_NETWORK --tenant_id $TENANT_ID --provider:network_type $PROVIDER_NETWORK_TYPE --provider:physical_network "$PHYSICAL_NETWORK" ${SEGMENTATION_ID:+--provider:segmentation_id $SEGMENTATION_ID} --shared | grep ' id ' | get_field 2) | 
| Naohiro Tamura | 907d41c | 2015-02-19 20:57:20 +0900 | [diff] [blame] | 550 |         die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PHYSICAL_NETWORK $TENANT_ID" | 
| Zhongyue Luo | 2548e6f | 2014-12-18 15:57:31 +0800 | [diff] [blame] | 551 |  | 
 | 552 |         if [[ "$IP_VERSION" =~ 4.* ]]; then | 
| John Davidge | 8a3b7d4 | 2015-07-07 11:10:54 +0100 | [diff] [blame] | 553 |             SUBNET_ID=$(neutron subnet-create --tenant_id $TENANT_ID --ip_version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} --name $PROVIDER_SUBNET_NAME --gateway $NETWORK_GATEWAY --subnetpool None $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2) | 
| Naohiro Tamura | 907d41c | 2015-02-19 20:57:20 +0900 | [diff] [blame] | 554 |             die_if_not_set $LINENO SUBNET_ID "Failure creating SUBNET_ID for $PROVIDER_SUBNET_NAME $TENANT_ID" | 
| Zhongyue Luo | 2548e6f | 2014-12-18 15:57:31 +0800 | [diff] [blame] | 555 |         fi | 
 | 556 |  | 
| John Kasperski | 50ce626 | 2015-11-23 15:47:45 -0600 | [diff] [blame] | 557 |         if [[ "$IP_VERSION" =~ .*6 ]] && [[ -n "$IPV6_PROVIDER_FIXED_RANGE" ]] && [[ -n "$IPV6_PROVIDER_NETWORK_GATEWAY" ]]; then | 
 | 558 |             SUBNET_V6_ID=$(neutron subnet-create --tenant_id $TENANT_ID --ip_version 6 --ipv6-address-mode $IPV6_ADDRESS_MODE --gateway $IPV6_PROVIDER_NETWORK_GATEWAY --name $IPV6_PROVIDER_SUBNET_NAME --subnetpool None $NET_ID $IPV6_PROVIDER_FIXED_RANGE | grep 'id' | get_field 2) | 
 | 559 |             die_if_not_set $LINENO SUBNET_V6_ID "Failure creating SUBNET_V6_ID for $IPV6_PROVIDER_SUBNET_NAME $TENANT_ID" | 
| Zhongyue Luo | 2548e6f | 2014-12-18 15:57:31 +0800 | [diff] [blame] | 560 |         fi | 
 | 561 |  | 
| Kahou Lei | d663e29 | 2015-10-24 12:18:57 -0700 | [diff] [blame] | 562 |         if [[ $Q_AGENT == "openvswitch" ]]; then | 
 | 563 |             sudo ip link set $OVS_PHYSICAL_BRIDGE up | 
 | 564 |             sudo ip link set br-int up | 
 | 565 |             sudo ip link set $PUBLIC_INTERFACE up | 
 | 566 |         fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 567 |     else | 
| Dirk Mueller | 25049cd | 2014-01-09 13:53:52 +0100 | [diff] [blame] | 568 |         NET_ID=$(neutron net-create --tenant-id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2) | 
| Naohiro Tamura | 4abc4d1 | 2015-02-17 22:20:19 +0900 | [diff] [blame] | 569 |         die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PRIVATE_NETWORK_NAME $TENANT_ID" | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 570 |  | 
 | 571 |         if [[ "$IP_VERSION" =~ 4.* ]]; then | 
 | 572 |             # Create IPv4 private subnet | 
 | 573 |             SUBNET_ID=$(_neutron_create_private_subnet_v4) | 
 | 574 |         fi | 
 | 575 |  | 
 | 576 |         if [[ "$IP_VERSION" =~ .*6 ]]; then | 
 | 577 |             # Create IPv6 private subnet | 
 | 578 |             IPV6_SUBNET_ID=$(_neutron_create_private_subnet_v6) | 
 | 579 |         fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 580 |     fi | 
 | 581 |  | 
 | 582 |     if [[ "$Q_L3_ENABLED" == "True" ]]; then | 
 | 583 |         # Create a router, and add the private subnet as one of its interfaces | 
 | 584 |         if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then | 
 | 585 |             # create a tenant-owned router. | 
| Dirk Mueller | 25049cd | 2014-01-09 13:53:52 +0100 | [diff] [blame] | 586 |             ROUTER_ID=$(neutron router-create --tenant-id $TENANT_ID $Q_ROUTER_NAME | grep ' id ' | get_field 2) | 
| DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 587 |             die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $TENANT_ID $Q_ROUTER_NAME" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 588 |         else | 
 | 589 |             # Plugin only supports creating a single router, which should be admin owned. | 
 | 590 |             ROUTER_ID=$(neutron router-create $Q_ROUTER_NAME | grep ' id ' | get_field 2) | 
| DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 591 |             die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $Q_ROUTER_NAME" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 592 |         fi | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 593 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 594 |         # Create an external network, and a subnet. Configure the external network as router gw | 
| YAMAMOTO Takashi | 6a633fd | 2014-07-23 12:02:18 +0900 | [diff] [blame] | 595 |         if [ "$Q_USE_PROVIDERNET_FOR_PUBLIC" = "True" ]; then | 
 | 596 |             EXT_NET_ID=$(neutron net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True --provider:network_type=flat --provider:physical_network=${PUBLIC_PHYSICAL_NETWORK} | grep ' id ' | get_field 2) | 
 | 597 |         else | 
 | 598 |             EXT_NET_ID=$(neutron net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2) | 
 | 599 |         fi | 
| DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 600 |         die_if_not_set $LINENO EXT_NET_ID "Failure creating EXT_NET_ID for $PUBLIC_NETWORK_NAME" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 601 |  | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 602 |         if [[ "$IP_VERSION" =~ 4.* ]]; then | 
 | 603 |             # Configure router for IPv4 public access | 
 | 604 |             _neutron_configure_router_v4 | 
 | 605 |         fi | 
| YAMAMOTO Takashi | 0f18c23 | 2014-09-12 23:44:58 +0900 | [diff] [blame] | 606 |  | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 607 |         if [[ "$IP_VERSION" =~ .*6 ]]; then | 
 | 608 |             # Configure router for IPv6 public access | 
 | 609 |             _neutron_configure_router_v6 | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 610 |         fi | 
| Sean Dague | 3bdb922 | 2013-10-22 08:36:16 -0400 | [diff] [blame] | 611 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 612 | } | 
 | 613 |  | 
 | 614 | # init_neutron() - Initialize databases, etc. | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 615 | function init_neutron { | 
| Ihar Hrachyshka | 157c84b | 2014-10-06 13:29:39 +0200 | [diff] [blame] | 616 |     recreate_database $Q_DB_NAME | 
| Salvatore Orlando | dd64988 | 2013-08-05 08:56:17 -0700 | [diff] [blame] | 617 |     # Run Neutron db migrations | 
 | 618 |     $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] | 619 | } | 
 | 620 |  | 
 | 621 | # install_neutron() - Collect source and prepare | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 622 | function install_neutron { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 623 |     git_clone $NEUTRON_REPO $NEUTRON_DIR $NEUTRON_BRANCH | 
 | 624 |     setup_develop $NEUTRON_DIR | 
| Kyle Mestery | 20b839f | 2014-12-08 06:17:27 +0000 | [diff] [blame] | 625 |     if is_service_enabled q-fwaas; then | 
 | 626 |         git_clone $NEUTRON_FWAAS_REPO $NEUTRON_FWAAS_DIR $NEUTRON_FWAAS_BRANCH | 
 | 627 |         setup_develop $NEUTRON_FWAAS_DIR | 
 | 628 |     fi | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 629 |     if is_service_enabled q-lbaas; then | 
 | 630 |         git_clone $NEUTRON_LBAAS_REPO $NEUTRON_LBAAS_DIR $NEUTRON_LBAAS_BRANCH | 
 | 631 |         setup_develop $NEUTRON_LBAAS_DIR | 
 | 632 |     fi | 
| Kyle Mestery | 20b839f | 2014-12-08 06:17:27 +0000 | [diff] [blame] | 633 |     if is_service_enabled q-vpn; then | 
 | 634 |         git_clone $NEUTRON_VPNAAS_REPO $NEUTRON_VPNAAS_DIR $NEUTRON_VPNAAS_BRANCH | 
 | 635 |         setup_develop $NEUTRON_VPNAAS_DIR | 
 | 636 |     fi | 
| Mate Lakat | 6df6489 | 2014-10-17 13:09:49 +0200 | [diff] [blame] | 637 |  | 
 | 638 |     if [ "$VIRT_DRIVER" == 'xenserver' ]; then | 
 | 639 |         local dom0_ip | 
 | 640 |         dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3-) | 
 | 641 |  | 
 | 642 |         local ssh_dom0 | 
 | 643 |         ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip" | 
 | 644 |  | 
 | 645 |         # Find where the plugins should go in dom0 | 
 | 646 |         local xen_functions | 
 | 647 |         xen_functions=$(cat $TOP_DIR/tools/xen/functions) | 
 | 648 |         local plugin_dir | 
 | 649 |         plugin_dir=$($ssh_dom0 "$xen_functions; set -eux; xapi_plugin_location") | 
 | 650 |  | 
 | 651 |         # install neutron plugins to dom0 | 
| Huan Xie | 201e3c1 | 2015-08-27 12:34:24 +0100 | [diff] [blame] | 652 |         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] | 653 |             $ssh_dom0 "tar -xzf - -C $plugin_dir && chmod a+x $plugin_dir/*" | 
 | 654 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 655 | } | 
 | 656 |  | 
 | 657 | # install_neutronclient() - Collect source and prepare | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 658 | function install_neutronclient { | 
| Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 659 |     if use_library_from_git "python-neutronclient"; then | 
 | 660 |         git_clone_by_name "python-neutronclient" | 
 | 661 |         setup_dev_lib "python-neutronclient" | 
 | 662 |         sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-neutronclient"]}/tools/,/etc/bash_completion.d/}neutron.bash_completion | 
| Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 663 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 664 | } | 
 | 665 |  | 
 | 666 | # install_neutron_agent_packages() - Collect source and prepare | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 667 | function install_neutron_agent_packages { | 
| Robert Li | 72b3e44 | 2014-07-17 15:04:52 -0400 | [diff] [blame] | 668 |     # radvd doesn't come with the OS. Install it if the l3 service is enabled. | 
 | 669 |     if is_service_enabled q-l3; then | 
 | 670 |         install_package radvd | 
 | 671 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 672 |     # install packages that are specific to plugin agent(s) | 
 | 673 |     if is_service_enabled q-agt q-dhcp q-l3; then | 
 | 674 |         neutron_plugin_install_agent_packages | 
 | 675 |     fi | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 676 |  | 
 | 677 |     if is_service_enabled q-lbaas; then | 
 | 678 |         neutron_agent_lbaas_install_agent_packages | 
 | 679 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 680 | } | 
 | 681 |  | 
 | 682 | # Start running processes, including screen | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 683 | function start_neutron_service_and_check { | 
| Adam Gandelman | 7614d21 | 2014-08-11 14:27:50 -0700 | [diff] [blame] | 684 |     local cfg_file_options="$(determine_config_files neutron-server)" | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 685 |     local service_port=$Q_PORT | 
 | 686 |     local service_protocol=$Q_PROTOCOL | 
 | 687 |     if is_service_enabled tls-proxy; then | 
 | 688 |         service_port=$Q_PORT_INT | 
 | 689 |         service_protocol="http" | 
 | 690 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 691 |     # Start the Neutron service | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 692 |     run_process q-svc "$NEUTRON_BIN_DIR/neutron-server $cfg_file_options" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 693 |     echo "Waiting for Neutron to start..." | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 694 |     if is_ssl_enabled_service "neutron"; then | 
 | 695 |         ssl_ca="--ca-certificate=${SSL_BUNDLE_FILE}" | 
 | 696 |     fi | 
| Sean Dague | 442e4e9 | 2015-06-24 13:24:02 -0400 | [diff] [blame] | 697 |  | 
 | 698 |     local testcmd="wget ${ssl_ca} --no-proxy -q -O- $service_protocol://$Q_HOST:$service_port" | 
 | 699 |     test_with_retry "$testcmd" "Neutron did not start" $SERVICE_TIMEOUT | 
 | 700 |  | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 701 |     # Start proxy if enabled | 
 | 702 |     if is_service_enabled tls-proxy; then | 
 | 703 |         start_tls_proxy '*' $Q_PORT $Q_HOST $Q_PORT_INT & | 
 | 704 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 705 | } | 
 | 706 |  | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 707 | # Control of the l2 agent is separated out to make it easier to test partial | 
 | 708 | # upgrades (everything upgraded except the L2 agent) | 
 | 709 | function start_neutron_l2_agent { | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 710 |     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] | 711 |  | 
| Kahou Lei | d663e29 | 2015-10-24 12:18:57 -0700 | [diff] [blame] | 712 |     if is_provider_network && [[ $Q_AGENT == "openvswitch" ]]; then | 
| Zhongyue Luo | 56b7efb | 2014-12-16 11:36:49 +0800 | [diff] [blame] | 713 |         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] | 714 |         sudo ip link set $OVS_PHYSICAL_BRIDGE up | 
 | 715 |         sudo ip link set br-int up | 
 | 716 |         sudo ip link set $PUBLIC_INTERFACE up | 
| yunhong jiang | ae9ee6b | 2014-10-08 07:01:02 -0700 | [diff] [blame] | 717 |         if is_ironic_hardware; then | 
 | 718 |             for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do | 
 | 719 |                 sudo ip addr del $IP dev $PUBLIC_INTERFACE | 
 | 720 |                 sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE | 
 | 721 |             done | 
| gong yong sheng | 348c6ac | 2015-06-23 14:03:47 +0800 | [diff] [blame] | 722 |             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] | 723 |         fi | 
| Sean M. Collins | 5ec6f8f | 2014-05-14 17:01:03 -0400 | [diff] [blame] | 724 |     fi | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 725 | } | 
 | 726 |  | 
 | 727 | function start_neutron_other_agents { | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 728 |     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] | 729 |  | 
| Paul Michali | e4289c8 | 2015-08-14 11:49:27 -0400 | [diff] [blame] | 730 |     if is_service_enabled neutron-vpnaas; then | 
 | 731 |         :  # Started by plugin | 
 | 732 |     elif is_service_enabled q-vpn; then | 
| Chris Dent | 2f27a0e | 2014-09-09 13:46:02 +0100 | [diff] [blame] | 733 |         run_process q-vpn "$AGENT_VPN_BINARY $(determine_config_files neutron-vpn-agent)" | 
| Ravi Chunduru | 95c93e2 | 2013-07-16 04:18:47 -0700 | [diff] [blame] | 734 |     else | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 735 |         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] | 736 |     fi | 
 | 737 |  | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 738 |     run_process q-meta "$AGENT_META_BINARY --config-file $NEUTRON_CONF --config-file=$Q_META_CONF_FILE" | 
 | 739 |     run_process q-lbaas "$AGENT_LBAAS_BINARY --config-file $NEUTRON_CONF --config-file=$LBAAS_AGENT_CONF_FILENAME" | 
 | 740 |     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] | 741 |  | 
 | 742 |     if [ "$VIRT_DRIVER" = 'xenserver' ]; then | 
 | 743 |         # For XenServer, start an agent for the domU openvswitch | 
| Davanum Srinivas | 59756e9 | 2015-09-23 17:42:54 -0400 | [diff] [blame] | 744 |         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] | 745 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 746 | } | 
 | 747 |  | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 748 | # Start running processes, including screen | 
 | 749 | function start_neutron_agents { | 
 | 750 |     # Start up the neutron agents if enabled | 
 | 751 |     start_neutron_l2_agent | 
 | 752 |     start_neutron_other_agents | 
 | 753 | } | 
 | 754 |  | 
 | 755 | function stop_neutron_l2_agent { | 
 | 756 |     stop_process q-agt | 
 | 757 | } | 
 | 758 |  | 
 | 759 | function stop_neutron_other { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 760 |     if is_service_enabled q-dhcp; then | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 761 |         stop_process q-dhcp | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 762 |         pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }') | 
 | 763 |         [ ! -z "$pid" ] && sudo kill -9 $pid | 
 | 764 |     fi | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 765 |  | 
 | 766 |     stop_process q-svc | 
 | 767 |     stop_process q-l3 | 
 | 768 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 769 |     if is_service_enabled q-meta; then | 
| Jakub Libosvar | 1f76328 | 2014-01-28 23:01:38 +0100 | [diff] [blame] | 770 |         sudo pkill -9 -f neutron-ns-metadata-proxy || : | 
| Chris Dent | 36891dc | 2015-02-03 16:22:44 +0000 | [diff] [blame] | 771 |         stop_process q-meta | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 772 |     fi | 
| Akihiro Motoki | edddb1f | 2013-12-09 20:21:06 +0900 | [diff] [blame] | 773 |  | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 774 |     if is_service_enabled q-lbaas; then | 
 | 775 |         neutron_lbaas_stop | 
 | 776 |     fi | 
| Akihiro Motoki | edddb1f | 2013-12-09 20:21:06 +0900 | [diff] [blame] | 777 |     if is_service_enabled q-fwaas; then | 
 | 778 |         neutron_fwaas_stop | 
 | 779 |     fi | 
 | 780 |     if is_service_enabled q-vpn; then | 
 | 781 |         neutron_vpn_stop | 
 | 782 |     fi | 
 | 783 |     if is_service_enabled q-metering; then | 
 | 784 |         neutron_metering_stop | 
 | 785 |     fi | 
| Li Ma | 50120fa | 2015-12-13 10:41:34 +0800 | [diff] [blame] | 786 |  | 
 | 787 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
 | 788 |         sudo pkill -9 -f $NEUTRON_ROOTWRAP-daemon || : | 
 | 789 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 790 | } | 
 | 791 |  | 
| Russell Bryant | 09b9460 | 2015-06-08 15:25:43 -0400 | [diff] [blame] | 792 | # stop_neutron() - Stop running processes (non-screen) | 
 | 793 | function stop_neutron { | 
 | 794 |     stop_neutron_other | 
 | 795 |     stop_neutron_l2_agent | 
 | 796 | } | 
 | 797 |  | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 798 | # _move_neutron_addresses_route() - Move the primary IP to the OVS bridge | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 799 | # on startup, or back to the public interface on cleanup. If no IP is | 
 | 800 | # 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] | 801 | function _move_neutron_addresses_route { | 
 | 802 |     local from_intf=$1 | 
 | 803 |     local to_intf=$2 | 
 | 804 |     local add_ovs_port=$3 | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 805 |     local del_ovs_port=$4 | 
 | 806 |     local af=$5 | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 807 |  | 
 | 808 |     if [[ -n "$from_intf" && -n "$to_intf" ]]; then | 
 | 809 |         # Remove the primary IP address from $from_intf and add it to $to_intf, | 
 | 810 |         # along with the default route, if it exists.  Also, when called | 
 | 811 |         # on configure we will also add $from_intf as a port on $to_intf, | 
 | 812 |         # assuming it is an OVS bridge. | 
 | 813 |  | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 814 |         local IP_ADD="" | 
 | 815 |         local IP_DEL="" | 
| Shinobu KINJO | f95315b | 2015-11-07 10:21:08 +0900 | [diff] [blame] | 816 |         local IP_UP="" | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 817 |         local DEFAULT_ROUTE_GW | 
| Sean M. Collins | 59e86a3 | 2015-11-09 11:06:39 -0500 | [diff] [blame] | 818 |         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] | 819 |         local ADD_OVS_PORT="" | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 820 |         local DEL_OVS_PORT="" | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 821 |  | 
| Brian Haley | bb9caea | 2015-11-16 17:18:42 -0500 | [diff] [blame] | 822 |         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] | 823 |  | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 824 |         if [ "$DEFAULT_ROUTE_GW" != "" ]; then | 
| Sean M. Collins | 59e86a3 | 2015-11-09 11:06:39 -0500 | [diff] [blame] | 825 |             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] | 826 |         fi | 
 | 827 |  | 
 | 828 |         if [[ "$add_ovs_port" == "True" ]]; then | 
| Raman Budny | db02bbf | 2015-03-31 13:09:09 +0300 | [diff] [blame] | 829 |             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] | 830 |         fi | 
 | 831 |  | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 832 |         if [[ "$del_ovs_port" == "True" ]]; then | 
 | 833 |             DEL_OVS_PORT="sudo ovs-vsctl --if-exists del-port $from_intf $to_intf" | 
 | 834 |         fi | 
 | 835 |  | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 836 |         if [[ "$IP_BRD" != "" ]]; then | 
| Brian Haley | 9451021 | 2015-09-02 15:40:04 -0400 | [diff] [blame] | 837 |             IP_DEL="sudo ip addr del $IP_BRD dev $from_intf" | 
 | 838 |             IP_ADD="sudo ip addr add $IP_BRD dev $to_intf" | 
| Shinobu KINJO | f95315b | 2015-11-07 10:21:08 +0900 | [diff] [blame] | 839 |             IP_UP="sudo ip link set $to_intf up" | 
| Adam Kacmarsky | 6b172c8 | 2015-08-13 15:14:05 -0600 | [diff] [blame] | 840 |         fi | 
 | 841 |  | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 842 |         # The add/del OVS port calls have to happen either before or | 
 | 843 |         # after the address is moved in order to not leave it orphaned. | 
 | 844 |         $DEL_OVS_PORT; $IP_DEL; $IP_ADD; $IP_UP; $ADD_OVS_PORT; $ADD_DEFAULT_ROUTE | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 845 |     fi | 
 | 846 | } | 
 | 847 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 848 | # cleanup_neutron() - Remove residual data files, anything left over from previous | 
 | 849 | # runs that a clean run would need to clean up | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 850 | function cleanup_neutron { | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 851 |  | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 852 |     if [[ -n "$OVS_PHYSICAL_BRIDGE" ]]; then | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 853 |         _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False True "inet" | 
| Adam Kacmarsky | 11298a0 | 2015-06-26 14:49:47 -0600 | [diff] [blame] | 854 |  | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 855 |         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] | 856 |             # ip(8) wants the prefix length when deleting | 
 | 857 |             local v6_gateway | 
 | 858 |             v6_gateway=$(ip -6 a s dev $OVS_PHYSICAL_BRIDGE | grep $IPV6_PUBLIC_NETWORK_GATEWAY | awk '{ print $2 }') | 
 | 859 |             sudo ip -6 addr del $v6_gateway dev $OVS_PHYSICAL_BRIDGE | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 860 |             _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False False "inet6" | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 861 |         fi | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 862 |  | 
| Yalei Wang | 316b348 | 2015-07-15 21:00:31 +0800 | [diff] [blame] | 863 |         if is_provider_network && is_ironic_hardware; then | 
 | 864 |             for IP in $(ip addr show dev $OVS_PHYSICAL_BRIDGE | grep ' inet ' | awk '{print $2}'); do | 
 | 865 |                 sudo ip addr del $IP dev $OVS_PHYSICAL_BRIDGE | 
 | 866 |                 sudo ip addr add $IP dev $PUBLIC_INTERFACE | 
 | 867 |             done | 
 | 868 |             sudo route del -net $FIXED_RANGE gw $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE | 
 | 869 |         fi | 
| yunhong jiang | ae9ee6b | 2014-10-08 07:01:02 -0700 | [diff] [blame] | 870 |     fi | 
 | 871 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 872 |     if is_neutron_ovs_base_plugin; then | 
 | 873 |         neutron_ovs_base_cleanup | 
 | 874 |     fi | 
 | 875 |  | 
| Sean M. Collins | 7bc2af7 | 2015-06-08 12:36:30 -0400 | [diff] [blame] | 876 |     if [[ $Q_AGENT == "linuxbridge" ]]; then | 
 | 877 |         neutron_lb_cleanup | 
 | 878 |     fi | 
 | 879 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 880 |     # delete all namespaces created by neutron | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 881 |     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] | 882 |         sudo ip netns delete ${ns} | 
 | 883 |     done | 
 | 884 | } | 
 | 885 |  | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 886 |  | 
| Maru Newby | 952fd90 | 2015-01-30 22:27:12 +0000 | [diff] [blame] | 887 | function _create_neutron_conf_dir { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 888 |     # Put config files in ``NEUTRON_CONF_DIR`` for everyone to find | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 889 |     sudo install -d -o $STACK_USER $NEUTRON_CONF_DIR | 
| Maru Newby | 952fd90 | 2015-01-30 22:27:12 +0000 | [diff] [blame] | 890 | } | 
 | 891 |  | 
 | 892 | # _configure_neutron_common() | 
 | 893 | # Set common config for all neutron server and agents. | 
 | 894 | # This MUST be called before other ``_configure_neutron_*`` functions. | 
 | 895 | function _configure_neutron_common { | 
 | 896 |     _create_neutron_conf_dir | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 897 |  | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 898 |     # Uses oslo config generator to generate core sample configuration files | 
 | 899 |     (cd $NEUTRON_DIR && exec ./tools/generate_config_file_samples.sh) | 
 | 900 |  | 
 | 901 |     cp $NEUTRON_DIR/etc/neutron.conf.sample $NEUTRON_CONF | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 902 |  | 
| Jerry Zhao | 296c1e3 | 2015-08-07 20:43:54 -0400 | [diff] [blame] | 903 |     Q_POLICY_FILE=$NEUTRON_CONF_DIR/policy.json | 
 | 904 |     cp $NEUTRON_DIR/etc/policy.json $Q_POLICY_FILE | 
 | 905 |  | 
 | 906 |     # allow neutron user to administer neutron to match neutron account | 
 | 907 |     sed -i 's/"context_is_admin":  "role:admin"/"context_is_admin":  "role:admin or user_name:neutron"/g' $Q_POLICY_FILE | 
 | 908 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 909 |     # Set plugin-specific variables ``Q_DB_NAME``, ``Q_PLUGIN_CLASS``. | 
 | 910 |     # For main plugin config file, set ``Q_PLUGIN_CONF_PATH``, ``Q_PLUGIN_CONF_FILENAME``. | 
 | 911 |     # For addition plugin config files, set ``Q_PLUGIN_EXTRA_CONF_PATH``, | 
 | 912 |     # ``Q_PLUGIN_EXTRA_CONF_FILES``.  For example: | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 913 |     # | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 914 |     #    ``Q_PLUGIN_EXTRA_CONF_FILES=(file1, file2)`` | 
 | 915 |     neutron_plugin_configure_common | 
 | 916 |  | 
| sbauza | e2c4ee2 | 2013-08-29 17:29:46 +0200 | [diff] [blame] | 917 |     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] | 918 |         die $LINENO "Neutron plugin not set.. exiting" | 
 | 919 |     fi | 
 | 920 |  | 
 | 921 |     # If needed, move config file from ``$NEUTRON_DIR/etc/neutron`` to ``NEUTRON_CONF_DIR`` | 
 | 922 |     mkdir -p /$Q_PLUGIN_CONF_PATH | 
 | 923 |     Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME | 
| Hirofumi Ichihara | 97cc85b | 2015-09-08 13:51:01 +0900 | [diff] [blame] | 924 |     # NOTE(hichihara): Some neutron vendor plugins were already decomposed and | 
 | 925 |     # 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] | 926 |     if [ -f "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" ]; then | 
 | 927 |         cp "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" /$Q_PLUGIN_CONF_FILE | 
 | 928 |     elif [ -f $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE ]; then | 
| Hirofumi Ichihara | 97cc85b | 2015-09-08 13:51:01 +0900 | [diff] [blame] | 929 |         cp $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE | 
 | 930 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 931 |  | 
| Ihar Hrachyshka | b816e5d | 2014-07-21 13:53:50 +0200 | [diff] [blame] | 932 |     iniset $NEUTRON_CONF database connection `database_connection_url $Q_DB_NAME` | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 933 |     iniset $NEUTRON_CONF DEFAULT state_path $DATA_DIR/neutron | 
| salvatore | e4e535b | 2014-10-29 18:22:46 +0100 | [diff] [blame] | 934 |     iniset $NEUTRON_CONF DEFAULT use_syslog $SYSLOG | 
| Brian Haley | 180f5eb | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 935 |     iniset $NEUTRON_CONF DEFAULT bind_host $Q_LISTEN_ADDRESS | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 936 |     iniset $NEUTRON_CONF oslo_concurrency lock_path $DATA_DIR/neutron/lock | 
 | 937 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 938 |     # If addition config files are set, make sure their path name is set as well | 
 | 939 |     if [[ ${#Q_PLUGIN_EXTRA_CONF_FILES[@]} > 0 && $Q_PLUGIN_EXTRA_CONF_PATH == '' ]]; then | 
 | 940 |         die $LINENO "Neutron additional plugin config not set.. exiting" | 
 | 941 |     fi | 
 | 942 |  | 
 | 943 |     # If additional config files exist, copy them over to neutron configuration | 
 | 944 |     # directory | 
 | 945 |     if [[ $Q_PLUGIN_EXTRA_CONF_PATH != '' ]]; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 946 |         local f | 
 | 947 |         for (( f=0; $f < ${#Q_PLUGIN_EXTRA_CONF_FILES[@]}; f+=1 )); do | 
 | 948 |             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] | 949 |         done | 
 | 950 |     fi | 
 | 951 |  | 
| Joe Gordon | bee5c50 | 2013-08-30 13:48:08 -0400 | [diff] [blame] | 952 |     if [ "$VIRT_DRIVER" = 'fake' ]; then | 
 | 953 |         # Disable arbitrary limits | 
 | 954 |         iniset $NEUTRON_CONF quotas quota_network -1 | 
 | 955 |         iniset $NEUTRON_CONF quotas quota_subnet -1 | 
 | 956 |         iniset $NEUTRON_CONF quotas quota_port -1 | 
 | 957 |         iniset $NEUTRON_CONF quotas quota_security_group -1 | 
 | 958 |         iniset $NEUTRON_CONF quotas quota_security_group_rule -1 | 
 | 959 |     fi | 
 | 960 |  | 
| Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 961 |     # Format logging | 
 | 962 |     if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then | 
| Salvatore Orlando | bc7f643 | 2013-11-25 10:11:14 -0800 | [diff] [blame] | 963 |         setup_colorized_logging $NEUTRON_CONF DEFAULT project_id | 
| venkata anil | 9b1df57 | 2015-01-15 07:38:22 +0000 | [diff] [blame] | 964 |     else | 
 | 965 |         # Show user_name and project_name by default like in nova | 
 | 966 |         iniset $NEUTRON_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s" | 
| Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 967 |     fi | 
 | 968 |  | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 969 |     if is_service_enabled tls-proxy; then | 
 | 970 |         # Set the service port for a proxy to take the original | 
 | 971 |         iniset $NEUTRON_CONF DEFAULT bind_port "$Q_PORT_INT" | 
 | 972 |     fi | 
 | 973 |  | 
 | 974 |     if is_ssl_enabled_service "nova"; then | 
| Jamie Lennox | dc757dd | 2015-03-09 14:48:09 +1100 | [diff] [blame] | 975 |         iniset $NEUTRON_CONF nova cafile $SSL_BUNDLE_FILE | 
| Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 976 |     fi | 
 | 977 |  | 
 | 978 |     if is_ssl_enabled_service "neutron"; then | 
 | 979 |         ensure_certificates NEUTRON | 
 | 980 |  | 
 | 981 |         iniset $NEUTRON_CONF DEFAULT use_ssl True | 
 | 982 |         iniset $NEUTRON_CONF DEFAULT ssl_cert_file "$NEUTRON_SSL_CERT" | 
 | 983 |         iniset $NEUTRON_CONF DEFAULT ssl_key_file "$NEUTRON_SSL_KEY" | 
 | 984 |     fi | 
 | 985 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 986 |     _neutron_setup_rootwrap | 
 | 987 | } | 
 | 988 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 989 | function _configure_neutron_debug_command { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 990 |     if [[ "$Q_USE_DEBUG_COMMAND" != "True" ]]; then | 
 | 991 |         return | 
 | 992 |     fi | 
 | 993 |  | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 994 |     cp $NEUTRON_DIR/etc/l3_agent.ini.sample $NEUTRON_TEST_CONFIG_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 995 |  | 
 | 996 |     iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT verbose False | 
 | 997 |     iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT debug False | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 998 |     iniset $NEUTRON_TEST_CONFIG_FILE 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 | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 1000 |         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] | 1001 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1002 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1003 |     _neutron_setup_interface_driver $NEUTRON_TEST_CONFIG_FILE | 
 | 1004 |  | 
 | 1005 |     neutron_plugin_configure_debug_command | 
 | 1006 | } | 
 | 1007 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1008 | function _configure_neutron_dhcp_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1009 |  | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 1010 |     cp $NEUTRON_DIR/etc/dhcp_agent.ini.sample $Q_DHCP_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1011 |  | 
 | 1012 |     iniset $Q_DHCP_CONF_FILE DEFAULT verbose True | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 1013 |     iniset $Q_DHCP_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 1014 |     iniset $Q_DHCP_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1015 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 1016 |         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] | 1017 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1018 |  | 
| Tan Lin | 27a196e | 2014-10-31 15:44:34 +0800 | [diff] [blame] | 1019 |     if ! is_service_enabled q-l3; then | 
 | 1020 |         if [[ "$ENABLE_ISOLATED_METADATA" = "True" ]]; then | 
 | 1021 |             iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata $ENABLE_ISOLATED_METADATA | 
 | 1022 |             iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network $ENABLE_METADATA_NETWORK | 
 | 1023 |         else | 
 | 1024 |             if [[ "$ENABLE_METADATA_NETWORK" = "True" ]]; then | 
 | 1025 |                 die "$LINENO" "Enable isolated metadata is a must for metadata network" | 
 | 1026 |             fi | 
 | 1027 |         fi | 
 | 1028 |     fi | 
 | 1029 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1030 |     _neutron_setup_interface_driver $Q_DHCP_CONF_FILE | 
 | 1031 |  | 
 | 1032 |     neutron_plugin_configure_dhcp_agent | 
 | 1033 | } | 
 | 1034 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1035 | function _configure_neutron_l3_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1036 |     Q_L3_ENABLED=True | 
| Nachi Ueno | 69b3ff6 | 2013-06-07 10:28:33 -0700 | [diff] [blame] | 1037 |  | 
| Paul Michali | 746dcee | 2014-04-02 19:12:22 +0000 | [diff] [blame] | 1038 |     if is_service_enabled q-vpn; then | 
| Paul Michali | 6fd4720 | 2015-02-23 17:07:48 -0500 | [diff] [blame] | 1039 |         neutron_vpn_configure_agent | 
| Paul Michali | 746dcee | 2014-04-02 19:12:22 +0000 | [diff] [blame] | 1040 |     fi | 
 | 1041 |  | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 1042 |     cp $NEUTRON_DIR/etc/l3_agent.ini.sample $Q_L3_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1043 |  | 
 | 1044 |     iniset $Q_L3_CONF_FILE DEFAULT verbose True | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 1045 |     iniset $Q_L3_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 1046 |     iniset $Q_L3_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1047 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 1048 |         iniset $Q_L3_CONF_FILE AGENT root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1049 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1050 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1051 |     _neutron_setup_interface_driver $Q_L3_CONF_FILE | 
 | 1052 |  | 
 | 1053 |     neutron_plugin_configure_l3_agent | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 1054 |  | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 1055 |     _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True False "inet" | 
| Adam Kacmarsky | 11298a0 | 2015-06-26 14:49:47 -0600 | [diff] [blame] | 1056 |  | 
 | 1057 |     if [[ $(ip -f inet6 a s dev "$PUBLIC_INTERFACE" | grep -c 'global') != 0 ]]; then | 
| Brian Haley | a0d1b01 | 2015-11-16 17:30:48 -0500 | [diff] [blame] | 1058 |         _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" False False "inet6" | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 1059 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1060 | } | 
 | 1061 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1062 | function _configure_neutron_metadata_agent { | 
| Martin Hickey | 30d5fae | 2015-11-10 13:44:15 +0000 | [diff] [blame] | 1063 |     cp $NEUTRON_DIR/etc/metadata_agent.ini.sample $Q_META_CONF_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1064 |  | 
 | 1065 |     iniset $Q_META_CONF_FILE DEFAULT verbose True | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 1066 |     iniset $Q_META_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1067 |     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] | 1068 |     iniset $Q_META_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1069 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
| Hirofumi Ichihara | 2bb3a64 | 2015-08-18 12:59:08 -0700 | [diff] [blame] | 1070 |         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] | 1071 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1072 | } | 
 | 1073 |  | 
| Dina Belova | 58adaa6 | 2014-07-11 18:18:12 +0400 | [diff] [blame] | 1074 | function _configure_neutron_ceilometer_notifications { | 
| JordanP | d4d4a34 | 2014-09-15 09:26:53 +0000 | [diff] [blame] | 1075 |     iniset $NEUTRON_CONF DEFAULT notification_driver messaging | 
| Dina Belova | 58adaa6 | 2014-07-11 18:18:12 +0400 | [diff] [blame] | 1076 | } | 
 | 1077 |  | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 1078 | function _configure_neutron_lbaas { | 
| Martin Hickey | 10bff0e | 2015-12-03 15:18:10 +0000 | [diff] [blame] | 1079 |     # Uses oslo config generator to generate LBaaS sample configuration files | 
 | 1080 |     (cd $NEUTRON_LBAAS_DIR && exec ./tools/generate_config_file_samples.sh) | 
 | 1081 |  | 
 | 1082 |     if [ -f $NEUTRON_LBAAS_DIR/etc/neutron_lbaas.conf.sample ]; then | 
 | 1083 |         cp $NEUTRON_LBAAS_DIR/etc/neutron_lbaas.conf.sample $NEUTRON_CONF_DIR/neutron_lbaas.conf | 
 | 1084 |         iniset $NEUTRON_CONF_DIR/neutron_lbaas.conf service_providers service_provider $DEFAULT_LB_PROVIDER | 
| Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 1085 |     fi | 
 | 1086 |     neutron_agent_lbaas_configure_common | 
 | 1087 |     neutron_agent_lbaas_configure_agent | 
 | 1088 | } | 
 | 1089 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1090 | function _configure_neutron_metering { | 
| Emilien Macchi | 40546f7 | 2013-09-24 15:10:25 +0200 | [diff] [blame] | 1091 |     neutron_agent_metering_configure_common | 
 | 1092 |     neutron_agent_metering_configure_agent | 
 | 1093 | } | 
 | 1094 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1095 | function _configure_neutron_fwaas { | 
| Doug Wiegley | 37da459 | 2015-01-30 23:30:08 -0700 | [diff] [blame] | 1096 |     if [ -f $NEUTRON_FWAAS_DIR/etc/neutron_fwaas.conf ]; then | 
 | 1097 |         cp $NEUTRON_FWAAS_DIR/etc/neutron_fwaas.conf $NEUTRON_CONF_DIR | 
 | 1098 |     fi | 
| Ravi Chunduru | 95c93e2 | 2013-07-16 04:18:47 -0700 | [diff] [blame] | 1099 |     neutron_fwaas_configure_common | 
 | 1100 |     neutron_fwaas_configure_driver | 
 | 1101 | } | 
 | 1102 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1103 | function _configure_neutron_vpn { | 
| Martin Hickey | 2b4d6d1 | 2015-12-04 14:40:03 +0000 | [diff] [blame] | 1104 |     # Uses oslo config generator to generate VPNaaS sample configuration files | 
 | 1105 |     (cd $NEUTRON_VPNAAS_DIR && exec ./tools/generate_config_file_samples.sh) | 
 | 1106 |     if [ -f $NEUTRON_VPNAAS_DIR/etc/neutron_vpnaas.conf.sample ]; then | 
 | 1107 |         cp $NEUTRON_VPNAAS_DIR/etc/neutron_vpnaas.conf.sample $NEUTRON_CONF_DIR/neutron_vpnaas.conf | 
| Martin Hickey | 47115b0 | 2015-12-18 11:08:38 +0000 | [diff] [blame] | 1108 |         iniset $NEUTRON_CONF_DIR/neutron_vpnaas.conf service_providers service_provider $DEFAULT_VPN_PROVIDER | 
| Doug Wiegley | 37da459 | 2015-01-30 23:30:08 -0700 | [diff] [blame] | 1109 |     fi | 
| Nachi Ueno | 69b3ff6 | 2013-06-07 10:28:33 -0700 | [diff] [blame] | 1110 |     neutron_vpn_install_agent_packages | 
 | 1111 |     neutron_vpn_configure_common | 
| Nachi Ueno | 69b3ff6 | 2013-06-07 10:28:33 -0700 | [diff] [blame] | 1112 | } | 
 | 1113 |  | 
| Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 1114 | function _configure_dvr { | 
 | 1115 |     iniset $NEUTRON_CONF DEFAULT router_distributed True | 
 | 1116 |     iniset $Q_L3_CONF_FILE DEFAULT agent_mode $Q_DVR_MODE | 
 | 1117 | } | 
 | 1118 |  | 
 | 1119 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1120 | # _configure_neutron_plugin_agent() - Set config files for neutron plugin agent | 
 | 1121 | # It is called when q-agt is enabled. | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1122 | function _configure_neutron_plugin_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1123 |     # Specify the default root helper prior to agent configuration to | 
 | 1124 |     # ensure that an agent's configuration can override the default | 
 | 1125 |     iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1126 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
 | 1127 |         iniset /$Q_PLUGIN_CONF_FILE  agent root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
 | 1128 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1129 |     iniset $NEUTRON_CONF DEFAULT verbose True | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 1130 |     iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1131 |  | 
 | 1132 |     # Configure agent for plugin | 
 | 1133 |     neutron_plugin_configure_plugin_agent | 
 | 1134 | } | 
 | 1135 |  | 
 | 1136 | # _configure_neutron_service() - Set config files for neutron service | 
 | 1137 | # It is called when q-svc is enabled. | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1138 | function _configure_neutron_service { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1139 |     Q_API_PASTE_FILE=$NEUTRON_CONF_DIR/api-paste.ini | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1140 |     cp $NEUTRON_DIR/etc/api-paste.ini $Q_API_PASTE_FILE | 
| Kevin Benton | 08a5fcc | 2014-07-18 16:06:12 -0700 | [diff] [blame] | 1141 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1142 |     # Update either configuration file with plugin | 
 | 1143 |     iniset $NEUTRON_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS | 
 | 1144 |  | 
 | 1145 |     if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then | 
 | 1146 |         iniset $NEUTRON_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES | 
 | 1147 |     fi | 
 | 1148 |  | 
 | 1149 |     iniset $NEUTRON_CONF DEFAULT verbose True | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 1150 |     iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
| Chris Dent | 74a85b0 | 2015-04-22 18:02:39 +0000 | [diff] [blame] | 1151 |     iniset $NEUTRON_CONF oslo_policy policy_file $Q_POLICY_FILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1152 |     iniset $NEUTRON_CONF DEFAULT allow_overlapping_ips $Q_ALLOW_OVERLAPPING_IP | 
 | 1153 |  | 
 | 1154 |     iniset $NEUTRON_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY | 
 | 1155 |     _neutron_setup_keystone $NEUTRON_CONF keystone_authtoken | 
 | 1156 |  | 
| Atsushi SAKAI | fe7b56c | 2015-11-13 17:06:16 +0900 | [diff] [blame] | 1157 |     # Configuration for neutron notifications to nova. | 
| Terry Wilson | f06c443 | 2014-05-20 10:54:51 -0500 | [diff] [blame] | 1158 |     iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_status_changes $Q_NOTIFY_NOVA_PORT_STATUS_CHANGES | 
 | 1159 |     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] | 1160 |  | 
 | 1161 |     iniset $NEUTRON_CONF nova auth_plugin password | 
 | 1162 |     iniset $NEUTRON_CONF nova auth_url $KEYSTONE_AUTH_URI | 
 | 1163 |     iniset $NEUTRON_CONF nova username nova | 
 | 1164 |     iniset $NEUTRON_CONF nova password $SERVICE_PASSWORD | 
 | 1165 |     iniset $NEUTRON_CONF nova user_domain_id default | 
 | 1166 |     iniset $NEUTRON_CONF nova project_name $SERVICE_TENANT_NAME | 
 | 1167 |     iniset $NEUTRON_CONF nova project_domain_id default | 
 | 1168 |     iniset $NEUTRON_CONF nova region_name $REGION_NAME | 
| Aaron Rosen | cea32b1 | 2014-03-04 16:20:14 -0800 | [diff] [blame] | 1169 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1170 |     # Configure plugin | 
 | 1171 |     neutron_plugin_configure_service | 
 | 1172 | } | 
 | 1173 |  | 
 | 1174 | # Utility Functions | 
 | 1175 | #------------------ | 
 | 1176 |  | 
| Isaku Yamahata | 9e136b4 | 2013-12-16 15:52:03 +0900 | [diff] [blame] | 1177 | # _neutron_service_plugin_class_add() - add service plugin class | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1178 | function _neutron_service_plugin_class_add { | 
| Isaku Yamahata | 9e136b4 | 2013-12-16 15:52:03 +0900 | [diff] [blame] | 1179 |     local service_plugin_class=$1 | 
 | 1180 |     if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then | 
 | 1181 |         Q_SERVICE_PLUGIN_CLASSES=$service_plugin_class | 
 | 1182 |     elif [[ ! ,${Q_SERVICE_PLUGIN_CLASSES}, =~ ,${service_plugin_class}, ]]; then | 
 | 1183 |         Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$service_plugin_class" | 
 | 1184 |     fi | 
 | 1185 | } | 
 | 1186 |  | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 1187 | # _neutron_deploy_rootwrap_filters() - deploy rootwrap filters to $Q_CONF_ROOTWRAP_D (owned by root). | 
 | 1188 | function _neutron_deploy_rootwrap_filters { | 
| gong yong sheng | 3d6eaae | 2015-09-15 15:00:29 +0800 | [diff] [blame] | 1189 |     if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
 | 1190 |         return | 
 | 1191 |     fi | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 1192 |     local srcdir=$1 | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 1193 |     sudo install -d -o root -m 755 $Q_CONF_ROOTWRAP_D | 
 | 1194 |     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] | 1195 | } | 
 | 1196 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1197 | # _neutron_setup_rootwrap() - configure Neutron's rootwrap | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1198 | function _neutron_setup_rootwrap { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1199 |     if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
 | 1200 |         return | 
 | 1201 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1202 |     # Wipe any existing ``rootwrap.d`` files first | 
 | 1203 |     Q_CONF_ROOTWRAP_D=$NEUTRON_CONF_DIR/rootwrap.d | 
 | 1204 |     if [[ -d $Q_CONF_ROOTWRAP_D ]]; then | 
 | 1205 |         sudo rm -rf $Q_CONF_ROOTWRAP_D | 
 | 1206 |     fi | 
| Ihar Hrachyshka | 5893cc7 | 2014-12-22 11:49:42 +0100 | [diff] [blame] | 1207 |  | 
 | 1208 |     _neutron_deploy_rootwrap_filters $NEUTRON_DIR | 
 | 1209 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1210 |     # Set up ``rootwrap.conf``, pointing to ``$NEUTRON_CONF_DIR/rootwrap.d`` | 
 | 1211 |     # location moved in newer versions, prefer new location | 
 | 1212 |     if test -r $NEUTRON_DIR/etc/neutron/rootwrap.conf; then | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 1213 |         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] | 1214 |     else | 
| Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 1215 |         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] | 1216 |     fi | 
 | 1217 |     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] | 1218 |     sudo sed -e 's:^exec_dirs=\(.*\)$:exec_dirs=\1,/usr/local/bin:' -i $Q_RR_CONF_FILE | 
 | 1219 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1220 |     # Specify ``rootwrap.conf`` as first parameter to neutron-rootwrap | 
 | 1221 |     ROOTWRAP_SUDOER_CMD="$NEUTRON_ROOTWRAP $Q_RR_CONF_FILE *" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1222 |     ROOTWRAP_DAEMON_SUDOER_CMD="$NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE" | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1223 |  | 
 | 1224 |     # Set up the rootwrap sudoers for neutron | 
 | 1225 |     TEMPFILE=`mktemp` | 
| Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 1226 |     echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1227 |     echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_DAEMON_SUDOER_CMD" >>$TEMPFILE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1228 |     chmod 0440 $TEMPFILE | 
 | 1229 |     sudo chown root:root $TEMPFILE | 
 | 1230 |     sudo mv $TEMPFILE /etc/sudoers.d/neutron-rootwrap | 
 | 1231 |  | 
 | 1232 |     # Update the root_helper | 
 | 1233 |     iniset $NEUTRON_CONF agent root_helper "$Q_RR_COMMAND" | 
| Yuriy Taraday | 2662395 | 2014-07-16 17:41:53 +0400 | [diff] [blame] | 1234 |     if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then | 
 | 1235 |         iniset $NEUTRON_CONF agent root_helper_daemon "$Q_RR_DAEMON_COMMAND" | 
 | 1236 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1237 | } | 
 | 1238 |  | 
| Ihar Hrachyshka | bb4654b | 2015-10-06 18:09:07 +0200 | [diff] [blame] | 1239 | # Configures keystone integration for neutron service | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1240 | function _neutron_setup_keystone { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1241 |     local conf_file=$1 | 
 | 1242 |     local section=$2 | 
| Jamie Lennox | 3561d7f | 2014-05-21 17:18:43 +1000 | [diff] [blame] | 1243 |  | 
| Brant Knudson | 0595237 | 2014-09-19 17:22:22 -0500 | [diff] [blame] | 1244 |     create_neutron_cache_dir | 
 | 1245 |     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] | 1246 | } | 
 | 1247 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1248 | function _neutron_setup_interface_driver { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1249 |  | 
 | 1250 |     # ovs_use_veth needs to be set before the plugin configuration | 
 | 1251 |     # occurs to allow plugins to override the setting. | 
 | 1252 |     iniset $1 DEFAULT ovs_use_veth $Q_OVS_USE_VETH | 
 | 1253 |  | 
 | 1254 |     neutron_plugin_setup_interface_driver $1 | 
 | 1255 | } | 
 | 1256 |  | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1257 | # Create private IPv4 subnet | 
 | 1258 | function _neutron_create_private_subnet_v4 { | 
 | 1259 |     local subnet_params="--tenant-id $TENANT_ID " | 
 | 1260 |     subnet_params+="--ip_version 4 " | 
 | 1261 |     subnet_params+="--gateway $NETWORK_GATEWAY " | 
 | 1262 |     subnet_params+="--name $PRIVATE_SUBNET_NAME " | 
| John Davidge | 8a3b7d4 | 2015-07-07 11:10:54 +0100 | [diff] [blame] | 1263 |     subnet_params+="--subnetpool None " | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1264 |     subnet_params+="$NET_ID $FIXED_RANGE" | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 1265 |     local subnet_id | 
 | 1266 |     subnet_id=$(neutron subnet-create $subnet_params | grep ' id ' | get_field 2) | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1267 |     die_if_not_set $LINENO subnet_id "Failure creating private IPv4 subnet for $TENANT_ID" | 
 | 1268 |     echo $subnet_id | 
 | 1269 | } | 
 | 1270 |  | 
 | 1271 | # Create private IPv6 subnet | 
 | 1272 | function _neutron_create_private_subnet_v6 { | 
 | 1273 |     die_if_not_set $LINENO IPV6_RA_MODE "IPV6 RA Mode not set" | 
 | 1274 |     die_if_not_set $LINENO IPV6_ADDRESS_MODE "IPV6 Address Mode not set" | 
 | 1275 |     local ipv6_modes="--ipv6-ra-mode $IPV6_RA_MODE --ipv6-address-mode $IPV6_ADDRESS_MODE" | 
 | 1276 |     local subnet_params="--tenant-id $TENANT_ID " | 
 | 1277 |     subnet_params+="--ip_version 6 " | 
 | 1278 |     subnet_params+="--gateway $IPV6_PRIVATE_NETWORK_GATEWAY " | 
 | 1279 |     subnet_params+="--name $IPV6_PRIVATE_SUBNET_NAME " | 
| John Davidge | 8a3b7d4 | 2015-07-07 11:10:54 +0100 | [diff] [blame] | 1280 |     subnet_params+="--subnetpool None " | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1281 |     subnet_params+="$NET_ID $FIXED_RANGE_V6 $ipv6_modes" | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 1282 |     local ipv6_subnet_id | 
 | 1283 |     ipv6_subnet_id=$(neutron subnet-create $subnet_params | grep ' id ' | get_field 2) | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1284 |     die_if_not_set $LINENO ipv6_subnet_id "Failure creating private IPv6 subnet for $TENANT_ID" | 
 | 1285 |     echo $ipv6_subnet_id | 
 | 1286 | } | 
 | 1287 |  | 
 | 1288 | # Create public IPv4 subnet | 
 | 1289 | function _neutron_create_public_subnet_v4 { | 
 | 1290 |     local subnet_params+="--ip_version 4 " | 
 | 1291 |     subnet_params+="${Q_FLOATING_ALLOCATION_POOL:+--allocation-pool $Q_FLOATING_ALLOCATION_POOL} " | 
 | 1292 |     subnet_params+="--gateway $PUBLIC_NETWORK_GATEWAY " | 
 | 1293 |     subnet_params+="--name $PUBLIC_SUBNET_NAME " | 
| John Davidge | 8a3b7d4 | 2015-07-07 11:10:54 +0100 | [diff] [blame] | 1294 |     subnet_params+="--subnetpool None " | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1295 |     subnet_params+="$EXT_NET_ID $FLOATING_RANGE " | 
 | 1296 |     subnet_params+="-- --enable_dhcp=False" | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 1297 |     local id_and_ext_gw_ip | 
 | 1298 |     id_and_ext_gw_ip=$(neutron subnet-create $subnet_params | grep -e 'gateway_ip' -e ' id ') | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1299 |     die_if_not_set $LINENO id_and_ext_gw_ip "Failure creating public IPv4 subnet" | 
 | 1300 |     echo $id_and_ext_gw_ip | 
 | 1301 | } | 
 | 1302 |  | 
 | 1303 | # Create public IPv6 subnet | 
 | 1304 | function _neutron_create_public_subnet_v6 { | 
 | 1305 |     local subnet_params="--ip_version 6 " | 
 | 1306 |     subnet_params+="--gateway $IPV6_PUBLIC_NETWORK_GATEWAY " | 
 | 1307 |     subnet_params+="--name $IPV6_PUBLIC_SUBNET_NAME " | 
| John Davidge | 8a3b7d4 | 2015-07-07 11:10:54 +0100 | [diff] [blame] | 1308 |     subnet_params+="--subnetpool None " | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1309 |     subnet_params+="$EXT_NET_ID $IPV6_PUBLIC_RANGE " | 
 | 1310 |     subnet_params+="-- --enable_dhcp=False" | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 1311 |     local ipv6_id_and_ext_gw_ip | 
 | 1312 |     ipv6_id_and_ext_gw_ip=$(neutron subnet-create $subnet_params | grep -e 'gateway_ip' -e ' id ') | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1313 |     die_if_not_set $LINENO ipv6_id_and_ext_gw_ip "Failure creating an IPv6 public subnet" | 
 | 1314 |     echo $ipv6_id_and_ext_gw_ip | 
 | 1315 | } | 
 | 1316 |  | 
 | 1317 | # Configure neutron router for IPv4 public access | 
 | 1318 | function _neutron_configure_router_v4 { | 
 | 1319 |     neutron router-interface-add $ROUTER_ID $SUBNET_ID | 
 | 1320 |     # Create a public subnet on the external network | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 1321 |     local id_and_ext_gw_ip | 
 | 1322 |     id_and_ext_gw_ip=$(_neutron_create_public_subnet_v4 $EXT_NET_ID) | 
 | 1323 |     local ext_gw_ip | 
 | 1324 |     ext_gw_ip=$(echo $id_and_ext_gw_ip  | get_field 2) | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1325 |     PUB_SUBNET_ID=$(echo $id_and_ext_gw_ip | get_field 5) | 
 | 1326 |     # Configure the external network as the default router gateway | 
 | 1327 |     neutron router-gateway-set $ROUTER_ID $EXT_NET_ID | 
 | 1328 |  | 
 | 1329 |     # This logic is specific to using the l3-agent for layer 3 | 
 | 1330 |     if is_service_enabled q-l3; then | 
 | 1331 |         # Configure and enable public bridge | 
| Sean M. Collins | 71947d5 | 2015-06-17 17:33:02 -0400 | [diff] [blame] | 1332 |         local ext_gw_interface="none" | 
| Cedric Brandily | b814b53 | 2015-10-22 22:25:45 +0200 | [diff] [blame] | 1333 |         if is_neutron_ovs_base_plugin; then | 
| Sean M. Collins | 71947d5 | 2015-06-17 17:33:02 -0400 | [diff] [blame] | 1334 |             ext_gw_interface=$(_neutron_get_ext_gw_interface) | 
 | 1335 |         elif [[ "$Q_AGENT" = "linuxbridge" ]]; then | 
 | 1336 |             # Search for the brq device the neutron router and network for $FIXED_RANGE | 
 | 1337 |             # will be using. | 
 | 1338 |             # e.x. brq3592e767-da for NET_ID 3592e767-da66-4bcb-9bec-cdb03cd96102 | 
 | 1339 |             ext_gw_interface=brq${EXT_NET_ID:0:11} | 
 | 1340 |         fi | 
 | 1341 |         if [[ "$ext_gw_interface" != "none" ]]; then | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1342 |             local cidr_len=${FLOATING_RANGE#*/} | 
| Sean M. Collins | 71947d5 | 2015-06-17 17:33:02 -0400 | [diff] [blame] | 1343 |             local testcmd="ip -o link | grep -q $ext_gw_interface" | 
 | 1344 |             test_with_retry "$testcmd" "$ext_gw_interface creation failed" | 
| YAMAMOTO Takashi | 909fa8f | 2015-03-27 10:56:16 +0900 | [diff] [blame] | 1345 |             if [[ $(ip addr show dev $ext_gw_interface | grep -c $ext_gw_ip) == 0 && ( $Q_USE_PROVIDERNET_FOR_PUBLIC == "False" || $Q_USE_PUBLIC_VETH == "True" ) ]]; then | 
| Sean M. Collins | 00e16a9 | 2015-02-20 11:45:21 -0500 | [diff] [blame] | 1346 |                 sudo ip addr add $ext_gw_ip/$cidr_len dev $ext_gw_interface | 
 | 1347 |                 sudo ip link set $ext_gw_interface up | 
 | 1348 |             fi | 
| Sirushti Murugesan | c00df20 | 2015-10-07 15:06:51 +0530 | [diff] [blame] | 1349 |             ROUTER_GW_IP=`neutron port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F'ip_address'  '{ print $2 }' | cut -f3 -d\" | tr '\n' ' '` | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1350 |             die_if_not_set $LINENO ROUTER_GW_IP "Failure retrieving ROUTER_GW_IP" | 
| gong yong sheng | 348c6ac | 2015-06-23 14:03:47 +0800 | [diff] [blame] | 1351 |             sudo ip route replace  $FIXED_RANGE via $ROUTER_GW_IP | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1352 |         fi | 
 | 1353 |         _neutron_set_router_id | 
 | 1354 |     fi | 
 | 1355 | } | 
 | 1356 |  | 
 | 1357 | # Configure neutron router for IPv6 public access | 
 | 1358 | function _neutron_configure_router_v6 { | 
 | 1359 |     neutron router-interface-add $ROUTER_ID $IPV6_SUBNET_ID | 
 | 1360 |     # Create a public subnet on the external network | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 1361 |     local ipv6_id_and_ext_gw_ip | 
 | 1362 |     ipv6_id_and_ext_gw_ip=$(_neutron_create_public_subnet_v6 $EXT_NET_ID) | 
 | 1363 |     local ipv6_ext_gw_ip | 
 | 1364 |     ipv6_ext_gw_ip=$(echo $ipv6_id_and_ext_gw_ip | get_field 2) | 
 | 1365 |     local ipv6_pub_subnet_id | 
 | 1366 |     ipv6_pub_subnet_id=$(echo $ipv6_id_and_ext_gw_ip | get_field 5) | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1367 |  | 
 | 1368 |     # If the external network has not already been set as the default router | 
 | 1369 |     # gateway when configuring an IPv4 public subnet, do so now | 
 | 1370 |     if [[ "$IP_VERSION" == "6" ]]; then | 
 | 1371 |         neutron router-gateway-set $ROUTER_ID $EXT_NET_ID | 
 | 1372 |     fi | 
 | 1373 |  | 
 | 1374 |     # This logic is specific to using the l3-agent for layer 3 | 
 | 1375 |     if is_service_enabled q-l3; then | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1376 |         # Ensure IPv6 forwarding is enabled on the host | 
 | 1377 |         sudo sysctl -w net.ipv6.conf.all.forwarding=1 | 
 | 1378 |         # Configure and enable public bridge | 
| Dane LeBlanc | a79e101 | 2015-03-26 14:48:07 -0400 | [diff] [blame] | 1379 |         # Override global IPV6_ROUTER_GW_IP with the true value from neutron | 
| Sirushti Murugesan | c00df20 | 2015-10-07 15:06:51 +0530 | [diff] [blame] | 1380 |         IPV6_ROUTER_GW_IP=`neutron port-list -c fixed_ips | grep $ipv6_pub_subnet_id | awk -F'ip_address' '{ print $2 }' | cut -f3 -d\" | tr '\n' ' '` | 
| Dane LeBlanc | a79e101 | 2015-03-26 14:48:07 -0400 | [diff] [blame] | 1381 |         die_if_not_set $LINENO IPV6_ROUTER_GW_IP "Failure retrieving IPV6_ROUTER_GW_IP" | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1382 |  | 
| Cedric Brandily | b814b53 | 2015-10-22 22:25:45 +0200 | [diff] [blame] | 1383 |         if is_neutron_ovs_base_plugin; then | 
| Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 1384 |             local ext_gw_interface | 
 | 1385 |             ext_gw_interface=$(_neutron_get_ext_gw_interface) | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1386 |             local ipv6_cidr_len=${IPV6_PUBLIC_RANGE#*/} | 
 | 1387 |  | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1388 |             # Configure interface for public bridge | 
 | 1389 |             sudo ip -6 addr add $ipv6_ext_gw_ip/$ipv6_cidr_len dev $ext_gw_interface | 
| gong yong sheng | 348c6ac | 2015-06-23 14:03:47 +0800 | [diff] [blame] | 1390 |             sudo ip -6 route replace $FIXED_RANGE_V6 via $IPV6_ROUTER_GW_IP dev $ext_gw_interface | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1391 |         fi | 
 | 1392 |         _neutron_set_router_id | 
 | 1393 |     fi | 
 | 1394 | } | 
 | 1395 |  | 
 | 1396 | # Explicitly set router id in l3 agent configuration | 
 | 1397 | function _neutron_set_router_id { | 
| Cedric Brandily | b814b53 | 2015-10-22 22:25:45 +0200 | [diff] [blame] | 1398 |     if [[ "$Q_L3_ROUTER_PER_TENANT" == "False" ]]; then | 
| John Davidge | 21529a5 | 2014-06-30 09:55:11 -0400 | [diff] [blame] | 1399 |         iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID | 
 | 1400 |     fi | 
 | 1401 | } | 
 | 1402 |  | 
 | 1403 | # Get ext_gw_interface depending on value of Q_USE_PUBLIC_VETH | 
 | 1404 | function _neutron_get_ext_gw_interface { | 
 | 1405 |     if [[ "$Q_USE_PUBLIC_VETH" == "True" ]]; then | 
 | 1406 |         echo $Q_PUBLIC_VETH_EX | 
 | 1407 |     else | 
 | 1408 |         # Disable in-band as we are going to use local port | 
 | 1409 |         # to communicate with VMs | 
 | 1410 |         sudo ovs-vsctl set Bridge $PUBLIC_BRIDGE \ | 
 | 1411 |             other_config:disable-in-band=true | 
 | 1412 |         echo $PUBLIC_BRIDGE | 
 | 1413 |     fi | 
 | 1414 | } | 
 | 1415 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1416 | # Functions for Neutron Exercises | 
 | 1417 | #-------------------------------- | 
 | 1418 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1419 | function delete_probe { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1420 |     local from_net="$1" | 
 | 1421 |     net_id=`_get_net_id $from_net` | 
 | 1422 |     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}'` | 
 | 1423 |     neutron-debug --os-tenant-name admin --os-username admin probe-delete $probe_id | 
 | 1424 | } | 
 | 1425 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1426 | function setup_neutron_debug { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1427 |     if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then | 
 | 1428 |         public_net_id=`_get_net_id $PUBLIC_NETWORK_NAME` | 
 | 1429 |         neutron-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create --device-owner compute $public_net_id | 
 | 1430 |         private_net_id=`_get_net_id $PRIVATE_NETWORK_NAME` | 
 | 1431 |         neutron-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create --device-owner compute $private_net_id | 
 | 1432 |     fi | 
 | 1433 | } | 
 | 1434 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1435 | function teardown_neutron_debug { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1436 |     delete_probe $PUBLIC_NETWORK_NAME | 
 | 1437 |     delete_probe $PRIVATE_NETWORK_NAME | 
 | 1438 | } | 
 | 1439 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1440 | function _get_net_id { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1441 |     neutron --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD net-list | grep $1 | awk '{print $2}' | 
 | 1442 | } | 
 | 1443 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1444 | function _get_probe_cmd_prefix { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1445 |     local from_net="$1" | 
 | 1446 |     net_id=`_get_net_id $from_net` | 
 | 1447 |     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` | 
 | 1448 |     echo "$Q_RR_COMMAND ip netns exec qprobe-$probe_id" | 
 | 1449 | } | 
 | 1450 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1451 | # ssh check | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1452 | function _ssh_check_neutron { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1453 |     local from_net=$1 | 
 | 1454 |     local key_file=$2 | 
 | 1455 |     local ip=$3 | 
 | 1456 |     local user=$4 | 
 | 1457 |     local timeout_sec=$5 | 
 | 1458 |     local probe_cmd = "" | 
 | 1459 |     probe_cmd=`_get_probe_cmd_prefix $from_net` | 
| Sean Dague | 442e4e9 | 2015-06-24 13:24:02 -0400 | [diff] [blame] | 1460 |     local testcmd="$probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success" | 
 | 1461 |     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] | 1462 | } | 
 | 1463 |  | 
 | 1464 | # Neutron 3rd party programs | 
 | 1465 | #--------------------------- | 
 | 1466 |  | 
 | 1467 | # please refer to ``lib/neutron_thirdparty/README.md`` for details | 
 | 1468 | NEUTRON_THIRD_PARTIES="" | 
 | 1469 | for f in $TOP_DIR/lib/neutron_thirdparty/*; do | 
| Sean Dague | 3bdb922 | 2013-10-22 08:36:16 -0400 | [diff] [blame] | 1470 |     third_party=$(basename $f) | 
 | 1471 |     if is_service_enabled $third_party; then | 
 | 1472 |         source $TOP_DIR/lib/neutron_thirdparty/$third_party | 
 | 1473 |         NEUTRON_THIRD_PARTIES="$NEUTRON_THIRD_PARTIES,$third_party" | 
 | 1474 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1475 | done | 
 | 1476 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1477 | function _neutron_third_party_do { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1478 |     for third_party in ${NEUTRON_THIRD_PARTIES//,/ }; do | 
 | 1479 |         ${1}_${third_party} | 
 | 1480 |     done | 
 | 1481 | } | 
 | 1482 |  | 
 | 1483 | # configure_neutron_third_party() - Set config files, create data dirs, etc | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1484 | function configure_neutron_third_party { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1485 |     _neutron_third_party_do configure | 
 | 1486 | } | 
 | 1487 |  | 
 | 1488 | # init_neutron_third_party() - Initialize databases, etc. | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1489 | function init_neutron_third_party { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1490 |     _neutron_third_party_do init | 
 | 1491 | } | 
 | 1492 |  | 
 | 1493 | # install_neutron_third_party() - Collect source and prepare | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1494 | function install_neutron_third_party { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1495 |     _neutron_third_party_do install | 
 | 1496 | } | 
 | 1497 |  | 
 | 1498 | # start_neutron_third_party() - Start running processes, including screen | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1499 | function start_neutron_third_party { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1500 |     _neutron_third_party_do start | 
 | 1501 | } | 
 | 1502 |  | 
 | 1503 | # stop_neutron_third_party - Stop running processes (non-screen) | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1504 | function stop_neutron_third_party { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1505 |     _neutron_third_party_do stop | 
 | 1506 | } | 
 | 1507 |  | 
| armando-migliaccio | ef1e080 | 2014-01-02 16:33:53 -0800 | [diff] [blame] | 1508 | # check_neutron_third_party_integration() - Check that third party integration is sane | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 1509 | function check_neutron_third_party_integration { | 
| armando-migliaccio | ef1e080 | 2014-01-02 16:33:53 -0800 | [diff] [blame] | 1510 |     _neutron_third_party_do check | 
 | 1511 | } | 
 | 1512 |  | 
| Sean M. Collins | 5ec6f8f | 2014-05-14 17:01:03 -0400 | [diff] [blame] | 1513 | function is_provider_network { | 
 | 1514 |     if [ "$Q_USE_PROVIDER_NETWORKING" == "True" ] && [ "$Q_L3_ENABLED" == "False" ]; then | 
 | 1515 |         return 0 | 
 | 1516 |     fi | 
 | 1517 |     return 1 | 
 | 1518 | } | 
 | 1519 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1520 |  | 
 | 1521 | # Restore xtrace | 
| Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 1522 | $_XTRACE_NEUTRON | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1523 |  | 
| Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 1524 | # Tell emacs to use shell-script-mode | 
 | 1525 | ## Local variables: | 
 | 1526 | ## mode: shell-script | 
 | 1527 | ## End: |