def address_is_associated_with_device(ec2, address, device_id, isinstance=True):
 address = ec2.get_all_addresses(address.public_ip)
 if address:
  if isinstance:
   return (address and (address[0].instance_id == device_id))
  else:
   return (address and (address[0].network_interface_id == device_id))
 return False

def address_is_associated_with_device ( ec2 , address , device_id , isinstance = True ) : address = ec2 . get_all_addresses ( address . public_ip ) if address : if isinstance : return ( address and ( address [ 0 ] . instance_id == device_id ) ) else : return ( address and ( address [ 0 ] . network_interface_id == device_id ) ) return False
check if the elastic ip is currently associated with the device .