fix ruff issues
Some checks failed
ci/woodpecker/pr/sanity-test/3 Pipeline failed
ci/woodpecker/pr/sanity-test/2 Pipeline failed
ci/woodpecker/pr/unit-test/1 Pipeline was successful
ci/woodpecker/pr/sanity-test/1 Pipeline failed
ci/woodpecker/pr/unit-test/2 Pipeline was successful
ci/woodpecker/pr/unit-test/3 Pipeline was successful
ci/woodpecker/pr/unit-test/4 Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/build-package unknown status
ci/woodpecker/pr/docs unknown status
Some checks failed
ci/woodpecker/pr/sanity-test/3 Pipeline failed
ci/woodpecker/pr/sanity-test/2 Pipeline failed
ci/woodpecker/pr/unit-test/1 Pipeline was successful
ci/woodpecker/pr/sanity-test/1 Pipeline failed
ci/woodpecker/pr/unit-test/2 Pipeline was successful
ci/woodpecker/pr/unit-test/3 Pipeline was successful
ci/woodpecker/pr/unit-test/4 Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/build-package unknown status
ci/woodpecker/pr/docs unknown status
This commit is contained in:
parent
c3c0298617
commit
36394d1873
@ -299,13 +299,13 @@ def _compare_state(desired_state, current_state, ignore=None):
|
||||
|
||||
if ignore is None:
|
||||
ignore = []
|
||||
if type(desired_state) is list:
|
||||
if (type(current_state) != list) or (len(desired_state) != len(current_state)):
|
||||
if isinstance(desired_state, list):
|
||||
if not isinstance(current_state, list) or (len(desired_state) != len(current_state)):
|
||||
return False
|
||||
return set(desired_state) == set(current_state)
|
||||
|
||||
if type(desired_state) is dict:
|
||||
if type(current_state) != dict:
|
||||
if isinstance(desired_state, dict):
|
||||
if not isinstance(current_state, dict):
|
||||
return False
|
||||
|
||||
# iterate over dictionary keys
|
||||
@ -341,7 +341,7 @@ def _convert_to_seconds(original_value):
|
||||
ray = value.split("s")
|
||||
seconds += int(ray.pop(0))
|
||||
return seconds
|
||||
except Exception: # noqa: BLE001
|
||||
except Exception: # noqa: BLE001,S110
|
||||
pass
|
||||
return original_value
|
||||
|
||||
@ -376,9 +376,9 @@ def get_keys_updated(desired_state, current_state, ignore=None):
|
||||
continue
|
||||
new_value = desired_state[key]
|
||||
old_value = current_state[key]
|
||||
if "ttl" in key and (_convert_to_seconds(old_value) != _convert_to_seconds(new_value)):
|
||||
differences.append(key)
|
||||
elif not _compare_state(new_value, old_value):
|
||||
if (
|
||||
"ttl" in key and (_convert_to_seconds(old_value) != _convert_to_seconds(new_value))
|
||||
) or not _compare_state(new_value, old_value):
|
||||
differences.append(key)
|
||||
return differences
|
||||
|
||||
|
@ -200,7 +200,7 @@ class Pkcs(object): # noqa
|
||||
def load_privatekey(self, path, passphrase=None):
|
||||
"""Load the specified OpenSSL private key."""
|
||||
try:
|
||||
privatekey = (
|
||||
return (
|
||||
crypto.load_privatekey(
|
||||
crypto.FILETYPE_PEM,
|
||||
open(path, "rb").read(), # noqa
|
||||
@ -212,8 +212,6 @@ class Pkcs(object): # noqa
|
||||
open(path, "rb").read(), # noqa
|
||||
)
|
||||
)
|
||||
|
||||
return privatekey
|
||||
except OSError as exc:
|
||||
raise PkcsError(exc) from exc
|
||||
|
||||
@ -221,8 +219,7 @@ class Pkcs(object): # noqa
|
||||
"""Load the specified certificate."""
|
||||
try:
|
||||
cert_content = open(path, "rb").read() # noqa
|
||||
cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert_content)
|
||||
return cert
|
||||
return crypto.load_certificate(crypto.FILETYPE_PEM, cert_content)
|
||||
except OSError as exc:
|
||||
raise PkcsError(exc) from exc
|
||||
|
||||
|
@ -842,8 +842,7 @@ from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||
|
||||
def get_nextvmid(module, proxmox):
|
||||
try:
|
||||
vmid = proxmox.cluster.nextid.get()
|
||||
return vmid
|
||||
return proxmox.cluster.nextid.get()
|
||||
except Exception as e: # noqa
|
||||
module.fail_json(
|
||||
msg=f"Unable to get next vmid. Failed with exception: {to_native(e)}",
|
||||
@ -1331,7 +1330,7 @@ def main():
|
||||
)
|
||||
|
||||
# Ensure source VM name exists when cloning
|
||||
if -1 == vmid:
|
||||
if vmid == -1:
|
||||
module.fail_json(msg=f"VM with name = {clone} does not exist in cluster")
|
||||
|
||||
# Ensure source VM id exists when cloning
|
||||
@ -1356,7 +1355,7 @@ def main():
|
||||
)
|
||||
except Exception as e: # noqa
|
||||
module.fail_json(
|
||||
vmid=vmid, msg=f"Unable to delete settings on VM {name} with vmid {vmid}: {str(e)}"
|
||||
vmid=vmid, msg=f"Unable to delete settings on VM {name} with vmid {vmid}: {e!s}"
|
||||
)
|
||||
|
||||
if revert is not None:
|
||||
@ -1369,7 +1368,7 @@ def main():
|
||||
module.fail_json(
|
||||
vmid=vmid,
|
||||
msg=f"Unable to revert settings on VM {name} with vmid {vmid}:"
|
||||
f"Maybe is not a pending task...{str(e)}",
|
||||
f"Maybe is not a pending task...{e!s}",
|
||||
)
|
||||
|
||||
if state == "present":
|
||||
@ -1504,7 +1503,7 @@ def main():
|
||||
elif state == "started":
|
||||
status = {}
|
||||
try:
|
||||
if -1 == vmid:
|
||||
if vmid == -1:
|
||||
module.fail_json(msg=f"VM with name = {name} does not exist in cluster")
|
||||
vm = get_vm(proxmox, vmid)
|
||||
if not vm:
|
||||
@ -1525,7 +1524,7 @@ def main():
|
||||
elif state == "stopped":
|
||||
status = {}
|
||||
try:
|
||||
if -1 == vmid:
|
||||
if vmid == -1:
|
||||
module.fail_json(msg=f"VM with name = {name} does not exist in cluster")
|
||||
|
||||
vm = get_vm(proxmox, vmid)
|
||||
@ -1550,7 +1549,7 @@ def main():
|
||||
elif state == "restarted":
|
||||
status = {}
|
||||
try:
|
||||
if -1 == vmid:
|
||||
if vmid == -1:
|
||||
module.fail_json(msg=f"VM with name = {name} does not exist in cluster")
|
||||
|
||||
vm = get_vm(proxmox, vmid)
|
||||
@ -1602,7 +1601,7 @@ def main():
|
||||
|
||||
elif state == "current":
|
||||
status = {}
|
||||
if -1 == vmid:
|
||||
if vmid == -1:
|
||||
module.fail_json(msg=f"VM with name = {name} does not exist in cluster")
|
||||
vm = get_vm(proxmox, vmid)
|
||||
if not vm:
|
||||
|
Loading…
Reference in New Issue
Block a user