def ListInstances(region, instances=None, node_types=[], states=[], names=[]):
 ec2 = _Connect(region)
 filters = {}
 if node_types:
  for i in node_types:
   assert (i in kValidNodeTypes), ('"%s" not in the list of valid node types: %s' % (i, ', '.join(kValidNodeTypes)))
  filters['tag:NodeType'] = node_types
 if names:
  filters['tag:Name'] = names
 if states:
  for i in states:
   assert (i in kValidStateNames), ('"%s" not in the list of valid state names: %s' % (i, ', '.join(kValidStateNames)))
  filters['instance-state-name'] = states
 matches = []
 for r in ec2.get_all_instances(instance_ids=instances, filters=filters):
  matches.extend(r.instances)
 return matches

def ListInstances ( region , instances = None , node_types = [ ] , states = [ ] , names = [ ] ) : ec2 = _Connect ( region ) filters = { } if node_types : for i in node_types : assert ( i in kValidNodeTypes ) , ( '"%s" not in the list of valid node types: %s' % ( i , ', ' . join ( kValidNodeTypes ) ) ) filters [ 'tag:NodeType' ] = node_types if names : filters [ 'tag:Name' ] = names if states : for i in states : assert ( i in kValidStateNames ) , ( '"%s" not in the list of valid state names: %s' % ( i , ', ' . join ( kValidStateNames ) ) ) filters [ 'instance-state-name' ] = states matches = [ ] for r in ec2 . get_all_instances ( instance_ids = instances , filters = filters ) : matches . extend ( r . instances ) return matches
list instance dns names in a given region .