PEP8 fixes

This commit is contained in:
Ed Cranford
2012-04-23 12:58:21 -05:00
parent 3e92682e3a
commit 01313e56fe
13 changed files with 38 additions and 25 deletions

View File

@@ -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 "<Account: %s>" % 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

View File

@@ -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

View File

@@ -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:

View File

@@ -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):

View File

@@ -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):

View File

@@ -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 "<Diagnostics: %s>" % self.version
class Interrogator(base.ManagerWithFind):
"""
Manager class for Interrogator resource

View File

@@ -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")

View File

@@ -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)

View File

@@ -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 ("<Root History: Instance %s enabled at %s by %s>"
% (self.id, self.created, self.user))
return ("<Root History: Instance %s enabled at %s by %s>"
% (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)

View File

@@ -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']
return body['rootEnabled']

View File

@@ -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 "<Device: %s>" % self.name
class StorageInfo(base.ManagerWithFind):
"""
Manage :class:`Storage` resources.

View File

@@ -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")
"users")

View File

@@ -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 "<Version: %s>" % self.id
class Versions(base.ManagerWithFind):
"""
Manage :class:`Versions` information.
"""
resource_class = Version
def index(self, url):
"""
Get a list of all versions.