openstack-manuals/doc/user-guide/source/sdk_authenticate_against_image_service_endpoint.rst
KATO Tomoyuki 25b7c094c7 Change 'Image Service' to 'Image service'
Follow the Documentation Conventions:
https://wiki.openstack.org/wiki/Documentation/Conventions

Change-Id: I595d7154efa33df41aa532a5dfea59a1abcaa36f
2015-06-01 09:31:14 +09:00

1.0 KiB

Authenticate against an Image service endpoint

To authenticate against an Image service endpoint, instantiate a glanceclient.v2.client.Client object:

from os import environ as env
import glanceclient.v2.client as glclient
import keystoneclient.v2_0.client as ksclient

keystone = ksclient.Client(auth_url=env['OS_AUTH_URL'],
                           username=env['OS_USERNAME'],
                           password=env['OS_PASSWORD'],
                           tenant_name=env['OS_TENANT_NAME'],
                           region_name=env['OS_REGION_NAME'])
glance_endpoint = keystone.service_catalog.url_for(service_type='image')
glance = glclient.Client(glance_endpoint, token=keystone.auth_token)