def get_unassociated_eip_address(domain='standard', region=None, key=None, keyid=None, profile=None):
 eip = None
 for address in get_all_eip_addresses(region=region, key=key, keyid=keyid, profile=profile):
  address_info = get_eip_address_info(addresses=address, region=region, key=key, keyid=keyid, profile=profile)[0]
  if address_info['instance_id']:
   log.debug('{0} is already associated with the instance {1}'.format(address, address_info['instance_id']))
   continue
  if address_info['network_interface_id']:
   log.debug('{0} is already associated with the network interface {1}'.format(address, address_info['network_interface_id']))
   continue
  if (address_info['domain'] == domain):
   log.debug("The first unassociated EIP address in the domain '{0}' is {1}".format(domain, address))
   eip = address
   break
 if (not eip):
  log.debug('No unassociated Elastic IP found!')
 return eip

def get_unassociated_eip_address ( domain = 'standard' , region = None , key = None , keyid = None , profile = None ) : eip = None for address in get_all_eip_addresses ( region = region , key = key , keyid = keyid , profile = profile ) : address_info = get_eip_address_info ( addresses = address , region = region , key = key , keyid = keyid , profile = profile ) [ 0 ] if address_info [ 'instance_id' ] : log . debug ( '{0} is already associated with the instance {1}' . format ( address , address_info [ 'instance_id' ] ) ) continue if address_info [ 'network_interface_id' ] : log . debug ( '{0} is already associated with the network interface {1}' . format ( address , address_info [ 'network_interface_id' ] ) ) continue if ( address_info [ 'domain' ] == domain ) : log . debug ( "The first unassociated EIP address in the domain '{0}' is {1}" . format ( domain , address ) ) eip = address break if ( not eip ) : log . debug ( 'No unassociated Elastic IP found!' ) return eip
return the first unassociated eip domain indicates whether the address is a ec2 address or a vpc address .