mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix various sonarcloud issues
This fixes various reported bugs through sonarcloud at: https://sonarcloud.io/project/issues?id=Rodney-Reis_ansible&resolved=false&types=BUG
This commit is contained in:
parent
f9ab9b4d68
commit
c2fb581414
12 changed files with 15 additions and 70 deletions
|
@ -1,20 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# Copyright 2013 Google Inc.
|
|
||||||
#
|
# Copyright: (c) 2013, Google Inc.
|
||||||
# This file is part of Ansible
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
GCE external inventory script
|
GCE external inventory script
|
||||||
|
@ -498,7 +485,7 @@ class GceInventory(object):
|
||||||
else:
|
else:
|
||||||
groups[machine_type] = [name]
|
groups[machine_type] = [name]
|
||||||
|
|
||||||
image = node.image and node.image or 'persistent_disk'
|
image = node.image or 'persistent_disk'
|
||||||
if image in groups:
|
if image in groups:
|
||||||
groups[image].append(name)
|
groups[image].append(name)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -2870,8 +2870,6 @@ class AnsibleModule(object):
|
||||||
if prompt_re.search(stdout) and not data:
|
if prompt_re.search(stdout) and not data:
|
||||||
if encoding:
|
if encoding:
|
||||||
stdout = to_native(stdout, encoding=encoding, errors=errors)
|
stdout = to_native(stdout, encoding=encoding, errors=errors)
|
||||||
else:
|
|
||||||
stdout = stdout
|
|
||||||
return (257, stdout, "A prompt was encountered while running a command, but no input data was specified")
|
return (257, stdout, "A prompt was encountered while running a command, but no input data was specified")
|
||||||
# only break out if no pipes are left to read or
|
# only break out if no pipes are left to read or
|
||||||
# the pipes are completely read and
|
# the pipes are completely read and
|
||||||
|
|
|
@ -300,9 +300,9 @@ def waitForDeviceResponse(command, prompt, timeout, obj):
|
||||||
except Exception:
|
except Exception:
|
||||||
# debugOutput(prompt)
|
# debugOutput(prompt)
|
||||||
if prompt == "(yes/no)?":
|
if prompt == "(yes/no)?":
|
||||||
retVal = retVal
|
pass
|
||||||
elif prompt == "Password:":
|
elif prompt == "Password:":
|
||||||
retVal = retVal
|
pass
|
||||||
else:
|
else:
|
||||||
retVal = retVal + "\n Error-101"
|
retVal = retVal + "\n Error-101"
|
||||||
flag = True
|
flag = True
|
||||||
|
|
|
@ -516,7 +516,6 @@ def recreate_tags_from_list(list_of_tags):
|
||||||
"""
|
"""
|
||||||
tags = list()
|
tags = list()
|
||||||
i = 0
|
i = 0
|
||||||
list_of_tags = list_of_tags
|
|
||||||
for i in range(len(list_of_tags)):
|
for i in range(len(list_of_tags)):
|
||||||
key_name = list_of_tags[i][0]
|
key_name = list_of_tags[i][0]
|
||||||
key_val = list_of_tags[i][1]
|
key_val = list_of_tags[i][1]
|
||||||
|
|
|
@ -113,7 +113,6 @@ def poll_reload_status(api_key=None, job_id=None, payload=None):
|
||||||
if response.json()['error']:
|
if response.json()['error']:
|
||||||
# the reload job was submitted but polling failed. Don't return this as an overall task failure.
|
# the reload job was submitted but polling failed. Don't return this as an overall task failure.
|
||||||
stderr = "Reload submitted successfully, but the Memset API returned a job error when attempting to poll the reload status."
|
stderr = "Reload submitted successfully, but the Memset API returned a job error when attempting to poll the reload status."
|
||||||
msg = msg
|
|
||||||
else:
|
else:
|
||||||
memset_api = response.json()
|
memset_api = response.json()
|
||||||
msg = None
|
msg = None
|
||||||
|
|
|
@ -187,8 +187,6 @@ def create_zone(args=None, zone_exists=None, payload=None):
|
||||||
api_method = 'dns.zone_info'
|
api_method = 'dns.zone_info'
|
||||||
_has_failed, _msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
_has_failed, _msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
||||||
memset_api = response.json()
|
memset_api = response.json()
|
||||||
else:
|
|
||||||
msg = msg
|
|
||||||
|
|
||||||
return(has_failed, has_changed, memset_api, msg)
|
return(has_failed, has_changed, memset_api, msg)
|
||||||
|
|
||||||
|
|
|
@ -588,7 +588,7 @@ class RHEVConn(object):
|
||||||
setMsg(str(e))
|
setMsg(str(e))
|
||||||
setFailed()
|
setFailed()
|
||||||
return False
|
return False
|
||||||
elif int(DISK.size) < (1024 * 1024 * 1024 * int(disksize)):
|
elif int(DISK.size) > (1024 * 1024 * 1024 * int(disksize)):
|
||||||
setMsg("Shrinking disks is not supported")
|
setMsg("Shrinking disks is not supported")
|
||||||
setMsg(str(e))
|
setMsg(str(e))
|
||||||
setFailed()
|
setFailed()
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
|
||||||
# This file is part of Ansible
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
'status': ['preview'],
|
'status': ['preview'],
|
||||||
'supported_by': 'community'}
|
'supported_by': 'community'}
|
||||||
|
@ -406,7 +393,6 @@ class StaticRoute(object):
|
||||||
if self.prefix.find('.') == -1:
|
if self.prefix.find('.') == -1:
|
||||||
return False
|
return False
|
||||||
if self.mask == '32':
|
if self.mask == '32':
|
||||||
self.prefix = self.prefix
|
|
||||||
return True
|
return True
|
||||||
if self.mask == '0':
|
if self.mask == '0':
|
||||||
self.prefix = '0.0.0.0'
|
self.prefix = '0.0.0.0'
|
||||||
|
@ -427,7 +413,6 @@ class StaticRoute(object):
|
||||||
if self.prefix.find(':') == -1:
|
if self.prefix.find(':') == -1:
|
||||||
return False
|
return False
|
||||||
if self.mask == '128':
|
if self.mask == '128':
|
||||||
self.prefix = self.prefix
|
|
||||||
return True
|
return True
|
||||||
if self.mask == '0':
|
if self.mask == '0':
|
||||||
self.prefix = '::'
|
self.prefix = '::'
|
||||||
|
|
|
@ -361,8 +361,6 @@ def bgpNeighborConfig(module, cmd, prompt, answer):
|
||||||
command = command + bgpNeighborArg1 + " "
|
command = command + bgpNeighborArg1 + " "
|
||||||
if(bgpNeighborArg2 is not None and bgpNeighborArg2 == "mutihop"):
|
if(bgpNeighborArg2 is not None and bgpNeighborArg2 == "mutihop"):
|
||||||
command = command + bgpNeighborArg2
|
command = command + bgpNeighborArg2
|
||||||
else:
|
|
||||||
command = command
|
|
||||||
|
|
||||||
elif(bgpNeighborArg1 == "connection-retry-time"):
|
elif(bgpNeighborArg1 == "connection-retry-time"):
|
||||||
command = command + bgpNeighborArg1 + " "
|
command = command + bgpNeighborArg1 + " "
|
||||||
|
@ -565,8 +563,6 @@ def bgpNeighborAFConfig(module, cmd, prompt, answer):
|
||||||
else:
|
else:
|
||||||
retVal = "Error-325"
|
retVal = "Error-325"
|
||||||
return retVal
|
return retVal
|
||||||
else:
|
|
||||||
command = command
|
|
||||||
|
|
||||||
elif(bgpNeighborAFArg1 == "default-originate"):
|
elif(bgpNeighborAFArg1 == "default-originate"):
|
||||||
command = command + bgpNeighborAFArg1 + " "
|
command = command + bgpNeighborAFArg1 + " "
|
||||||
|
@ -643,8 +639,6 @@ def bgpNeighborAFConfig(module, cmd, prompt, answer):
|
||||||
command = command + bgpNeighborAFArg1 + " "
|
command = command + bgpNeighborAFArg1 + " "
|
||||||
if(bgpNeighborAFArg2 is not None and bgpNeighborAFArg2 == "extended"):
|
if(bgpNeighborAFArg2 is not None and bgpNeighborAFArg2 == "extended"):
|
||||||
command = command + bgpNeighborAFArg2
|
command = command + bgpNeighborAFArg2
|
||||||
else:
|
|
||||||
command = command
|
|
||||||
|
|
||||||
elif(bgpNeighborAFArg1 == "soft-reconfiguration"):
|
elif(bgpNeighborAFArg1 == "soft-reconfiguration"):
|
||||||
command = command + bgpNeighborAFArg1 + " inbound"
|
command = command + bgpNeighborAFArg1 + " inbound"
|
||||||
|
|
|
@ -197,8 +197,7 @@ class NetAppCDOTAggregate(object):
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
elif self.state == 'present':
|
elif self.state == 'present':
|
||||||
if self.name is not None and not self.name == \
|
if self.name is not None and not self.name == self.name:
|
||||||
self.name:
|
|
||||||
rename_aggregate = True
|
rename_aggregate = True
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,6 @@
|
||||||
# (c) 2015, Ansible Inc,
|
# Copyright: (c) 2015, Ansible Inc,
|
||||||
#
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
@ -64,7 +51,7 @@ class ActionModule(ActionBase):
|
||||||
play_context.connection = 'netconf'
|
play_context.connection = 'netconf'
|
||||||
play_context.port = int(self.provider['port'] or self._play_context.port or 830)
|
play_context.port = int(self.provider['port'] or self._play_context.port or 830)
|
||||||
elif self.provider.get('transport') in ('nxapi', 'eapi') and play_context.network_os in ('nxos', 'eos'):
|
elif self.provider.get('transport') in ('nxapi', 'eapi') and play_context.network_os in ('nxos', 'eos'):
|
||||||
play_context.connection = play_context.connection
|
play_context.connection = 'local'
|
||||||
play_context.port = int(self.provider['port'] or self._play_context.port or 22)
|
play_context.port = int(self.provider['port'] or self._play_context.port or 22)
|
||||||
else:
|
else:
|
||||||
play_context.connection = 'network_cli'
|
play_context.connection = 'network_cli'
|
||||||
|
|
|
@ -179,7 +179,6 @@ class OpenShiftCloudProvider(CloudProvider):
|
||||||
return
|
return
|
||||||
|
|
||||||
client = HttpClient(self.args, always=True, insecure=True)
|
client = HttpClient(self.args, always=True, insecure=True)
|
||||||
endpoint = endpoint
|
|
||||||
|
|
||||||
for dummy in range(1, 30):
|
for dummy in range(1, 30):
|
||||||
display.info('Waiting for OpenShift service: %s' % endpoint, verbosity=1)
|
display.info('Waiting for OpenShift service: %s' % endpoint, verbosity=1)
|
||||||
|
|
Loading…
Reference in a new issue