Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to detect keystone version

I'm writing application with novaclient and I want to use keystoneauth1.session object (together with keystoneauth1.identity).

I don't know which version would be running on remote server (I'm writing generic application to work with any installation of Openstack). I can use 'v2' or 'v3' versions. Is any way to ask remote (keystone) server about it's preferable version?

My current code (with some cutoffs):

from keystoneauth1.identity import v2
from keystoneauth1 import session
from keystoneclient import client as keystoneclient
auth = v2.Password(
    auth_url=e['OS_AUTH_URL'],
    username=e['OS_USERNAME'],
    password=e['OS_PASSWORD'],
    tenant_name=e['OS_TENANT_NAME']
)
sess = session.Session(auth=auth)
nova = novaclient.Client('2', session=sess)
print nova.flavors.list()

I have similar code for v3 (with different names - 'project_name' instead of 'tenant_name', etc. How should I choose one?

How to detect keystone version

I'm writing application with novaclient and I want to use keystoneauth1.session object (together with keystoneauth1.identity).

I don't know which version would be running on remote server (I'm writing generic application to work with any installation of Openstack). I can use 'v2' or 'v3' versions. Is any way to ask remote (keystone) server about it's preferable version?

My current code (with some cutoffs):

import os
from novaclient import client as novaclient
from keystoneauth1.identity import v2
from keystoneauth1 import session
from keystoneclient import client as keystoneclient
e = os.environ
auth = v2.Password(
    auth_url=e['OS_AUTH_URL'],
    username=e['OS_USERNAME'],
    password=e['OS_PASSWORD'],
    tenant_name=e['OS_TENANT_NAME']
)
sess = session.Session(auth=auth)
nova = novaclient.Client('2', session=sess)
print nova.flavors.list()

I have similar code for v3 (with different names - 'project_name' instead of 'tenant_name', etc. How should I choose one?