def get_subnet_association(subnets, region=None, key=None, keyid=None, profile=None):
 try:
  conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
  subnets = conn.get_all_subnets(subnet_ids=subnets)
 except BotoServerError as e:
  return {'error': salt.utils.boto.get_error(e)}
 vpc_ids = set()
 for subnet in subnets:
  log.debug('examining subnet id: {0} for vpc_id'.format(subnet.id))
  if (subnet in subnets):
   log.debug('subnet id: {0} is associated with vpc id: {1}'.format(subnet.id, subnet.vpc_id))
   vpc_ids.add(subnet.vpc_id)
 if (not vpc_ids):
  return {'vpc_id': None}
 elif (len(vpc_ids) == 1):
  return {'vpc_id': vpc_ids.pop()}
 else:
  return {'vpc_ids': list(vpc_ids)}

def get_subnet_association ( subnets , region = None , key = None , keyid = None , profile = None ) : try : conn = _get_conn ( region = region , key = key , keyid = keyid , profile = profile ) subnets = conn . get_all_subnets ( subnet_ids = subnets ) except BotoServerError as e : return { 'error' : salt . utils . boto . get_error ( e ) } vpc_ids = set ( ) for subnet in subnets : log . debug ( 'examining subnet id: {0} for vpc_id' . format ( subnet . id ) ) if ( subnet in subnets ) : log . debug ( 'subnet id: {0} is associated with vpc id: {1}' . format ( subnet . id , subnet . vpc_id ) ) vpc_ids . add ( subnet . vpc_id ) if ( not vpc_ids ) : return { 'vpc_id' : None } elif ( len ( vpc_ids ) == 1 ) : return { 'vpc_id' : vpc_ids . pop ( ) } else : return { 'vpc_ids' : list ( vpc_ids ) }
given a subnet or list of subnets .