Bug 1116847
Includes slight refactoring of L3 logic in main lib/quantum as previous
logic treated l3-agent as only way to do L3, whereas NVP has its own L3
support.
Change-Id: Ifd8c6864add5939432b544285cf027e52329dea2
| ... | ... |
@@ -284,14 +284,13 @@ function create_quantum_initial_network() {
|
| 284 | 284 |
SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2) |
| 285 | 285 |
fi |
| 286 | 286 |
|
| 287 |
- if is_service_enabled q-l3; then |
|
| 287 |
+ if [[ "$Q_L3_ENABLED" == "True" ]]; then |
|
| 288 | 288 |
# Create a router, and add the private subnet as one of its interfaces |
| 289 |
- if [[ "$Q_USE_NAMESPACE" == "True" ]]; then |
|
| 290 |
- # If namespaces are enabled, create a tenant-owned router. |
|
| 289 |
+ if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then |
|
| 290 |
+ # create a tenant-owned router. |
|
| 291 | 291 |
ROUTER_ID=$(quantum router-create --tenant_id $TENANT_ID $Q_ROUTER_NAME | grep ' id ' | get_field 2) |
| 292 | 292 |
else |
| 293 |
- # If namespaces are disabled, the L3 agent can only target |
|
| 294 |
- # a single router, which should not be tenant-owned. |
|
| 293 |
+ # Plugin only supports creating a single router, which should be admin owned. |
|
| 295 | 294 |
ROUTER_ID=$(quantum router-create $Q_ROUTER_NAME | grep ' id ' | get_field 2) |
| 296 | 295 |
fi |
| 297 | 296 |
quantum router-interface-add $ROUTER_ID $SUBNET_ID |
| ... | ... |
@@ -300,16 +299,19 @@ function create_quantum_initial_network() {
|
| 300 | 300 |
EXT_GW_IP=$(quantum subnet-create --ip_version 4 ${Q_FLOATING_ALLOCATION_POOL:+--allocation-pool $Q_FLOATING_ALLOCATION_POOL} $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
|
| 301 | 301 |
quantum router-gateway-set $ROUTER_ID $EXT_NET_ID |
| 302 | 302 |
|
| 303 |
- if is_quantum_ovs_base_plugin && [[ "$Q_USE_NAMESPACE" = "True" ]]; then |
|
| 304 |
- CIDR_LEN=${FLOATING_RANGE#*/}
|
|
| 305 |
- sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE |
|
| 306 |
- sudo ip link set $PUBLIC_BRIDGE up |
|
| 307 |
- ROUTER_GW_IP=`quantum port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
|
|
| 308 |
- sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP |
|
| 309 |
- fi |
|
| 310 |
- if [[ "$Q_USE_NAMESPACE" == "False" ]]; then |
|
| 311 |
- # Explicitly set router id in l3 agent configuration |
|
| 312 |
- iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID |
|
| 303 |
+ if is_service_enabled q-l3; then |
|
| 304 |
+ # logic is specific to using the l3-agent for l3 |
|
| 305 |
+ if is_quantum_ovs_base_plugin && [[ "$Q_USE_NAMESPACE" = "True" ]]; then |
|
| 306 |
+ CIDR_LEN=${FLOATING_RANGE#*/}
|
|
| 307 |
+ sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE |
|
| 308 |
+ sudo ip link set $PUBLIC_BRIDGE up |
|
| 309 |
+ ROUTER_GW_IP=`quantum port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
|
|
| 310 |
+ sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP |
|
| 311 |
+ fi |
|
| 312 |
+ if [[ "$Q_USE_NAMESPACE" == "False" ]]; then |
|
| 313 |
+ # Explicitly set router id in l3 agent configuration |
|
| 314 |
+ iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID |
|
| 315 |
+ fi |
|
| 313 | 316 |
fi |
| 314 | 317 |
fi |
| 315 | 318 |
} |
| ... | ... |
@@ -450,6 +452,9 @@ function _configure_quantum_dhcp_agent() {
|
| 450 | 450 |
} |
| 451 | 451 |
|
| 452 | 452 |
function _configure_quantum_l3_agent() {
|
| 453 |
+ Q_L3_ENABLED=True |
|
| 454 |
+ # for l3-agent, only use per tenant router if we have namespaces |
|
| 455 |
+ Q_L3_ROUTER_PER_TENANT=$Q_USE_NAMESPACE |
|
| 453 | 456 |
AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent" |
| 454 | 457 |
PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
|
| 455 | 458 |
Q_L3_CONF_FILE=$QUANTUM_CONF_DIR/l3_agent.ini |
| 456 | 459 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,150 @@ |
| 0 |
+# Quantum Nicira NVP plugin |
|
| 1 |
+# --------------------------- |
|
| 2 |
+ |
|
| 3 |
+# Save trace setting |
|
| 4 |
+MY_XTRACE=$(set +o | grep xtrace) |
|
| 5 |
+set +o xtrace |
|
| 6 |
+ |
|
| 7 |
+source $TOP_DIR/lib/quantum_plugins/ovs_base |
|
| 8 |
+ |
|
| 9 |
+function setup_integration_bridge() {
|
|
| 10 |
+ OVS_BRIDGE=${OVS_BRIDGE:-br-int}
|
|
| 11 |
+ _quantum_ovs_base_setup_bridge $OVS_BRIDGE |
|
| 12 |
+ # Set manager to NVP controller (1st of list) |
|
| 13 |
+ if [[ "$NVP_CONTROLLERS" != "" ]]; then |
|
| 14 |
+ # Get the first controller |
|
| 15 |
+ controllers=(${NVP_CONTROLLERS//,/ })
|
|
| 16 |
+ OVS_MGR_IP=${controllers[0]}
|
|
| 17 |
+ elif [[ "$NVP_CONTROLLER_CONNECTION" != "" ]]; then |
|
| 18 |
+ conn=(${NVP_CONTROLLER_CONNECTION//\:/ })
|
|
| 19 |
+ OVS_MGR_IP=${conn[0]}
|
|
| 20 |
+ else |
|
| 21 |
+ echo "Error - No controller specified. Unable to set a manager for OVS" |
|
| 22 |
+ exit 1 |
|
| 23 |
+ fi |
|
| 24 |
+ sudo ovs-vsctl set-manager ssl:$OVS_MGR_IP |
|
| 25 |
+} |
|
| 26 |
+ |
|
| 27 |
+function is_quantum_ovs_base_plugin() {
|
|
| 28 |
+ # NVP uses OVS, but not the l3-agent |
|
| 29 |
+ return 0 |
|
| 30 |
+} |
|
| 31 |
+ |
|
| 32 |
+function quantum_plugin_create_nova_conf() {
|
|
| 33 |
+ NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtOpenVswitchDriver"}
|
|
| 34 |
+ # if n-cpu is enabled, then setup integration bridge |
|
| 35 |
+ if is_service_enabled n-cpu; then |
|
| 36 |
+ setup_integration_bridge |
|
| 37 |
+ fi |
|
| 38 |
+} |
|
| 39 |
+ |
|
| 40 |
+function quantum_plugin_install_agent_packages() {
|
|
| 41 |
+ # Nicira Plugin does not run q-agt |
|
| 42 |
+ : |
|
| 43 |
+} |
|
| 44 |
+ |
|
| 45 |
+function quantum_plugin_configure_common() {
|
|
| 46 |
+ Q_PLUGIN_CONF_PATH=etc/quantum/plugins/nicira |
|
| 47 |
+ Q_PLUGIN_CONF_FILENAME=nvp.ini |
|
| 48 |
+ Q_DB_NAME="quantum_nvp" |
|
| 49 |
+ Q_PLUGIN_CLASS="quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin.NvpPluginV2" |
|
| 50 |
+} |
|
| 51 |
+ |
|
| 52 |
+function quantum_plugin_configure_debug_command() {
|
|
| 53 |
+ : |
|
| 54 |
+} |
|
| 55 |
+ |
|
| 56 |
+function quantum_plugin_configure_dhcp_agent() {
|
|
| 57 |
+ setup_integration_bridge |
|
| 58 |
+ iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata True |
|
| 59 |
+ iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network True |
|
| 60 |
+ iniset $Q_DHCP_CONF_FILE DEFAULT ovs_use_veth True |
|
| 61 |
+} |
|
| 62 |
+ |
|
| 63 |
+function quantum_plugin_configure_l3_agent() {
|
|
| 64 |
+ # Nicira plugin does not run L3 agent |
|
| 65 |
+ echo "ERROR - q-l3 should must not be executed with Nicira plugin!" |
|
| 66 |
+ exit 1 |
|
| 67 |
+} |
|
| 68 |
+ |
|
| 69 |
+function quantum_plugin_configure_plugin_agent() {
|
|
| 70 |
+ # Nicira plugin does not run L2 agent |
|
| 71 |
+ echo "ERROR - q-agt must not be executed with Nicira plugin!" |
|
| 72 |
+ exit 1 |
|
| 73 |
+} |
|
| 74 |
+ |
|
| 75 |
+function quantum_plugin_configure_service() {
|
|
| 76 |
+ if [[ "$MAX_LP_PER_BRIDGED_LS" != "" ]]; then |
|
| 77 |
+ iniset /$Q_PLUGIN_CONF_FILE NVP max_lp_per_bridged_ls $MAX_LP_PER_BRIDGED_LS |
|
| 78 |
+ fi |
|
| 79 |
+ if [[ "$MAX_LP_PER_OVERLAY_LS" != "" ]]; then |
|
| 80 |
+ iniset /$Q_PLUGIN_CONF_FILE NVP max_lp_per_overlay_ls $MAX_LP_PER_OVERLAY_LS |
|
| 81 |
+ fi |
|
| 82 |
+ if [[ "$FAILOVER_TIME" != "" ]]; then |
|
| 83 |
+ iniset /$Q_PLUGIN_CONF_FILE NVP failover_time $FAILOVER_TIME |
|
| 84 |
+ fi |
|
| 85 |
+ if [[ "$CONCURRENT_CONNECTIONS" != "" ]]; then |
|
| 86 |
+ iniset /$Q_PLUGIN_CONF_FILE NVP concurrent_connections $CONCURRENT_CONNECTIONS |
|
| 87 |
+ fi |
|
| 88 |
+ |
|
| 89 |
+ if [[ "$DEFAULT_CLUSTER" != "" ]]; then |
|
| 90 |
+ # Make name shorter for sake of readability |
|
| 91 |
+ DC=$DEFAULT_CLUSTER |
|
| 92 |
+ if [[ "$DEFAULT_TZ_UUID" != "" ]]; then |
|
| 93 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" default_tz_uuid $DEFAULT_TZ_UUID |
|
| 94 |
+ else |
|
| 95 |
+ echo "ERROR - The nicira plugin won't work without a default transport zone." |
|
| 96 |
+ exit 1 |
|
| 97 |
+ fi |
|
| 98 |
+ if [[ "$DEFAULT_L3_GW_SVC_UUID" != "" ]]; then |
|
| 99 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" default_l3_gw_service_uuid $DEFAULT_L3_GW_SVC_UUID |
|
| 100 |
+ Q_L3_ENABLED=True |
|
| 101 |
+ Q_L3_ROUTER_PER_TENANT=True |
|
| 102 |
+ iniset /$Q_PLUGIN_CONF_FILE NVP enable_metadata_access_network True |
|
| 103 |
+ else |
|
| 104 |
+ echo "WARNING - No l3 gw service enabled. You will not be able to use the L3 API extension" |
|
| 105 |
+ fi |
|
| 106 |
+ if [[ "$DEFAULT_L2_GW_SVC_UUID" != "" ]]; then |
|
| 107 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" default_l2_gw_service_uuid $DEFAULT_L2_GW_SVC_UUID |
|
| 108 |
+ fi |
|
| 109 |
+ # NVP_CONTROLLERS must be a comma separated string |
|
| 110 |
+ if [[ "$NVP_CONTROLLERS" != "" ]]; then |
|
| 111 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" nvp_controllers $NVP_CONTROLLERS |
|
| 112 |
+ elif [[ "$NVP_CONTROLLER_CONNECTION" != "" ]]; then |
|
| 113 |
+ # Only 1 controller can be specified in this case |
|
| 114 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" nvp_controller_connection $NVP_CONTROLLER_CONNECTION |
|
| 115 |
+ else |
|
| 116 |
+ echo "ERROR - The nicira plugin needs at least an NVP controller." |
|
| 117 |
+ exit 1 |
|
| 118 |
+ fi |
|
| 119 |
+ if [[ "$NVP_USER" != "" ]]; then |
|
| 120 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" nvp_user $NVP_USER |
|
| 121 |
+ fi |
|
| 122 |
+ if [[ "$NVP_PASSWORD" != "" ]]; then |
|
| 123 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" nvp_password $NVP_PASSWORD |
|
| 124 |
+ fi |
|
| 125 |
+ if [[ "$NVP_REQ_TIMEOUT" != "" ]]; then |
|
| 126 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" req_timeout $NVP_REQ_TIMEOUT |
|
| 127 |
+ fi |
|
| 128 |
+ if [[ "$NVP_HTTP_TIMEOUT" != "" ]]; then |
|
| 129 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" http_timeout $NVP_HTTP_TIMEOUT |
|
| 130 |
+ fi |
|
| 131 |
+ if [[ "$NVP_RETRIES" != "" ]]; then |
|
| 132 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" retries $NVP_RETRIES |
|
| 133 |
+ fi |
|
| 134 |
+ if [[ "$NVP_REDIRECTS" != "" ]]; then |
|
| 135 |
+ iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" redirects $NVP_REDIRECTS |
|
| 136 |
+ fi |
|
| 137 |
+ else |
|
| 138 |
+ echo "ERROR - Default cluster not configured. Quantum will not start" |
|
| 139 |
+ exit 1 |
|
| 140 |
+ fi |
|
| 141 |
+} |
|
| 142 |
+ |
|
| 143 |
+function quantum_plugin_setup_interface_driver() {
|
|
| 144 |
+ local conf_file=$1 |
|
| 145 |
+ iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver |
|
| 146 |
+} |
|
| 147 |
+ |
|
| 148 |
+# Restore xtrace |
|
| 149 |
+$MY_XTRACE |