From c093404b7eef9e418380ff2fdb22fd9ddc1824dd Mon Sep 17 00:00:00 2001 From: Kirill Zaitsev Date: Wed, 2 Mar 2016 17:53:24 +0300 Subject: [PATCH] Distinguish between glance and glare endpoints Since glare has been moved to a separate service (instead of being glance v3) muranoclient has to distinguish between glance and glare. This commit adds a glare-url parameter, that is used for glare artefact client Change-Id: Ief54eb0b3e0bf6def7cee1e2d75f8aebaf113466 Closes-Bug: #1551733 --- muranoclient/glance/client.py | 5 +-- muranoclient/shell.py | 34 +++++++++++++++---- .../glare-endpoint-cdba1b2351c19592.yaml | 6 ++++ 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 releasenotes/notes/glare-endpoint-cdba1b2351c19592.yaml diff --git a/muranoclient/glance/client.py b/muranoclient/glance/client.py index 6c588f13..dc09a496 100644 --- a/muranoclient/glance/client.py +++ b/muranoclient/glance/client.py @@ -19,7 +19,7 @@ from muranoclient.glance import artifacts class Client(object): - """Client for the OpenStack Glance v3 API. + """Client for the OpenStack glance-glare API. :param string endpoint: A user-supplied endpoint URL for the glance service. @@ -30,7 +30,8 @@ class Client(object): def __init__(self, endpoint, type_name, type_version, **kwargs): endpoint, version = utils.strip_version(endpoint) - self.version = version or 3.0 + # TODO(kzaitsev): start using this variable + self.version = version or 0.1 self.http_client = http.HTTPClient(endpoint, **kwargs) self.type_name = type_name diff --git a/muranoclient/shell.py b/muranoclient/shell.py index 492b168d..fa29ac60 100644 --- a/muranoclient/shell.py +++ b/muranoclient/shell.py @@ -131,6 +131,10 @@ class MuranoShell(object): default=utils.env('GLANCE_URL'), help='Defaults to env[GLANCE_URL].') + parser.add_argument('--glare-url', + default=utils.env('GLARE_URL'), + help='Defaults to env[GLARE_URL].') + parser.add_argument('--murano-api-version', default=utils.env( 'MURANO_API_VERSION', default='1'), @@ -352,13 +356,13 @@ class MuranoShell(object): "If you specify --os-no-client-auth" " you must also specify a Murano API URL" " via either --murano-url or env[MURANO_URL]") - if (not args.glance_url and - args.murano_packages_service == 'glance'): + if (not args.glare_url and + args.murano_packages_service in ['glance', 'glare']): raise exc.CommandError( "If you specify --os-no-client-auth and" " set murano-packages-service to 'glance'" - " you must also specify a Glance API URL" - " via either --glance-url or env[GLANCE_URL]") + " you must also specify a glance glare API URL" + " via either --glare-url or env[GLARE_API]") else: # Tenant name or ID is needed to make keystoneclient retrieve a @@ -461,8 +465,26 @@ class MuranoShell(object): "Image creation will be unavailable.") kwargs['glance_client'] = None - if args.murano_packages_service == 'glance': - artifacts_client = art_client.Client(endpoint=glance_endpoint, + if args.murano_packages_service in ['glance', 'glare']: + glare_endpoint = args.glare_url + + if not glare_endpoint: + # no glare_endpoint and we requested to store packages in glare + # let's check keystone + try: + glare_endpoint = keystone_auth.get_endpoint( + keystone_session, + service_type='artifact', + region_name=args.os_region_name) + except Exception: + raise exc.CommandError( + "You set murano-packages-service to {}" + " but there is not 'artifact' endpoint in keystone" + " Either register one or specify endpoint " + " via either --glare-url or env[GLARE_API]".format( + args.murano_packages_service)) + + artifacts_client = art_client.Client(endpoint=glare_endpoint, type_name='murano', type_version=1, username=args.os_username, diff --git a/releasenotes/notes/glare-endpoint-cdba1b2351c19592.yaml b/releasenotes/notes/glare-endpoint-cdba1b2351c19592.yaml new file mode 100644 index 00000000..7df29099 --- /dev/null +++ b/releasenotes/notes/glare-endpoint-cdba1b2351c19592.yaml @@ -0,0 +1,6 @@ +--- +features: + - Since glare has been moved to a separate service muranoclient CLI now + distinguishes between --glance-url and --glare-url. If --glare-url is + not supplied muranoclient requests an endpoint of type 'artifact' + from keystone.