xenserver: Add defaults for ENABLE_BRCOMPAT, ENABLE_FAKE_PROC_NET.
[sliver-openvswitch.git] / xenserver / etc_init.d_openvswitch
index e404c60..fc89a3e 100755 (executable)
@@ -57,11 +57,13 @@ else
     }
 fi
 
-. /etc/xensource-inventory
+test -e /etc/xensource-inventory && . /etc/xensource-inventory
 test -e /etc/sysconfig/openvswitch && . /etc/sysconfig/openvswitch
+if test -e /etc/xensource/network.conf; then
+    NETWORK_MODE=$(cat /etc/xensource/network.conf)
+fi
 
-NETWORK_MODE=$(cat /etc/xensource/network.conf)
-case $NETWORK_MODE in
+case ${NETWORK_MODE:=openvswitch} in
     vswitch|openvswitch)
         ;;
     bridge)
@@ -74,14 +76,19 @@ case $NETWORK_MODE in
 esac
 
 # General config variables in /etc/sysconfig/openvswitch
-if test "$PRODUCT_VERSION" = "5.5.0"; then
-    # XenServer 5.5.0 needs ovs-brcompatd and /proc/net simulation.
+if [ -f /etc/xensource-inventory ]; then
+    if test "$PRODUCT_VERSION" = "5.5.0"; then
+        # XenServer 5.5.0 needs ovs-brcompatd and /proc/net simulation.
+        : ${ENABLE_BRCOMPAT:=y}
+        : ${ENABLE_FAKE_PROC_NET:=y}
+    else
+        # Later versions don't need them.
+        : ${ENABLE_BRCOMPAT:=n}
+        : ${ENABLE_FAKE_PROC_NET:=n}
+    fi
+else
     : ${ENABLE_BRCOMPAT:=y}
     : ${ENABLE_FAKE_PROC_NET:=y}
-else
-    # Later versions don't need them.
-    : ${ENABLE_BRCOMPAT:=n}
-    : ${ENABLE_FAKE_PROC_NET:=n}
 fi
 : ${ENABLE_MONITOR:=y}
 : ${FORCE_COREFILES:=y}
@@ -343,7 +350,17 @@ function set_system_ids {
             external-ids:system-id="$INSTALLATION_UUID" \
             external-ids:xs-system-uuid="$INSTALLATION_UUID"
     else
-        action "Configuring Open vSwitch system IDs" false
+       if test -f /etc/openvswitch/install_uuid.conf; then
+            . /etc/openvswitch/install_uuid.conf
+       elif INSTALLATION_UUID=`uuidgen`; then
+           echo "INSTALLATION_UUID=$INSTALLATION_UUID" > /etc/openvswitch/install_uuid.conf
+       else
+           log_failure_msg "missing uuidgen, could not generate system UUID"
+           return
+        fi
+        $vsctl --no-wait --timeout=5 set Open_vSwitch . \
+            external-ids:system-id="$INSTALLATION_UUID"
+        action "Configuring Open vSwitch system IDs" true
     fi
 }
 
@@ -397,10 +414,12 @@ function start {
         start_brcompatd
     fi
 
-    # Start daemon to monitor external ids
-    PYTHONPATH=/usr/share/openvswitch/python \
-               /usr/share/openvswitch/scripts/ovs-external-ids \
-               --pidfile --detach $monitor_opt "$VSWITCHD_OVSDB_SERVER"
+    if [ -f /etc/xensource-inventory ]; then
+        # Start daemon to monitor external ids
+        PYTHONPATH=/usr/share/openvswitch/python \
+                   /usr/share/openvswitch/scripts/ovs-external-ids \
+                   --pidfile --detach $monitor_opt "$VSWITCHD_OVSDB_SERVER"
+    fi
 
     touch /var/lock/subsys/openvswitch
 }