'Returns RequestSpec object creating it from legacy dictionary.
FIXME(dulek): This should go away in early O as we stop supporting
backward compatibility with M.'

@classmethod
def from_primitives(cls, spec):

    spec = spec.copy()
    spec_obj = cls()
    vol_props = spec.pop('volume_properties', {})
    if (vol_props is not None):
        vol_props = VolumeProperties(**vol_props)
    spec_obj.volume_properties = vol_props
    if ('volume' in spec):
        vol = spec.pop('volume', {})
        vol.pop('name', None)
        if (vol is not None):
            vol = objects.Volume(**vol)
        spec_obj.volume = vol
    if ('volume_type' in spec):
        vol_type = spec.pop('volume_type', {})
        if (vol_type is not None):
            vol_type = objects.VolumeType(**vol_type)
        spec_obj.volume_type = vol_type
    spec.pop('resource_properties', None)
    for (k, v) in spec.items():
        setattr(spec_obj, k, v)
    return spec_obj
