def build_request_spec(ctxt, image, instances, instance_type=None):
 instance = instances[0]
 if (instance_type is None):
  if isinstance(instance, obj_instance.Instance):
   instance_type = instance.get_flavor()
  else:
   instance_type = flavors.extract_flavor(instance)
 if isinstance(instance, obj_instance.Instance):
  instance = obj_base.obj_to_primitive(instance)
  instance['system_metadata'] = dict(instance.get('system_metadata', {}))
 if isinstance(instance_type, objects.Flavor):
  instance_type = obj_base.obj_to_primitive(instance_type)
  try:
   flavors.save_flavor_info(instance.get('system_metadata', {}), instance_type)
  except KeyError:
   pass
 request_spec = {'image': (image or {}), 'instance_properties': instance, 'instance_type': instance_type, 'num_instances': len(instances)}
 return jsonutils.to_primitive(request_spec)

def build_request_spec ( ctxt , image , instances , instance_type = None ) : instance = instances [ 0 ] if ( instance_type is None ) : if isinstance ( instance , obj_instance . Instance ) : instance_type = instance . get_flavor ( ) else : instance_type = flavors . extract_flavor ( instance ) if isinstance ( instance , obj_instance . Instance ) : instance = obj_base . obj_to_primitive ( instance ) instance [ 'system_metadata' ] = dict ( instance . get ( 'system_metadata' , { } ) ) if isinstance ( instance_type , objects . Flavor ) : instance_type = obj_base . obj_to_primitive ( instance_type ) try : flavors . save_flavor_info ( instance . get ( 'system_metadata' , { } ) , instance_type ) except KeyError : pass request_spec = { 'image' : ( image or { } ) , 'instance_properties' : instance , 'instance_type' : instance_type , 'num_instances' : len ( instances ) } return jsonutils . to_primitive ( request_spec )
build a request_spec for the scheduler .