2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-19 14:37:21 +00:00

xenserver: Hoist identical bridge and vswitch functions into common code.

The previous commit made pif_bridge_name() in the bridge and vswitch
versions of interface-reconfigure functionally identical, so this commit
hoists them into a single common implementation in InterfaceReconfigure.py.

pif_is_bridged() also comes along for the ride because it is also generic
and because it is logically related.  Only the bridge code uses it at the
moment.

Suggested-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Ben Pfaff
2010-02-23 09:47:31 -08:00
parent 6987c81c05
commit 96c7918c40
3 changed files with 28 additions and 44 deletions

View File

@@ -637,6 +637,34 @@ def pif_netdev_name(pif):
else:
return pifrec['device']
#
# Bridges
#
def pif_is_bridged(pif):
pifrec = db().get_pif_record(pif)
nwrec = db().get_network_record(pifrec['network'])
if nwrec['bridge']:
# TODO: sanity check that nwrec['bridgeless'] != 'true'
return True
else:
# TODO: sanity check that nwrec['bridgeless'] == 'true'
return False
def pif_bridge_name(pif):
"""Return the bridge name of a pif.
PIF must be a bridged PIF."""
pifrec = db().get_pif_record(pif)
nwrec = db().get_network_record(pifrec['network'])
if nwrec['bridge']:
return nwrec['bridge']
else:
raise Error("PIF %(uuid)s does not have a bridge name" % pifrec)
#
# Bonded PIFs
#