summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorPeter Razumovsky <prazumovsky@mirantis.com>2015-09-21 16:38:07 +0300
committerPeter Razumovsky <prazumovsky@mirantis.com>2015-10-08 15:13:52 +0300
commit2d5a9b18d662765328c2d84f26d61c794968e8c6 (patch)
treea58a30a167074db3d547fde1b06f1900734d83fb /contrib
parentcdc6e9672300df057fc480a5a66678af1d50132f (diff)
downloadheat-2d5a9b18d662765328c2d84f26d61c794968e8c6.tar.gz
Fix [H405] pep rule in contrib
Implements bp docstring-improvements Change-Id: I4da78917bc129074f1b7c0055b0da2e63b5896e1
Diffstat (limited to 'contrib')
-rw-r--r--contrib/rackspace/heat_keystoneclient_v2/client.py13
-rw-r--r--contrib/rackspace/rackspace/clients.py14
-rw-r--r--contrib/rackspace/rackspace/resources/auto_scale.py3
-rw-r--r--contrib/rackspace/rackspace/resources/cloud_dns.py1
-rw-r--r--contrib/rackspace/rackspace/resources/cloud_loadbalancer.py3
-rw-r--r--contrib/rackspace/rackspace/tests/test_auto_scale.py53
-rw-r--r--contrib/rackspace/rackspace/tests/test_rackspace_dns.py28
7 files changed, 50 insertions, 65 deletions
diff --git a/contrib/rackspace/heat_keystoneclient_v2/client.py b/contrib/rackspace/heat_keystoneclient_v2/client.py
index 4ef21d415..aa23b9f75 100644
--- a/contrib/rackspace/heat_keystoneclient_v2/client.py
+++ b/contrib/rackspace/heat_keystoneclient_v2/client.py
@@ -28,7 +28,6 @@ LOG.info(_LI("Keystone V2 loaded"))
class KeystoneClientV2(object):
-
"""Wrap keystone client so we can encapsulate logic used in resources.
Note: This is intended to be initialized from a resource on a per-session
@@ -37,6 +36,7 @@ class KeystoneClientV2(object):
via the code in engine/client.py, so there should not be any need to
directly instantiate instances of this class inside resources themselves.
"""
+
def __init__(self, context):
# If a trust_id is specified in the context, we immediately
# authenticate so we can populate the context with a trust token
@@ -148,13 +148,14 @@ class KeystoneClientV2(object):
return getattr(cfg.CONF.clients, option)
def create_stack_user(self, username, password=''):
- """
- Create a user defined as part of a stack, either via template
+ """Create a user.
+
+ User can be defined as part of a stack, either via template
or created internally by a resource. This user will be added to
the heat_stack_user_role as defined in the config
Returns the keystone ID of the resulting user
"""
- if(len(username) > 64):
+ if len(username) > 64:
LOG.warn(_LW("Truncating the username %s to the last 64 "
"characters."), username)
# get the last 64 characters of the username
@@ -224,11 +225,11 @@ class KeystoneClientV2(object):
return self.delete_stack_user(user_id)
def create_stack_domain_project(self, project_id):
- '''Use the tenant ID as domain project.'''
+ """Use the tenant ID as domain project."""
return self.context.tenant_id
def delete_stack_domain_project(self, project_id):
- '''Pass through method since no project was created.'''
+ """Pass through method since no project was created."""
pass
def create_stack_domain_user_keypair(self, user_id, project_id):
diff --git a/contrib/rackspace/rackspace/clients.py b/contrib/rackspace/rackspace/clients.py
index caa672dda..dd737b6ec 100644
--- a/contrib/rackspace/rackspace/clients.py
+++ b/contrib/rackspace/rackspace/clients.py
@@ -106,8 +106,7 @@ class RackspaceNovaClient(nova.NovaClientPlugin,
class RackspaceCloudNetworksClient(RackspaceClientPlugin):
def _create(self):
- """
- Rackspace cloud networks client.
+ """Rackspace cloud networks client.
Though pyrax "fixed" the network client bugs that were introduced
in 1.8, it still doesn't work for contexts because of caching of the
@@ -128,8 +127,7 @@ class RackspaceCloudNetworksClient(RackspaceClientPlugin):
class RackspaceTroveClient(trove.TroveClientPlugin):
- """
- Rackspace trove client.
+ """Rackspace trove client.
Since the pyrax module uses its own client implementation for Cloud
Databases, we have to skip pyrax on this one and override the super
@@ -178,7 +176,7 @@ class RackspaceCinderClient(cinder.CinderClientPlugin):
class RackspaceSwiftClient(swift.SwiftClientPlugin):
def is_valid_temp_url_path(self, path):
- '''Return True if path is a valid Swift TempURL path, False otherwise.
+ """Return True if path is a valid Swift TempURL path, False otherwise.
A Swift TempURL path must:
- Be five parts, ['', 'v1', 'account', 'container', 'object']
@@ -188,7 +186,7 @@ class RackspaceSwiftClient(swift.SwiftClientPlugin):
:param path: The TempURL path
:type path: string
- '''
+ """
parts = path.split('/', 4)
return bool(len(parts) == 5 and
not parts[0] and
@@ -199,9 +197,7 @@ class RackspaceSwiftClient(swift.SwiftClientPlugin):
def get_temp_url(self, container_name, obj_name, timeout=None,
method='PUT'):
- '''
- Return a Swift TempURL.
- '''
+ """Return a Swift TempURL."""
def tenant_uuid():
access = self.context.auth_token_info['access']
for role in access['user']['roles']:
diff --git a/contrib/rackspace/rackspace/resources/auto_scale.py b/contrib/rackspace/rackspace/resources/auto_scale.py
index e351eed7c..b48ef2e13 100644
--- a/contrib/rackspace/rackspace/resources/auto_scale.py
+++ b/contrib/rackspace/rackspace/resources/auto_scale.py
@@ -37,7 +37,6 @@ except ImportError:
class Group(resource.Resource):
-
"""Represents a scaling group."""
# pyrax differs drastically from the actual Auto Scale API. We'll prefer
@@ -387,7 +386,6 @@ class Group(resource.Resource):
class ScalingPolicy(resource.Resource):
-
"""Represents a Rackspace Auto Scale scaling policy."""
support_status = support.SupportStatus(
@@ -512,7 +510,6 @@ class ScalingPolicy(resource.Resource):
class WebHook(resource.Resource):
-
"""Represents a Rackspace AutoScale webhook.
Exposes the URLs of the webhook as attributes.
diff --git a/contrib/rackspace/rackspace/resources/cloud_dns.py b/contrib/rackspace/rackspace/resources/cloud_dns.py
index a613f4b4f..a577401e2 100644
--- a/contrib/rackspace/rackspace/resources/cloud_dns.py
+++ b/contrib/rackspace/rackspace/resources/cloud_dns.py
@@ -36,7 +36,6 @@ LOG = logging.getLogger(__name__)
class CloudDns(resource.Resource):
-
"""Represents a DNS resource."""
support_status = support.SupportStatus(
diff --git a/contrib/rackspace/rackspace/resources/cloud_loadbalancer.py b/contrib/rackspace/rackspace/resources/cloud_loadbalancer.py
index 4139d1c3d..945010468 100644
--- a/contrib/rackspace/rackspace/resources/cloud_loadbalancer.py
+++ b/contrib/rackspace/rackspace/resources/cloud_loadbalancer.py
@@ -71,7 +71,6 @@ class LoadbalancerBuildError(exception.HeatException):
class CloudLoadBalancer(resource.Resource):
-
"""Represents a Rackspace Cloud Loadbalancer."""
support_status = support.SupportStatus(
@@ -875,7 +874,7 @@ class CloudLoadBalancer(resource.Resource):
return scheduler.TaskRunner(disable_content_caching)
def check_update_complete(self, checkers):
- '''Push all checkers to completion in list order.'''
+ """Push all checkers to completion in list order."""
for checker in checkers:
if not checker.started():
checker.start()
diff --git a/contrib/rackspace/rackspace/tests/test_auto_scale.py b/contrib/rackspace/rackspace/tests/test_auto_scale.py
index 1df754f4e..bb0c834f2 100644
--- a/contrib/rackspace/rackspace/tests/test_auto_scale.py
+++ b/contrib/rackspace/rackspace/tests/test_auto_scale.py
@@ -216,9 +216,9 @@ class ScalingGroupTest(common.HeatTestCase):
self.stack.status_reason)
def test_group_create(self):
- """
- Creating a group passes all the correct arguments to pyrax and saves
- the group ID as the resource ID.
+ """Creating a group passes all the correct arguments to pyrax.
+
+ Also saves the group ID as the resource ID.
"""
self._setup_test_stack()
self.assertEqual(1, len(self.fake_auto_scale.groups))
@@ -330,8 +330,9 @@ Resources:
self.assertIn('boom', str(exc))
def test_update_group_config(self):
- """
- Updating the groupConfiguration section in a template results in a
+ """Updates the groupConfiguration section.
+
+ Updates the groupConfiguration section in a template results in a
pyrax call to update the group configuration.
"""
self._setup_test_stack()
@@ -349,8 +350,9 @@ Resources:
5, self.fake_auto_scale.groups['0'].kwargs['min_entities'])
def test_update_launch_config(self):
- """
- Updating the launchConfigresults section in a template results in a
+ """Updates the launchConfigresults section.
+
+ Updates the launchConfigresults section in a template results in a
pyrax call to update the launch configuration.
"""
self._setup_test_stack()
@@ -371,19 +373,14 @@ Resources:
self.fake_auto_scale.groups['0'].kwargs['load_balancers'])
def test_delete(self):
- """
- Deleting a ScalingGroup resource invokes the pyrax API to delete it.
- """
+ """Deleting a ScalingGroup resource invokes pyrax API to delete it."""
self._setup_test_stack()
resource = self.stack['my_group']
scheduler.TaskRunner(resource.delete)()
self.assertEqual({}, self.fake_auto_scale.groups)
def test_delete_without_backing_group(self):
- """
- If no backing scaling group exists, resource deletion silently
- succeeds.
- """
+ """Resource deletion succeeds, if no backing scaling group exists."""
self._setup_test_stack()
resource = self.stack['my_group']
del self.fake_auto_scale.groups['0']
@@ -391,7 +388,8 @@ Resources:
self.assertEqual({}, self.fake_auto_scale.groups)
def test_delete_waits_for_server_deletion(self):
- """
+ """Test case for waiting for successful resource deletion.
+
The delete operation may fail until the servers are really gone; the
resource retries until success.
"""
@@ -410,7 +408,8 @@ Resources:
self.assertEqual(4, next(delete_counter))
def test_delete_blows_up_on_other_errors(self):
- """
+ """Test case for correct error handling during deletion.
+
Only the Forbidden (403) error is honored as an indicator of pending
deletion; other errors cause deletion to fail.
"""
@@ -458,9 +457,9 @@ class PolicyTest(common.HeatTestCase):
self.stack.status_reason)
def test_create_webhook_change(self):
- """
- Creating the resource creates the scaling policy with pyrax,
- and sets the resource's ID to {group_id}:{policy_id}
+ """Creating the resource creates the scaling policy with pyrax.
+
+ Also sets the resource's ID to {group_id}:{policy_id}.
"""
self._setup_test_stack(self.policy_template)
resource = self.stack['my_policy']
@@ -475,7 +474,8 @@ class PolicyTest(common.HeatTestCase):
self.fake_auto_scale.policies['0'].kwargs)
def test_webhook_change_percent(self):
- """
+ """Test case for specified changePercent.
+
When changePercent is specified, it translates to pyrax arguments
'change' and 'is_percent'.
"""
@@ -494,7 +494,8 @@ class PolicyTest(common.HeatTestCase):
self.fake_auto_scale.policies['0'].kwargs)
def test_webhook_desired_capacity(self):
- """
+ """Test case for desiredCapacity property.
+
The desiredCapacity property translates to the desired_capacity pyrax
argument.
"""
@@ -529,9 +530,7 @@ class PolicyTest(common.HeatTestCase):
self.fake_auto_scale.policies['0'].kwargs)
def test_update(self):
- """
- Updating the resource calls the appropriate update method with pyrax.
- """
+ """Updating the resource calls appropriate update method with pyrax."""
self._setup_test_stack(self.policy_template)
resource = self.stack['my_policy']
uprops = copy.deepcopy(dict(resource.properties.data))
@@ -560,7 +559,8 @@ class PolicyTest(common.HeatTestCase):
self.assertEqual({}, self.fake_auto_scale.policies)
def test_delete_policy_non_existent(self):
- """
+ """Test case for deleting resource without backing policy.
+
Deleting a resource for which there is no backing policy succeeds
silently.
"""
@@ -651,7 +651,8 @@ class WebHookTest(common.HeatTestCase):
self.assertEqual({}, self.fake_auto_scale.webhooks)
def test_delete_without_backing_webhook(self):
- """
+ """Test case for deleting resource without backing webhook.
+
Deleting a resource for which there is no backing webhook succeeds
silently.
"""
diff --git a/contrib/rackspace/rackspace/tests/test_rackspace_dns.py b/contrib/rackspace/rackspace/tests/test_rackspace_dns.py
index 741812b59..77feca7ef 100644
--- a/contrib/rackspace/rackspace/tests/test_rackspace_dns.py
+++ b/contrib/rackspace/rackspace/tests/test_rackspace_dns.py
@@ -159,9 +159,7 @@ class RackspaceDnsTest(common.HeatTestCase):
return create_args
def test_create_domain_only(self):
- """
- Test domain create only without any records.
- """
+ """Test domain create only without any records."""
fake_dns_instance = FakeDnsInstance()
t = template_format.parse(domain_only_template)
instance = self._setup_test_cloud_dns_instance('dnsinstance_create', t)
@@ -172,9 +170,9 @@ class RackspaceDnsTest(common.HeatTestCase):
self.m.VerifyAll()
def test_create_domain_with_a_record(self):
- """
- Test domain create with an A record. This should not have a
- priority field.
+ """Test domain create with an A record.
+
+ This should not have a priority field.
"""
fake_dns_instance = FakeDnsInstance()
t = template_format.parse(domain_only_template)
@@ -193,9 +191,9 @@ class RackspaceDnsTest(common.HeatTestCase):
self.m.VerifyAll()
def test_create_domain_with_mx_record(self):
- """
- Test domain create with an MX record. This should have a
- priority field.
+ """Test domain create with an MX record.
+
+ This should have a priority field.
"""
fake_dns_instance = FakeDnsInstance()
t = template_format.parse(domain_only_template)
@@ -233,9 +231,7 @@ class RackspaceDnsTest(common.HeatTestCase):
self.assertIn('boom', str(exc))
def test_update(self, updateRecords=None):
- """
- Helper function for testing domain updates.
- """
+ """Helper function for testing domain updates."""
fake_dns_instance = FakeDnsInstance()
t = template_format.parse(domain_only_template)
instance = self._setup_test_cloud_dns_instance('dnsinstance_update', t)
@@ -264,15 +260,11 @@ class RackspaceDnsTest(common.HeatTestCase):
self.m.VerifyAll()
def test_update_domain_only(self):
- """
- Test domain update without any records.
- """
+ """Test domain update without any records."""
self.test_update()
def test_update_domain_with_a_record(self):
- """
- Test domain update with an A record.
- """
+ """Test domain update with an A record."""
a_record = [{'type': 'A',
'name': 'ftp.example.com',
'data': '192.0.2.8',