'Gets an acceptable default image disk_format based on the schema.'

def _get_image_create_disk_format_default(self, context):

    preferred_disk_formats = (fields.DiskFormat.QCOW2, fields.DiskFormat.VHD, fields.DiskFormat.VMDK, fields.DiskFormat.RAW)
    image_schema = self._client.call(context, 2, 'get', 'image', controller='schemas')
    disk_format_schema = (image_schema.raw()['properties'].get('disk_format') if image_schema else {})
    if (disk_format_schema and ('enum' in disk_format_schema)):
        supported_disk_formats = disk_format_schema['enum']
        for preferred_format in preferred_disk_formats:
            if (preferred_format in supported_disk_formats):
                return preferred_format
        LOG.debug('Unable    to    find    a    preferred    disk_format    for    image    creation    with    the    Image    Service    v2    API.    Using:    %s', supported_disk_formats[0])
        return supported_disk_formats[0]
    LOG.warning('Unable    to    determine    disk_format    schema    from    the    Image    Service    v2    API.    Defaulting    to    %(preferred_disk_format)s.', {'preferred_disk_format': preferred_disk_formats[0]})
    return preferred_disk_formats[0]
