Fix [H405] pep rule in heat/resources

Implements bp docstring-improvements

Change-Id: I8a9328f59b6996f65715ec35102eb6c9585f6ed1
This commit is contained in:
Peter Razumovsky 2015-09-22 11:00:54 +03:00
parent 2f9ea624de
commit c797cf1c28
50 changed files with 259 additions and 342 deletions

View File

@ -233,7 +233,8 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
return done
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
"""
"""Updates self.properties, if Properties has changed.
If Properties has changed, update self.properties, so we get the new
values during any subsequent adjustment.
"""
@ -261,9 +262,7 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
def adjust(self, adjustment,
adjustment_type=sc_util.CFN_CHANGE_IN_CAPACITY,
min_adjustment_step=None, signal=False):
"""
Adjust the size of the scaling group if the cooldown permits.
"""
"""Adjust the size of the scaling group if the cooldown permits."""
if self._cooldown_inprogress():
LOG.info(_LI("%(name)s NOT performing scaling adjustment, "
"cooldown %(cooldown)s"),
@ -320,7 +319,7 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
adjustment))
def _tags(self):
"""Add Identifing Tags to all servers in the group.
"""Add Identifying Tags to all servers in the group.
This is so the Dimensions received from cfn-push-stats all include
the groupname and stack id.
@ -372,10 +371,11 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
super(AutoScalingGroup, self).validate()
def _resolve_attribute(self, name):
'''
"""Resolves the resource's attributes.
heat extension: "InstanceList" returns comma delimited list of server
ip addresses.
'''
"""
if name == self.INSTANCE_LIST:
return u','.join(inst.FnGetAtt('PublicIp')
for inst in grouputils.get_members(self)) or None

View File

@ -234,9 +234,7 @@ class LaunchConfiguration(resource.Resource):
return self.physical_resource_name_or_FnGetRefId()
def validate(self):
'''
Validate any of the provided params
'''
"""Validate any of the provided params."""
super(LaunchConfiguration, self).validate()
# now we don't support without snapshot_id in bdm
bdm = self.properties.get(self.BLOCK_DEVICE_MAPPINGS)

View File

@ -24,9 +24,7 @@ from heat.engine.resources import stack_resource
class NestedStack(stack_resource.StackResource):
'''
A Resource representing a child stack to allow composition of templates.
'''
"""Represents a child stack to allow composition of templates."""
PROPERTIES = (
TEMPLATE_URL, TIMEOUT_IN_MINS, PARAMETERS,

View File

@ -19,13 +19,14 @@ from heat.engine import support
class WaitConditionHandle(wc_base.BaseWaitConditionHandle):
'''
"""AWS WaitConditionHandle resource.
the main point of this class is to :
have no dependencies (so the instance can reference it)
generate a unique url (to be returned in the reference)
then the cfn-signal will use this url to post to and
WaitCondition will poll it to see if has been written to.
'''
"""
support_status = support.SupportStatus(version='2014.1')
@ -47,8 +48,8 @@ class WaitConditionHandle(wc_base.BaseWaitConditionHandle):
self.handle_signal(details=new_metadata)
def handle_signal(self, details=None):
'''
Validate and update the resource metadata
"""Validate and update the resource metadata.
metadata must use the following format:
{
"Status" : "Status (must be SUCCESS or FAILURE)",
@ -56,7 +57,7 @@ class WaitConditionHandle(wc_base.BaseWaitConditionHandle):
"Data" : "Arbitrary Data",
"Reason" : "Reason String"
}
'''
"""
if details is None:
return
return super(WaitConditionHandle, self).handle_signal(details)

View File

@ -231,9 +231,7 @@ class ElasticIpAssociation(resource.Resource):
return self.physical_resource_name_or_FnGetRefId()
def validate(self):
'''
Validate any of the provided parameters
'''
"""Validate any of the provided parameters."""
super(ElasticIpAssociation, self).validate()
eip = self.properties[self.EIP]
allocation_id = self.properties[self.ALLOCATION_ID]

View File

@ -351,9 +351,10 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin):
self.ipaddress = None
def _set_ipaddress(self, networks):
'''
Read the server's IP address from a list of networks provided by Nova
'''
"""Set IP address to self.ipaddress from a list of networks.
Read the server's IP address from a list of networks provided by Nova.
"""
# Just record the first ipaddress
for n in sorted(networks, reverse=True):
if len(networks[n]) > 0:
@ -361,9 +362,10 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin):
break
def _ipaddress(self):
'''
Return the server's IP address, fetching it from Nova if necessary
'''
"""Return the server's IP address.
Fetching it from Nova if necessary.
"""
if self.ipaddress is None:
self.ipaddress = self.client_plugin().server_to_ipaddress(
self.resource_id)
@ -371,9 +373,10 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin):
return self.ipaddress or '0.0.0.0'
def _availability_zone(self):
'''
Return Server's Availability Zone, fetching it from Nova if necessary.
'''
"""Return Server's Availability Zone.
Fetching it from Nova if necessary.
"""
availability_zone = self.properties[self.AVAILABILITY_ZONE]
if availability_zone is None:
try:
@ -600,9 +603,10 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin):
return out
def volumes(self):
"""
Return an iterator over (volume_id, device) tuples for all volumes
that should be attached to this instance.
"""Return an iterator for all volumes that should be attached.
Return an iterator over (volume_id, device) tuples for all volumes that
should be attached to this instance.
"""
volumes = self.properties[self.VOLUMES]
@ -749,7 +753,7 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin):
return updaters
def check_update_complete(self, updaters):
'''Push all updaters to completion in list order.'''
"""Push all updaters to completion in list order."""
for prg in updaters:
if not prg.called:
handler = getattr(self.client_plugin(), prg.handler)
@ -764,16 +768,12 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin):
return all(prg.complete for prg in updaters)
def metadata_update(self, new_metadata=None):
'''
Refresh the metadata if new_metadata is None
'''
"""Refresh the metadata if new_metadata is None."""
if new_metadata is None:
self.metadata_set(self.t.metadata())
def validate(self):
'''
Validate any of the provided params
'''
"""Validate any of the provided params."""
res = super(Instance, self).validate()
if res:
return res
@ -833,11 +833,12 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin):
return self.client_plugin().check_delete_server_complete(server_id)
def handle_suspend(self):
'''
Suspend an instance - note we do not wait for the SUSPENDED state,
this is polled for by check_suspend_complete in a similar way to the
create logic so we can take advantage of coroutines
'''
"""Suspend an instance.
Note we do not wait for the SUSPENDED state, this is polled for by
check_suspend_complete in a similar way to the create logic so we can
take advantage of coroutines.
"""
if self.resource_id is None:
raise exception.Error(_('Cannot suspend %s, resource_id not set') %
self.name)
@ -875,11 +876,12 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin):
raise exc
def handle_resume(self):
'''
Resume an instance - note we do not wait for the ACTIVE state,
this is polled for by check_resume_complete in a similar way to the
create logic so we can take advantage of coroutines
'''
"""Resume an instance.
Note we do not wait for the ACTIVE state, this is polled for by
check_resume_complete in a similar way to the create logic so we can
take advantage of coroutines.
"""
if self.resource_id is None:
raise exception.Error(_('Cannot resume %s, resource_id not set') %
self.name)

View File

@ -184,12 +184,13 @@ class AccessKey(resource.Resource):
self._register_access_key()
def _get_user(self):
"""
"""Derive the keystone userid, stored in the User resource_id.
Helper function to derive the keystone userid, which is stored in the
resource_id of the User associated with this key. We want to avoid
resource_id of the User associated with this key. We want to avoid
looking the name up via listing keystone users, as this requires admin
rights in keystone, so FnGetAtt which calls _secret_accesskey won't
work for normal non-admin users
work for normal non-admin users.
"""
# Lookup User resource by intrinsic reference (which is what is passed
# into the UserName parameter. Would be cleaner to just make the User
@ -225,9 +226,10 @@ class AccessKey(resource.Resource):
user._delete_keypair()
def _secret_accesskey(self):
'''
Return the user's access key, fetching it from keystone if necessary
'''
"""Return the user's access key.
Fetching it from keystone if necessary.
"""
if self._secret is None:
if not self.resource_id:
LOG.info(_LI('could not get secret for %(username)s '

View File

@ -274,7 +274,6 @@ class LoadBalancer(stack_resource.StackResource):
(https://getfedora.org/cloud/download/)
and apart from installing packages goes through some hoops
around SELinux due to pecularities of heat-cfntools.
"""
PROPERTIES = (
@ -570,11 +569,11 @@ backend servers
return self.create_with_template(templ, params)
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
'''
re-generate the Metadata
save it to the db.
rely on the cfn-hup to reconfigure HAProxy
'''
"""Re-generate the Metadata.
Save it to the db.
Rely on the cfn-hup to reconfigure HAProxy.
"""
new_props = json_snippet.properties(self.properties_schema,
self.context)
@ -606,9 +605,7 @@ backend servers
return True
def validate(self):
'''
Validate any of the provided params
'''
"""Validate any of the provided params."""
res = super(LoadBalancer, self).validate()
if res:
return res
@ -630,9 +627,7 @@ backend servers
return six.text_type(self.name)
def _resolve_attribute(self, name):
'''
We don't really support any of these yet.
'''
"""We don't really support any of these yet."""
if name == self.DNS_NAME:
return self.get_output('PublicIp')
elif name in self.attributes_schema:

View File

@ -19,8 +19,7 @@ from heat.engine import support
class CinderEncryptedVolumeType(resource.Resource):
"""
A resource for encrypting a cinder volume type.
"""A resource for encrypting a cinder volume type.
Note that default cinder security policy usage of this resource
is limited to being used by administrators only.

View File

@ -20,8 +20,7 @@ from heat.engine import support
class CinderVolumeType(resource.Resource):
"""
A resource for creating cinder volume types.
"""A resource for creating cinder volume types.
Note that default cinder security policy usage of this resource
is limited to being used by administrators only.

View File

@ -19,9 +19,7 @@ from heat.engine import support
class GlanceImage(resource.Resource):
'''
A resource managing for image in Glance.
'''
"""A resource managing images in Glance."""
support_status = support.SupportStatus(version='2014.2')

View File

@ -20,8 +20,7 @@ from heat.rpc import api as rpc_api
class CloudConfig(software_config.SoftwareConfig):
'''
A configuration resource for representing cloud-init cloud-config.
"""A configuration resource for representing cloud-init cloud-config.
This resource allows cloud-config YAML to be defined and stored by the
config API. Any intrinsic functions called in the config will be resolved
@ -31,7 +30,7 @@ class CloudConfig(software_config.SoftwareConfig):
or OS::Heat::MultipartMime parts config. Since cloud-config is boot-only
configuration, any changes to the definition will result in the
replacement of all servers which reference it.
'''
"""
support_status = support.SupportStatus(version='2014.1')

View File

@ -98,10 +98,11 @@ class Restarter(signal_responder.SignalResponder):
self.stack.restart_resource(victim.name)
def _resolve_attribute(self, name):
'''
"""Resolves the resource's attributes.
heat extension: "AlarmUrl" returns the url to post to the policy
when there is an alarm.
'''
"""
if name == self.ALARM_URL and self.resource_id is not None:
return six.text_type(self._get_ec2_signed_url())

View File

@ -123,7 +123,8 @@ class InstanceGroup(stack_resource.StackResource):
}
def __init__(self, name, json_snippet, stack):
"""
"""Initialisation of the resource.
UpdatePolicy is currently only specific to InstanceGroup and
AutoScalingGroup. Therefore, init is overridden to parse for the
UpdatePolicy.
@ -133,9 +134,7 @@ class InstanceGroup(stack_resource.StackResource):
self.context)
def validate(self):
"""
Add validation for update_policy
"""
"""Add validation for update_policy."""
super(InstanceGroup, self).validate()
if self.update_policy is not None:
@ -177,8 +176,7 @@ class InstanceGroup(stack_resource.StackResource):
return self.create_with_template(initial_template)
def check_create_complete(self, task):
"""
When stack creation is done, update the load balancer.
"""When stack creation is done, update the loadbalancer.
If any instances failed to be created, delete them.
"""
@ -188,7 +186,8 @@ class InstanceGroup(stack_resource.StackResource):
return done
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
"""
"""Updates self.properties, if Properties has changed.
If Properties has changed, update self.properties, so we
get the new values during any subsequent adjustment.
"""
@ -214,8 +213,8 @@ class InstanceGroup(stack_resource.StackResource):
self.resize(curr_size)
def _tags(self):
"""
Make sure that we add a tag that Ceilometer can pick up.
"""Make sure that we add a tag that Ceilometer can pick up.
These need to be prepended with 'metering.'.
"""
tags = self.properties.get(self.TAGS) or []
@ -255,8 +254,7 @@ class InstanceGroup(stack_resource.StackResource):
def _create_template(self, num_instances, num_replace=0,
template_version=('HeatTemplateFormatVersion',
'2012-12-12')):
"""
Create a template to represent autoscaled instances.
"""Create a template to represent autoscaled instances.
Also see heat.scaling.template.member_definitions.
"""
@ -291,8 +289,9 @@ class InstanceGroup(stack_resource.StackResource):
return self.stack.timeout_secs() - total_pause_time
def _replace(self, min_in_service, batch_size, pause_sec):
"""
Replace the instances in the group using updated launch configuration
"""Replace the instances in the group.
Replace the instances in the group using updated launch configuration.
"""
def changing_instances(tmpl):
instances = grouputils.get_members(self)
@ -331,8 +330,7 @@ class InstanceGroup(stack_resource.StackResource):
@staticmethod
def _get_batches(capacity, batch_size, min_in_service):
"""
Return an iterator over the batches in a batched update.
"""Return an iterator over the batches in a batched update.
Each batch is a tuple comprising the total size of the group after
processing the batch, and the number of members that can receive the
@ -380,10 +378,11 @@ class InstanceGroup(stack_resource.StackResource):
return self.physical_resource_name_or_FnGetRefId()
def _resolve_attribute(self, name):
'''
"""Resolves the resource's attributes.
heat extension: "InstanceList" returns comma delimited list of server
ip addresses.
'''
"""
if name == self.INSTANCE_LIST:
return u','.join(inst.FnGetAtt('PublicIp')
for inst in grouputils.get_members(self)) or None

View File

@ -26,9 +26,7 @@ from heat.rpc import api as rpc_api
class MultipartMime(software_config.SoftwareConfig):
'''
A resource which assembles a collection of software configurations
as a multi-part mime message.
"""Assembles a collection of software configurations as a multi-part mime.
Parts in the message can be populated with inline configuration or
references to other config resources. If the referenced resource is itself
@ -42,7 +40,7 @@ class MultipartMime(software_config.SoftwareConfig):
configuration elements including scripts and cloud-config. Since
cloud-init is boot-only configuration, any changes to the definition
will result in the replacement of all servers which reference it.
'''
"""
support_status = support.SupportStatus(version='2014.1')

View File

@ -20,14 +20,13 @@ from heat.engine import support
class NoneResource(resource.Resource):
'''
A resource which enables easily disabling certain resources via the
resource_registry. It does nothing, but can effectively stub out
any other resource because it will accept any properties and return
any attribute (as None). Note this resource always does nothing
on update (e.g it is not replaced even if a change to the stubbed
resource properties would cause replacement).
'''
"""Enables easily disabling certain resources via the resource_registry.
It does nothing, but can effectively stub out any other resource because it
will accept any properties and return any attribute (as None). Note this
resource always does nothing on update (e.g it is not replaced even if a
change to the stubbed resource properties would cause replacement).
"""
support_status = support.SupportStatus(version='5.0.0')
properties_schema = {}

View File

@ -26,11 +26,10 @@ from heat.engine import support
class RandomString(resource.Resource):
'''
A resource which generates a random string.
"""A resource which generates a random string.
This is useful for configuring passwords and secrets on services.
'''
"""
support_status = support.SupportStatus(version='2014.1')

View File

@ -31,9 +31,9 @@ LOG = logging.getLogger(__name__)
class RemoteStack(resource.Resource):
"""
A Resource representing a stack which can be created using specified
context.
"""A Resource representing a stack.
Stack can be created using specified context.
"""
default_client_name = 'heat'

View File

@ -39,9 +39,7 @@ template_template = {
class ResourceGroup(stack_resource.StackResource):
"""
A resource that creates one or more identically configured nested
resources.
"""Creates one or more identically configured nested resources.
In addition to the `refs` attribute, this resource implements synthetic
attributes that mirror those of the resources in the group. When

View File

@ -110,9 +110,7 @@ class AutoScalingPolicy(signal_responder.SignalResponder,
}
def validate(self):
"""
Add validation for min_adjustment_step
"""
"""Add validation for min_adjustment_step."""
super(AutoScalingPolicy, self).validate()
self._validate_min_adjustment_step()
@ -131,7 +129,8 @@ class AutoScalingPolicy(signal_responder.SignalResponder,
self.resource_id_set(self._get_user_id())
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
"""
"""Updates self.properties, if Properties has changed.
If Properties has changed, update self.properties, so we get the new
values during any subsequent adjustment.
"""

View File

@ -22,8 +22,7 @@ from heat.rpc import api as rpc_api
class SoftwareComponent(sc.SoftwareConfig):
'''
A resource for describing and storing a software component.
"""A resource for describing and storing a software component.
This resource is similar to OS::Heat::SoftwareConfig. In contrast to
SoftwareConfig which allows for storing only one configuration (e.g. one
@ -34,7 +33,7 @@ class SoftwareComponent(sc.SoftwareConfig):
This resource is backed by the persistence layer and the API of the
SoftwareConfig resource, and only adds handling for the additional
'configs' property and attribute.
'''
"""
support_status = support.SupportStatus(version='2014.2')
@ -121,13 +120,12 @@ class SoftwareComponent(sc.SoftwareConfig):
self.resource_id_set(sc[rpc_api.SOFTWARE_CONFIG_ID])
def _resolve_attribute(self, name):
'''
Retrieve attributes of the SoftwareComponent resource.
"""Retrieve attributes of the SoftwareComponent resource.
'configs' returns the list of configurations for the software
component's lifecycle actions. If the attribute does not exist,
an empty list is returned.
'''
"""
if name == self.CONFIGS_ATTR and self.resource_id:
try:
sc = self.rpc_client().show_software_config(
@ -139,7 +137,7 @@ class SoftwareComponent(sc.SoftwareConfig):
self.rpc_client().ignore_error_named(ex, 'NotFound')
def validate(self):
'''Validate SoftwareComponent properties consistency.'''
"""Validate SoftwareComponent properties consistency."""
super(SoftwareComponent, self).validate()
# One lifecycle action (e.g. CREATE) can only be associated with one

View File

@ -25,8 +25,7 @@ LOG = logging.getLogger(__name__)
class SoftwareConfig(resource.Resource):
'''
A resource for describing and storing software configuration.
"""A resource for describing and storing software configuration.
The software_configs API which backs this resource creates immutable
configs, so any change to the template resource definition will result
@ -44,7 +43,7 @@ class SoftwareConfig(resource.Resource):
inputs and outputs which the config script is expected to consume and
produce. Inputs and outputs are optional and will map to concepts which
are specific to the configuration tool being used.
'''
"""
support_status = support.SupportStatus(version='2014.1')
@ -174,10 +173,11 @@ class SoftwareConfig(resource.Resource):
self.rpc_client().ignore_error_named(ex, 'NotFound')
def _resolve_attribute(self, name):
'''
"""Retrieve attributes of the SoftwareConfig resource.
"config" returns the config value of the software config. If the
software config does not exist, returns an empty string.
'''
"""
if name == self.CONFIG_ATTR and self.resource_id:
try:
sc = self.rpc_client().show_software_config(

View File

@ -37,9 +37,9 @@ LOG = logging.getLogger(__name__)
class SoftwareDeployment(signal_responder.SignalResponder):
'''
This resource associates a server with some configuration which
is to be deployed to that server.
"""This resource associates a server with some configuration.
The configuration is to be deployed to that server.
A deployment allows input values to be specified which map to the inputs
schema defined in the config resource. These input values are interpreted
@ -64,7 +64,7 @@ class SoftwareDeployment(signal_responder.SignalResponder):
actions, or a config can read the value of the deploy_action input to
allow conditional logic to perform different configuration for different
actions.
'''
"""
support_status = support.SupportStatus(version='2014.1')
@ -505,9 +505,7 @@ class SoftwareDeployment(signal_responder.SignalResponder):
timeutils.utcnow().isoformat())
def FnGetAtt(self, key, *path):
'''
Resource attributes map to deployment outputs values
'''
"""Resource attributes map to deployment outputs values."""
sd = self.rpc_client().show_software_deployment(
self.context, self.resource_id)
ov = sd[rpc_api.SOFTWARE_DEPLOYMENT_OUTPUT_VALUES] or {}
@ -527,11 +525,10 @@ class SoftwareDeployment(signal_responder.SignalResponder):
return None
def validate(self):
'''
Validate any of the provided params
"""Validate any of the provided params.
:raises StackValidationFailed: if any property failed validation.
'''
"""
super(SoftwareDeployment, self).validate()
server = self.properties[self.SERVER]
if server:
@ -546,16 +543,16 @@ class SoftwareDeployment(signal_responder.SignalResponder):
class SoftwareDeploymentGroup(resource_group.ResourceGroup):
'''
This resource associates a group of servers with some configuration which
is to be deployed to all servers in the group.
"""This resource associates a group of servers with some configuration.
The configuration is to be deployed to all servers in the group.
The properties work in a similar way to OS::Heat::SoftwareDeployment,
and in addition to the attributes documented, you may pass any
attribute supported by OS::Heat::SoftwareDeployment, including those
exposing arbitrary outputs, and return a map of deployment names to
the specified attribute.
'''
"""
support_status = support.SupportStatus(version='5.0.0')

View File

@ -26,14 +26,15 @@ from heat.engine import support
class StructuredConfig(sc.SoftwareConfig):
'''
"""A resource which has same logic with OS::Heat::SoftwareConfig.
This resource is like OS::Heat::SoftwareConfig except that the config
property is represented by a Map rather than a String.
This is useful for configuration tools which use YAML or JSON as their
configuration syntax. The resulting configuration is transferred,
stored and returned by the software_configs API as parsed JSON.
'''
"""
support_status = support.SupportStatus(version='2014.1')
@ -65,7 +66,8 @@ class StructuredConfig(sc.SoftwareConfig):
class StructuredDeployment(sd.SoftwareDeployment):
'''
"""A resource which has same logic with OS::Heat::SoftwareDeployment.
A deployment resource like OS::Heat::SoftwareDeployment, but which
performs input value substitution on the config defined by a
OS::Heat::StructuredConfig resource.
@ -78,7 +80,7 @@ class StructuredDeployment(sd.SoftwareDeployment):
with the value of input_name in this resource's input_values. If get_input
needs to be passed through to the substituted configuration then a
different input_key property value can be specified.
'''
"""
support_status = support.SupportStatus(version='2014.1')

View File

@ -104,9 +104,9 @@ class HeatWaitConditionHandle(wc_base.BaseWaitConditionHandle):
endpoint=self.data().get('endpoint')))
def handle_signal(self, details=None):
'''
Validate and update the resource metadata.
metadata is not mandatory, but if passed it must use the following
"""Validate and update the resource metadata.
Metadata is not mandatory, but if passed it must use the following
format:
{
"status" : "Status (must be SUCCESS or FAILURE)",
@ -115,7 +115,7 @@ class HeatWaitConditionHandle(wc_base.BaseWaitConditionHandle):
}
Optionally "id" may also be specified, but if missing the index
of the signal received will be used.
'''
"""
rsrc_metadata = self.metadata_get(refresh=True)
signal_num = len(rsrc_metadata) + 1
reason = 'Signal %s received' % signal_num
@ -129,14 +129,15 @@ class HeatWaitConditionHandle(wc_base.BaseWaitConditionHandle):
class UpdateWaitConditionHandle(aws_wch.WaitConditionHandle):
'''
"""WaitConditionHandle that clears signals and changes handle on update.
This works identically to a regular WaitConditionHandle, except that
on update it clears all signals received and changes the handle. Using
this handle means that you must setup the signal senders to send their
signals again any time the update handle changes. This allows us to roll
out new configurations and be confident that they are rolled out once
UPDATE COMPLETE is reached.
'''
"""
support_status = support.SupportStatus(version='2014.1')

View File

@ -20,9 +20,7 @@ from heat.engine import support
class KeystoneRoleAssignmentMixin(object):
'''
Keystone Role assignment class implements role assignments between
user/groups and project/domain.
"""Implements role assignments between user/groups and project/domain.
heat_template_version: 2013-05-23
@ -48,7 +46,7 @@ class KeystoneRoleAssignmentMixin(object):
domain: {get_param: group_role_domain}
- role: {get_param: group_role}
project: {get_param: group_role_project}
'''
"""
PROPERTIES = (
ROLES
@ -312,7 +310,7 @@ class KeystoneRoleAssignmentMixin(object):
class KeystoneUserRoleAssignment(resource.Resource,
KeystoneRoleAssignmentMixin):
'''Resource for granting roles to a user.'''
"""Resource for granting roles to a user."""
support_status = support.SupportStatus(
version='5.0.0',
@ -363,7 +361,7 @@ class KeystoneUserRoleAssignment(resource.Resource,
class KeystoneGroupRoleAssignment(resource.Resource,
KeystoneRoleAssignmentMixin):
'''Resource for granting roles to a group.'''
"""Resource for granting roles to a group."""
support_status = support.SupportStatus(
version='5.0.0',

View File

@ -19,9 +19,7 @@ from heat.engine import support
class BayModel(resource.Resource):
"""
A resource for the BayModel in Magnum.
"""
"""A resource for the BayModel in Magnum."""
support_status = support.SupportStatus(version='5.0.0')

View File

@ -19,7 +19,8 @@ from heat.engine import support
class SecurityService(resource.Resource):
"""
"""A resource that implements security service of Manila.
A security_service is a set of options that defines a security domain
for a particular shared filesystem protocol, such as an
Active Directory domain or a Kerberos domain.

View File

@ -21,7 +21,8 @@ from heat.engine import support
class ManilaShareNetwork(resource.Resource):
"""
"""A resource that stores network information for share servers.
Stores network information that will be used by share servers,
where shares are hosted.
"""

View File

@ -18,8 +18,7 @@ from heat.engine import support
class ManilaShareType(resource.Resource):
"""
A resource for creating manila share type.
"""A resource for creating manila share type.
A share_type is an administrator-defined "type of service", comprised of
a tenant visible description, and a list of non-tenant-visible key/value

View File

@ -20,9 +20,10 @@ from heat.engine import support
class MonascaAlarmDefinition(resource.Resource):
"""Heat Template Resource for Monasca Alarm definition. This plug-in
requires python-monascaclient>=1.0.22 .So to enable this plug-in, install
this client library and restart the heat-engine.
"""Heat Template Resource for Monasca Alarm definition.
This plug-in requires python-monascaclient>=1.0.22. So to enable this
plug-in, install this client library and restart the heat-engine.
"""
support_status = support.SupportStatus(

View File

@ -20,9 +20,10 @@ from heat.engine import support
class MonascaNotification(resource.Resource):
"""Heat Template Resource for Monasca Notification. This plug-in
requires python-monascaclient>=1.0.22 .So to enable this plug-in, install
this client library and restart the heat-engine.
"""Heat Template Resource for Monasca Notification.
This plug-in requires python-monascaclient>=1.0.22. So to enable this
plug-in, install this client library and restart the heat-engine.
"""
support_status = support.SupportStatus(

View File

@ -20,9 +20,7 @@ from heat.engine import support
class Firewall(neutron.NeutronResource):
"""
A resource for the Firewall resource in Neutron FWaaS.
"""
"""A resource for the Firewall resource in Neutron FWaaS."""
PROPERTIES = (
NAME, DESCRIPTION, ADMIN_STATE_UP, FIREWALL_POLICY_ID,
@ -143,9 +141,7 @@ class Firewall(neutron.NeutronResource):
class FirewallPolicy(neutron.NeutronResource):
"""
A resource for the FirewallPolicy resource in Neutron FWaaS.
"""
"""A resource for the FirewallPolicy resource in Neutron FWaaS."""
PROPERTIES = (
NAME, DESCRIPTION, SHARED, AUDITED, FIREWALL_RULES,
@ -250,9 +246,7 @@ class FirewallPolicy(neutron.NeutronResource):
class FirewallRule(neutron.NeutronResource):
"""
A resource for the FirewallRule resource in Neutron FWaaS.
"""
"""A resource for the FirewallRule resource in Neutron FWaaS."""
PROPERTIES = (
NAME, DESCRIPTION, SHARED, PROTOCOL, IP_VERSION,

View File

@ -25,9 +25,7 @@ from heat.engine import support
class HealthMonitor(neutron.NeutronResource):
"""
A resource for managing health monitors for load balancers in Neutron.
"""
"""A resource for managing health monitors for loadbalancers in Neutron."""
PROPERTIES = (
DELAY, TYPE, MAX_RETRIES, TIMEOUT, ADMIN_STATE_UP,
@ -173,9 +171,7 @@ class HealthMonitor(neutron.NeutronResource):
class Pool(neutron.NeutronResource):
"""
A resource for managing load balancer pools in Neutron.
"""
"""A resource for managing load balancer pools in Neutron."""
PROPERTIES = (
PROTOCOL, SUBNET_ID, SUBNET, LB_METHOD, NAME, DESCRIPTION,
@ -551,9 +547,7 @@ class Pool(neutron.NeutronResource):
class PoolMember(neutron.NeutronResource):
"""
A resource to handle load balancer members.
"""
"""A resource to handle loadbalancer members."""
support_status = support.SupportStatus(version='2014.1')
@ -676,9 +670,7 @@ class PoolMember(neutron.NeutronResource):
class LoadBalancer(resource.Resource):
"""
A resource to link a neutron pool with servers.
"""
"""A resource to link a neutron pool with servers."""
PROPERTIES = (
POOL_ID, PROTOCOL_PORT, MEMBERS,

View File

@ -20,9 +20,7 @@ from heat.engine import support
class MeteringLabel(neutron.NeutronResource):
"""
A resource for creating neutron metering label.
"""
"""A resource for creating neutron metering label."""
support_status = support.SupportStatus(version='2014.1')
@ -95,9 +93,7 @@ class MeteringLabel(neutron.NeutronResource):
class MeteringRule(neutron.NeutronResource):
"""
A resource to create rule for some label.
"""
"""A resource to create rule for some label."""
support_status = support.SupportStatus(version='2014.1')

View File

@ -26,9 +26,7 @@ from heat.engine import support
class NetworkGateway(neutron.NeutronResource):
'''
A resource for the Network Gateway resource in Neutron Network Gateway.
'''
"""Network Gateway resource in Neutron Network Gateway."""
support_status = support.SupportStatus(version='2014.1')
@ -163,9 +161,7 @@ class NetworkGateway(neutron.NeutronResource):
self.resource_id)['network_gateway']
def validate(self):
'''
Validate any of the provided params
'''
"""Validate any of the provided params."""
super(NetworkGateway, self).validate()
connections = self.properties[self.CONNECTIONS]

View File

@ -26,9 +26,7 @@ class NeutronResource(resource.Resource):
default_client_name = 'neutron'
def validate(self):
'''
Validate any of the provided params
'''
"""Validate any of the provided params."""
res = super(NeutronResource, self).validate()
if res:
return res
@ -36,13 +34,14 @@ class NeutronResource(resource.Resource):
@staticmethod
def validate_properties(properties):
'''
Validates to ensure nothing in value_specs overwrites
any key that exists in the schema.
"""Validate properties for the resource.
Validates to ensure nothing in value_specs overwrites any key that
exists in the schema.
Also ensures that shared and tenant_id is not specified
in value_specs.
'''
"""
if 'value_specs' in six.iterkeys(properties):
vs = properties.get('value_specs')
banned_keys = set(['shared', 'tenant_id']).union(
@ -68,13 +67,14 @@ class NeutronResource(resource.Resource):
@staticmethod
def prepare_properties(properties, name):
'''
"""Prepares the property values for correct Neutron create call.
Prepares the property values so that they can be passed directly to
the Neutron create call.
Removes None values and value_specs, merges value_specs with the main
values.
'''
"""
props = dict((k, v) for k, v in properties.items()
if v is not None and k != 'value_specs')
@ -87,13 +87,14 @@ class NeutronResource(resource.Resource):
return props
def prepare_update_properties(self, definition):
'''
"""Prepares the property values for correct Neutron update call.
Prepares the property values so that they can be passed directly to
the Neutron update call.
Removes any properties which are not update_allowed, then processes
as for prepare_properties.
'''
"""
p = definition.properties(self.properties_schema, self.context)
update_props = dict((k, v) for k, v in p.items()
if p.props.get(k).schema.update_allowed)
@ -127,13 +128,13 @@ class NeutronResource(resource.Resource):
@staticmethod
def get_secgroup_uuids(security_groups, client, tenant_id):
'''
Returns a list of security group UUIDs.
"""Returns a list of security group UUIDs.
Args:
security_groups: List of security group names or UUIDs
client: reference to neutronclient
tenant_id: the tenant id to match the security_groups
'''
"""
warnings.warn('neutron.NeutronResource.get_secgroup_uuids is '
'deprecated. Use '
'self.client_plugin("neutron").get_secgroup_uuids')

View File

@ -86,10 +86,11 @@ class ProviderNet(net.Net):
}
def validate(self):
'''
"""Resource's validation.
Validates to ensure that segmentation_id is not there for flat
network type.
'''
"""
super(ProviderNet, self).validate()
if (self.properties[self.PROVIDER_SEGMENTATION_ID] and
@ -111,9 +112,10 @@ class ProviderNet(net.Net):
self.add_provider_extension(props, self.PROVIDER_SEGMENTATION_ID)
def handle_create(self):
'''
"""Creates the resource with provided properties.
Adds 'provider:' extension to the required properties during create.
'''
"""
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
@ -124,9 +126,10 @@ class ProviderNet(net.Net):
self.resource_id_set(prov_net['id'])
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
'''
"""Updates the resource with provided properties.
Adds 'provider:' extension to the required properties during update.
'''
"""
props = self.prepare_update_properties(json_snippet)
self.prepare_provider_properties(self, props)

View File

@ -20,9 +20,7 @@ from heat.engine import support
class VPNService(neutron.NeutronResource):
"""
A resource for VPN service in Neutron.
"""
"""A resource for VPN service in Neutron."""
PROPERTIES = (
NAME, DESCRIPTION, ADMIN_STATE_UP,
@ -181,9 +179,7 @@ class VPNService(neutron.NeutronResource):
class IPsecSiteConnection(neutron.NeutronResource):
"""
A resource for IPsec site connection in Neutron.
"""
"""A resource for IPsec site connection in Neutron."""
PROPERTIES = (
NAME, DESCRIPTION, PEER_ADDRESS, PEER_ID, PEER_CIDRS, MTU,
@ -425,9 +421,7 @@ class IPsecSiteConnection(neutron.NeutronResource):
class IKEPolicy(neutron.NeutronResource):
"""
A resource for IKE policy in Neutron.
"""
"""A resource for IKE policy in Neutron."""
PROPERTIES = (
NAME, DESCRIPTION, AUTH_ALGORITHM, ENCRYPTION_ALGORITHM,
@ -593,9 +587,7 @@ class IKEPolicy(neutron.NeutronResource):
class IPsecPolicy(neutron.NeutronResource):
"""
A resource for IPsec policy in Neutron.
"""
"""A resource for IPsec policy in Neutron."""
PROPERTIES = (
NAME, DESCRIPTION, TRANSFORM_PROTOCOL, ENCAPSULATION_MODE,

View File

@ -18,8 +18,7 @@ from heat.engine import support
class NovaFlavor(resource.Resource):
"""
A resource for creating OpenStack virtual hardware templates.
"""A resource for creating OpenStack virtual hardware templates.
Due to default nova security policy usage of this resource is limited to
being used by administrators only. The rights may also be delegated to

View File

@ -21,8 +21,7 @@ from heat.engine import support
class KeyPair(resource.Resource):
"""
A resource for creating Nova key pairs.
"""A resource for creating Nova key pairs.
**Note** that if a new key is generated setting `save_private_key` to
`True` results in the system saving the private key which can then be

View File

@ -18,9 +18,7 @@ from heat.engine import support
class ServerGroup(resource.Resource):
"""
A resource for managing a Nova server group.
"""
"""A resource for managing a Nova server group."""
support_status = support.SupportStatus(version='2014.2')

View File

@ -602,9 +602,7 @@ class Server(stack_user.StackUser, sh.SchedulerHintsMixin,
self.metadata_set(meta)
def _register_access_key(self):
'''
Access is limited to this resource, which created the keypair
'''
"""Access is limited to this resource, which created the keypair."""
def access_allowed(resource_name):
return resource_name == self.name
@ -1077,7 +1075,7 @@ class Server(stack_user.StackUser, sh.SchedulerHintsMixin,
return updaters
def check_update_complete(self, updaters):
'''Push all updaters to completion in list order.'''
"""Push all updaters to completion in list order."""
for prg in updaters:
if not prg.called:
handler = getattr(self.client_plugin(), prg.handler)
@ -1095,9 +1093,7 @@ class Server(stack_user.StackUser, sh.SchedulerHintsMixin,
return status
def metadata_update(self, new_metadata=None):
'''
Refresh the metadata if new_metadata is None
'''
"""Refresh the metadata if new_metadata is None."""
if new_metadata is None:
# Re-resolve the template metadata and merge it with the
# current resource metadata. This is necessary because the
@ -1111,10 +1107,10 @@ class Server(stack_user.StackUser, sh.SchedulerHintsMixin,
@staticmethod
def _check_maximum(count, maximum, msg):
'''
Check a count against a maximum, unless maximum is -1 which indicates
that there is no limit
'''
"""Check a count against a maximum.
Unless maximum is -1 which indicates that there is no limit.
"""
if maximum != -1 and count > maximum:
raise exception.StackValidationFailed(message=msg)
@ -1312,11 +1308,12 @@ class Server(stack_user.StackUser, sh.SchedulerHintsMixin,
prg.server_id)
def handle_suspend(self):
'''
Suspend a server - note we do not wait for the SUSPENDED state,
this is polled for by check_suspend_complete in a similar way to the
create logic so we can take advantage of coroutines
'''
"""Suspend a server.
Note we do not wait for the SUSPENDED state, this is polled for by
check_suspend_complete in a similar way to the create logic so we can
take advantage of coroutines.
"""
if self.resource_id is None:
raise exception.Error(_('Cannot suspend %s, resource_id not set') %
self.name)
@ -1354,11 +1351,12 @@ class Server(stack_user.StackUser, sh.SchedulerHintsMixin,
raise exc
def handle_resume(self):
'''
Resume a server - note we do not wait for the ACTIVE state,
this is polled for by check_resume_complete in a similar way to the
create logic so we can take advantage of coroutines
'''
"""Resume a server.
Note we do not wait for the ACTIVE state, this is polled for by
check_resume_complete in a similar way to the create logic so we can
take advantage of coroutines.
"""
if self.resource_id is None:
raise exception.Error(_('Cannot resume %s, resource_id not set') %
self.name)

View File

@ -123,10 +123,10 @@ class SwiftContainer(resource.Resource):
@staticmethod
def _build_meta_headers(obj_type, meta_props):
'''
Returns a new dict where each key is prepended with:
X-Container-Meta-
'''
"""Returns a new dict.
Each key of new dict is prepended with "X-Container-Meta-".
"""
if meta_props is None:
return {}
return dict(

View File

@ -27,9 +27,7 @@ LOG = logging.getLogger(__name__)
class OSDBInstance(resource.Resource):
'''
OpenStack cloud database instance resource.
'''
"""OpenStack cloud database instance resource."""
support_status = support.SupportStatus(version='2014.1')
@ -299,9 +297,7 @@ class OSDBInstance(resource.Resource):
return self.physical_resource_name()
def handle_create(self):
'''
Create cloud database instance.
'''
"""Create cloud database instance."""
self.flavor = self.client_plugin().get_flavor_id(
self.properties[self.FLAVOR])
self.volume = {'size': self.properties[self.SIZE]}
@ -381,9 +377,7 @@ class OSDBInstance(resource.Resource):
raise
def check_create_complete(self, instance_id):
'''
Check if cloud DB instance creation is complete.
'''
"""Check if cloud DB instance creation is complete."""
instance = self._refresh_instance(instance_id) # refresh attributes
if instance is None:
return False
@ -415,9 +409,7 @@ class OSDBInstance(resource.Resource):
self._verify_check_conditions(checks)
def handle_delete(self):
'''
Delete a cloud database instance.
'''
"""Delete a cloud database instance."""
if not self.resource_id:
return
@ -430,9 +422,7 @@ class OSDBInstance(resource.Resource):
return instance.id
def check_delete_complete(self, instance_id):
'''
Check for completion of cloud DB instance deletion
'''
"""Check for completion of cloud DB instance deletion."""
if not instance_id:
return True
@ -446,9 +436,7 @@ class OSDBInstance(resource.Resource):
return False
def validate(self):
'''
Validate any of the provided params
'''
"""Validate any of the provided params."""
res = super(OSDBInstance, self).validate()
if res:
return res

View File

@ -17,10 +17,7 @@ cfg.CONF.import_opt('stack_scheduler_hints', 'heat.common.config')
class SchedulerHintsMixin(object):
'''
Utility class to encapsulate Scheduler Hint related logic shared
between resources.
'''
"""Utility class to encapsulate Scheduler Hint related logic."""
HEAT_ROOT_STACK_ID = 'heat_root_stack_id'
HEAT_STACK_ID = 'heat_stack_id'
@ -30,7 +27,7 @@ class SchedulerHintsMixin(object):
HEAT_RESOURCE_UUID = 'heat_resource_uuid'
def _scheduler_hints(self, scheduler_hints):
'''Augment scheduler hints with supplemental content.'''
"""Augment scheduler hints with supplemental content."""
if cfg.CONF.stack_scheduler_hints:
if scheduler_hints is None:
scheduler_hints = {}

View File

@ -38,10 +38,11 @@ LOG = logging.getLogger(__name__)
class StackResource(resource.Resource):
'''
"""Allows entire stack to be managed as a resource in a parent stack.
An abstract Resource subclass that allows the management of an entire Stack
as a resource in a parent stack.
'''
"""
# Assume True as this is evaluated before the stack is created
# so there is no way to know for sure without subclass-specific
@ -125,13 +126,14 @@ class StackResource(resource.Resource):
return False
def nested(self, force_reload=False, show_deleted=False):
'''Return a Stack object representing the nested (child) stack.
if we catch NotFound exception when loading, return None.
"""Return a Stack object representing the nested (child) stack.
If we catch NotFound exception when loading, return None.
:param force_reload: Forces reloading from the DB instead of returning
the locally cached Stack object
:param show_deleted: Returns the stack even if it's been deleted
'''
"""
if force_reload:
self._nested = None
@ -147,26 +149,23 @@ class StackResource(resource.Resource):
return self._nested
def child_template(self):
'''
Default implementation to get the child template.
"""Default implementation to get the child template.
Resources that inherit from StackResource should override this method
with specific details about the template used by them.
'''
"""
raise NotImplementedError()
def child_params(self):
'''
Default implementation to get the child params.
"""Default implementation to get the child params.
Resources that inherit from StackResource should override this method
with specific details about the parameters used by them.
'''
"""
raise NotImplementedError()
def preview(self):
'''
Preview a StackResource as resources within a Stack.
"""Preview a StackResource as resources within a Stack.
This method overrides the original Resource.preview to return a preview
of all the resources contained in this Stack. For this to be possible,
@ -174,7 +173,7 @@ class StackResource(resource.Resource):
``child_params`` with specific information to allow the stack to be
parsed correctly. If any of these methods is missing, the entire
StackResource will be returned as if it were a regular Resource.
'''
"""
try:
child_template = self.child_template()
params = self.child_params()
@ -438,9 +437,7 @@ class StackResource(resource.Resource):
cookie=cookie)
def delete_nested(self):
'''
Delete the nested stack.
'''
"""Delete the nested stack."""
stack = self.nested()
if stack is None:
return
@ -510,12 +507,11 @@ class StackResource(resource.Resource):
return {}
def get_output(self, op):
'''
Return the specified Output value from the nested stack.
"""Return the specified Output value from the nested stack.
If the output key does not exist, raise an InvalidTemplateAttribute
exception.
'''
"""
stack = self.nested()
if stack is None:
return None

View File

@ -42,13 +42,12 @@ def generate_class(name, template_name, env, files=None):
class TemplateResource(stack_resource.StackResource):
'''
A resource implemented by a nested stack.
"""A resource implemented by a nested stack.
This implementation passes resource properties as parameters to the nested
stack. Outputs of the nested stack are exposed as attributes of this
resource.
'''
"""
def __init__(self, name, json_snippet, stack):
self._parsed_nested = None
@ -124,9 +123,10 @@ class TemplateResource(stack_resource.StackResource):
self._resolve_all_attributes)
def child_params(self):
'''
"""Override method of child_params for the resource.
:return: parameter values for our nested stack based on our properties
'''
"""
params = {}
for pname, pval in iter(self.properties.props.items()):
if not pval.implemented():
@ -284,9 +284,7 @@ class TemplateResource(stack_resource.StackResource):
self.child_params())
def metadata_update(self, new_metadata=None):
'''
Refresh the metadata if new_metadata is None
'''
"""Refresh the metadata if new_metadata is None."""
if new_metadata is None:
self.metadata_set(self.t.metadata())

View File

@ -18,9 +18,7 @@ from heat.engine import resource
class BaseVolume(resource.Resource):
'''
Base Volume Manager.
'''
"""Base Volume Manager."""
default_client_name = 'cinder'
@ -113,11 +111,10 @@ class BaseVolume(resource.Resource):
result=_('Volume backup failed'))
def _delete_volume(self):
"""Call the volume delete API
"""Call the volume delete API.
Returns False if further checking of volume status is required,
True otherwise.
"""
try:
cinder = self.client()
@ -164,9 +161,7 @@ class BaseVolume(resource.Resource):
class BaseVolumeAttachment(resource.Resource):
'''
Base Volume Attachment Manager.
'''
"""Base Volume Attachment Manager."""
default_client_name = 'cinder'

View File

@ -24,13 +24,13 @@ LOG = logging.getLogger(__name__)
class BaseWaitConditionHandle(signal_responder.SignalResponder):
'''
Base WaitConditionHandle resource.
"""Base WaitConditionHandle resource.
The main point of this class is to :
- have no dependencies (so the instance can reference it)
- create credentials to allow for signalling from the instance.
- handle signals from the instance, validate and store result
'''
"""
properties_schema = {}
WAIT_STATUSES = (
@ -75,16 +75,12 @@ class BaseWaitConditionHandle(signal_responder.SignalResponder):
return signal_reason
def get_status(self):
'''
Return a list of the Status values for the handle signals
'''
"""Return a list of the Status values for the handle signals."""
return [v[self.STATUS]
for v in six.itervalues(self.metadata_get(refresh=True))]
def get_status_reason(self, status):
'''
Return a list of reasons associated with a particular status
'''
"""Return a list of reasons associated with a particular status."""
return [v[self.REASON]
for v in six.itervalues(self.metadata_get(refresh=True))
if v[self.STATUS] == status]