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:
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:
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):
# 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):
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)