diff options
author | Gurucharan Shetty <gshetty@nicira.com> | 2013-05-19 00:05:09 -0700 |
---|---|---|
committer | Gurucharan Shetty <gshetty@nicira.com> | 2013-05-20 15:05:00 -0700 |
commit | 3f09392de97c5ce5817a82cb965d450b924cdbfc (patch) | |
tree | b5c4b8fd1ca8acc3214a6d8b96693913f475b09a /xenserver | |
parent | 72ad5389dfcc60d6e5eef723725f3281ee77f6bf (diff) |
ovs-xapi-sync: Handle multiple xs-network-uuids for xs 6.1.
For xenservers with version less than 6.1, interface reconfiguration
happened through interface-reconfigure scripts in this repo. In cases
where there were multiple xs-network-uuids for a single bridge,
interface-reconfigure script would add the network uuid associated
with the non-VLAN network as the first record. ovs-xapi-sync would
just blindly use the first record to create the bridge-id
But it looks like for xenserver 6.1, interface-reconfigure script
is no longer used and xenserver natively writes the xs-network-uuids.
So, in ovs-xapi-sync we no longer can copy the first value in
xs-network-uuids as bridge-id. This commit fetches the PIF record
for each xs-network-uuids and the network that does not have a VLAN
associated with it is copied over to bridge-id.
Bug #17090.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Diffstat (limited to 'xenserver')
-rwxr-xr-x | xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync index cb35e7a3..e14b319b 100755 --- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync +++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync @@ -88,6 +88,25 @@ def get_network_by_bridge(br_name): return None +# There are possibilities when multiple xs-network-uuids are set for a bridge. +# In cases like that, we should choose the bridge-id whose PIF does not have a +# VLAN associated with it. +def get_single_bridge_id(bridge_ids, default=None): + if not init_session(): + vlog.warn("Failed to get single bridge id from %s because" + "XAPI session could not be initialized" % bridge_ids) + return default + + for bridge_id in bridge_ids: + recs = session.xenapi.network.get_all_records_where('field "uuid"="%s"' % bridge_id) + if recs: + pifs = recs.values()[0]['PIFs'] + for pif in pifs: + rec = session.xenapi.PIF.get_record(pif) + if rec['VLAN'] == '-1': + return bridge_id + + return default # By default, the "bridge-id" external id in the Bridge table is the # same as "xs-network-uuids". This may be overridden by defining a @@ -286,6 +305,9 @@ def main(): bridge_id = nbd if bridge_id is None: bridge_id = row.external_ids.get("xs-network-uuids") + if bridge_id and len(bridge_id.split(";")) > 1: + bridge_ids = bridge_id.split(";") + bridge_id = get_single_bridge_id(bridge_ids, bridge_ids[0]) if bridge_id is not None: set_external_id(row, "bridge-id", bridge_id.split(";")[0]) |