def get_metadata_from_object(instance):
 metadata = {'display_name': instance.name, 'name': getattr(instance, 'OS-EXT-SRV-ATTR:instance_name', u''), 'instance_type': (instance.flavor['id'] if instance.flavor else None), 'host': instance.hostId, 'image_ref': (instance.image['id'] if instance.image else None)}
 if (instance.image and instance.image.get('links')):
  metadata['image_ref_url'] = instance.image['links'][0]['href']
 else:
  metadata['image_ref_url'] = None
 for name in INSTANCE_PROPERTIES:
  metadata[name] = getattr(instance, name, u'')
 return metadata

def get_metadata_from_object ( instance ) : metadata = { 'display_name' : instance . name , 'name' : getattr ( instance , 'OS-EXT-SRV-ATTR:instance_name' , u'' ) , 'instance_type' : ( instance . flavor [ 'id' ] if instance . flavor else None ) , 'host' : instance . hostId , 'image_ref' : ( instance . image [ 'id' ] if instance . image else None ) } if ( instance . image and instance . image . get ( 'links' ) ) : metadata [ 'image_ref_url' ] = instance . image [ 'links' ] [ 0 ] [ 'href' ] else : metadata [ 'image_ref_url' ] = None for name in INSTANCE_PROPERTIES : metadata [ name ] = getattr ( instance , name , u'' ) return metadata
return a metadata dictionary for the instance .