def get_vlanid_and_vswitch_for_portgroup(session, pg_name, cluster=None):
 host_mor = vm_util.get_host_ref(session, cluster)
 port_grps_on_host_ret = session._call_method(vutil, 'get_object_property', host_mor, 'config.network.portgroup')
 if (not port_grps_on_host_ret):
  msg = _('ESX SOAP server returned an empty port group for the host system in its response')
  LOG.error(msg)
  raise exception.NovaException(msg)
 port_grps_on_host = port_grps_on_host_ret.HostPortGroup
 for p_gp in port_grps_on_host:
  if (p_gp.spec.name == pg_name):
   p_grp_vswitch_name = p_gp.spec.vswitchName
   return (p_gp.spec.vlanId, p_grp_vswitch_name)
 return (None, None)

def get_vlanid_and_vswitch_for_portgroup ( session , pg_name , cluster = None ) : host_mor = vm_util . get_host_ref ( session , cluster ) port_grps_on_host_ret = session . _call_method ( vutil , 'get_object_property' , host_mor , 'config.network.portgroup' ) if ( not port_grps_on_host_ret ) : msg = _ ( 'ESX SOAP server returned an empty port group for the host system in its response' ) LOG . error ( msg ) raise exception . NovaException ( msg ) port_grps_on_host = port_grps_on_host_ret . HostPortGroup for p_gp in port_grps_on_host : if ( p_gp . spec . name == pg_name ) : p_grp_vswitch_name = p_gp . spec . vswitchName return ( p_gp . spec . vlanId , p_grp_vswitch_name ) return ( None , None )
get the vlan id and vswicth associated with the port group .