1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #3194/1fec1d0c backport][stable-3] Fix sanity failures (#3195)

* Fix new devel sanity errors. (#3194)

(cherry picked from commit 1fec1d0c81)

* Add two more.

* Fix PR #.

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2021-08-12 13:46:55 +02:00 committed by GitHub
parent 0eecd48ea8
commit 1a3c221995
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 45 additions and 30 deletions

View file

@ -0,0 +1,16 @@
bugfixes:
- "memcached cache plugin - change function argument names to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "logdns callback plugin - improve split call to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "saltstack connection plugin - fix function signature (https://github.com/ansible-collections/community.general/pull/3194)."
- "online inventory plugin - improve split call to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "netapp module utils - remove always-true conditional to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "online module utils - improve split call to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "scaleway module utils - improve split call to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "one_template - change function argument name to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "packet_device - use generator to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "packet_sshkey - use generator to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "maven_artifact - improve split call to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "launchd - use private attribute to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "ufw - use generator to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3194)."
- "scaleway inventory script - improve split call to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3195)."
- "vbox inventory script - change function argument name to fix sanity errors (https://github.com/ansible-collections/community.general/pull/3195)."

View file

@ -154,12 +154,12 @@ class CacheModuleKeys(MutableSet):
def __len__(self):
return len(self._keyset)
def add(self, key):
self._keyset[key] = time.time()
def add(self, value):
self._keyset[value] = time.time()
self._cache.set(self.PREFIX, self._keyset)
def discard(self, key):
del self._keyset[key]
def discard(self, value):
del self._keyset[value]
self._cache.set(self.PREFIX, self._keyset)
def remove_by_timerange(self, s_min, s_max):

View file

@ -78,7 +78,7 @@ def get_mac():
# Getting hostname of system:
def get_hostname():
return str(socket.gethostname()).split('.local')[0]
return str(socket.gethostname()).split('.local', 1)[0]
# Getting IP of system:

View file

@ -51,7 +51,7 @@ class Connection(ConnectionBase):
self._connected = True
return self
def exec_command(self, cmd, sudoable=False, in_data=None):
def exec_command(self, cmd, in_data=None, sudoable=False):
""" run a command on the remote minion """
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)

View file

@ -235,7 +235,7 @@ class InventoryModule(BaseInventoryPlugin):
self.headers = {
'Authorization': "Bearer %s" % token,
'User-Agent': "ansible %s Python %s" % (ansible_version, python_version.split(' ')[0]),
'User-Agent': "ansible %s Python %s" % (ansible_version, python_version.split(' ', 1)[0]),
'Content-type': 'application/json'
}

View file

@ -384,8 +384,8 @@ class NetAppESeriesModule(object):
path = path[1:]
request_url = self.url + self.DEFAULT_REST_API_PATH + path
if self.log_requests or True:
self.module.log(pformat(dict(url=request_url, data=data, method=method)))
# if self.log_requests:
self.module.log(pformat(dict(url=request_url, data=data, method=method)))
return request(url=request_url, data=data, method=method, headers=headers, use_proxy=True, force=False, last_mod_time=None,
timeout=self.DEFAULT_TIMEOUT, http_agent=self.HTTP_AGENT, force_basic_auth=True, ignore_errors=ignore_errors, **self.creds)

View file

@ -101,7 +101,7 @@ class Online(object):
@staticmethod
def get_user_agent_string(module):
return "ansible %s Python %s" % (module.ansible_version, sys.version.split(' ')[0])
return "ansible %s Python %s" % (module.ansible_version, sys.version.split(' ', 1)[0])
def get(self, path, data=None, headers=None):
return self.send('GET', path, data, headers)

View file

@ -142,7 +142,7 @@ class Scaleway(object):
@staticmethod
def get_user_agent_string(module):
return "ansible %s Python %s" % (module.ansible_version, sys.version.split(' ')[0])
return "ansible %s Python %s" % (module.ansible_version, sys.version.split(' ', 1)[0])
def get(self, path, data=None, headers=None, params=None):
return self.send(method='GET', path=path, data=data, headers=headers, params=params)

View file

@ -213,8 +213,8 @@ class TemplateModule(OpenNebulaModule):
def get_template_by_id(self, template_id):
return self.get_template(lambda template: (template.ID == template_id))
def get_template_by_name(self, template_name):
return self.get_template(lambda template: (template.NAME == template_name))
def get_template_by_name(self, name):
return self.get_template(lambda template: (template.NAME == name))
def get_template_instance(self, requested_id, requested_name):
if requested_id:

View file

@ -509,11 +509,10 @@ def wait_for_devices_active(module, packet_conn, watched_devices):
def wait_for_public_IPv(module, packet_conn, created_devices):
def has_public_ip(addr_list, ip_v):
return any([a['public'] and a['address_family'] == ip_v and
a['address'] for a in addr_list])
return any(a['public'] and a['address_family'] == ip_v and a['address'] for a in addr_list)
def all_have_public_ip(ds, ip_v):
return all([has_public_ip(d.ip_addresses, ip_v) for d in ds])
return all(has_public_ip(d.ip_addresses, ip_v) for d in ds)
address_family = module.params.get('wait_for_public_IPv')

View file

@ -168,7 +168,7 @@ def get_sshkey_selector(module):
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

View file

@ -565,7 +565,7 @@ class MavenDownloader:
return "Cannot find %s checksum from %s" % (checksum_alg, remote_url)
try:
# Check if remote checksum only contains md5/sha1 or md5/sha1 + filename
_remote_checksum = remote_checksum.split(None)[0]
_remote_checksum = remote_checksum.split(None, 1)[0]
remote_checksum = _remote_checksum
# remote_checksum is empty so we continue and keep original checksum string
# This should not happen since we check for remote_checksum before

View file

@ -141,14 +141,14 @@ class Plist:
self.__changed = False
self.__service = service
state, pid, dummy, dummy = LaunchCtlList(module, service).run()
state, pid, dummy, dummy = LaunchCtlList(module, self.__service).run()
# Check if readPlist is available or not
self.old_plistlib = hasattr(plistlib, 'readPlist')
self.__file = self.__find_service_plist(service)
self.__file = self.__find_service_plist(self.__service)
if self.__file is None:
msg = 'Unable to infer the path of %s service plist file' % service
msg = 'Unable to infer the path of %s service plist file' % self.__service
if pid is None and state == ServiceState.UNLOADED:
msg += ' and it was not found among active services'
module.fail_json(msg=msg)

View file

@ -526,8 +526,8 @@ def main():
lines = [(numbered_line_re.match(line), '(v6)' in line) for line in numbered_state.splitlines()]
lines = [(int(matcher.group(1)), ipv6) for (matcher, ipv6) in lines if matcher]
last_number = max([no for (no, ipv6) in lines]) if lines else 0
has_ipv4 = any([not ipv6 for (no, ipv6) in lines])
has_ipv6 = any([ipv6 for (no, ipv6) in lines])
has_ipv4 = any(not ipv6 for (no, ipv6) in lines)
has_ipv6 = any(ipv6 for (no, ipv6) in lines)
if relative_to_cmd == 'first-ipv4':
relative_to = 1
elif relative_to_cmd == 'last-ipv4':

View file

@ -51,7 +51,7 @@ class ScalewayAPI:
def __init__(self, auth_token, region):
self.session = requests.session()
self.session.headers.update({
'User-Agent': 'Ansible Python/%s' % (sys.version.split(' ')[0])
'User-Agent': 'Ansible Python/%s' % (sys.version.split(' ', 1)[0])
})
self.session.headers.update({
'X-Auth-Token': auth_token.encode('latin1')

View file

@ -12,10 +12,10 @@ import json
class SetEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
return json.JSONEncoder.default(self, obj)
def default(self, o):
if isinstance(o, set):
return list(o)
return json.JSONEncoder.default(self, o)
VBOX = "VBoxManage"

View file

@ -32,8 +32,8 @@ class DictDataLoader(DataLoader):
# TODO: the real _get_file_contents returns a bytestring, so we actually convert the
# unicode/text it's created with to utf-8
def _get_file_contents(self, path):
path = to_text(path)
def _get_file_contents(self, file_name):
path = to_text(file_name)
if path in self._file_mapping:
return (to_bytes(self._file_mapping[path]), False)
else: