Merge pull request #150 from SandyWalsh/remove_api_key

Remove api key
This commit is contained in:
Sandy Walsh 2011-11-16 08:38:52 -08:00
commit 1f4971a136
17 changed files with 77 additions and 73 deletions

View File

@ -36,11 +36,11 @@ Installing this package gets you a shell command, ``nova``, that you
can use to interact with any Rackspace compatible API (including OpenStack). can use to interact with any Rackspace compatible API (including OpenStack).
You'll need to provide your OpenStack username and API key. You can do this You'll need to provide your OpenStack username and API key. You can do this
with the ``--username``, ``--apikey`` and ``--projectid`` params, but it's easier to just with the ``--username``, ``--password`` and ``--projectid`` params, but it's easier to just
set them as environment variables:: set them as environment variables::
export NOVA_USERNAME=openstack export NOVA_USERNAME=openstack
export NOVA_API_KEY=yadayada export NOVA_PASSWORD=yadayada
export NOVA_PROJECT_ID=myproject export NOVA_PROJECT_ID=myproject
You will also need to define the authentication url with ``--url`` and the You will also need to define the authentication url with ``--url`` and the
@ -62,8 +62,9 @@ can specify the one you want with ``--region_name`` (or
You'll find complete documentation on the shell by running You'll find complete documentation on the shell by running
``nova help``:: ``nova help``::
usage: nova [--username USERNAME] [--apikey APIKEY] [--projectid PROJECTID] usage: nova [--username USERNAME] [--password PASSWORD] [--projectid PROJECTID]
[--url URL] [--version VERSION] [--region_name NAME] [--url URL] [--version VERSION] [--region_name NAME]
[--endpoint_name NAME]
<subcommand> ... <subcommand> ...
Command-line interface to the OpenStack Nova API. Command-line interface to the OpenStack Nova API.
@ -151,8 +152,8 @@ You'll find complete documentation on the shell by running
Optional arguments: Optional arguments:
--username USERNAME Defaults to env[NOVA_USERNAME]. --username USERNAME Defaults to env[NOVA_USERNAME].
--apikey APIKEY Defaults to env[NOVA_API_KEY]. --password PASSWORD Defaults to env[NOVA_PASSWORD].
--apikey PROJECTID Defaults to env[NOVA_PROJECT_ID]. --projectid PROJECTID Defaults to env[NOVA_PROJECT_ID].
--url AUTH_URL Defaults to env[NOVA_URL] or --url AUTH_URL Defaults to env[NOVA_URL] or
https://auth.api.rackspacecloud.com/v1.0 https://auth.api.rackspacecloud.com/v1.0
if undefined. if undefined.
@ -174,7 +175,7 @@ __ http://packages.python.org/python-novaclient/
By way of a quick-start:: By way of a quick-start::
>>> import novaclient >>> import novaclient
>>> nt = novaclient.OpenStack(USERNAME, API_KEY,PROJECT_ID [, AUTH_URL]) >>> nt = novaclient.OpenStack(USERNAME, PASSWORD, PROJECT_ID [, AUTH_URL])
>>> nt.flavors.list() >>> nt.flavors.list()
[...] [...]
>>> nt.servers.list() >>> nt.servers.list()

View File

@ -12,7 +12,7 @@ Usage
First create an instance of :class:`OpenStack` with your credentials:: First create an instance of :class:`OpenStack` with your credentials::
>>> from novaclient import OpenStack >>> from novaclient import OpenStack
>>> nova = OpenStack(USERNAME, API_KEY, AUTH_URL) >>> nova = OpenStack(USERNAME, PASSWORD, AUTH_URL)
Then call methods on the :class:`OpenStack` object: Then call methods on the :class:`OpenStack` object:

View File

@ -11,7 +11,7 @@ First, you'll need an OpenStack Nova account and an API key. You get this
by using the `nova-manage` command in OpenStack Nova. by using the `nova-manage` command in OpenStack Nova.
You'll need to provide :program:`nova` with your OpenStack username and You'll need to provide :program:`nova` with your OpenStack username and
API key. You can do this with the :option:`--username`, :option:`--apikey` API key. You can do this with the :option:`--username`, :option:`--password`
and :option:`--projectid` options, but it's easier to just set them as and :option:`--projectid` options, but it's easier to just set them as
environment variables by setting two environment variables: environment variables by setting two environment variables:
@ -19,9 +19,9 @@ environment variables by setting two environment variables:
Your OpenStack Nova username. Your OpenStack Nova username.
.. envvar:: NOVA_API_KEY .. envvar:: NOVA_PASSWORD
Your API key. Your password.
.. envvar:: NOVA_PROJECT_ID .. envvar:: NOVA_PROJECT_ID
@ -38,7 +38,7 @@ environment variables by setting two environment variables:
For example, in Bash you'd use:: For example, in Bash you'd use::
export NOVA_USERNAME=yourname export NOVA_USERNAME=yourname
export NOVA_API_KEY=yadayadayada export NOVA_PASSWORD=yadayadayada
export NOVA_PROJECT_ID=myproject export NOVA_PROJECT_ID=myproject
export NOVA_URL=http://... export NOVA_URL=http://...
export NOVA_VERSION=1.0 export NOVA_VERSION=1.0

View File

@ -37,11 +37,11 @@ class HTTPClient(httplib2.Http):
USER_AGENT = 'python-novaclient' USER_AGENT = 'python-novaclient'
def __init__(self, user, apikey, projectid, auth_url, insecure=False, def __init__(self, user, password, projectid, auth_url, insecure=False,
timeout=None, token=None, region_name=None): timeout=None, token=None, region_name=None):
super(HTTPClient, self).__init__(timeout=timeout) super(HTTPClient, self).__init__(timeout=timeout)
self.user = user self.user = user
self.apikey = apikey self.password = password
self.projectid = projectid self.projectid = projectid
self.auth_url = auth_url self.auth_url = auth_url
self.version = 'v1.0' self.version = 'v1.0'
@ -239,7 +239,7 @@ class HTTPClient(httplib2.Http):
raise NoTokenLookupException() raise NoTokenLookupException()
headers = {'X-Auth-User': self.user, headers = {'X-Auth-User': self.user,
'X-Auth-Key': self.apikey} 'X-Auth-Key': self.password}
if self.projectid: if self.projectid:
headers['X-Auth-Project-Id'] = self.projectid headers['X-Auth-Project-Id'] = self.projectid
@ -260,7 +260,7 @@ class HTTPClient(httplib2.Http):
"""Authenticate against a v2.0 auth service.""" """Authenticate against a v2.0 auth service."""
body = {"auth": { body = {"auth": {
"passwordCredentials": {"username": self.user, "passwordCredentials": {"username": self.user,
"password": self.apikey}}} "password": self.password}}}
if self.projectid: if self.projectid:
body['auth']['tenantName'] = self.projectid body['auth']['tenantName'] = self.projectid

View File

@ -62,9 +62,9 @@ class OpenStackComputeShell(object):
default=env('NOVA_USERNAME'), default=env('NOVA_USERNAME'),
help='Defaults to env[NOVA_USERNAME].') help='Defaults to env[NOVA_USERNAME].')
parser.add_argument('--apikey', parser.add_argument('--password',
default=env('NOVA_API_KEY'), default=env('NOVA_PASSWORD'),
help='Defaults to env[NOVA_API_KEY].') help='Defaults to env[NOVA_PASSWORD].')
parser.add_argument('--projectid', parser.add_argument('--projectid',
default=env('NOVA_PROJECT_ID'), default=env('NOVA_PROJECT_ID'),
@ -153,21 +153,21 @@ class OpenStackComputeShell(object):
self.do_help(args) self.do_help(args)
return 0 return 0
user, apikey, projectid, url, region_name, insecure = \ user, password, projectid, url, region_name, insecure = \
args.username, args.apikey, args.projectid, args.url, \ args.username, args.password, args.projectid, args.url, \
args.region_name, args.insecure args.region_name, args.insecure
#FIXME(usrleon): Here should be restrict for project id same as #FIXME(usrleon): Here should be restrict for project id same as
# for username or apikey but for compatibility it is not. # for username or password but for compatibility it is not.
if not user: if not user:
raise exc.CommandError("You must provide a username, either" raise exc.CommandError("You must provide a username, either"
"via --username or via " "via --username or via "
"env[NOVA_USERNAME]") "env[NOVA_USERNAME]")
if not apikey: if not password:
raise exc.CommandError("You must provide an API key, either" raise exc.CommandError("You must provide a password, either"
"via --apikey or via" "via --password or via"
"env[NOVA_API_KEY]") "env[NOVA_PASSWORD]")
if options.version and options.version != '1.0': if options.version and options.version != '1.0':
if not projectid: if not projectid:
raise exc.CommandError("You must provide an projectid, either" raise exc.CommandError("You must provide an projectid, either"
@ -179,7 +179,7 @@ class OpenStackComputeShell(object):
"via --url or via" "via --url or via"
"env[NOVA_URL") "env[NOVA_URL")
self.cs = self.get_api_class(options.version)(user, apikey, projectid, self.cs = self.get_api_class(options.version)(user, password, projectid,
url, insecure, region_name=region_name) url, insecure, region_name=region_name)
try: try:

View File

@ -14,7 +14,7 @@ class Client(object):
Create an instance with your creds:: Create an instance with your creds::
>>> client = Client(USERNAME, API_KEY, PROJECT_ID, AUTH_URL) >>> client = Client(USERNAME, PASSWORD, PROJECT_ID, AUTH_URL)
Then call methods on its managers:: Then call methods on its managers::
@ -25,7 +25,7 @@ class Client(object):
""" """
def __init__(self, username, api_key, project_id, auth_url=None, def __init__(self, username, password, project_id, auth_url=None,
insecure=False, timeout=None, token=None, region_name=None): insecure=False, timeout=None, token=None, region_name=None):
self.accounts = accounts.AccountManager(self) self.accounts = accounts.AccountManager(self)
@ -39,7 +39,7 @@ class Client(object):
_auth_url = auth_url or 'https://auth.api.rackspacecloud.com/v1.0' _auth_url = auth_url or 'https://auth.api.rackspacecloud.com/v1.0'
self.client = client.HTTPClient(username, self.client = client.HTTPClient(username,
api_key, password,
project_id, project_id,
_auth_url, _auth_url,
insecure=insecure, insecure=insecure,

View File

@ -674,7 +674,8 @@ def do_delete(cs, args):
@utils.arg('--api_url', dest='api_url', default=None, help='New URL.') @utils.arg('--api_url', dest='api_url', default=None, help='New URL.')
@utils.arg('--zone_username', dest='zone_username', default=None, @utils.arg('--zone_username', dest='zone_username', default=None,
help='New zone username.') help='New zone username.')
@utils.arg('--password', dest='password', default=None, help='New password.') @utils.arg('--zone_password', dest='zone_password', default=None,
help='New password.')
@utils.arg('--weight_offset', dest='weight_offset', default=None, @utils.arg('--weight_offset', dest='weight_offset', default=None,
help='Child Zone weight offset.') help='Child Zone weight offset.')
@utils.arg('--weight_scale', dest='weight_scale', default=None, @utils.arg('--weight_scale', dest='weight_scale', default=None,
@ -689,8 +690,8 @@ def do_zone(cs, args):
zone_delta['api_url'] = args.api_url zone_delta['api_url'] = args.api_url
if args.zone_username: if args.zone_username:
zone_delta['username'] = args.zone_username zone_delta['username'] = args.zone_username
if args.password: if args.zone_password:
zone_delta['password'] = args.password zone_delta['password'] = args.zone_password
if args.weight_offset: if args.weight_offset:
zone_delta['weight_offset'] = args.weight_offset zone_delta['weight_offset'] = args.weight_offset
if args.weight_scale: if args.weight_scale:
@ -713,7 +714,7 @@ def do_zone_info(cs, args):
@utils.arg('--zone_username', metavar='<zone_username>', @utils.arg('--zone_username', metavar='<zone_username>',
help='Optional Authentication username. (Default=None)', help='Optional Authentication username. (Default=None)',
default=None) default=None)
@utils.arg('--password', metavar='<password>', @utils.arg('--zone_password', metavar='<zone_password>',
help='Authentication password. (Default=None)', help='Authentication password. (Default=None)',
default=None) default=None)
@utils.arg('--weight_offset', metavar='<weight_offset>', @utils.arg('--weight_offset', metavar='<weight_offset>',
@ -725,7 +726,7 @@ def do_zone_info(cs, args):
def do_zone_add(cs, args): def do_zone_add(cs, args):
"""Add a new child zone.""" """Add a new child zone."""
zone = cs.zones.create(args.zone_name, args.api_url, zone = cs.zones.create(args.zone_name, args.api_url,
args.zone_username, args.password, args.zone_username, args.zone_password,
args.weight_offset, args.weight_scale) args.weight_offset, args.weight_scale)
utils.print_dict(zone._info) utils.print_dict(zone._info)

View File

@ -18,7 +18,7 @@ class Client(object):
Create an instance with your creds:: Create an instance with your creds::
>>> client = Client(USERNAME, API_KEY, PROJECT_ID, AUTH_URL) >>> client = Client(USERNAME, PASSWORD, PROJECT_ID, AUTH_URL)
Then call methods on its managers:: Then call methods on its managers::
@ -30,7 +30,7 @@ class Client(object):
""" """
# FIXME(jesse): project_id isn't required to autenticate # FIXME(jesse): project_id isn't required to autenticate
def __init__(self, username, api_key, project_id, auth_url, def __init__(self, username, password, project_id, auth_url,
insecure=False, timeout=None, token=None, region_name=None): insecure=False, timeout=None, token=None, region_name=None):
self.flavors = flavors.FlavorManager(self) self.flavors = flavors.FlavorManager(self)
self.floating_ips = floating_ips.FloatingIPManager(self) self.floating_ips = floating_ips.FloatingIPManager(self)
@ -48,7 +48,7 @@ class Client(object):
security_group_rules.SecurityGroupRuleManager(self) security_group_rules.SecurityGroupRuleManager(self)
self.client = client.HTTPClient(username, self.client = client.HTTPClient(username,
api_key, password,
project_id, project_id,
auth_url, auth_url,
insecure=insecure, insecure=insecure,

View File

@ -486,15 +486,16 @@ def do_reboot(cs, args):
@utils.arg('server', metavar='<server>', help='Name or ID of server.') @utils.arg('server', metavar='<server>', help='Name or ID of server.')
@utils.arg('image', metavar='<image>', help="Name or ID of new image.") @utils.arg('image', metavar='<image>', help="Name or ID of new image.")
@utils.arg('--password', dest='password', metavar='<password>', default=False, @utils.arg('--rebuild_password', dest='rebuild_password',
metavar='<rebuild_password>', default=False,
help="Set the provided password on the rebuild instance.") help="Set the provided password on the rebuild instance.")
def do_rebuild(cs, args): def do_rebuild(cs, args):
"""Shutdown, re-image, and re-boot a server.""" """Shutdown, re-image, and re-boot a server."""
server = _find_server(cs, args.server) server = _find_server(cs, args.server)
image = _find_image(cs, args.image) image = _find_image(cs, args.image)
if args.password != False: if args.rebuild_password != False:
_password = args.password _password = args.rebuild_password
else: else:
_password = None _password = None
@ -706,7 +707,8 @@ def _find_flavor(cs, flavor):
@utils.arg('--api_url', dest='api_url', default=None, help='New URL.') @utils.arg('--api_url', dest='api_url', default=None, help='New URL.')
@utils.arg('--zone_username', dest='zone_username', default=None, @utils.arg('--zone_username', dest='zone_username', default=None,
help='New zone username.') help='New zone username.')
@utils.arg('--password', dest='password', default=None, help='New password.') @utils.arg('--zone_password', dest='zone_password', default=None,
help='New password.')
@utils.arg('--weight_offset', dest='weight_offset', default=None, @utils.arg('--weight_offset', dest='weight_offset', default=None,
help='Child Zone weight offset.') help='Child Zone weight offset.')
@utils.arg('--weight_scale', dest='weight_scale', default=None, @utils.arg('--weight_scale', dest='weight_scale', default=None,
@ -721,8 +723,8 @@ def do_zone(cs, args):
zone_delta['api_url'] = args.api_url zone_delta['api_url'] = args.api_url
if args.zone_username: if args.zone_username:
zone_delta['username'] = args.zone_username zone_delta['username'] = args.zone_username
if args.password: if args.zone_password:
zone_delta['password'] = args.password zone_delta['password'] = args.zone_password
if args.weight_offset: if args.weight_offset:
zone_delta['weight_offset'] = args.weight_offset zone_delta['weight_offset'] = args.weight_offset
if args.weight_scale: if args.weight_scale:
@ -745,7 +747,7 @@ def do_zone_info(cs, args):
@utils.arg('--zone_username', metavar='<zone_username>', @utils.arg('--zone_username', metavar='<zone_username>',
help='Optional Authentication username. (Default=None)', help='Optional Authentication username. (Default=None)',
default=None) default=None)
@utils.arg('--password', metavar='<password>', @utils.arg('--zone_password', metavar='<zone_password>',
help='Authentication password. (Default=None)', help='Authentication password. (Default=None)',
default=None) default=None)
@utils.arg('--weight_offset', metavar='<weight_offset>', @utils.arg('--weight_offset', metavar='<weight_offset>',
@ -757,7 +759,7 @@ def do_zone_info(cs, args):
def do_zone_add(cs, args): def do_zone_add(cs, args):
"""Add a new child zone.""" """Add a new child zone."""
zone = cs.zones.create(args.zone_name, args.api_url, zone = cs.zones.create(args.zone_name, args.api_url,
args.zone_username, args.password, args.zone_username, args.zone_password,
args.weight_offset, args.weight_scale) args.weight_offset, args.weight_scale)
utils.print_dict(zone._info) utils.print_dict(zone._info)

View File

@ -12,7 +12,7 @@ mock_request = mock.Mock(return_value=(fake_response, fake_body))
def get_client(): def get_client():
cl = client.HTTPClient("username", "apikey", cl = client.HTTPClient("username", "password",
"project_id", "auth_test") "project_id", "auth_test")
return cl return cl

View File

@ -14,7 +14,7 @@ class ShellTest(utils.TestCase):
global _old_env global _old_env
fake_env = { fake_env = {
'NOVA_USERNAME': 'username', 'NOVA_USERNAME': 'username',
'NOVA_API_KEY': 'password', 'NOVA_PASSWORD': 'password',
'NOVA_PROJECT_ID': 'project_id', 'NOVA_PROJECT_ID': 'project_id',
'NOVA_URL': 'http://no.where', 'NOVA_URL': 'http://no.where',
} }

View File

@ -10,7 +10,7 @@ from tests import fakes
class FakeClient(fakes.FakeClient, client.Client): class FakeClient(fakes.FakeClient, client.Client):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
client.Client.__init__(self, 'username', 'apikey', client.Client.__init__(self, 'username', 'password',
'project_id', 'auth_url') 'project_id', 'auth_url')
self.client = FakeHTTPClient(**kwargs) self.client = FakeHTTPClient(**kwargs)
@ -18,7 +18,7 @@ class FakeClient(fakes.FakeClient, client.Client):
class FakeHTTPClient(base_client.HTTPClient): class FakeHTTPClient(base_client.HTTPClient):
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.username = 'username' self.username = 'username'
self.apikey = 'apikey' self.password = 'password'
self.auth_url = 'auth_url' self.auth_url = 'auth_url'
self.callstack = [] self.callstack = []

View File

@ -9,7 +9,7 @@ from tests import utils
class AuthenticationTests(utils.TestCase): class AuthenticationTests(utils.TestCase):
def test_authenticate_success(self): def test_authenticate_success(self):
cs = client.Client("username", "apikey", "project_id") cs = client.Client("username", "password", "project_id")
management_url = 'https://servers.api.rackspacecloud.com/v1.0/443470' management_url = 'https://servers.api.rackspacecloud.com/v1.0/443470'
auth_response = httplib2.Response({ auth_response = httplib2.Response({
'status': 204, 'status': 204,
@ -23,7 +23,7 @@ class AuthenticationTests(utils.TestCase):
cs.client.authenticate() cs.client.authenticate()
headers = { headers = {
'X-Auth-User': 'username', 'X-Auth-User': 'username',
'X-Auth-Key': 'apikey', 'X-Auth-Key': 'password',
'X-Auth-Project-Id': 'project_id', 'X-Auth-Project-Id': 'project_id',
'User-Agent': cs.client.USER_AGENT 'User-Agent': cs.client.USER_AGENT
} }
@ -37,7 +37,7 @@ class AuthenticationTests(utils.TestCase):
test_auth_call() test_auth_call()
def test_authenticate_failure(self): def test_authenticate_failure(self):
cs = client.Client("username", "apikey", "project_id") cs = client.Client("username", "password", "project_id")
auth_response = httplib2.Response({'status': 401}) auth_response = httplib2.Response({'status': 401})
mock_request = mock.Mock(return_value=(auth_response, None)) mock_request = mock.Mock(return_value=(auth_response, None))
@ -48,7 +48,7 @@ class AuthenticationTests(utils.TestCase):
test_auth_call() test_auth_call()
def test_auth_automatic(self): def test_auth_automatic(self):
cs = client.Client("username", "apikey", "project_id") cs = client.Client("username", "password", "project_id")
http_client = cs.client http_client = cs.client
http_client.management_url = '' http_client.management_url = ''
mock_request = mock.Mock(return_value=(None, None)) mock_request = mock.Mock(return_value=(None, None))
@ -63,7 +63,7 @@ class AuthenticationTests(utils.TestCase):
test_auth_call() test_auth_call()
def test_auth_manual(self): def test_auth_manual(self):
cs = client.Client("username", "apikey", "project_id") cs = client.Client("username", "password", "project_id")
@mock.patch.object(cs.client, 'authenticate') @mock.patch.object(cs.client, 'authenticate')
def test_auth_call(m): def test_auth_call(m):

View File

@ -14,7 +14,7 @@ class ShellTest(utils.TestCase):
self.old_environment = os.environ.copy() self.old_environment = os.environ.copy()
os.environ = { os.environ = {
'NOVA_USERNAME': 'username', 'NOVA_USERNAME': 'username',
'NOVA_API_KEY': 'password', 'NOVA_PASSWORD': 'password',
'NOVA_PROJECT_ID': 'project_id', 'NOVA_PROJECT_ID': 'project_id',
'NOVA_VERSION': '1.0', 'NOVA_VERSION': '1.0',
} }
@ -304,7 +304,7 @@ class ShellTest(utils.TestCase):
self.assert_called('GET', '/zones/1') self.assert_called('GET', '/zones/1')
self.run_command('zone 1 --api_url=http://zzz ' self.run_command('zone 1 --api_url=http://zzz '
'--zone_username=frank --password=xxx') '--zone_username=frank --zone_password=xxx')
self.assert_called( self.assert_called(
'PUT', '/zones/1', 'PUT', '/zones/1',
{'zone': {'username': 'frank', 'password': 'xxx', {'zone': {'username': 'frank', 'password': 'xxx',
@ -313,7 +313,7 @@ class ShellTest(utils.TestCase):
def test_zone_add(self): def test_zone_add(self):
self.run_command('zone-add child_zone http://zzz ' self.run_command('zone-add child_zone http://zzz '
'--zone_username=frank --password=xxx ' '--zone_username=frank --zone_password=xxx '
'--weight_offset=0.0 --weight_scale=1.0') '--weight_offset=0.0 --weight_scale=1.0')
self.assert_called( self.assert_called(
'POST', '/zones', 'POST', '/zones',

View File

@ -8,7 +8,7 @@ from tests import fakes
class FakeClient(fakes.FakeClient, client.Client): class FakeClient(fakes.FakeClient, client.Client):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
client.Client.__init__(self, 'username', 'apikey', client.Client.__init__(self, 'username', 'password',
'project_id', 'auth_url') 'project_id', 'auth_url')
self.client = FakeHTTPClient(**kwargs) self.client = FakeHTTPClient(**kwargs)
@ -17,7 +17,7 @@ class FakeHTTPClient(base_client.HTTPClient):
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.username = 'username' self.username = 'username'
self.apikey = 'apikey' self.password = 'password'
self.auth_url = 'auth_url' self.auth_url = 'auth_url'
self.callstack = [] self.callstack = []
@ -324,7 +324,7 @@ class FakeHTTPClient(base_client.HTTPClient):
]}) ]})
def get_os_floating_ips_1(self, **kw): def get_os_floating_ips_1(self, **kw):
return (200, {'floating_ip': return (200, {'floating_ip':
{'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1'} {'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1'}
}) })

View File

@ -19,7 +19,7 @@ def to_http_response(resp_dict):
class AuthenticateAgainstKeystoneTests(utils.TestCase): class AuthenticateAgainstKeystoneTests(utils.TestCase):
def test_authenticate_success(self): def test_authenticate_success(self):
cs = client.Client("username", "apikey", "project_id", "auth_url/v2.0") cs = client.Client("username", "password", "project_id", "auth_url/v2.0")
resp = {"access": resp = {"access":
{"token": {"expires": "12345", "id": "FAKE_ID"}, {"token": {"expires": "12345", "id": "FAKE_ID"},
"serviceCatalog": [ "serviceCatalog": [
@ -44,7 +44,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
'Content-Type': 'application/json', } 'Content-Type': 'application/json', }
body = {'auth': { body = {'auth': {
'passwordCredentials': {'username': cs.client.user, 'passwordCredentials': {'username': cs.client.user,
'password': cs.client.apikey}, 'password': cs.client.password},
'tenantName': cs.client.projectid, }} 'tenantName': cs.client.projectid, }}
token_url = urlparse.urljoin(cs.client.auth_url, "tokens") token_url = urlparse.urljoin(cs.client.auth_url, "tokens")
@ -60,7 +60,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
test_auth_call() test_auth_call()
def test_authenticate_failure(self): def test_authenticate_failure(self):
cs = client.Client("username", "apikey", "project_id", "auth_url/v2.0") cs = client.Client("username", "password", "project_id", "auth_url/v2.0")
resp = {"unauthorized": {"message": "Unauthorized", "code": "401"}} resp = {"unauthorized": {"message": "Unauthorized", "code": "401"}}
auth_response = httplib2.Response({ auth_response = httplib2.Response({
"status": 401, "status": 401,
@ -77,7 +77,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
test_auth_call() test_auth_call()
def test_auth_redirect(self): def test_auth_redirect(self):
cs = client.Client("username", "apikey", "project_id", "auth_url/v1.0") cs = client.Client("username", "password", "project_id", "auth_url/v1.0")
dict_correct_response = {"access": {"token": {"expires": "12345", "id": "FAKE_ID"}, dict_correct_response = {"access": {"token": {"expires": "12345", "id": "FAKE_ID"},
"serviceCatalog": [{ "serviceCatalog": [{
"type": "compute", "type": "compute",
@ -116,7 +116,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
'Content-Type': 'application/json',} 'Content-Type': 'application/json',}
body = {'auth': { body = {'auth': {
'passwordCredentials': {'username': cs.client.user, 'passwordCredentials': {'username': cs.client.user,
'password': cs.client.apikey}, 'password': cs.client.password},
'tenantName': cs.client.projectid,}} 'tenantName': cs.client.projectid,}}
token_url = urlparse.urljoin(cs.client.auth_url, "tokens") token_url = urlparse.urljoin(cs.client.auth_url, "tokens")
@ -135,7 +135,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
class AuthenticationTests(utils.TestCase): class AuthenticationTests(utils.TestCase):
def test_authenticate_success(self): def test_authenticate_success(self):
cs = client.Client("username", "apikey", "project_id", "auth_url") cs = client.Client("username", "password", "project_id", "auth_url")
management_url = 'https://servers.api.rackspacecloud.com/v1.1/443470' management_url = 'https://servers.api.rackspacecloud.com/v1.1/443470'
auth_response = httplib2.Response({ auth_response = httplib2.Response({
'status': 204, 'status': 204,
@ -149,7 +149,7 @@ class AuthenticationTests(utils.TestCase):
cs.client.authenticate() cs.client.authenticate()
headers = { headers = {
'X-Auth-User': 'username', 'X-Auth-User': 'username',
'X-Auth-Key': 'apikey', 'X-Auth-Key': 'password',
'X-Auth-Project-Id': 'project_id', 'X-Auth-Project-Id': 'project_id',
'User-Agent': cs.client.USER_AGENT 'User-Agent': cs.client.USER_AGENT
} }
@ -163,7 +163,7 @@ class AuthenticationTests(utils.TestCase):
test_auth_call() test_auth_call()
def test_authenticate_failure(self): def test_authenticate_failure(self):
cs = client.Client("username", "apikey", "project_id", "auth_url") cs = client.Client("username", "password", "project_id", "auth_url")
auth_response = httplib2.Response({'status': 401}) auth_response = httplib2.Response({'status': 401})
mock_request = mock.Mock(return_value=(auth_response, None)) mock_request = mock.Mock(return_value=(auth_response, None))
@ -174,7 +174,7 @@ class AuthenticationTests(utils.TestCase):
test_auth_call() test_auth_call()
def test_auth_automatic(self): def test_auth_automatic(self):
cs = client.Client("username", "apikey", "project_id", "auth_url") cs = client.Client("username", "password", "project_id", "auth_url")
http_client = cs.client http_client = cs.client
http_client.management_url = '' http_client.management_url = ''
mock_request = mock.Mock(return_value=(None, None)) mock_request = mock.Mock(return_value=(None, None))
@ -189,7 +189,7 @@ class AuthenticationTests(utils.TestCase):
test_auth_call() test_auth_call()
def test_auth_manual(self): def test_auth_manual(self):
cs = client.Client("username", "apikey", "project_id", "auth_url") cs = client.Client("username", "password", "project_id", "auth_url")
@mock.patch.object(cs.client, 'authenticate') @mock.patch.object(cs.client, 'authenticate')
def test_auth_call(m): def test_auth_call(m):

View File

@ -17,7 +17,7 @@ class ShellTest(utils.TestCase):
self.old_environment = os.environ.copy() self.old_environment = os.environ.copy()
os.environ = { os.environ = {
'NOVA_USERNAME': 'username', 'NOVA_USERNAME': 'username',
'NOVA_API_KEY': 'password', 'NOVA_PASSWORD': 'password',
'NOVA_PROJECT_ID': 'project_id', 'NOVA_PROJECT_ID': 'project_id',
'NOVA_VERSION': '1.1', 'NOVA_VERSION': '1.1',
'NOVA_URL': 'http://no.where', 'NOVA_URL': 'http://no.where',
@ -228,7 +228,7 @@ class ShellTest(utils.TestCase):
# {'rebuild': {'imageRef': 1}}) # {'rebuild': {'imageRef': 1}})
self.assert_called('GET', '/images/2') self.assert_called('GET', '/images/2')
self.run_command('rebuild sample-server 1 --password asdf') self.run_command('rebuild sample-server 1 --rebuild_password asdf')
# XXX need a way to test multiple calls # XXX need a way to test multiple calls
#self.assert_called('POST', '/servers/1234/action', #self.assert_called('POST', '/servers/1234/action',
# {'rebuild': {'imageRef': 1, 'adminPass': 'asdf'}}) # {'rebuild': {'imageRef': 1, 'adminPass': 'asdf'}})
@ -267,7 +267,7 @@ class ShellTest(utils.TestCase):
self.assert_called('GET', '/images/2') self.assert_called('GET', '/images/2')
def test_show_bad_id(self): def test_show_bad_id(self):
self.assertRaises(exceptions.CommandError, self.assertRaises(exceptions.CommandError,
self.run_command, 'show xxx') self.run_command, 'show xxx')
def test_delete(self): def test_delete(self):