From a2ec480f3c205f8a2349dc2960d508e6d36eda02 Mon Sep 17 00:00:00 2001 From: Peter Razumovsky Date: Thu, 17 Sep 2015 15:56:48 +0300 Subject: [PATCH] Fix [H405] pep rule in heat/scaling Implements bp docstring-improvements Change-Id: If1b98962ce20f28cefd01ccf7d6f88f7e908d0db --- heat/scaling/cooldown.py | 11 ++++++----- heat/scaling/lbutils.py | 5 ++--- heat/scaling/rolling_update.py | 7 ++----- heat/scaling/scalingutil.py | 3 ++- heat/scaling/template.py | 6 ++---- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/heat/scaling/cooldown.py b/heat/scaling/cooldown.py index bf7c82fb07..e5d523a0c1 100644 --- a/heat/scaling/cooldown.py +++ b/heat/scaling/cooldown.py @@ -16,11 +16,12 @@ import six class CooldownMixin(object): - ''' - Utility class to encapsulate Cooldown related logic which is shared - between AutoScalingGroup and ScalingPolicy. This logic includes both - cooldown timestamp comparing and scaling in progress checking. - ''' + """Utility class to encapsulate Cooldown related logic. + + This class is shared between AutoScalingGroup and ScalingPolicy. + This logic includes both cooldown timestamp comparing and scaling in + progress checking. + """ def _cooldown_inprogress(self): inprogress = False try: diff --git a/heat/scaling/lbutils.py b/heat/scaling/lbutils.py index 62bd34f78e..1e04be617f 100644 --- a/heat/scaling/lbutils.py +++ b/heat/scaling/lbutils.py @@ -23,12 +23,11 @@ from heat.engine import scheduler def reload_loadbalancers(group, load_balancers, exclude=None): - ''' - Notify the LoadBalancer to reload its config. + """Notify the LoadBalancer to reload its config. This must be done after activation (instance in ACTIVE state), otherwise the instances' IP addresses may not be available. - ''' + """ exclude = exclude or [] id_list = grouputils.get_member_refids(group, exclude=exclude) for name, lb in six.iteritems(load_balancers): diff --git a/heat/scaling/rolling_update.py b/heat/scaling/rolling_update.py index c662aa4c6e..6cae3cc2c4 100644 --- a/heat/scaling/rolling_update.py +++ b/heat/scaling/rolling_update.py @@ -12,8 +12,7 @@ def needs_update(targ_capacity, curr_capacity, num_up_to_date): - """ - Return whether there are more batch updates to do. + """Return whether there are more batch updates to do. Inputs are the target size for the group, the current size of the group, and the number of members that already have the latest definition. @@ -23,8 +22,7 @@ def needs_update(targ_capacity, curr_capacity, num_up_to_date): def next_batch(targ_capacity, curr_capacity, num_up_to_date, batch_size, min_in_service): - """ - Return details of the next batch in a batched update. + """Return details of the next batch in a batched update. The result is a tuple containing the new size of the group and the number of members that may receive the new definition (by a combination of @@ -35,7 +33,6 @@ def next_batch(targ_capacity, curr_capacity, num_up_to_date, batch_size, size, and the minimum number of members to keep in service during a rolling update. """ - assert num_up_to_date <= curr_capacity efft_min_sz = min(min_in_service, targ_capacity, curr_capacity) diff --git a/heat/scaling/scalingutil.py b/heat/scaling/scalingutil.py index 4799a0b7bc..91a7671747 100644 --- a/heat/scaling/scalingutil.py +++ b/heat/scaling/scalingutil.py @@ -24,7 +24,8 @@ CFN_ADJUSTMENT_TYPES = ( def calculate_new_capacity(current, adjustment, adjustment_type, min_adjustment_step, minimum, maximum): - """ + """Calculates new capacity from the given adjustments. + Given the current capacity, calculates the new capacity which results from applying the given adjustment of the given adjustment-type. The new capacity will be kept within the maximum and minimum bounds. diff --git a/heat/scaling/template.py b/heat/scaling/template.py index c2d54a629b..ca83ca6a64 100644 --- a/heat/scaling/template.py +++ b/heat/scaling/template.py @@ -21,8 +21,7 @@ def _identity(resource_name, definition): def member_definitions(old_resources, new_definition, num_resources, num_new, get_new_id, customise=_identity): - """ - Iterate over resource definitions for a scaling group + """Iterate over resource definitions for a scaling group Generates the definitions for the next change to the scaling group. Each item is a (name, definition) tuple. @@ -60,8 +59,7 @@ def member_definitions(old_resources, new_definition, def make_template(resource_definitions, version=('heat_template_version', '2015-04-30'), child_env=None): - """ - Return a Template object containing the given resource definitions. + """Return a Template object containing the given resource definitions. By default, the template will be in the HOT format. A different format can be specified by passing a (version_type, version_string) tuple matching