mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Fix new devel sanity errors. (#3194) (cherry picked from commit1fec1d0c81
) * Add two more. * Fix PR #. Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit1a3c221995
) Co-authored-by: patchback[bot] <45432694+patchback[bot]@users.noreply.github.com>
This commit is contained in:
parent
d85908da6e
commit
bc02dc4c44
17 changed files with 45 additions and 30 deletions
16
changelogs/fragments/3194-sanity.yml
Normal file
16
changelogs/fragments/3194-sanity.yml
Normal 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)."
|
8
plugins/cache/memcached.py
vendored
8
plugins/cache/memcached.py
vendored
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -58,7 +58,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)
|
||||
|
||||
|
|
|
@ -234,7 +234,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'
|
||||
}
|
||||
|
||||
|
|
|
@ -383,8 +383,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)
|
||||
|
|
|
@ -100,7 +100,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)
|
||||
|
|
|
@ -141,7 +141,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)
|
||||
|
|
|
@ -212,8 +212,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:
|
||||
|
|
|
@ -508,11 +508,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')
|
||||
|
||||
|
|
|
@ -167,7 +167,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
|
||||
|
||||
|
||||
|
|
|
@ -556,7 +556,7 @@ class MavenDownloader:
|
|||
return "Cannot find md5 from " + remote_url
|
||||
try:
|
||||
# Check if remote md5 only contains md5 or md5 + filename
|
||||
_remote_md5 = remote_md5.split(None)[0]
|
||||
_remote_md5 = remote_md5.split(None, 1)[0]
|
||||
remote_md5 = _remote_md5
|
||||
# remote_md5 is empty so we continue and keep original md5 string
|
||||
# This should not happen since we check for remote_md5 before
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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':
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue