Browse code

Merge "Devstack support for Quantum L3 agent"

Jenkins authored on 2012/09/09 13:58:37
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,37 @@
0
+# lib/quantum
1
+# functions - funstions specific to quantum
2
+
3
+# Save trace setting
4
+XTRACE=$(set +o | grep xtrace)
5
+set +o xtrace
6
+
7
+# Configures keystone integration for quantum service and agents
8
+function quantum_setup_keystone() {
9
+    local conf_file=$1
10
+    local section=$2
11
+    local use_auth_url=$3
12
+    if [[ -n $use_auth_url ]]; then
13
+        iniset $conf_file $section auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0"
14
+    else
15
+        iniset $conf_file $section auth_host $KEYSTONE_SERVICE_HOST
16
+        iniset $conf_file $section auth_port $KEYSTONE_AUTH_PORT
17
+        iniset $conf_file $section auth_protocol $KEYSTONE_SERVICE_PROTOCOL
18
+    fi
19
+    iniset $conf_file $section admin_tenant_name $SERVICE_TENANT_NAME
20
+    iniset $conf_file $section admin_user $Q_ADMIN_USERNAME
21
+    iniset $conf_file $section admin_password $SERVICE_PASSWORD
22
+}
23
+
24
+function quantum_setup_ovs_bridge() {
25
+    local bridge=$1
26
+    for PORT in `sudo ovs-vsctl --no-wait list-ports $bridge`; do
27
+        if [[ "$PORT" =~ tap* ]]; then echo `sudo ip link delete $PORT` > /dev/null; fi
28
+        sudo ovs-vsctl --no-wait del-port $bridge $PORT
29
+    done
30
+    sudo ovs-vsctl --no-wait -- --if-exists del-br $bridge
31
+    sudo ovs-vsctl --no-wait add-br $bridge
32
+    sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge
33
+}
34
+
35
+# Restore xtrace
36
+$XTRACE
... ...
@@ -270,6 +270,7 @@ source $TOP_DIR/lib/cinder
270 270
 source $TOP_DIR/lib/n-vol
271 271
 source $TOP_DIR/lib/ceilometer
272 272
 source $TOP_DIR/lib/heat
273
+source $TOP_DIR/lib/quantum
273 274
 
274 275
 # Set the destination directories for OpenStack projects
275 276
 NOVA_DIR=$DEST/nova
... ...
@@ -300,6 +301,8 @@ Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-quantum}
300 300
 Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone}
301 301
 # Use namespace or not
302 302
 Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True}
303
+# Meta data IP
304
+Q_META_DATA_IP=${Q_META_DATA_IP:-}
303 305
 
304 306
 # Name of the LVM volume group to use/create for iscsi volumes
305 307
 VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes}
... ...
@@ -1163,7 +1166,7 @@ if is_service_enabled quantum; then
1163 1163
     Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
1164 1164
     cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
1165 1165
 
1166
-    sudo sed -i -e "s/^sql_connection =.*$/sql_connection = mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/$Q_DB_NAME?charset=utf8/g" /$Q_PLUGIN_CONF_FILE
1166
+    iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/$Q_DB_NAME?charset=utf8
1167 1167
 
1168 1168
     OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-True}
1169 1169
     if [[ "$Q_PLUGIN" = "openvswitch" && "$OVS_ENABLE_TUNNELING" = "True" ]]; then
... ...
@@ -1205,12 +1208,7 @@ if is_service_enabled q-svc; then
1205 1205
     iniset $Q_CONF_FILE DEFAULT core_plugin $Q_PLUGIN_CLASS
1206 1206
 
1207 1207
     iniset $Q_CONF_FILE DEFAULT auth_strategy $Q_AUTH_STRATEGY
1208
-    iniset $Q_API_PASTE_FILE filter:authtoken auth_host $KEYSTONE_SERVICE_HOST
1209
-    iniset $Q_API_PASTE_FILE filter:authtoken auth_port $KEYSTONE_AUTH_PORT
1210
-    iniset $Q_API_PASTE_FILE filter:authtoken auth_protocol $KEYSTONE_SERVICE_PROTOCOL
1211
-    iniset $Q_API_PASTE_FILE filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME
1212
-    iniset $Q_API_PASTE_FILE filter:authtoken admin_user $Q_ADMIN_USERNAME
1213
-    iniset $Q_API_PASTE_FILE filter:authtoken admin_password $SERVICE_PASSWORD
1208
+    quantum_setup_keystone $Q_API_PASTE_FILE filter:authtoken
1214 1209
 fi
1215 1210
 
1216 1211
 # Quantum agent (for compute nodes)
... ...
@@ -1218,13 +1216,7 @@ if is_service_enabled q-agt; then
1218 1218
     if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
1219 1219
         # Set up integration bridge
1220 1220
         OVS_BRIDGE=${OVS_BRIDGE:-br-int}
1221
-        for PORT in `sudo ovs-vsctl --no-wait list-ports $OVS_BRIDGE`; do
1222
-            if [[ "$PORT" =~ tap* ]]; then echo `sudo ip link delete $PORT` > /dev/null; fi
1223
-            sudo ovs-vsctl --no-wait del-port $OVS_BRIDGE $PORT
1224
-        done
1225
-        sudo ovs-vsctl --no-wait -- --if-exists del-br $OVS_BRIDGE
1226
-        sudo ovs-vsctl --no-wait add-br $OVS_BRIDGE
1227
-        sudo ovs-vsctl --no-wait br-set-external-id $OVS_BRIDGE bridge-id br-int
1221
+        quantum_setup_ovs_bridge $OVS_BRIDGE
1228 1222
         if [[ "$OVS_ENABLE_TUNNELING" == "True" ]]; then
1229 1223
             iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
1230 1224
         else
... ...
@@ -1264,10 +1256,7 @@ if is_service_enabled q-dhcp; then
1264 1264
 
1265 1265
     # Update database
1266 1266
     iniset $Q_DHCP_CONF_FILE DEFAULT db_connection "mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/$Q_DB_NAME?charset=utf8"
1267
-    iniset $Q_DHCP_CONF_FILE DEFAULT auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0"
1268
-    iniset $Q_DHCP_CONF_FILE DEFAULT admin_tenant_name $SERVICE_TENANT_NAME
1269
-    iniset $Q_DHCP_CONF_FILE DEFAULT admin_user $Q_ADMIN_USERNAME
1270
-    iniset $Q_DHCP_CONF_FILE DEFAULT admin_password $SERVICE_PASSWORD
1267
+    quantum_setup_keystone $Q_DHCP_CONF_FILE DEFAULT set_auth_url
1271 1268
 
1272 1269
     if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
1273 1270
         iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
... ...
@@ -1276,6 +1265,45 @@ if is_service_enabled q-dhcp; then
1276 1276
     fi
1277 1277
 fi
1278 1278
 
1279
+# Quantum L3
1280
+if is_service_enabled q-l3; then
1281
+    AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent"
1282
+    PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
1283
+    Q_L3_CONF_FILE=/etc/quantum/l3_agent.ini
1284
+
1285
+    cp $QUANTUM_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE
1286
+
1287
+    # Set verbose
1288
+    iniset $Q_L3_CONF_FILE DEFAULT verbose True
1289
+    # Set debug
1290
+    iniset $Q_L3_CONF_FILE DEFAULT debug True
1291
+
1292
+    iniset $Q_L3_CONF_FILE DEFAULT metadata_ip $Q_META_DATA_IP
1293
+    iniset $Q_L3_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
1294
+    iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
1295
+
1296
+    quantum_setup_keystone $Q_L3_CONF_FILE DEFAULT set_auth_url
1297
+    if [[ "$Q_PLUGIN" == "openvswitch" ]]; then
1298
+        iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
1299
+        # Set up external bridge
1300
+        # Create it if it does not exist
1301
+        sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
1302
+        sudo ovs-vsctl --no-wait br-set-external-id $PUBLIC_BRIDGE bridge-id $PUBLIC_BRIDGE
1303
+        # remove internal ports
1304
+        for PORT in `sudo ovs-vsctl --no-wait list-ports $PUBLIC_BRIDGE`; do
1305
+            TYPE=$(sudo ovs-vsctl get interface $PORT type)
1306
+            if [[ "$TYPE" == "internal" ]]; then
1307
+                echo `sudo ip link delete $PORT` > /dev/null
1308
+                sudo ovs-vsctl --no-wait del-port $bridge $PORT
1309
+            fi
1310
+        done
1311
+        # ensure no IP is configured on the public bridge
1312
+        sudo ip addr flush dev $PUBLIC_BRIDGE
1313
+    elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1314
+        iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
1315
+    fi
1316
+fi
1317
+
1279 1318
 # Quantum RPC support - must be updated prior to starting any of the services
1280 1319
 if is_service_enabled quantum; then
1281 1320
     iniset $Q_CONF_FILE DEFAULT control_exchange quantum
... ...
@@ -1289,16 +1317,6 @@ if is_service_enabled quantum; then
1289 1289
     fi
1290 1290
 fi
1291 1291
 
1292
-# Start the Quantum services
1293
-screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE"
1294
-
1295
-# Start up the quantum agent
1296
-screen_it q-agt "sudo python $AGENT_BINARY --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE"
1297
-
1298
-# Start up the quantum agent
1299
-screen_it q-dhcp "sudo python $AGENT_DHCP_BINARY --config-file $Q_CONF_FILE --config-file=$Q_DHCP_CONF_FILE"
1300
-
1301
-
1302 1292
 # Nova
1303 1293
 # ----
1304 1294
 
... ...
@@ -2078,7 +2096,6 @@ if is_service_enabled key; then
2078 2078
       echo "keystone did not start"
2079 2079
       exit 1
2080 2080
     fi
2081
-
2082 2081
     # ``keystone_data.sh`` creates services, admin and demo users, and roles.
2083 2082
     SERVICE_ENDPOINT=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0
2084 2083
 
... ...
@@ -2120,16 +2137,51 @@ if is_service_enabled n-api; then
2120 2120
     fi
2121 2121
 fi
2122 2122
 
2123
-# If we're using Quantum (i.e. q-svc is enabled), network creation has to
2124
-# happen after we've started the Quantum service.
2125 2123
 if is_service_enabled q-svc; then
2124
+    # Start the Quantum service
2125
+    screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE"
2126
+    echo "Waiting for Quantum to start..."
2127
+    if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:9696; do sleep 1; done"; then
2128
+      echo "Quantum did not start"
2129
+      exit 1
2130
+    fi
2131
+
2132
+    # Configure Quantum elements
2133
+    # Configure internal network & subnet
2134
+
2126 2135
     TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1)
2127 2136
 
2128 2137
     # Create a small network
2129 2138
     # Since quantum command is executed in admin context at this point,
2130 2139
     # ``--tenant_id`` needs to be specified.
2131 2140
     NET_ID=$(quantum net-create --tenant_id $TENANT_ID net1 | grep ' id ' | get_field 2)
2132
-    quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE
2141
+    SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
2142
+    if is_service_enabled q-l3; then
2143
+        # Create a router, and add the private subnet as one of its interfaces
2144
+        ROUTER_ID=$(quantum router-create --tenant_id $TENANT_ID router1 | grep ' id ' | get_field 2)
2145
+        quantum router-interface-add $ROUTER_ID $SUBNET_ID
2146
+        # Create an external network, and a subnet. Configure the external network as router gw
2147
+        EXT_NET_ID=$(quantum net-create ext_net -- --router:external=True | grep ' id ' | get_field 2)
2148
+        EXT_GW_IP=$(quantum subnet-create --ip_version 4 $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
2149
+        quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
2150
+        if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
2151
+            CIDR_LEN=${FLOATING_RANGE#*/}
2152
+            sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
2153
+            sudo ip link set $PUBLIC_BRIDGE up
2154
+        fi
2155
+        if [[ "$Q_USE_NAMESPACE" == "False" ]]; then
2156
+            # Explicitly set router id in l3 agent configuration
2157
+            iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID
2158
+        fi
2159
+   fi
2160
+
2161
+   # Start up the quantum agent
2162
+   screen_it q-agt "sudo python $AGENT_BINARY --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE"
2163
+   # Start up the quantum dhcp agent
2164
+   screen_it q-dhcp "sudo python $AGENT_DHCP_BINARY --config-file $Q_CONF_FILE --config-file=$Q_DHCP_CONF_FILE"
2165
+   # Start up the quantum l3 agent
2166
+   screen_it q-l3 "sudo python $AGENT_L3_BINARY --config-file $Q_CONF_FILE --config-file=$Q_L3_CONF_FILE"
2167
+
2133 2168
 elif is_service_enabled mysql && is_service_enabled nova; then
2134 2169
     # Create a small network
2135 2170
     $NOVA_BIN_DIR/nova-manage network create private $FIXED_RANGE 1 $FIXED_NETWORK_SIZE $NETWORK_CREATE_ARGS