def find_device(ec2, module, device_id, isinstance=True):
 if isinstance:
  try:
   reservations = ec2.get_all_reservations(instance_ids=[device_id])
  except boto.exception.EC2ResponseError as e:
   module.fail_json(msg=str(e))
  if (len(reservations) == 1):
   instances = reservations[0].instances
   if (len(instances) == 1):
    return instances[0]
 else:
  try:
   interfaces = ec2.get_all_network_interfaces(network_interface_ids=[device_id])
  except boto.exception.EC2ResponseError as e:
   module.fail_json(msg=str(e))
  if (len(interfaces) == 1):
   return interfaces[0]
 raise EIPException(('could not find instance' + device_id))

def find_device ( ec2 , module , device_id , isinstance = True ) : if isinstance : try : reservations = ec2 . get_all_reservations ( instance_ids = [ device_id ] ) except boto . exception . EC2ResponseError as e : module . fail_json ( msg = str ( e ) ) if ( len ( reservations ) == 1 ) : instances = reservations [ 0 ] . instances if ( len ( instances ) == 1 ) : return instances [ 0 ] else : try : interfaces = ec2 . get_all_network_interfaces ( network_interface_ids = [ device_id ] ) except boto . exception . EC2ResponseError as e : module . fail_json ( msg = str ( e ) ) if ( len ( interfaces ) == 1 ) : return interfaces [ 0 ] raise EIPException ( ( 'could not find instance' + device_id ) )
find a device in zenoss .