'Returns a legacy request_spec dict from the RequestSpec object.
Since we need to manage backwards compatibility and rolling upgrades
within our RPC API, we need to accept to provide an helper for
primitiving the right RequestSpec object into a legacy dict until we
drop support for old Scheduler RPC API versions.
If you don\'t understand why this method is needed, please don\'t use it.'

def to_legacy_request_spec_dict(self):

    req_spec = {}
    if (not self.obj_attr_is_set('num_instances')):
        req_spec['num_instances'] = self.fields['num_instances'].default
    else:
        req_spec['num_instances'] = self.num_instances
    req_spec['image'] = self._to_legacy_image()
    req_spec['instance_properties'] = self._to_legacy_instance()
    if self.obj_attr_is_set('flavor'):
        req_spec['instance_type'] = self.flavor
    else:
        req_spec['instance_type'] = {}
    return req_spec
