xenapi: xe network-attach for OVS bridge creation
For Neutron we need an additional OVS bridge to be present. The xe
network-create command did not create the bridge immediately. A
workaround was applied to attach a network interface to that network,
forcing xapi to create the underlying OVS bridge. It turned out, that
the xe network-attach command could be used instead, so the workaround
is removed and replaced with the proper solution by this patch.
Fixes bug 1197305
Change-Id: I10cc763531b71238f0bc12a12de985f8f35d7e27
diff --git a/tools/xen/functions b/tools/xen/functions
index 4e37554..fd14075 100644
--- a/tools/xen/functions
+++ b/tools/xen/functions
@@ -250,3 +250,21 @@
done
unset IFS
}
+
+function have_multiple_hosts() {
+ xe host-list --minimal | grep -q ","
+}
+
+function attach_network() {
+ local bridge_or_net_name
+
+ bridge_or_net_name="$1"
+
+ local net
+ local host
+
+ net=$(_network_uuid "$bridge_or_net_name")
+ host=$(xe host-list --minimal)
+
+ xe network-attach uuid=$net host-uuid=$host
+}
diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh
index 21aa729..6eb3013 100755
--- a/tools/xen/install_os_domU.sh
+++ b/tools/xen/install_os_domU.sh
@@ -50,6 +50,15 @@
cd $THIS_DIR
+# Die if multiple hosts listed
+if have_multiple_hosts; then
+ cat >&2 << EOF
+ERROR: multiple hosts found. This might mean that the XenServer is a member
+of a pool - Exiting.
+EOF
+ exit 1
+fi
+
# Install plugins
## Nova plugins
@@ -256,7 +265,7 @@
# is created by XenServer). This is required for Neutron. Also pass that as a
# kernel parameter for DomU
if is_service_enabled neutron; then
- add_interface "$GUEST_NAME" "$XEN_INT_BRIDGE_OR_NET_NAME" $XEN_INT_DEV_NR
+ attach_network "$XEN_INT_BRIDGE_OR_NET_NAME"
XEN_INTEGRATION_BRIDGE=$(bridge_for "$XEN_INT_BRIDGE_OR_NET_NAME")
append_kernel_cmdline \
diff --git a/tools/xen/xenrc b/tools/xen/xenrc
index 97c0930..03b30ac 100644
--- a/tools/xen/xenrc
+++ b/tools/xen/xenrc
@@ -35,7 +35,6 @@
MGT_DEV_NR=0
VM_DEV_NR=1
PUB_DEV_NR=2
-XEN_INT_DEV_NR=3
# Host Interface, i.e. the interface on the nova vm you want to expose the
# services on. Usually the device connected to the management network or the