def get_registry_client(cxt): global _CLIENT_CREDS, _CLIENT_KWARGS, _CLIENT_HOST, _CLIENT_PORT kwargs = _CLIENT_KWARGS.copy() kwargs['auth_tok'] = cxt.auth_tok if _CLIENT_CREDS: kwargs['creds'] = _CLIENT_CREDS return client.RegistryClient(_CLIENT_HOST, _CLIENT_PORT, **kwargs)
if pieces.scheme not in schemes: return None scheme = 'swift+config' ref = 'ref1' _, path = pieces.path.lstrip('/').split('/', 1) parts = (scheme, ref, path, None, None, None) new_url = urllib.parse.urlunparse(parts) loc['url'] = new_url return loc if __name__ == '__main__': try: c = client.RegistryClient(OS_REGISTRY_HOST, OS_REGISTRY_PORT, auth_tok=OS_AUTH_TOKEN) except TypeError: c = client.RegistryClient(OS_REGISTRY_HOST, OS_REGISTRY_PORT, auth_token=OS_AUTH_TOKEN) images = c.image_get_all() for image in images: if image['status'] != 'active': continue locations = image['locations'] image_id = image['id'] for location in locations: fix_url(location)