def get_vswitch_for_vlan_interface(session, vlan_interface, cluster=None):
 host_mor = vm_util.get_host_ref(session, cluster)
 vswitches_ret = session._call_method(vutil, 'get_object_property', host_mor, 'config.network.vswitch')
 if (not vswitches_ret):
  return
 vswitches = vswitches_ret.HostVirtualSwitch
 for elem in vswitches:
  try:
   for nic_elem in elem.pnic:
    if (str(nic_elem).split('-')[(-1)].find(vlan_interface) != (-1)):
     return elem.name
  except AttributeError:
   pass

def get_vswitch_for_vlan_interface ( session , vlan_interface , cluster = None ) : host_mor = vm_util . get_host_ref ( session , cluster ) vswitches_ret = session . _call_method ( vutil , 'get_object_property' , host_mor , 'config.network.vswitch' ) if ( not vswitches_ret ) : return vswitches = vswitches_ret . HostVirtualSwitch for elem in vswitches : try : for nic_elem in elem . pnic : if ( str ( nic_elem ) . split ( '-' ) [ ( - 1 ) ] . find ( vlan_interface ) != ( - 1 ) ) : return elem . name except AttributeError : pass
gets the vswitch associated with the physical network adapter with the name supplied .