Comment 6 for bug 1885357

Revision history for this message
David Coronel (davecore) wrote :

I notice that my _get_volume_type volume creation flow code is different from the one in master[1]:

====================
    def _get_volume_type(self, context, volume_type,
                         source_volume, snapshot, image_volume_type_id):
        if volume_type:
            return volume_type
        identifier = collections.defaultdict(str)
        try:
            if source_volume:
                identifier = {'source': 'volume',
                              'id': source_volume['volume_type_id']}
            elif snapshot:
                identifier = {'source': 'snapshot',
                              'id': snapshot['volume_type_id']}
            elif image_volume_type_id:
                identifier = {'source': 'image',
                              'id': image_volume_type_id}
            elif CONF.default_volume_type:
                identifier = {'source': 'default volume type config',
                              'id': CONF.default_volume_type}
            if identifier:
                return objects.VolumeType.get_by_name_or_id(
                    context, identifier['id'])
        except (exception.VolumeTypeNotFound,
                exception.VolumeTypeNotFoundByName,
                exception.InvalidVolumeType):
            LOG.exception("Failed to find volume type from "
                          "source %(source)s, identifier %(id)s", identifier)
        return None
====================

[1] https://github.com/openstack/cinder/blob/master/cinder/volume/flows/api/create_volume.py#L352