From 0e1e38d2e43fddb90b8010bd3e43b3da641cf643 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Thu, 17 Nov 2011 12:48:58 -0800 Subject: [PATCH] Revert api_key change in novaclient Client argument Fixes bug 891442 Also, still need to support NOVA_API_KEY environment variable for now. Bump version to 2.6.8 so we can get this into pypi Updated setup.py to build properly Change-Id: I16233ac559bf44b78666118d68975509da6bfb0d --- novaclient/shell.py | 21 +++++++++++++++------ novaclient/v1_0/client.py | 5 ++++- novaclient/v1_1/client.py | 5 ++++- setup.py | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/novaclient/shell.py b/novaclient/shell.py index 5e0eef40b..534b5aa54 100644 --- a/novaclient/shell.py +++ b/novaclient/shell.py @@ -62,6 +62,10 @@ class OpenStackComputeShell(object): default=env('NOVA_USERNAME'), help='Defaults to env[NOVA_USERNAME].') + parser.add_argument('--apikey', + default=env('NOVA_API_KEY'), + help='Defaults to env[NOVA_API_KEY].') + parser.add_argument('--password', default=env('NOVA_PASSWORD'), help='Defaults to env[NOVA_PASSWORD].') @@ -157,9 +161,10 @@ class OpenStackComputeShell(object): self.do_help(args) return 0 - user, password, projectid, url, region_name, endpoint_name, insecure =\ - args.username, args.password, args.projectid, args.url, \ - args.region_name, args.endpoint_name, args.insecure + (user, apikey, password, projectid, url, region_name, + endpoint_name, insecure) = (args.username, args.apikey, + args.password, args.projectid, args.url, + args.region_name, args.endpoint_name, args.insecure) if not endpoint_name: endpoint_name = 'publicURL' @@ -171,10 +176,14 @@ class OpenStackComputeShell(object): raise exc.CommandError("You must provide a username, either" "via --username or via " "env[NOVA_USERNAME]") + if not password: - raise exc.CommandError("You must provide a password, either" - "via --password or via" - "env[NOVA_PASSWORD]") + if not apikey: + raise exc.CommandError("You must provide a password, either" + "via --password or via env[NOVA_PASSWORD]") + else: + password = apikey + if options.version and options.version != '1.0': if not projectid: raise exc.CommandError("You must provide an projectid, either" diff --git a/novaclient/v1_0/client.py b/novaclient/v1_0/client.py index 794ed9516..7e326cd3f 100644 --- a/novaclient/v1_0/client.py +++ b/novaclient/v1_0/client.py @@ -25,10 +25,13 @@ class Client(object): """ - def __init__(self, username, password, project_id, auth_url=None, + def __init__(self, username, api_key, project_id, auth_url=None, insecure=False, timeout=None, token=None, region_name=None, endpoint_name='publicURL'): + # FIXME(comstud): Rename the api_key argument above when we + # know it's not being used as keyword argument + password = api_key self.accounts = accounts.AccountManager(self) self.backup_schedules = backup_schedules.BackupScheduleManager(self) self.flavors = flavors.FlavorManager(self) diff --git a/novaclient/v1_1/client.py b/novaclient/v1_1/client.py index b89d40478..2e00345c5 100644 --- a/novaclient/v1_1/client.py +++ b/novaclient/v1_1/client.py @@ -30,9 +30,12 @@ class Client(object): """ # FIXME(jesse): project_id isn't required to authenticate - def __init__(self, username, password, project_id, auth_url, + def __init__(self, username, api_key, project_id, auth_url, insecure=False, timeout=None, token=None, region_name=None, endpoint_name='publicURL'): + # FIXME(comstud): Rename the api_key argument above when we + # know it's not being used as keyword argument + password = api_key self.flavors = flavors.FlavorManager(self) self.floating_ips = floating_ips.FloatingIPManager(self) self.images = images.ImageManager(self) diff --git a/setup.py b/setup.py index 09e150920..d69ad981d 100644 --- a/setup.py +++ b/setup.py @@ -28,14 +28,14 @@ def read_file(file_name): setuptools.setup( name="python-novaclient", - version="2.6.7", + version="2.6.8", author="Rackspace, based on work by Jacob Kaplan-Moss", author_email="github@racklabs.com", description="Client library for OpenStack Nova API.", long_description=read_file("README.rst"), license="Apache License, Version 2.0", url="https://github.com/openstack/python-novaclient", - packages=["novaclient"], + packages=["novaclient", "novaclient.v1_0", "novaclient.v1_1"], install_requires=requirements, tests_require=["nose", "mock"], test_suite="nose.collector",