mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07:00
PEP 8 E111 & E114 cleanup. (#20838)
This commit is contained in:
parent
1609afbd12
commit
cb76200c7d
119 changed files with 339 additions and 378 deletions
|
@ -184,9 +184,9 @@ def do_grant(kms, keyarn, role_arn, granttypes, mode='grant', dry_run=True, clea
|
|||
if not dry_run:
|
||||
statement['Principal']['AWS'].append(role_arn)
|
||||
elif role_arn in statement['Principal']['AWS']: # not one the places the role should be
|
||||
changes_needed[granttype] = 'remove'
|
||||
if not dry_run:
|
||||
statement['Principal']['AWS'].remove(role_arn)
|
||||
changes_needed[granttype] = 'remove'
|
||||
if not dry_run:
|
||||
statement['Principal']['AWS'].remove(role_arn)
|
||||
|
||||
elif mode == 'deny' and statement['Sid'] == statement_label[granttype] and role_arn in statement['Principal']['AWS']:
|
||||
# we don't selectively deny. that's a grant with a
|
||||
|
|
|
@ -222,7 +222,7 @@ class CloudFormationServiceManager:
|
|||
result = response.get(result_key)
|
||||
next_token = response.get('NextToken')
|
||||
if not next_token:
|
||||
return result
|
||||
return result
|
||||
return result + self.paginated_response(func, result_key, next_token)
|
||||
|
||||
def to_dict(items, key, value):
|
||||
|
@ -246,7 +246,7 @@ def main():
|
|||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
# Describe the stack
|
||||
service_mgr = CloudFormationServiceManager(module)
|
||||
|
|
|
@ -388,7 +388,7 @@ def main():
|
|||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
service_mgr = CloudFrontServiceManager(module)
|
||||
|
||||
|
|
|
@ -139,13 +139,13 @@ class CloudTrailManager:
|
|||
ret = self.conn.describe_trails(trail_name_list=[name])
|
||||
trailList = ret.get('trailList', [])
|
||||
if len(trailList) == 1:
|
||||
return trailList[0]
|
||||
return trailList[0]
|
||||
return None
|
||||
|
||||
def exists(self, name=None):
|
||||
ret = self.view(name)
|
||||
if ret:
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def enable_logging(self, name):
|
||||
|
@ -180,7 +180,7 @@ def main():
|
|||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True, required_together=required_together)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
ec2_url, access_key, secret_key, region = get_ec2_creds(module)
|
||||
aws_connect_params = dict(aws_access_key_id=access_key,
|
||||
|
|
|
@ -344,7 +344,7 @@ def validate_index(index, module):
|
|||
module.fail_json(msg='%s is not a valid option for an index' % key)
|
||||
for required_option in INDEX_REQUIRED_OPTIONS:
|
||||
if required_option not in index:
|
||||
module.fail_json(msg='%s is a required option for an index' % required_option)
|
||||
module.fail_json(msg='%s is a required option for an index' % required_option)
|
||||
if index['type'] not in INDEX_TYPE_OPTIONS:
|
||||
module.fail_json(msg='%s is not a valid index type, must be one of %s' % (index['type'], INDEX_TYPE_OPTIONS))
|
||||
|
||||
|
|
|
@ -1033,7 +1033,7 @@ def create_instances(module, ec2, vpc, override_count=None):
|
|||
grp_details = ec2.get_all_security_groups(group_ids=group_id)
|
||||
group_name = [grp_item.name for grp_item in grp_details]
|
||||
except boto.exception.NoAuthHandlerFound as e:
|
||||
module.fail_json(msg = str(e))
|
||||
module.fail_json(msg = str(e))
|
||||
|
||||
# Lookup any instances that much our run id.
|
||||
|
||||
|
@ -1065,11 +1065,11 @@ def create_instances(module, ec2, vpc, override_count=None):
|
|||
'user_data': user_data}
|
||||
|
||||
if ebs_optimized:
|
||||
params['ebs_optimized'] = ebs_optimized
|
||||
params['ebs_optimized'] = ebs_optimized
|
||||
|
||||
# 'tenancy' always has a default value, but it is not a valid parameter for spot instance request
|
||||
if not spot_price:
|
||||
params['tenancy'] = tenancy
|
||||
params['tenancy'] = tenancy
|
||||
|
||||
if boto_supports_profile_name_arg(ec2):
|
||||
params['instance_profile_name'] = instance_profile_name
|
||||
|
@ -1184,8 +1184,8 @@ def create_instances(module, ec2, vpc, override_count=None):
|
|||
if boto_supports_param_in_spot_request(ec2, 'placement_group'):
|
||||
params['placement_group'] = placement_group
|
||||
elif placement_group :
|
||||
module.fail_json(
|
||||
msg="placement_group parameter requires Boto version 2.3.0 or higher.")
|
||||
module.fail_json(
|
||||
msg="placement_group parameter requires Boto version 2.3.0 or higher.")
|
||||
|
||||
# You can't tell spot instances to 'stop'; they will always be
|
||||
# 'terminate'd. For convenience, we'll ignore the latter value.
|
||||
|
|
|
@ -178,7 +178,7 @@ def list_launch_configs(connection, module):
|
|||
launch_config['CreatedTime'] = str(launch_config['CreatedTime'])
|
||||
|
||||
if sort:
|
||||
snaked_launch_configs.sort(key=lambda e: e[sort], reverse=(sort_order=='descending'))
|
||||
snaked_launch_configs.sort(key=lambda e: e[sort], reverse=(sort_order=='descending'))
|
||||
|
||||
try:
|
||||
if sort and sort_start and sort_end:
|
||||
|
|
|
@ -176,12 +176,12 @@ def main():
|
|||
module.fail_json(msg="tags argument is required when state is absent")
|
||||
for (key, value) in set(tags.items()):
|
||||
if (key, value) not in set(tagdict.items()):
|
||||
baddict[key] = value
|
||||
if set(baddict) == set(tags):
|
||||
module.exit_json(msg="Nothing to remove here. Move along.", changed=False)
|
||||
baddict[key] = value
|
||||
if set(baddict) == set(tags):
|
||||
module.exit_json(msg="Nothing to remove here. Move along.", changed=False)
|
||||
for (key, value) in set(tags.items()):
|
||||
if (key, value) in set(tagdict.items()):
|
||||
dictremove[key] = value
|
||||
dictremove[key] = value
|
||||
tagger = ec2.delete_tags(resource, dictremove)
|
||||
gettags = ec2.get_all_tags(filters=filters)
|
||||
module.exit_json(msg="Tags %s removed for resource %s." % (dictremove,resource), changed=True)
|
||||
|
|
|
@ -333,7 +333,7 @@ def main():
|
|||
supplied_options = connection.get_all_dhcp_options(filters={'dhcp-options-id':params['dhcp_options_id']})
|
||||
if len(supplied_options) != 1:
|
||||
if params['state'] != 'absent':
|
||||
module.fail_json(msg=" a dhcp_options_id was supplied, but does not exist")
|
||||
module.fail_json(msg=" a dhcp_options_id was supplied, but does not exist")
|
||||
else:
|
||||
found = True
|
||||
dhcp_option = supplied_options[0]
|
||||
|
|
|
@ -131,7 +131,7 @@ def list_dhcp_options(client, module):
|
|||
|
||||
snaked_dhcp_options_array = []
|
||||
for dhcp_option in all_dhcp_options_array:
|
||||
snaked_dhcp_options_array.append(camel_dict_to_snake_dict(dhcp_option))
|
||||
snaked_dhcp_options_array.append(camel_dict_to_snake_dict(dhcp_option))
|
||||
|
||||
module.exit_json(dhcp_options=snaked_dhcp_options_array)
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ def get_nat_gateways(client, subnet_id=None, nat_gateway_id=None,
|
|||
err_msg = '{0} Retrieving gateways'.format(DRY_RUN_MSGS)
|
||||
|
||||
except botocore.exceptions.ClientError as e:
|
||||
err_msg = str(e)
|
||||
err_msg = str(e)
|
||||
|
||||
return gateways_retrieved, err_msg, existing_gateways
|
||||
|
||||
|
@ -592,7 +592,7 @@ def get_eip_allocation_id_by_address(client, eip_address, check_mode=False):
|
|||
)
|
||||
|
||||
except botocore.exceptions.ClientError as e:
|
||||
err_msg = str(e)
|
||||
err_msg = str(e)
|
||||
|
||||
return allocation_id, err_msg
|
||||
|
||||
|
|
|
@ -353,10 +353,10 @@ def main():
|
|||
)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
service_mgr = EcsServiceManager(module)
|
||||
|
||||
|
|
|
@ -217,10 +217,10 @@ def main():
|
|||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
show_details = module.params.get('details', False)
|
||||
|
||||
|
|
|
@ -248,10 +248,10 @@ def main():
|
|||
|
||||
# Validate Requirements
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
# Validate Inputs
|
||||
if module.params['operation'] == 'run':
|
||||
|
|
|
@ -224,10 +224,10 @@ def main():
|
|||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
task_to_describe = None
|
||||
task_mgr = EcsTaskManager(module)
|
||||
|
|
|
@ -314,7 +314,7 @@ def main():
|
|||
# If VPC configuration is desired
|
||||
if vpc_subnet_ids or vpc_security_group_ids:
|
||||
if len(vpc_subnet_ids) < 1:
|
||||
module.fail_json(msg='At least 1 subnet is required')
|
||||
module.fail_json(msg='At least 1 subnet is required')
|
||||
|
||||
if len(vpc_security_group_ids) < 1:
|
||||
module.fail_json(msg='At least 1 security group is required')
|
||||
|
|
|
@ -352,7 +352,7 @@ class RDSConnection:
|
|||
try:
|
||||
self.connection = connect_to_aws(boto.rds, region, **aws_connect_params)
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg=e.error_message)
|
||||
module.fail_json(msg=e.error_message)
|
||||
|
||||
def get_db_instance(self, instancename):
|
||||
try:
|
||||
|
@ -438,7 +438,7 @@ class RDS2Connection:
|
|||
try:
|
||||
self.connection = connect_to_aws(boto.rds2, region, **aws_connect_params)
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg=e.error_message)
|
||||
module.fail_json(msg=e.error_message)
|
||||
|
||||
def get_db_instance(self, instancename):
|
||||
try:
|
||||
|
|
|
@ -282,8 +282,8 @@ def gather_files(fileroot, include=None, exclude=None):
|
|||
if include:
|
||||
found = False
|
||||
for x in include.split(','):
|
||||
if fnmatch.fnmatch(fn, x):
|
||||
found = True
|
||||
if fnmatch.fnmatch(fn, x):
|
||||
found = True
|
||||
if not found:
|
||||
# not on the include list, so we don't want it.
|
||||
continue
|
||||
|
@ -376,7 +376,7 @@ def filter_list(s3, bucket, s3filelist, strategy):
|
|||
keeplist = list(s3filelist)
|
||||
|
||||
for e in keeplist:
|
||||
e['_strategy'] = strategy
|
||||
e['_strategy'] = strategy
|
||||
|
||||
# init/fetch info from S3 if we're going to use it for comparisons
|
||||
if not strategy == 'force':
|
||||
|
|
|
@ -319,10 +319,10 @@ class SnsTopicManager(object):
|
|||
def ensure_gone(self):
|
||||
self.arn_topic = self._arn_topic_lookup()
|
||||
if self.arn_topic:
|
||||
self._get_topic_subs()
|
||||
if self.subscriptions_existing:
|
||||
self._delete_subscriptions()
|
||||
self._delete_topic()
|
||||
self._get_topic_subs()
|
||||
if self.subscriptions_existing:
|
||||
self._delete_subscriptions()
|
||||
self._delete_topic()
|
||||
|
||||
|
||||
def get_info(self):
|
||||
|
|
|
@ -258,11 +258,11 @@ try:
|
|||
import azure as windows_azure
|
||||
|
||||
if hasattr(windows_azure, '__version__') and LooseVersion(windows_azure.__version__) <= "0.11.1":
|
||||
from azure import WindowsAzureError as AzureException
|
||||
from azure import WindowsAzureMissingResourceError as AzureMissingException
|
||||
from azure import WindowsAzureError as AzureException
|
||||
from azure import WindowsAzureMissingResourceError as AzureMissingException
|
||||
else:
|
||||
from azure.common import AzureException as AzureException
|
||||
from azure.common import AzureMissingResourceHttpError as AzureMissingException
|
||||
from azure.common import AzureException as AzureException
|
||||
from azure.common import AzureMissingResourceHttpError as AzureMissingException
|
||||
|
||||
from azure.servicemanagement import (ServiceManagementService, OSVirtualHardDisk, SSH, PublicKeys,
|
||||
PublicKey, LinuxConfigurationSet, ConfigurationSetInputEndpoints,
|
||||
|
|
|
@ -508,7 +508,7 @@ class AzureRMNetworkInterface(AzureRMModuleBase):
|
|||
id=pip.id,
|
||||
location=pip.location,
|
||||
resource_guid=pip.resource_guid)
|
||||
#name=pip.name,
|
||||
#name=pip.name,
|
||||
|
||||
if results['network_security_group'].get('id'):
|
||||
nsg = self.get_security_group(results['network_security_group']['name'])
|
||||
|
|
|
@ -605,7 +605,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
self.log("Using image version {0}".format(self.image['version']))
|
||||
|
||||
if not self.storage_blob_name:
|
||||
self.storage_blob_name = self.name + '.vhd'
|
||||
self.storage_blob_name = self.name + '.vhd'
|
||||
|
||||
if self.storage_account_name:
|
||||
self.get_storage_account(self.storage_account_name)
|
||||
|
|
|
@ -286,7 +286,7 @@ class ClcPublicIp(object):
|
|||
result = None
|
||||
try:
|
||||
for ip_address in server.PublicIPs().public_ips:
|
||||
result = ip_address.Delete()
|
||||
result = ip_address.Delete()
|
||||
except CLCException as ex:
|
||||
self.module.fail_json(msg='Failed to remove public ip from the server : {0}. {1}'.format(
|
||||
server.id, ex.response_text
|
||||
|
|
|
@ -335,7 +335,7 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
|||
|
||||
poll_async = self.module.params.get('poll_async')
|
||||
if poll_async:
|
||||
firewall_rule = self.poll_job(res, 'firewallrule')
|
||||
firewall_rule = self.poll_job(res, 'firewallrule')
|
||||
return firewall_rule
|
||||
|
||||
|
||||
|
@ -359,7 +359,7 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
|||
|
||||
poll_async = self.module.params.get('poll_async')
|
||||
if poll_async:
|
||||
res = self.poll_job(res, 'firewallrule')
|
||||
res = self.poll_job(res, 'firewallrule')
|
||||
return firewall_rule
|
||||
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
|||
args['projectid'] = self.get_project('id')
|
||||
sgs = self.cs.listSecurityGroups(**args)
|
||||
if not sgs or 'securitygroup' not in sgs:
|
||||
self.module.fail_json(msg="security group '%s' not found" % security_group_name)
|
||||
self.module.fail_json(msg="security group '%s' not found" % security_group_name)
|
||||
return sgs['securitygroup'][0]
|
||||
|
||||
|
||||
|
|
|
@ -291,8 +291,8 @@ class ImageManager(DockerBaseClass):
|
|||
# If name contains a tag, it takes precedence over tag parameter.
|
||||
repo, repo_tag = parse_repository_tag(self.name)
|
||||
if repo_tag:
|
||||
self.name = repo
|
||||
self.tag = repo_tag
|
||||
self.name = repo
|
||||
self.tag = repo_tag
|
||||
|
||||
if self.state in ['present', 'build']:
|
||||
self.present()
|
||||
|
|
|
@ -520,8 +520,8 @@ def get_stdout(path_name):
|
|||
new_line = re.sub(r'\x1b\[.+m', '', line.encode('ascii'))
|
||||
full_stdout += new_line
|
||||
if new_line.strip():
|
||||
# Assuming last line contains the error message
|
||||
last_line = new_line.strip().encode('utf-8')
|
||||
# Assuming last line contains the error message
|
||||
last_line = new_line.strip().encode('utf-8')
|
||||
fd.close()
|
||||
os.remove(path_name)
|
||||
return full_stdout, last_line
|
||||
|
|
|
@ -332,7 +332,7 @@ def handle_put(module, gs, bucket, obj, overwrite, src, expiration):
|
|||
|
||||
# If bucket exists but key doesn't, just upload.
|
||||
if bucket_rc and not key_rc:
|
||||
upload_gsfile(module, gs, bucket, obj, src, expiration)
|
||||
upload_gsfile(module, gs, bucket, obj, src, expiration)
|
||||
|
||||
def handle_delete(module, gs, bucket, obj):
|
||||
if bucket and not obj:
|
||||
|
|
|
@ -287,7 +287,7 @@ def main():
|
|||
json_output['ipv4_range'] = network.cidr
|
||||
if network and mode == 'custom' and subnet_name:
|
||||
if not hasattr(gce, 'ex_get_subnetwork'):
|
||||
module.fail_json(msg="Update libcloud to a more recent version (>1.0) that supports network 'mode' parameter", changed=False)
|
||||
module.fail_json(msg="Update libcloud to a more recent version (>1.0) that supports network 'mode' parameter", changed=False)
|
||||
|
||||
subnet = gce.ex_get_subnetwork(subnet_name, region=subnet_region)
|
||||
json_output['subnet_name'] = subnet_name
|
||||
|
|
|
@ -220,7 +220,7 @@ def main():
|
|||
except ResourceNotFoundError:
|
||||
module.fail_json(msg='Instance %s not found in zone %s' % (instance_name, zone), changed=False)
|
||||
except GoogleBaseError as e:
|
||||
module.fail_json(msg=str(e), changed=False, exception=traceback.format_exc())
|
||||
module.fail_json(msg=str(e), changed=False, exception=traceback.format_exc())
|
||||
|
||||
# Tag nodes
|
||||
instance_pattern_matches = []
|
||||
|
|
|
@ -626,10 +626,10 @@ class RHEVConn(object):
|
|||
setFailed()
|
||||
return False
|
||||
elif int(DISK.size) < (1024 * 1024 * 1024 * int(disksize)):
|
||||
setMsg("Shrinking disks is not supported")
|
||||
setMsg(str(e))
|
||||
setFailed()
|
||||
return False
|
||||
setMsg("Shrinking disks is not supported")
|
||||
setMsg(str(e))
|
||||
setFailed()
|
||||
return False
|
||||
else:
|
||||
setMsg("The size of the disk is correct")
|
||||
if str(DISK.interface) != str(diskinterface):
|
||||
|
|
|
@ -154,7 +154,7 @@ def get_vms(session):
|
|||
|
||||
vms = change_keys(recs, key='uuid')
|
||||
for vm in vms.values():
|
||||
xs_vms[vm['name_label']] = vm
|
||||
xs_vms[vm['name_label']] = vm
|
||||
return xs_vms
|
||||
|
||||
|
||||
|
@ -165,7 +165,7 @@ def get_srs(session):
|
|||
return None
|
||||
srs = change_keys(recs, key='uuid')
|
||||
for sr in srs.values():
|
||||
xs_srs[sr['name_label']] = sr
|
||||
xs_srs[sr['name_label']] = sr
|
||||
return xs_srs
|
||||
|
||||
def main():
|
||||
|
|
|
@ -443,14 +443,14 @@ def _create_server(module, nova):
|
|||
server = nova.servers.create(*bootargs, **bootkwargs)
|
||||
server = nova.servers.get(server.id)
|
||||
except Exception as e:
|
||||
module.fail_json( msg = "Error in creating instance: %s " % e.message)
|
||||
module.fail_json( msg = "Error in creating instance: %s " % e.message)
|
||||
if module.params['wait'] == 'yes':
|
||||
expire = time.time() + int(module.params['wait_for'])
|
||||
while time.time() < expire:
|
||||
try:
|
||||
server = nova.servers.get(server.id)
|
||||
except Exception as e:
|
||||
module.fail_json( msg = "Error in getting info from instance: %s" % e.message)
|
||||
module.fail_json( msg = "Error in getting info from instance: %s" % e.message)
|
||||
if server.status == 'ACTIVE':
|
||||
server = _add_floating_ip(module, nova, server)
|
||||
|
||||
|
@ -466,7 +466,7 @@ def _create_server(module, nova):
|
|||
|
||||
module.fail_json(msg = "Timeout waiting for the server to come up.. Please check manually")
|
||||
if server.status == 'ERROR':
|
||||
module.fail_json(msg = "Error in creating the server.. Please check manually")
|
||||
module.fail_json(msg = "Error in creating the server.. Please check manually")
|
||||
private = openstack_find_nova_addresses(getattr(server, 'addresses'), 'fixed', 'private')
|
||||
public = openstack_find_nova_addresses(getattr(server, 'addresses'), 'floating', 'public')
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ def _get_server_state(module, nova):
|
|||
server_info = info
|
||||
break
|
||||
except Exception as e:
|
||||
module.fail_json(msg = "Error in getting the server list: %s" % e.message)
|
||||
module.fail_json(msg = "Error in getting the server list: %s" % e.message)
|
||||
return server_info, server
|
||||
|
||||
def _get_port_id(neutron, module, instance_id):
|
||||
|
|
|
@ -267,12 +267,12 @@ def main():
|
|||
module.fail_json(msg='python-keystoneclient and either python-neutronclient or python-quantumclient are required')
|
||||
|
||||
if module.params['provider_network_type'] in ['vlan' , 'flat']:
|
||||
if not module.params['provider_physical_network']:
|
||||
module.fail_json(msg = " for vlan and flat networks, variable provider_physical_network should be set.")
|
||||
if not module.params['provider_physical_network']:
|
||||
module.fail_json(msg = " for vlan and flat networks, variable provider_physical_network should be set.")
|
||||
|
||||
if module.params['provider_network_type'] in ['vlan', 'gre']:
|
||||
if not module.params['provider_segmentation_id']:
|
||||
module.fail_json(msg = " for vlan & gre networks, variable provider_segmentation_id should be set.")
|
||||
if not module.params['provider_segmentation_id']:
|
||||
module.fail_json(msg = " for vlan & gre networks, variable provider_segmentation_id should be set.")
|
||||
|
||||
neutron = _get_neutron_client(module, module.params)
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ def _get_router_id(module, neutron):
|
|||
except Exception as e:
|
||||
module.fail_json(msg = "Error in getting the router list: %s " % e.message)
|
||||
if not routers['routers']:
|
||||
return None
|
||||
return None
|
||||
return routers['routers'][0]['id']
|
||||
|
||||
def _get_net_id(neutron, module):
|
||||
|
|
|
@ -201,7 +201,7 @@ def _get_net_id(neutron, module):
|
|||
except Exception as e:
|
||||
module.fail_json("Error in listing neutron networks: %s" % e.message)
|
||||
if not networks['networks']:
|
||||
return None
|
||||
return None
|
||||
return networks['networks'][0]['id']
|
||||
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ def _check_set_power_state(module, cloud, node):
|
|||
if 'power off' in str(node['power_state']):
|
||||
if (_is_false(module.params['power']) and
|
||||
_is_false(module.params['state'])):
|
||||
return False
|
||||
return False
|
||||
if (_is_false(module.params['power']) and
|
||||
_is_false(module.params['state'])):
|
||||
module.exit_json(
|
||||
|
|
|
@ -100,7 +100,7 @@ def process_object(
|
|||
if container_obj:
|
||||
if name:
|
||||
if cloud_obj.get_object_metadata(container, name):
|
||||
cloud_obj.delete_object(container, name)
|
||||
cloud_obj.delete_object(container, name)
|
||||
changed= True
|
||||
else:
|
||||
cloud_obj.delete_container(container)
|
||||
|
|
|
@ -176,7 +176,7 @@ def _can_update(subnet, module, cloud):
|
|||
else:
|
||||
module.fail_json(msg='No network found for %s' % network_name)
|
||||
if netid != subnet['network_id']:
|
||||
module.fail_json(msg='Cannot update network_name in existing \
|
||||
module.fail_json(msg='Cannot update network_name in existing \
|
||||
subnet')
|
||||
if ip_version and subnet['ip_version'] != ip_version:
|
||||
module.fail_json(msg='Cannot update ip_version in existing subnet')
|
||||
|
|
|
@ -500,7 +500,7 @@ def act_on_devices(target_state, module, packet_conn):
|
|||
created_devices = [create_single_device(module, packet_conn, n)
|
||||
for n in create_hostnames]
|
||||
if module.params.get('wait'):
|
||||
created_devices = wait_for_ips(module, packet_conn, created_devices)
|
||||
created_devices = wait_for_ips(module, packet_conn, created_devices)
|
||||
changed = True
|
||||
|
||||
processed_devices = created_devices + process_devices
|
||||
|
|
|
@ -169,10 +169,10 @@ def get_sshkey_selector(module):
|
|||
def selector(k):
|
||||
if 'key' in select_dict:
|
||||
# if key string is specified, compare only the key strings
|
||||
return k.key == select_dict['key']
|
||||
return k.key == select_dict['key']
|
||||
else:
|
||||
# if key string not specified, all the fields must match
|
||||
return all([select_dict[f] == getattr(k,f) for f in select_dict])
|
||||
return all([select_dict[f] == getattr(k,f) for f in select_dict])
|
||||
return selector
|
||||
|
||||
|
||||
|
|
|
@ -246,4 +246,4 @@ def main():
|
|||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.vca import *
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -86,10 +86,10 @@ except ImportError:
|
|||
|
||||
|
||||
def find_vswitch_by_name(host, vswitch_name):
|
||||
for vss in host.config.network.vswitch:
|
||||
if vss.name == vswitch_name:
|
||||
return vss
|
||||
return None
|
||||
for vss in host.config.network.vswitch:
|
||||
if vss.name == vswitch_name:
|
||||
return vss
|
||||
return None
|
||||
|
||||
|
||||
class VMwareHostVirtualSwitch(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue