Browse code

Adds LinuxBridge plugin setup support.

Change-Id: I4c3250ac9bd3f3eb466a211bcaddaf1855d6ef8d

Shweta P authored on 2012/04/05 05:17:40
Showing 1 changed files
... ...
@@ -990,14 +990,36 @@ fi
990 990
 
991 991
 # Quantum
992 992
 # -------
993
-
994
-# Quantum service
995
-if is_service_enabled q-svc; then
993
+if is_service_enabled quantum; then
994
+    # Put config files in /etc/quantum for everyone to find
996 995
     QUANTUM_CONF_DIR=/etc/quantum
997 996
     if [[ ! -d $QUANTUM_CONF_DIR ]]; then
998 997
         sudo mkdir -p $QUANTUM_CONF_DIR
999 998
     fi
1000 999
     sudo chown `whoami` $QUANTUM_CONF_DIR
1000
+
1001
+    # Set default values when using Linux Bridge plugin
1002
+    if [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1003
+        # set the config file
1004
+        QUANTUM_LB_CONF_DIR=$QUANTUM_CONF_DIR/plugins/linuxbridge
1005
+        mkdir -p $QUANTUM_LB_CONF_DIR
1006
+        QUANTUM_LB_CONFIG_FILE=$QUANTUM_LB_CONF_DIR/linuxbridge_conf.ini
1007
+        # must remove this file from existing location, otherwise Quantum will prefer it
1008
+        if [[ -e $QUANTUM_DIR/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini ]]; then
1009
+            sudo mv $QUANTUM_DIR/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini $QUANTUM_LB_CONFIG_FILE
1010
+        fi
1011
+        #set the default network interface
1012
+        QUANTUM_LB_PRIVATE_INTERFACE=${QUANTUM_LB_PRIVATE_INTERFACE:-$GUEST_INTERFACE_DEFAULT}
1013
+    fi
1014
+fi
1015
+# Quantum service
1016
+if is_service_enabled q-svc; then
1017
+    QUANTUM_PLUGIN_INI_FILE=$QUANTUM_CONF_DIR/plugins.ini
1018
+    # must remove this file from existing location, otherwise Quantum will prefer it
1019
+    if [[ -e $QUANTUM_DIR/etc/plugins.ini ]]; then
1020
+        sudo mv $QUANTUM_DIR/etc/plugins.ini $QUANTUM_PLUGIN_INI_FILE
1021
+    fi
1022
+
1001 1023
     if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
1002 1024
         # Install deps
1003 1025
         # FIXME add to files/apts/quantum, but don't install if not needed!
... ...
@@ -1016,13 +1038,27 @@ if is_service_enabled q-svc; then
1016 1016
             echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin."
1017 1017
             exit 1
1018 1018
         fi
1019
-        QUANTUM_PLUGIN_INI_FILE=$QUANTUM_CONF_DIR/plugins.ini
1020
-        # must remove this file from existing location, otherwise Quantum will prefer it
1021
-        if [[ -e $QUANTUM_DIR/etc/plugins.ini ]]; then
1022
-            sudo mv $QUANTUM_DIR/etc/plugins.ini $QUANTUM_PLUGIN_INI_FILE
1023
-        fi
1024 1019
         # Make sure we're using the openvswitch plugin
1025 1020
         sudo sed -i -e "s/^provider =.*$/provider = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin/g" $QUANTUM_PLUGIN_INI_FILE
1021
+    elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1022
+        # Install deps
1023
+        # FIXME add to files/apts/quantum, but don't install if not needed!
1024
+        install_package python-configobj
1025
+        # Create database for the plugin/agent
1026
+        if is_service_enabled mysql; then
1027
+            mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS quantum_linux_bridge;'
1028
+            mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE IF NOT EXISTS quantum_linux_bridge;'
1029
+        else
1030
+            echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin."
1031
+            exit 1
1032
+        fi
1033
+        # Make sure we're using the linuxbridge plugin and set the mysql hostname, username and password in the config file
1034
+        sudo sed -i -e "s/^provider =.*$/provider = quantum.plugins.linuxbridge.LinuxBridgePlugin.LinuxBridgePlugin/g" $QUANTUM_PLUGIN_INI_FILE
1035
+        sudo sed -i -e "s/^connection = sqlite$/#connection = sqlite/g" $QUANTUM_LB_CONFIG_FILE
1036
+        sudo sed -i -e "s/^#connection = mysql$/connection = mysql/g" $QUANTUM_LB_CONFIG_FILE
1037
+        sudo sed -i -e "s/^user = .*$/user = $MYSQL_USER/g" $QUANTUM_LB_CONFIG_FILE
1038
+        sudo sed -i -e "s/^pass = .*$/pass = $MYSQL_PASSWORD/g" $QUANTUM_LB_CONFIG_FILE
1039
+        sudo sed -i -e "s/^host = .*$/host = $MYSQL_HOST/g" $QUANTUM_LB_CONFIG_FILE
1026 1040
     fi
1027 1041
     if [[ -e $QUANTUM_DIR/etc/quantum.conf ]]; then
1028 1042
         sudo mv $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF_DIR/quantum.conf
... ...
@@ -1048,8 +1084,12 @@ if is_service_enabled q-agt; then
1048 1048
         fi
1049 1049
         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
1050 1050
         screen_it q-agt "sleep 4; sudo python $QUANTUM_DIR/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py $QUANTUM_OVS_CONFIG_FILE -v"
1051
+    elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1052
+       # Start up the quantum <-> linuxbridge agent
1053
+       install_package bridge-utils
1054
+       sudo sed -i -e "s/^physical_interface = .*$/physical_interface = $QUANTUM_LB_PRIVATE_INTERFACE/g" $QUANTUM_LB_CONFIG_FILE
1055
+       screen_it q-agt "sleep 4; sudo python $QUANTUM_DIR/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py $QUANTUM_LB_CONFIG_FILE -v"
1051 1056
     fi
1052
-
1053 1057
 fi
1054 1058
 
1055 1059
 # Melange service
... ...
@@ -1520,6 +1560,11 @@ if is_service_enabled quantum; then
1520 1520
         add_nova_opt "libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtOpenVswitchDriver"
1521 1521
         add_nova_opt "linuxnet_interface_driver=nova.network.linux_net.LinuxOVSInterfaceDriver"
1522 1522
         add_nova_opt "quantum_use_dhcp=True"
1523
+    elif is_service_enabled q-svc && [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1524
+        add_nova_opt "libvirt_vif_type=ethernet"
1525
+        add_nova_opt "libvirt_vif_driver=nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"
1526
+        add_nova_opt "linuxnet_interface_driver=nova.network.linux_net.QuantumLinuxBridgeInterfaceDriver"
1527
+        add_nova_opt "quantum_use_dhcp=True"
1523 1528
     fi
1524 1529
 else
1525 1530
     add_nova_opt "network_manager=nova.network.manager.$NET_MAN"