Bases: object
Top-level object to access the OpenStack Compute API.
Create an instance with your creds:
>>> client = Client(USERNAME, PASSWORD, PROJECT_ID, AUTH_URL)
Or, alternatively, you can create a client instance using the keystoneclient.session API:
>>> from keystoneclient.auth.identity import v2
>>> from keystoneclient import session
>>> from novaclient.client import Client
>>> auth = v2.Password(auth_url=AUTH_URL,
username=USERNAME,
password=PASSWORD,
tenant_name=PROJECT_ID)
>>> sess = session.Session(auth=auth)
>>> nova = client.Client(VERSION, session=sess)
Then call methods on its managers:
>>> client.servers.list()
...
>>> client.flavors.list()
...
It is also possible to use an instance as a context manager in which case there will be a session kept alive for the duration of the with statement:
>>> with Client(USERNAME, PASSWORD, PROJECT_ID, AUTH_URL) as client:
... client.servers.list()
... client.flavors.list()
...
It is also possible to have a permanent (process-long) connection pool, by passing a connection_pool=True:
>>> client = Client(USERNAME, PASSWORD, PROJECT_ID,
... AUTH_URL, connection_pool=True)
Parameters: |
|
---|
Authenticate against the server.
Normally this is called automatically when you first access the API, but you can call this method to force authentication right now.
Returns on success; raises exceptions.Unauthorized if the credentials are wrong.