Created
December 15, 2016 13:28
-
-
Save amarao/708313a2d5b7240432a4233684d8f0ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import glanceclient | |
import keystoneclient | |
import os | |
def get_glance(): | |
keystone_auth = keystoneclient.v2_0.Client( | |
auth_url=os.environ["OS_AUTH_URL"], | |
username=os.environ["OS_USERNAME"], | |
tenant_name=os.environ["OS_TENANT_NAME"], | |
password=os.environ["OS_PASSWORD"] | |
) | |
token = keystone_auth.get_token(keystone_auth.session) | |
glance_endpoint = keystone_auth.service_catalog.url_for( | |
service_type="image", | |
endpoint_type="publicURL" | |
) | |
glance = glanceclient.Client( | |
version="1", | |
endpoint=glance_endpoint, | |
token=token, | |
cacert='/etc/ssl/certs' | |
) | |
return glance | |
glance = get_glance() | |
print list(glance.images.list()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment