From: Ben Pfaff Date: Fri, 29 May 2009 22:15:53 +0000 (-0700) Subject: xenserver: Put XenServer network UUIDs into ovs-vswitchd.conf. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0af00a8152f1c93c0cafbd02a1da949b3cb7993e;p=openvswitch xenserver: Put XenServer network UUIDs into ovs-vswitchd.conf. vNetManager needs the UUIDs of the XenServer networks represented by a bridge. interface-reconfigure has all the necessary information to figure this out, so make it add them to the configuration file. --- diff --git a/xenserver/opt_xensource_libexec_interface-reconfigure b/xenserver/opt_xensource_libexec_interface-reconfigure index b0dac5af..fab85135 100755 --- a/xenserver/opt_xensource_libexec_interface-reconfigure +++ b/xenserver/opt_xensource_libexec_interface-reconfigure @@ -302,9 +302,9 @@ class DatabaseCache(object): return pifs[0] - def get_pif_by_record(self, record): + def get_pifs_by_record(self, record): """record is partial pif record. - Get the pif whose record matches. + Get the pif(s) whose record matches. """ def match(pifrec): for key in record: @@ -312,9 +312,15 @@ class DatabaseCache(object): return False return True - pifs = map(lambda (ref,rec): ref, - filter(lambda (ref,rec): match(rec), - self.__pifs.items())) + return map(lambda (ref,rec): ref, + filter(lambda (ref,rec): match(rec), + self.__pifs.items())) + + def get_pif_by_record(self, record): + """record is partial pif record. + Get the pif whose record matches. + """ + pifs = self.get_pifs_by_record(record) if len(pifs) == 0: raise Error("No matching PIF \"%s\"" % str(record)) elif len(pifs) > 1: @@ -366,6 +372,8 @@ class DatabaseCache(object): if self.__networks.has_key(network): return self.__networks[network] raise Error("Unknown network \"%s\"" % network) + def get_all_networks(self): + return self.__networks def get_bond_record(self, bond): if self.__bonds.has_key(bond): @@ -852,6 +860,18 @@ def action_up(pif): # implicitly being asked to take them down.) del_ports = add_ports + physdevs + bond_masters + # What networks does this datapath carry? + # + # - The network corresponding to the datapath's PIF. + # + # - The networks corresponding to any VLANs attached to the + # datapath's PIF. + network_uuids = [] + for nwpif in db.get_pifs_by_record({'device': pifrec['device'], + 'host': pifrec['host']}): + net = db.get_pif_record(nwpif)['network'] + network_uuids += [db.get_network_record(net)['uuid']] + # Now modify the ovs-vswitchd config file. argv = [] for port in set(del_ports): @@ -876,6 +896,9 @@ def action_up(pif): os.unlink("%s/br-%s" % (vswitch_config_dir, bridge)) except OSError: pass + argv += ['--del-match=bridge.%s.xs-network-uuids=*' % datapath] + argv += ['--add=bridge.%s.xs-network-uuids=%s' % (datapath, uuid) + for uuid in set(network_uuids)] if bond_master: argv += configure_bond(bond_master) modify_config(argv)