Browse code

Merge "xenapi: xe network-attach for OVS bridge creation"

Jenkins authored on 2013/07/16 00:03:22
Showing 3 changed files
... ...
@@ -250,3 +250,21 @@ function destroy_all_vifs_of()
250 250
     done
251 251
     unset IFS
252 252
 }
253
+
254
+function have_multiple_hosts() {
255
+    xe host-list --minimal | grep -q ","
256
+}
257
+
258
+function attach_network() {
259
+    local bridge_or_net_name
260
+
261
+    bridge_or_net_name="$1"
262
+
263
+    local net
264
+    local host
265
+
266
+    net=$(_network_uuid "$bridge_or_net_name")
267
+    host=$(xe host-list --minimal)
268
+
269
+    xe network-attach uuid=$net host-uuid=$host
270
+}
... ...
@@ -50,6 +50,15 @@ xe_min()
50 50
 
51 51
 cd $THIS_DIR
52 52
 
53
+# Die if multiple hosts listed
54
+if have_multiple_hosts; then
55
+    cat >&2 << EOF
56
+ERROR: multiple hosts found. This might mean that the XenServer is a member
57
+of a pool - Exiting.
58
+EOF
59
+    exit 1
60
+fi
61
+
53 62
 # Install plugins
54 63
 
55 64
 ## Nova plugins
... ...
@@ -256,7 +265,7 @@ $THIS_DIR/build_xva.sh "$GUEST_NAME"
256 256
 # is created by XenServer). This is required for Neutron. Also pass that as a
257 257
 # kernel parameter for DomU
258 258
 if is_service_enabled neutron; then
259
-    add_interface "$GUEST_NAME" "$XEN_INT_BRIDGE_OR_NET_NAME" $XEN_INT_DEV_NR
259
+    attach_network "$XEN_INT_BRIDGE_OR_NET_NAME"
260 260
 
261 261
     XEN_INTEGRATION_BRIDGE=$(bridge_for "$XEN_INT_BRIDGE_OR_NET_NAME")
262 262
     append_kernel_cmdline \
... ...
@@ -35,7 +35,6 @@ GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
35 35
 MGT_DEV_NR=0
36 36
 VM_DEV_NR=1
37 37
 PUB_DEV_NR=2
38
-XEN_INT_DEV_NR=3
39 38
 
40 39
 # Host Interface, i.e. the interface on the nova vm you want to expose the
41 40
 # services on. Usually the device connected to the management network or the