X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=xenserver%2Fusr_share_openvswitch_scripts_ovs-external-ids;h=07303e3eabd29792c9c75a6b2a7b3491bba08f32;hb=fb3ea74b114e7c1089dfb8851d0b5fb18aa9a6ce;hp=13c644f0bdf5ab47290744c3eb65e37e28c209c1;hpb=7ed7b619e31c7c48c4f6d0dfb411173be96924c5;p=openvswitch diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-external-ids b/xenserver/usr_share_openvswitch_scripts_ovs-external-ids index 13c644f0..07303e3e 100755 --- a/xenserver/usr_share_openvswitch_scripts_ovs-external-ids +++ b/xenserver/usr_share_openvswitch_scripts_ovs-external-ids @@ -88,26 +88,24 @@ def get_bridge_id(br_name, default=None): # same as "xs-vif-uuid". This may be overridden by defining a # "nicira-iface-id" key in the "other_config" field of the VIF # record of XAPI. -def get_iface_id(if_name, default=None): +def get_iface_id(if_name, xs_vif_uuid): if not if_name.startswith("vif"): - return default - - domain,device = if_name.strip("vif").split(".") + # Treat whatever was passed into 'xs_vif_uuid' as a default + # value for non-VIFs. + return xs_vif_uuid if not init_session(): s_log.warning("Failed to get interface id %s because" " XAPI session could not be initialized" % if_name) - return default - - for n in session.xenapi.VM.get_all(): - if session.xenapi.VM.get_domid(n) == domain: - vifs = session.xenapi.VM.get_VIFs(n) - for vif in vifs: - rec = session.xenapi.VIF.get_record(vif) - if rec['device'] == device: - return rec['other_config'].get('nicira-iface-id', default) - return None + return xs_vif_uuid + try: + vif = session.xenapi.VIF.get_by_uuid(xs_vif_uuid) + rec = session.xenapi.VIF.get_record(vif) + return rec['other_config'].get('nicira-iface-id', xs_vif_uuid) + except XenAPI.Failure: + s_log.warning("Could not find XAPI entry for VIF %s" % if_name) + return xs_vif_uuid def set_external_id(table, record, key, value): col = 'external-ids:"' + key + '"="' + value + '"'