Browse code

Merge "Adds LinuxBridge plugin setup support."

Jenkins authored on 2012/05/09 03:16:41
Showing 1 changed files
... ...
@@ -1005,14 +1005,36 @@ fi
1005 1005
 
1006 1006
 # Quantum
1007 1007
 # -------
1008
-
1009
-# Quantum service
1010
-if is_service_enabled q-svc; then
1008
+if is_service_enabled quantum; then
1009
+    # Put config files in /etc/quantum for everyone to find
1011 1010
     QUANTUM_CONF_DIR=/etc/quantum
1012 1011
     if [[ ! -d $QUANTUM_CONF_DIR ]]; then
1013 1012
         sudo mkdir -p $QUANTUM_CONF_DIR
1014 1013
     fi
1015 1014
     sudo chown `whoami` $QUANTUM_CONF_DIR
1015
+
1016
+    # Set default values when using Linux Bridge plugin
1017
+    if [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1018
+        # set the config file
1019
+        QUANTUM_LB_CONF_DIR=$QUANTUM_CONF_DIR/plugins/linuxbridge
1020
+        mkdir -p $QUANTUM_LB_CONF_DIR
1021
+        QUANTUM_LB_CONFIG_FILE=$QUANTUM_LB_CONF_DIR/linuxbridge_conf.ini
1022
+        # must remove this file from existing location, otherwise Quantum will prefer it
1023
+        if [[ -e $QUANTUM_DIR/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini ]]; then
1024
+            sudo mv $QUANTUM_DIR/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini $QUANTUM_LB_CONFIG_FILE
1025
+        fi
1026
+        #set the default network interface
1027
+        QUANTUM_LB_PRIVATE_INTERFACE=${QUANTUM_LB_PRIVATE_INTERFACE:-$GUEST_INTERFACE_DEFAULT}
1028
+    fi
1029
+fi
1030
+# Quantum service
1031
+if is_service_enabled q-svc; then
1032
+    QUANTUM_PLUGIN_INI_FILE=$QUANTUM_CONF_DIR/plugins.ini
1033
+    # must remove this file from existing location, otherwise Quantum will prefer it
1034
+    if [[ -e $QUANTUM_DIR/etc/plugins.ini ]]; then
1035
+        sudo mv $QUANTUM_DIR/etc/plugins.ini $QUANTUM_PLUGIN_INI_FILE
1036
+    fi
1037
+
1016 1038
     if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
1017 1039
         # Install deps
1018 1040
         # FIXME add to files/apts/quantum, but don't install if not needed!
... ...
@@ -1031,13 +1053,27 @@ if is_service_enabled q-svc; then
1031 1031
             echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin."
1032 1032
             exit 1
1033 1033
         fi
1034
-        QUANTUM_PLUGIN_INI_FILE=$QUANTUM_CONF_DIR/plugins.ini
1035
-        # must remove this file from existing location, otherwise Quantum will prefer it
1036
-        if [[ -e $QUANTUM_DIR/etc/plugins.ini ]]; then
1037
-            sudo mv $QUANTUM_DIR/etc/plugins.ini $QUANTUM_PLUGIN_INI_FILE
1038
-        fi
1039 1034
         # Make sure we're using the openvswitch plugin
1040 1035
         sudo sed -i -e "s/^provider =.*$/provider = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin/g" $QUANTUM_PLUGIN_INI_FILE
1036
+    elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1037
+        # Install deps
1038
+        # FIXME add to files/apts/quantum, but don't install if not needed!
1039
+        install_package python-configobj
1040
+        # Create database for the plugin/agent
1041
+        if is_service_enabled mysql; then
1042
+            mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS quantum_linux_bridge;'
1043
+            mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE IF NOT EXISTS quantum_linux_bridge;'
1044
+        else
1045
+            echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin."
1046
+            exit 1
1047
+        fi
1048
+        # Make sure we're using the linuxbridge plugin and set the mysql hostname, username and password in the config file
1049
+        sudo sed -i -e "s/^provider =.*$/provider = quantum.plugins.linuxbridge.LinuxBridgePlugin.LinuxBridgePlugin/g" $QUANTUM_PLUGIN_INI_FILE
1050
+        sudo sed -i -e "s/^connection = sqlite$/#connection = sqlite/g" $QUANTUM_LB_CONFIG_FILE
1051
+        sudo sed -i -e "s/^#connection = mysql$/connection = mysql/g" $QUANTUM_LB_CONFIG_FILE
1052
+        sudo sed -i -e "s/^user = .*$/user = $MYSQL_USER/g" $QUANTUM_LB_CONFIG_FILE
1053
+        sudo sed -i -e "s/^pass = .*$/pass = $MYSQL_PASSWORD/g" $QUANTUM_LB_CONFIG_FILE
1054
+        sudo sed -i -e "s/^host = .*$/host = $MYSQL_HOST/g" $QUANTUM_LB_CONFIG_FILE
1041 1055
     fi
1042 1056
     if [[ -e $QUANTUM_DIR/etc/quantum.conf ]]; then
1043 1057
         sudo mv $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF_DIR/quantum.conf
... ...
@@ -1063,8 +1099,12 @@ if is_service_enabled q-agt; then
1063 1063
         fi
1064 1064
         sudo sed -i -e "s/^sql_connection =.*$/sql_connection = mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/ovs_quantum?charset=utf8/g" $QUANTUM_OVS_CONFIG_FILE
1065 1065
         screen_it q-agt "sleep 4; sudo python $QUANTUM_DIR/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py $QUANTUM_OVS_CONFIG_FILE -v"
1066
+    elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1067
+       # Start up the quantum <-> linuxbridge agent
1068
+       install_package bridge-utils
1069
+       sudo sed -i -e "s/^physical_interface = .*$/physical_interface = $QUANTUM_LB_PRIVATE_INTERFACE/g" $QUANTUM_LB_CONFIG_FILE
1070
+       screen_it q-agt "sleep 4; sudo python $QUANTUM_DIR/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py $QUANTUM_LB_CONFIG_FILE -v"
1066 1071
     fi
1067
-
1068 1072
 fi
1069 1073
 
1070 1074
 # Melange service
... ...
@@ -1535,6 +1575,11 @@ if is_service_enabled quantum; then
1535 1535
         add_nova_opt "libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtOpenVswitchDriver"
1536 1536
         add_nova_opt "linuxnet_interface_driver=nova.network.linux_net.LinuxOVSInterfaceDriver"
1537 1537
         add_nova_opt "quantum_use_dhcp=True"
1538
+    elif is_service_enabled q-svc && [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1539
+        add_nova_opt "libvirt_vif_type=ethernet"
1540
+        add_nova_opt "libvirt_vif_driver=nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"
1541
+        add_nova_opt "linuxnet_interface_driver=nova.network.linux_net.QuantumLinuxBridgeInterfaceDriver"
1542
+        add_nova_opt "quantum_use_dhcp=True"
1538 1543
     fi
1539 1544
 else
1540 1545
     add_nova_opt "network_manager=nova.network.manager.$NET_MAN"