Bulk autopep8 (modules)

As agreed in 2017-12-07 Core meeting bulk fix pep8 issues

Generated using:
autopep8 1.3.3 (pycodestyle: 2.3.1)
autopep8 -r  --max-line-length 160 --in-place --ignore E305,E402,E722,E741 lib/ansible/modules

Manually fix issues that autopep8 has introduced
This commit is contained in:
John Barker
2017-12-07 16:27:06 +00:00
committed by John R Barker
parent d13d7e9404
commit c57a7f05e1
314 changed files with 3462 additions and 3383 deletions

View File

@@ -306,14 +306,17 @@ def _get_volume_quotas(cloud, project):
return cloud.get_volume_quotas(project)
def _get_network_quotas(cloud, project):
return cloud.get_network_quotas(project)
def _get_compute_quotas(cloud, project):
return cloud.get_compute_quotas(project)
def _get_quotas(module, cloud, project):
quota = {}
@@ -334,6 +337,7 @@ def _get_quotas(module, cloud, project):
return quota
def _scrub_results(quota):
filter_attr = [
@@ -350,6 +354,7 @@ def _scrub_results(quota):
return quota
def _system_state_change_details(module, project_quota_output):
quota_change_request = {}
@@ -368,6 +373,7 @@ def _system_state_change_details(module, project_quota_output):
return (changes_required, quota_change_request)
def _system_state_change(module, project_quota_output):
"""
Determine if changes are required to the current project quota.
@@ -386,6 +392,7 @@ def _system_state_change(module, project_quota_output):
else:
return False
def main():
argument_spec = openstack_full_argument_spec(
@@ -427,8 +434,8 @@ def main():
)
module = AnsibleModule(argument_spec,
supports_check_mode=True
)
supports_check_mode=True
)
if not HAS_SHADE:
module.fail_json(msg='shade is required for this module')
@@ -437,7 +444,7 @@ def main():
cloud_params = dict(module.params)
cloud = shade.operator_cloud(**cloud_params)
#In order to handle the different volume types we update module params after.
# In order to handle the different volume types we update module params after.
dynamic_types = [
'gigabytes_types',
'snapshots_types',
@@ -448,22 +455,22 @@ def main():
for k, v in module.params[dynamic_type].items():
module.params[k] = int(v)
#Get current quota values
# Get current quota values
project_quota_output = _get_quotas(module, cloud, cloud_params['name'])
changes_required = False
if module.params['state'] == "absent":
#If a quota state is set to absent we should assume there will be changes.
#The default quota values are not accessible so we can not determine if
#no changes will occur or not.
# If a quota state is set to absent we should assume there will be changes.
# The default quota values are not accessible so we can not determine if
# no changes will occur or not.
if module.check_mode:
module.exit_json(changed=True)
#Calling delete_network_quotas when a quota has not been set results
#in an error, according to the shade docs it should return the
#current quota.
#The following error string is returned:
#network client call failed: Quota for tenant 69dd91d217e949f1a0b35a4b901741dc could not be found.
# Calling delete_network_quotas when a quota has not been set results
# in an error, according to the shade docs it should return the
# current quota.
# The following error string is returned:
# network client call failed: Quota for tenant 69dd91d217e949f1a0b35a4b901741dc could not be found.
neutron_msg1 = "network client call failed: Quota for tenant"
neutron_msg2 = "could not be found"
@@ -495,7 +502,7 @@ def main():
quota_call = getattr(cloud, 'set_%s_quotas' % (quota_type))
quota_call(cloud_params['name'], **quota_change_request[quota_type])
#Get quota state post changes for validation
# Get quota state post changes for validation
project_quota_update = _get_quotas(module, cloud, cloud_params['name'])
if project_quota_output == project_quota_update:
@@ -504,8 +511,8 @@ def main():
project_quota_output = project_quota_update
module.exit_json(changed=changes_required,
openstack_quotas=project_quota_output
)
openstack_quotas=project_quota_output
)
except shade.OpenStackCloudException as e:
module.fail_json(msg=str(e), extra_data=e.extra_data)