xenserver: Fix --force up/down behavior in a resource pool.
authorBen Pfaff <blp@nicira.com>
Wed, 13 May 2009 21:15:58 +0000 (14:15 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 13 May 2009 21:15:58 +0000 (14:15 -0700)
The PIFs key of a network lists one PIF for each member of the pool, not
one PIF per bond or whatever I had in mind.  So we need to iterate over
all the PIFs in the network and find the one for our current host.

xenserver/opt_xensource_libexec_interface-reconfigure

index 70125374d9de12cb239bb1f6b1560a752802acb0..d30beec2b7430fd6d3fb66c966de17cb3ed26001 100755 (executable)
@@ -315,16 +315,13 @@ class DatabaseCache(object):
         answer = None
         for network in networks:
             nwrec = self.get_network_record(network)
-            pif_uuids = nwrec['PIFs']
-            if len(pif_uuids) != 1:
-                continue
-            pif = pif_uuids[0]
-            pifrec = self.get_pif_record(pif)
-            if pifrec['host'] != host:
-                continue
-            if answer:
-                raise Error("Multiple PIFs on %s for network %s" % (host, bridge))
-            answer = pif
+            for pif in nwrec['PIFs']:
+                pifrec = self.get_pif_record(pif)
+                if pifrec['host'] != host:
+                    continue
+                if answer:
+                    raise Error("Multiple PIFs on %s for network %s" % (host, bridge))
+                answer = pif
         if not answer:
             raise Error("No PIF on %s for network %s" % (host, bridge))
         return answer