From 01313e56fe446ea3eaa459b0cc9dcf89c043de7d Mon Sep 17 00:00:00 2001 From: Ed Cranford Date: Mon, 23 Apr 2012 12:58:21 -0500 Subject: [PATCH] PEP8 fixes --- reddwarfclient/accounts.py | 7 ++++--- reddwarfclient/base.py | 5 ++--- reddwarfclient/common.py | 3 ++- reddwarfclient/config.py | 2 +- reddwarfclient/databases.py | 3 ++- reddwarfclient/diagnostics.py | 2 ++ reddwarfclient/flavors.py | 2 +- reddwarfclient/instances.py | 3 ++- reddwarfclient/management.py | 21 ++++++++++++--------- reddwarfclient/root.py | 5 +++-- reddwarfclient/storage.py | 2 ++ reddwarfclient/users.py | 4 ++-- reddwarfclient/versions.py | 4 +++- 13 files changed, 38 insertions(+), 25 deletions(-) diff --git a/reddwarfclient/accounts.py b/reddwarfclient/accounts.py index 6d0e1dd2..8c5db215 100644 --- a/reddwarfclient/accounts.py +++ b/reddwarfclient/accounts.py @@ -15,6 +15,7 @@ from novaclient import base + class Account(base.Resource): """ Account is an opaque instance used to hold account information. @@ -22,13 +23,14 @@ class Account(base.Resource): def __repr__(self): return "" % self.name + class Accounts(base.ManagerWithFind): """ Manage :class:`Account` information. """ resource_class = Account - + def _list(self, url, response_key): resp, body = self.api.client.get(url) if not body: @@ -41,7 +43,7 @@ class Accounts(base.ManagerWithFind): :rtype: :class:`Account`. """ - + acct_name = self._get_account_name(account) return self._list("/mgmt/accounts/%s" % acct_name, 'account') @@ -52,4 +54,3 @@ class Accounts(base.ManagerWithFind): return account.name except AttributeError: return account - diff --git a/reddwarfclient/base.py b/reddwarfclient/base.py index eceabef4..db627a1a 100644 --- a/reddwarfclient/base.py +++ b/reddwarfclient/base.py @@ -1,7 +1,7 @@ - def isid(obj): """ - Returns true if the given object can be converted to an ID, false otherwise. + Returns true if the given object can be converted to an ID, + false otherwise. """ if hasattr(obj, "id"): return True @@ -12,4 +12,3 @@ def isid(obj): return False else: return True - diff --git a/reddwarfclient/common.py b/reddwarfclient/common.py index 5a3c6169..48bfdb74 100644 --- a/reddwarfclient/common.py +++ b/reddwarfclient/common.py @@ -95,7 +95,8 @@ class Auth(object): def __init__(self): pass - def login(self, user, apikey, tenant="dbaas", auth_url="http://localhost:5000/v1.1", + def login(self, user, apikey, tenant="dbaas", + auth_url="http://localhost:5000/v1.1", service_name="reddwarf", service_url=None): """Login to retrieve an auth token to use for other api calls""" try: diff --git a/reddwarfclient/config.py b/reddwarfclient/config.py index c0e8b52d..e3429322 100644 --- a/reddwarfclient/config.py +++ b/reddwarfclient/config.py @@ -42,7 +42,7 @@ class Configs(base.ManagerWithFind): """ Delete an existing configuration """ - url = "/mgmt/configs/%s"% config + url = "/mgmt/configs/%s" % config self._delete(url) def list(self): diff --git a/reddwarfclient/databases.py b/reddwarfclient/databases.py index a88090a7..2c721f35 100644 --- a/reddwarfclient/databases.py +++ b/reddwarfclient/databases.py @@ -5,7 +5,8 @@ import exceptions class Database(base.Resource): """ - According to Wikipedia, "A database is a system intended to organize, store, and retrieve + According to Wikipedia, "A database is a system intended to organize, + store, and retrieve large amounts of data easily." """ def __repr__(self): diff --git a/reddwarfclient/diagnostics.py b/reddwarfclient/diagnostics.py index 9dd3906d..934ebcfd 100644 --- a/reddwarfclient/diagnostics.py +++ b/reddwarfclient/diagnostics.py @@ -16,6 +16,7 @@ from novaclient import base import exceptions + class Diagnostics(base.Resource): """ Account is an opaque instance used to hold account information. @@ -23,6 +24,7 @@ class Diagnostics(base.Resource): def __repr__(self): return "" % self.version + class Interrogator(base.ManagerWithFind): """ Manager class for Interrogator resource diff --git a/reddwarfclient/flavors.py b/reddwarfclient/flavors.py index fcaa646a..a205fcc1 100644 --- a/reddwarfclient/flavors.py +++ b/reddwarfclient/flavors.py @@ -20,6 +20,7 @@ import exceptions from reddwarfclient.common import check_for_exceptions + class Flavor(base.Resource): """ A Flavor is an Instance type, specifying among other things, RAM size. @@ -75,4 +76,3 @@ class Flavors(base.ManagerWithFind): """ return self._get("/flavors/%s" % base.getid(flavor), "flavor") - diff --git a/reddwarfclient/instances.py b/reddwarfclient/instances.py index 73645dd8..e918d48c 100644 --- a/reddwarfclient/instances.py +++ b/reddwarfclient/instances.py @@ -113,7 +113,8 @@ class Instances(base.ManagerWithFind): :param instance_id: The instance id to delete """ - resp, body = self.api.client.delete("/instances/%s" % base.getid(instance)) + resp, body = self.api.client.delete("/instances/%s" % + base.getid(instance)) if resp.status in (422, 500): raise exceptions.from_response(resp, body) diff --git a/reddwarfclient/management.py b/reddwarfclient/management.py index ca1e24ec..ca234dc4 100644 --- a/reddwarfclient/management.py +++ b/reddwarfclient/management.py @@ -18,10 +18,12 @@ from novaclient import base from reddwarfclient.common import check_for_exceptions from reddwarfclient.instances import Instance + class RootHistory(base.Resource): def __repr__(self): - return ("" - % (self.id, self.created, self.user)) + return ("" + % (self.id, self.created, self.user)) + class Management(base.ManagerWithFind): """ @@ -41,7 +43,7 @@ class Management(base.ManagerWithFind): :rtype: :class:`Instance`. """ - + return self._list("/mgmt/instances/%s" % base.getid(instance), 'instance') @@ -63,7 +65,8 @@ class Management(base.ManagerWithFind): resp, body = self.api.client.get(url) if not body: raise Exception("Call to " + url + " did not return a body.") - return [self.resource_class(self, instance) for instance in body['instances']] + return [self.resource_class(self, instance) + for instance in body['instances']] def root_enabled_history(self, instance): """ @@ -94,8 +97,8 @@ class Management(base.ManagerWithFind): self._action(instance_id, body) def update(self, instance_id): - """ - Update the guest agent via apt-get. - """ - body = {'update': {}} - self._action(instance_id, body) + """ + Update the guest agent via apt-get. + """ + body = {'update': {}} + self._action(instance_id, body) diff --git a/reddwarfclient/root.py b/reddwarfclient/root.py index 0aa16f9c..a71b200e 100644 --- a/reddwarfclient/root.py +++ b/reddwarfclient/root.py @@ -19,6 +19,7 @@ from reddwarfclient import users from reddwarfclient.common import check_for_exceptions import exceptions + class Root(base.ManagerWithFind): """ Manager class for Root resource @@ -37,7 +38,7 @@ class Root(base.ManagerWithFind): def is_root_enabled(self, instance_id): """ Return True if root is enabled for the instance; - False otherwise""" + False otherwise""" resp, body = self.api.client.get(self.url % instance_id) check_for_exceptions(resp, body) - return body['rootEnabled'] \ No newline at end of file + return body['rootEnabled'] diff --git a/reddwarfclient/storage.py b/reddwarfclient/storage.py index ab16bf6b..5edeebb3 100644 --- a/reddwarfclient/storage.py +++ b/reddwarfclient/storage.py @@ -15,6 +15,7 @@ from novaclient import base + class Device(base.Resource): """ Storage is an opaque instance used to hold storage information. @@ -22,6 +23,7 @@ class Device(base.Resource): def __repr__(self): return "" % self.name + class StorageInfo(base.ManagerWithFind): """ Manage :class:`Storage` resources. diff --git a/reddwarfclient/users.py b/reddwarfclient/users.py index 2b59b68f..f3a49a67 100644 --- a/reddwarfclient/users.py +++ b/reddwarfclient/users.py @@ -43,7 +43,7 @@ class Users(base.ManagerWithFind): def delete(self, instance_id, user): """Delete an existing user in the specified instance""" - url = "/instances/%s/users/%s"% (instance_id, user) + url = "/instances/%s/users/%s" % (instance_id, user) resp, body = self.api.client.delete(url) check_for_exceptions(resp, body) @@ -62,4 +62,4 @@ class Users(base.ManagerWithFind): :rtype: list of :class:`User`. """ return self._list("/instances/%s/users" % base.getid(instance), - "users") \ No newline at end of file + "users") diff --git a/reddwarfclient/versions.py b/reddwarfclient/versions.py index 6f09f1b1..b666e6a5 100644 --- a/reddwarfclient/versions.py +++ b/reddwarfclient/versions.py @@ -15,6 +15,7 @@ from novaclient import base + class Version(base.Resource): """ Version is an opaque instance used to hold version information. @@ -22,13 +23,14 @@ class Version(base.Resource): def __repr__(self): return "" % self.id + class Versions(base.ManagerWithFind): """ Manage :class:`Versions` information. """ resource_class = Version - + def index(self, url): """ Get a list of all versions.