minor tweaks and long overdue pep8
This commit is contained in:
parent
881427de9d
commit
0a3eda6cdd
@ -185,7 +185,8 @@ class HTTPClient(httplib2.Http):
|
||||
_logger.debug("Using Endpoint URL: %s" % url)
|
||||
resp, body = self.request(url, "GET",
|
||||
headers={'X-Auth_Token': self.auth_token})
|
||||
return self._extract_service_catalog(url, resp, body, extract_token=False)
|
||||
return self._extract_service_catalog(url, resp, body,
|
||||
extract_token=False)
|
||||
|
||||
def authenticate(self):
|
||||
magic_tuple = urlparse.urlsplit(self.auth_url)
|
||||
@ -201,7 +202,7 @@ class HTTPClient(httplib2.Http):
|
||||
|
||||
# TODO(sandy): Assume admin endpoint is 35357 for now.
|
||||
# Ideally this is going to have to be provided by the service catalog.
|
||||
new_netloc = netloc.replace(':%d' % port, ':%d' % (35357))
|
||||
new_netloc = netloc.replace(':%d' % port, ':%d' % (35357,))
|
||||
admin_url = urlparse.urlunsplit(
|
||||
(scheme, new_netloc, path, query, frag))
|
||||
|
||||
|
@ -1,2 +1 @@
|
||||
from novaclient.keystone.client import Client
|
||||
|
||||
|
@ -78,7 +78,7 @@ class TenantManager(base.ManagerWithFind):
|
||||
"""
|
||||
update a tenant with a new name and description
|
||||
"""
|
||||
body = {"tenant": {'id': tenant_id }}
|
||||
body = {"tenant": {'id': tenant_id}}
|
||||
if enabled is not None:
|
||||
body['tenant']['enabled'] = enabled
|
||||
if description:
|
||||
|
@ -36,7 +36,7 @@ class UserManager(base.ManagerWithFind):
|
||||
"""
|
||||
# FIXME(ja): why do we have to send id in params and url?
|
||||
params = {"user": {"id": base.getid(user),
|
||||
"email": email }}
|
||||
"email": email}}
|
||||
|
||||
self._update("/users/%s" % base.getid(user), params)
|
||||
|
||||
@ -45,7 +45,7 @@ class UserManager(base.ManagerWithFind):
|
||||
Update enabled-ness
|
||||
"""
|
||||
params = {"user": {"id": base.getid(user),
|
||||
"enabled": enabled }}
|
||||
"enabled": enabled}}
|
||||
|
||||
self._update("/users/%s/enabled" % base.getid(user), params)
|
||||
|
||||
@ -54,7 +54,7 @@ class UserManager(base.ManagerWithFind):
|
||||
Update password
|
||||
"""
|
||||
params = {"user": {"id": base.getid(user),
|
||||
"password": password }}
|
||||
"password": password}}
|
||||
|
||||
self._update("/users/%s/password" % base.getid(user), params)
|
||||
|
||||
@ -63,7 +63,7 @@ class UserManager(base.ManagerWithFind):
|
||||
Update default tenant.
|
||||
"""
|
||||
params = {"user": {"id": base.getid(user),
|
||||
"tenantId": base.getid(tenant) }}
|
||||
"tenantId": base.getid(tenant)}}
|
||||
|
||||
# FIXME(ja): seems like a bad url - default tenant is an attribute
|
||||
# not a subresource!???
|
||||
@ -73,7 +73,8 @@ class UserManager(base.ManagerWithFind):
|
||||
"""
|
||||
Create a user.
|
||||
"""
|
||||
# FIXME(ja): email should be optional but keystone currently requires it
|
||||
# FIXME(ja): email should be optional but keystone currently
|
||||
# requires it
|
||||
params = {"user": {"id": user_id,
|
||||
"password": password,
|
||||
"tenantId": tenant_id,
|
||||
|
@ -38,10 +38,13 @@ class ServiceCatalog(object):
|
||||
for endpoint in self.catalog['endpoints']:
|
||||
if not filter_value or endpoint[attr] == filter_value:
|
||||
return endpoint[endpoint_type]
|
||||
raise novaclient.exceptions.EndpointNotFound()
|
||||
|
||||
# We don't always get a service catalog back ...
|
||||
if not 'serviceCatalog' in self.catalog['access']:
|
||||
return None
|
||||
|
||||
# Full catalog ...
|
||||
catalog = self.catalog['access']['serviceCatalog']
|
||||
|
||||
for service in catalog:
|
||||
|
@ -174,9 +174,8 @@ class OpenStackComputeShell(object):
|
||||
"via --url or via"
|
||||
"env[NOVA_URL")
|
||||
|
||||
self.cs = self.get_api_class(options.version) \
|
||||
(user, apikey, projectid, url,
|
||||
region_name=region_name)
|
||||
self.cs = self.get_api_class(options.version)(user, apikey, projectid,
|
||||
url, region_name=region_name)
|
||||
|
||||
try:
|
||||
self.cs.authenticate()
|
||||
|
@ -58,9 +58,9 @@ class ImageManager(base.ManagerWithFind):
|
||||
self._delete("/images/%s" % base.getid(image))
|
||||
|
||||
def set_meta(self, image, metadata):
|
||||
"""
|
||||
"""
|
||||
Set an images metadata
|
||||
|
||||
|
||||
:param image: The :class:`Image` to add metadata to
|
||||
:param metadata: A dict of metadata to add to the image
|
||||
"""
|
||||
@ -69,9 +69,9 @@ class ImageManager(base.ManagerWithFind):
|
||||
"metadata")
|
||||
|
||||
def delete_meta(self, image, keys):
|
||||
"""
|
||||
"""
|
||||
Delete metadata from an image
|
||||
|
||||
|
||||
:param image: The :class:`Image` to add metadata to
|
||||
:param keys: A list of metadata keys to delete from the image
|
||||
"""
|
||||
|
@ -253,7 +253,7 @@ def do_zone_boot(cs, args):
|
||||
min_count=min_count,
|
||||
max_count=max_count)
|
||||
print "Reservation ID=", reservation_id
|
||||
|
||||
|
||||
|
||||
def _translate_flavor_keys(collection):
|
||||
convert = [('ram', 'memory_mb'), ('disk', 'local_gb')]
|
||||
@ -844,6 +844,7 @@ def do_volume_detach(cs, args):
|
||||
cs.volumes.delete_server_volume(_find_server(cs, args.server).id,
|
||||
args.attachment_id)
|
||||
|
||||
|
||||
def _print_floating_ip_list(floating_ips):
|
||||
utils.print_list(floating_ips, ['Ip', 'Instance Id', 'Fixed Ip'])
|
||||
|
||||
@ -1038,7 +1039,8 @@ def do_secgroup_delete_group_rule(cs, args):
|
||||
|
||||
|
||||
@utils.arg('name', metavar='<name>', help='Name of key.')
|
||||
@utils.arg('--pub_key', metavar='<pub_key>', help='Path to a public ssh key.', default=None)
|
||||
@utils.arg('--pub_key', metavar='<pub_key>', help='Path to a public ssh key.',
|
||||
default=None)
|
||||
def do_keypair_add(cs, args):
|
||||
"""Create a new key pair for use with instances"""
|
||||
name = args.name
|
||||
@ -1049,8 +1051,9 @@ def do_keypair_add(cs, args):
|
||||
with open(pub_key) as f:
|
||||
pub_key = f.read()
|
||||
except IOError, e:
|
||||
raise exceptions.CommandError("Can't open or read '%s': %s" % (pub_key, e))
|
||||
|
||||
raise exceptions.CommandError("Can't open or read '%s': %s" % \
|
||||
(pub_key, e))
|
||||
|
||||
keypair = cs.keypairs.create(name, pub_key)
|
||||
|
||||
if not pub_key:
|
||||
@ -1070,4 +1073,3 @@ def do_keypair_list(cs, args):
|
||||
keypairs = cs.keypairs.list()
|
||||
columns = ['Name', 'Fingerprint']
|
||||
utils.print_list(keypairs, columns)
|
||||
|
||||
|
@ -125,5 +125,5 @@ class VolumeManager(base.ManagerWithFind):
|
||||
:param server_id: The ID of the server
|
||||
:param attachment_id: The ID of the attachment
|
||||
"""
|
||||
return self._delete("/servers/%s/os-volume_attachments/%s" % (server_id,
|
||||
attachment_id,))
|
||||
return self._delete("/servers/%s/os-volume_attachments/%s" %
|
||||
(server_id, attachment_id,))
|
||||
|
Loading…
Reference in New Issue
Block a user