

def swift_temp_url(self, image_info):
    "Generate a no-auth Swift temporary URL.\n\n        This function will generate (or return the cached one if temp URL\n        cache is enabled) the temporary Swift URL using the image\n        id from Glance and the config options: 'swift_endpoint_url',\n        'swift_api_version', 'swift_account' and 'swift_container'.\n        The temporary URL will be valid for 'swift_temp_url_duration' seconds.\n        This allows Ironic to download a Glance image without passing around\n        an auth_token.\n\n        :param image_info: The return from a GET request to Glance for a\n            certain image_id. Should be a dictionary, with keys like 'name' and\n            'checksum'. See\n            http://docs.openstack.org/developer/glance/glanceapi.html for\n            examples.\n        :returns: A signed Swift URL from which an image can be downloaded,\n            without authentication.\n\n        :raises: InvalidParameterValue if Swift config options are not set\n            correctly.\n        :raises: MissingParameterValue if a required parameter is not set.\n        :raises: ImageUnacceptable if the image info from Glance does not\n            have a image ID.\n        "
    self._validate_temp_url_config()
    if (('id' not in image_info) or (not uuidutils.is_uuid_like(image_info['id']))):
        raise exc.ImageUnacceptable((_('The given image info does not have a valid image id: %s') % image_info))
    image_id = image_info['id']
    url_fragments = {
        'api_version': CONF.glance.swift_api_version,
        'account': CONF.glance.swift_account,
        'container': self._get_swift_container(image_id),
        'object_id': image_id,
    }
    endpoint_url = CONF.glance.swift_endpoint_url
    if (CONF.glance.temp_url_endpoint_type == 'radosgw'):
        chunks = urlparse.urlsplit(CONF.glance.swift_endpoint_url)
        if (not chunks.path):
            endpoint_url = urlparse.urljoin(endpoint_url, 'swift')
        elif (chunks.path != '/swift'):
            raise exc.InvalidParameterValue((_('Swift endpoint URL should only contain scheme, hostname, optional port and optional /swift path without trailing slash; provided value is: %s') % endpoint_url))
        template = '/{api_version}/{container}/{object_id}'
    else:
        template = '/{api_version}/{account}/{container}/{object_id}'
    url_path = template.format(**url_fragments)
    return self._generate_temp_url(path=url_path, seconds=CONF.glance.swift_temp_url_duration, key=CONF.glance.swift_temp_url_key, method='GET', endpoint=endpoint_url, image_id=image_id)

dataset/ETHPy150Open openstack/ironic/ironic/common/glance_service/v2/image_service.py GlanceImageService.swift_temp_url/original