Doug Hellmann 5e4032150d Fix "help" command and implement "list server" and "show server"
blueprint client-manager
blueprint nova-client
bug 992841

Move the authentication logic into a new ClientManager class so that only commands that need to authenticate will trigger that code.
Implement "list server" and "show server" commands as examples of using the ClientManager, Lister, and ShowOne classes.

Change-Id: I9845b70b33bae4b193dbe41871bf0ca8e286a727
2012-05-04 09:35:40 -04:00

33 lines
1.0 KiB
Python

import logging
from novaclient import client as nova_client
LOG = logging.getLogger(__name__)
def make_client(instance):
"""Returns a compute service client.
"""
LOG.debug('instantiating compute client')
# FIXME(dhellmann): Where is the endpoint value used?
# url = instance.get_endpoint_for_service_type('compute')
client = nova_client.Client(
version=instance._compute_api_version,
username=instance._username,
api_key=instance._password,
project_id=instance._tenant_name,
auth_url=instance._auth_url,
# FIXME(dhellmann): add constructor argument for this
insecure=False,
region_name=instance._region_name,
# FIXME(dhellmann): get endpoint_type from option?
endpoint_type='publicURL',
# FIXME(dhellmann): add extension discovery
extensions=[],
service_type='compute',
# FIXME(dhellmann): what is service_name?
service_name='',
)
client.authenticate()
return client