xenserver: Generate system UUID for non-XenServer systems.
authorBen Pfaff <blp@nicira.com>
Wed, 5 Jan 2011 19:08:25 +0000 (11:08 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 7 Jan 2011 18:31:29 +0000 (10:31 -0800)
Currently the scripts in xensever/ are intended specifically for XenServer,
but supporting other distros seems like a worthy goal, so this is a step
in the right direction.

It would be good to be able to determine a suitable system-type and
system-version, but those are less important than system-id.

Signed-off-by: Patrick Mullaney <pm.mullaney@gmail.com>
[changed not to set xs-system-uuid on non-XenServer systems]
[whitespace changes]
[changed to handle missing uuidgen, suggested by Justin Pettit]
Signed-off-by: Ben Pfaff <blp@nicira.com>
xenserver/etc_init.d_openvswitch

index e404c60..49cd673 100755 (executable)
@@ -343,7 +343,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
 }