1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

Improve Python code: address unused variables (#11049)

* Address F841 (unused variable).

* Reformat.

* Add changelog fragment.

* More cleanup.

* Remove trailing whitespace.

* Readd removed code as a comment with TODO.
This commit is contained in:
Felix Fontein 2025-11-09 08:14:35 +01:00 committed by GitHub
parent 0d8521c718
commit 396f467bbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
90 changed files with 232 additions and 235 deletions

View file

@ -145,7 +145,7 @@ class ElasticSource:
self.host = socket.gethostname()
try:
self.ip_address = socket.gethostbyname(socket.gethostname())
except Exception as e:
except Exception:
self.ip_address = None
self.user = getpass.getuser()

View file

@ -254,7 +254,7 @@ class CallbackModule(CallbackBase):
try:
self.token = self.get_option("token")
except KeyError as e:
except KeyError:
self._display.warning(
"Logentries token was not provided, this is required for this callback to operate, disabling"
)

View file

@ -210,7 +210,7 @@ class OpenTelemetrySource:
self.host = socket.gethostname()
try:
self.ip_address = socket.gethostbyname(socket.gethostname())
except Exception as e:
except Exception:
self.ip_address = None
self.user = getpass.getuser()

View file

@ -129,7 +129,7 @@ class CallbackModule(CallbackBase):
def v2_runner_on_async_failed(self, result):
res = result._result
host = result._host.get_name()
jid = result._result.get("ansible_job_id")
# jid = result._result.get("ansible_job_id")
self.logger.error(
"%s ansible-command: task execution FAILED; host: %s; message: %s",
self.hostname,

View file

@ -229,7 +229,6 @@ def _configure_alignments(table, field_names, column_alignments):
field_names: List of field names to align
column_alignments: Dict of column alignments
"""
valid_alignments = {"left", "center", "right", "l", "c", "r"}
if not isinstance(column_alignments, dict):
return

View file

@ -135,7 +135,7 @@ class InventoryModule(BaseInventoryPlugin):
def _fetch_information(self, url):
try:
response = open_url(url, headers=self.headers)
except Exception as e:
except Exception:
self.display.warning(f"An error happened while fetching: {url}")
return None

View file

@ -112,7 +112,7 @@ try:
if LooseVersion(websocket.__version__) <= LooseVersion("1.0.0"):
raise ImportError
except ImportError as e:
except ImportError:
HAS_WEBSOCKET = False

View file

@ -49,7 +49,7 @@ try:
import chef
HAS_CHEF = True
except ImportError as missing_module:
except ImportError:
HAS_CHEF = False

View file

@ -120,7 +120,7 @@ try:
import consul
HAS_CONSUL = True
except ImportError as e:
except ImportError:
HAS_CONSUL = False

View file

@ -86,19 +86,19 @@ class BtrfsCommands:
def subvolume_set_default(self, filesystem_path, subvolume_id):
command = [self.__btrfs, "subvolume", "set-default", str(subvolume_id), to_bytes(filesystem_path)]
result = self.__module.run_command(command, check_rc=True)
self.__module.run_command(command, check_rc=True)
def subvolume_create(self, subvolume_path):
command = [self.__btrfs, "subvolume", "create", to_bytes(subvolume_path)]
result = self.__module.run_command(command, check_rc=True)
self.__module.run_command(command, check_rc=True)
def subvolume_snapshot(self, snapshot_source, snapshot_destination):
command = [self.__btrfs, "subvolume", "snapshot", to_bytes(snapshot_source), to_bytes(snapshot_destination)]
result = self.__module.run_command(command, check_rc=True)
self.__module.run_command(command, check_rc=True)
def subvolume_delete(self, subvolume_path):
command = [self.__btrfs, "subvolume", "delete", to_bytes(subvolume_path)]
result = self.__module.run_command(command, check_rc=True)
self.__module.run_command(command, check_rc=True)
class BtrfsInfoProvider:

View file

@ -57,11 +57,11 @@ def auth_argument_spec(spec=None):
def find_project(gitlab_instance, identifier):
try:
project = gitlab_instance.projects.get(identifier)
except Exception as e:
except Exception:
current_user = gitlab_instance.user
try:
project = gitlab_instance.projects.get(f"{current_user.username}/{identifier}")
except Exception as e:
except Exception:
return None
return project
@ -70,7 +70,7 @@ def find_project(gitlab_instance, identifier):
def find_group(gitlab_instance, identifier):
try:
group = gitlab_instance.groups.get(identifier)
except Exception as e:
except Exception:
return None
return group

View file

@ -186,7 +186,7 @@ class RedfishUtils:
)
try:
data = json.loads(to_native(resp.read()))
except Exception as e:
except Exception:
# No response data; this is okay in certain cases
data = None
if not allow_no_resp:
@ -233,7 +233,7 @@ class RedfishUtils:
)
try:
data = json.loads(to_native(resp.read()))
except Exception as e:
except Exception:
# No response data; this is okay in many cases
data = None
except HTTPError as e:
@ -1991,7 +1991,7 @@ class RedfishUtils:
try:
with open(image_file, "rb") as f:
image_payload = f.read()
except Exception as e:
except Exception:
return {"ret": False, "msg": f"Could not read file {image_file}"}
# Check that multipart HTTP push updates are supported
@ -2409,7 +2409,7 @@ class RedfishUtils:
return {"ret": False, "msg": "Key BootOrder not found"}
boot = data["Boot"]
boot_order = boot["BootOrder"]
# boot_order = boot["BootOrder"] - TODO is this needed?
boot_options_dict = self._get_boot_options_dict(boot)
# Verify the requested boot options are valid
@ -3742,7 +3742,7 @@ class RedfishUtils:
response = self.get_request(f"{self.root_uri}/redfish/v1/Managers/{manager}", override_headers=None)
try:
result["service_identification"] = response["data"]["ServiceIdentification"]
except Exception as e:
except Exception:
self.module.fail_json(msg=f"Service ID not found for manager {manager}")
result["ret"] = True
return result
@ -3826,7 +3826,6 @@ class RedfishUtils:
def get_hpe_thermal_config(self):
result = {}
key = "Thermal"
# Go through list
for chassis_uri in self.chassis_uris:
response = self.get_request(self.root_uri + chassis_uri)
@ -3840,8 +3839,6 @@ class RedfishUtils:
return {"ret": False}
def get_hpe_fan_percent_min(self):
result = {}
key = "Thermal"
# Go through list
for chassis_uri in self.chassis_uris:
response = self.get_request(self.root_uri + chassis_uri)
@ -3946,17 +3943,6 @@ class RedfishUtils:
# Validate input parameters
required_parameters = ["RAIDType", "Drives"]
allowed_parameters = [
"CapacityBytes",
"DisplayName",
"InitializeMethod",
"MediaSpanCount",
"Name",
"ReadCachePolicy",
"StripSizeBytes",
"VolumeUsage",
"WriteCachePolicy",
]
for parameter in required_parameters:
if not volume_details.get(parameter):
@ -4029,7 +4015,6 @@ class RedfishUtils:
reg_data = reg_resp["data"]
# Get BIOS attribute registry URI
lst = []
# Get the location URI
response = self.check_location_uri(reg_data, reg_uri)

View file

@ -268,7 +268,6 @@ class Scaleway:
def fetch_paginated_resources(self, resource_key, **pagination_kwargs):
response = self.get(path=self.api_path, params=pagination_kwargs)
status_code = response.status_code
if not response.ok:
self.module.fail_json(
msg=f"Error getting {resource_key} [{response.status_code}: {response.json['message']}]"

View file

@ -289,7 +289,7 @@ def get_object_ref(module, name, uuid=None, obj_type="VM", fail=True, msg_prefix
# Find object by UUID. If no object is found using given UUID,
# an exception will be generated.
obj_ref = xapi_session.xenapi_request(f"{real_obj_type}.get_by_uuid", (uuid,))
except XenAPI.Failure as f:
except XenAPI.Failure:
if fail:
module.fail_json(msg=f"{msg_prefix}{obj_type} with UUID '{uuid}' not found!")
elif name:

View file

@ -167,7 +167,7 @@ try:
import aerospike
from time import sleep
import re
except ImportError as ie:
except ImportError:
LIB_FOUND = False
LIB_FOUND_ERR = traceback.format_exc()
else:

View file

@ -272,8 +272,6 @@ def main():
if state == "absent":
module.exit_json(changed=False, msg=f"Logical Volume {lv} does not exist.")
changed = False
this_lv = parse_lv(lv_info)
if state == "present" and not size:

View file

@ -656,7 +656,7 @@ def run_instance(module, ecs, exact_count):
system_disk_size = module.params["system_disk_size"]
system_disk_name = module.params["system_disk_name"]
system_disk_description = module.params["system_disk_description"]
allocate_public_ip = module.params["allocate_public_ip"]
# allocate_public_ip = module.params["allocate_public_ip"] TODO - this is unused!
period = module.params["period"]
auto_renew = module.params["auto_renew"]
instance_charge_type = module.params["instance_charge_type"]

View file

@ -155,7 +155,7 @@ def local_rpm_package_name(path):
fd = os.open(path, os.O_RDONLY)
try:
header = ts.hdrFromFdno(fd)
except rpm.error as e:
except rpm.error:
return None
finally:
os.close(fd)

View file

@ -593,7 +593,7 @@ class BtrfsSubvolumeModule:
mount = self.module.get_bin_path("mount", required=True)
command = [mount, "-o", f"noatime,subvolid={int(subvolid)}", device, mountpoint]
result = self.module.run_command(command, check_rc=True)
self.module.run_command(command, check_rc=True)
return mountpoint

View file

@ -183,11 +183,6 @@ def main():
supports_check_mode=True,
)
result = dict(
changed=False,
http_code="",
)
if module.check_mode:
response, info = discord_check_mode(module)
if info["status"] != 200:

View file

@ -332,7 +332,7 @@ def main():
if os.path.exists(b_old) and not os.path.exists(b_new):
try:
os.rename(b_old, b_new)
except OSError as e:
except OSError:
pass
if not module.check_mode:

View file

@ -95,13 +95,13 @@ class GitlabBranch:
def get_project(self, project):
try:
return self.repo.projects.get(project)
except Exception as e:
except Exception:
return False
def get_branch(self, branch):
try:
return self.project.branches.get(branch)
except Exception as e:
except Exception:
return False
def create_branch(self, branch, ref_branch):
@ -171,7 +171,7 @@ def main():
try:
this_gitlab.delete_branch(this_branch)
module.exit_json(changed=True, msg=f"Branch {branch} deleted.")
except Exception as e:
except Exception:
module.fail_json(msg="Error delete branch.", exception=traceback.format_exc())
else:
module.exit_json(changed=False, msg="No changes are needed.")

View file

@ -197,7 +197,7 @@ class GitLabGroup:
member = group.members.get(gitlab_user_id)
if member:
return member
except gitlab.exceptions.GitlabGetError as e:
except gitlab.exceptions.GitlabGetError:
return None
# check if the user is a member of the group
@ -210,7 +210,7 @@ class GitLabGroup:
# add user to a group
def add_member_to_group(self, gitlab_user_id, gitlab_group_id, access_level):
group = self._gitlab.groups.get(gitlab_group_id)
add_member = group.members.create({"user_id": gitlab_user_id, "access_level": access_level})
group.members.create({"user_id": gitlab_user_id, "access_level": access_level})
# remove user from a group
def remove_user_from_group(self, gitlab_user_id, gitlab_group_id):

View file

@ -177,7 +177,7 @@ class GitLabProjectMembers:
try:
project_exists = self._gitlab.projects.get(project_name)
return project_exists.id
except gitlab.exceptions.GitlabGetError as e:
except gitlab.exceptions.GitlabGetError:
project_exists = self._gitlab.projects.list(search=project_name, all=False)
if project_exists:
return project_exists[0].id
@ -200,7 +200,7 @@ class GitLabProjectMembers:
member = project.members.get(gitlab_user_id)
if member:
return member
except gitlab.exceptions.GitlabGetError as e:
except gitlab.exceptions.GitlabGetError:
return None
# check if the user is a member of the project
@ -213,7 +213,7 @@ class GitLabProjectMembers:
# add user to a project
def add_member_to_project(self, gitlab_user_id, gitlab_project_id, access_level):
project = self._gitlab.projects.get(gitlab_project_id)
add_member = project.members.create({"user_id": gitlab_user_id, "access_level": access_level})
project.members.create({"user_id": gitlab_user_id, "access_level": access_level})
# remove user from a project
def remove_user_from_project(self, gitlab_user_id, gitlab_project_id):

View file

@ -112,7 +112,7 @@ class GitlabProtectedBranch:
def protected_branch_exist(self, name):
try:
return self.project.protectedbranches.get(name)
except Exception as e:
except Exception:
return False
def create_or_update_protected_branch(self, name, options):

View file

@ -443,7 +443,6 @@ class Infinity:
add a new LAN network into a given supernet Fusionlayer Infinity via rest api or default supernet
required fields=['network_name', 'network_family', 'network_type', 'network_address','network_size' ]
"""
method = "post"
resource_url = "networks"
response = None
if network_name is None or network_address is None or network_size is None:

View file

@ -172,9 +172,6 @@ def optionDict(line, iface, option, value, address_family):
def getValueFromLine(s):
spaceRe = re.compile(r"\s+")
m = list(spaceRe.finditer(s))[-1]
valueEnd = m.start()
option = s.split()[0]
optionStart = s.find(option)
optionLen = len(option)

View file

@ -230,7 +230,6 @@ def get_group_dict(description=None, external=None, gid=None, nonposix=None):
def get_group_diff(client, ipa_group, module_group):
data = []
# With group_add attribute nonposix is passed, whereas with group_mod only posix can be passed.
if "nonposix" in module_group:
# Only non-posix groups can be changed to posix

View file

@ -181,7 +181,7 @@ def get_vault_diff(client, ipa_vault, module_vault, module):
def ensure(module, client):
state = module.params["state"]
name = module.params["cn"]
user = module.params["username"]
# user = module.params["username"] TODO is this really not needed?
replace = module.params["replace"]
module_vault = get_vault_dict(

View file

@ -177,7 +177,7 @@ def main():
key = binascii.unhexlify(module.params["key"])
else:
key = None
except Exception as e:
except Exception:
module.fail_json(msg="Unable to convert 'key' from hex string.")
# --- run command ---

View file

@ -212,7 +212,7 @@ class JenkinsBuild:
try:
response = self.server.get_build_info(self.name, self.build_number)
return response
except jenkins.JenkinsException as e:
except jenkins.JenkinsException:
response = {}
response["result"] = "ABSENT"
return response

View file

@ -153,7 +153,7 @@ class JenkinsBuildInfo:
self.build_number = job_info["lastBuild"]["number"]
return self.server.get_build_info(self.name, self.build_number)
except jenkins.JenkinsException as e:
except jenkins.JenkinsException:
response = {}
response["result"] = "ABSENT"
return response

View file

@ -552,7 +552,7 @@ class JenkinsPlugin:
data = urlencode(script_data)
# Send the installation request
r = self._get_url_data(
self._get_url_data(
f"{self.url}/scriptText",
msg_status="Cannot install plugin.",
msg_exception="Plugin installation has failed.",

View file

@ -227,10 +227,7 @@ def main():
# Make it easier to refer to current module parameters
name = module.params.get("name")
force = module.params.get("force")
state = module.params.get("state")
enabled = module.params.get("enabled")
provider_id = module.params.get("provider_id")
provider_type = module.params.get("provider_type")
parent_id = module.params.get("parent_id")

View file

@ -367,8 +367,6 @@ def main():
name = module.params.get("name")
force = module.params.get("force")
state = module.params.get("state")
enabled = module.params.get("enabled")
provider_id = module.params.get("provider_id")
parent_id = module.params.get("parent_id")
# Get a list of all Keycloak components that are of keyprovider type.

View file

@ -630,7 +630,6 @@ def main():
# Make it easier to refer to current module parameters
state = module.params.get("state")
enabled = module.params.get("enabled")
parent_id = module.params.get("parent_id")
provider_type = module.params.get("provider_type")
provider_id = module.params.get("provider_id")

View file

@ -470,8 +470,7 @@ def main():
service = module.params["name"]
plist_filename = module.params["plist"]
action = module.params["state"]
rc = 0
out = err = ""
err = ""
result = {
"name": service,
"changed": False,

View file

@ -226,7 +226,7 @@ def netStatParse(raw):
pid_and_name = ""
process = ""
formatted_line = line.split()
protocol, recv_q, send_q, address, foreign_address, rest = (
protocol, _recv_q, _send_q, address, foreign_address, rest = (
formatted_line[0],
formatted_line[1],
formatted_line[2],

View file

@ -218,7 +218,7 @@ class ManageIQAlertProfiles:
# if we have any updated values
changed = True
try:
result = self.client.post(old_profile["href"], resource=profile_dict, action="edit")
self.client.post(old_profile["href"], resource=profile_dict, action="edit")
except Exception as e:
msg = "Updating profile '{name}' failed: {error}"
msg = msg.format(name=old_profile["name"], error=e)

View file

@ -808,7 +808,7 @@ class ManageIQProvider:
"""
try:
url = f"{self.api_url}/providers/{provider['id']}"
result = self.client.post(url, action="refresh")
self.client.post(url, action="refresh")
except Exception as e:
self.module.fail_json(msg=f"failed to refresh provider {name}: {e}")

View file

@ -275,7 +275,7 @@ class ManageIQTenant:
# try to update tenant
try:
result = self.client.post(tenant["href"], action="edit", resource=resource)
self.client.post(tenant["href"], action="edit", resource=resource)
except Exception as e:
self.module.fail_json(msg=f"failed to update tenant {tenant['name']}: {e}")

View file

@ -115,7 +115,6 @@ def get_facts(args=None):
"""
retvals, payload = dict(), dict()
has_changed, has_failed = False, False
msg, stderr, memset_api = None, None, None
payload["name"] = args["name"]
@ -135,14 +134,12 @@ def get_facts(args=None):
return retvals
# we don't want to return the same thing twice
msg = None
memset_api = response.json()
retvals["changed"] = has_changed
retvals["failed"] = has_failed
for val in ["msg", "memset_api"]:
if val is not None:
retvals[val] = eval(val)
retvals["msg"] = None
retvals["memset_api"] = memset_api
return retvals

View file

@ -246,7 +246,6 @@ def get_facts(args=None):
"""
retvals, payload = dict(), dict()
has_changed, has_failed = False, False
msg, stderr, memset_api = None, None, None
payload["name"] = args["name"]
@ -266,14 +265,12 @@ def get_facts(args=None):
return retvals
# we don't want to return the same thing twice
msg = None
memset_api = response.json()
retvals["changed"] = has_changed
retvals["failed"] = has_failed
for val in ["msg", "memset_api"]:
if val is not None:
retvals[val] = eval(val)
retvals["msg"] = None
retvals["memset_api"] = memset_api
return retvals

View file

@ -273,9 +273,9 @@ def create_or_delete(args=None):
retvals["failed"] = has_failed
retvals["changed"] = has_changed
for val in ["msg", "stderr", "memset_api"]:
if val is not None:
retvals[val] = eval(val)
retvals["msg"] = msg
retvals["stderr"] = stderr
retvals["memset_api"] = memset_api
return retvals

View file

@ -517,8 +517,6 @@ def main():
)
service = module.params["name"]
rc = 0
out = err = ""
result = {
"name": service,
"changed": False,

View file

@ -89,7 +89,7 @@ try:
import pyodbc
HAS_PYODBC = True
except ImportError as e:
except ImportError:
HAS_PYODBC = False
@ -153,7 +153,7 @@ def main():
result["description"].append(description)
result["row_count"] = cursor.rowcount
except pyodbc.ProgrammingError as pe:
except pyodbc.ProgrammingError:
pass
except Exception as e:
module.fail_json(msg=f"Exception while reading rows: {e}")

View file

@ -437,7 +437,7 @@ def change_service_permissions(module, auth, service_id, permissions):
data = {"action": {"perform": "chmod", "params": {"octet": permissions}}}
try:
status_result = open_url(
open_url(
f"{auth.url}/service/{service_id!s}/action",
method="POST",
force_basic_auth=True,
@ -453,7 +453,7 @@ def change_service_owner(module, auth, service_id, owner_id):
data = {"action": {"perform": "chown", "params": {"owner_id": owner_id}}}
try:
status_result = open_url(
open_url(
f"{auth.url}/service/{service_id!s}/action",
method="POST",
force_basic_auth=True,
@ -469,7 +469,7 @@ def change_service_group(module, auth, service_id, group_id):
data = {"action": {"perform": "chgrp", "params": {"group_id": group_id}}}
try:
status_result = open_url(
open_url(
f"{auth.url}/service/{service_id!s}/action",
method="POST",
force_basic_auth=True,
@ -666,7 +666,7 @@ def delete_service(module, auth, service_id):
return service_info
try:
result = open_url(
open_url(
f"{auth.url}/service/{service_id!s}",
method="DELETE",
force_basic_auth=True,

View file

@ -1271,7 +1271,6 @@ def create_exact_count_of_vms(
vm_count_diff = exact_count - len(vm_list)
changed = vm_count_diff != 0
new_vms_list = []
instances_list = []
tagged_instances_list = vm_list

View file

@ -179,7 +179,7 @@ def main():
backend_name = module.params["backend"]
name = module.params["name"]
value = module.params["value"]
state = module.params["state"]
# state = module.params["state"] TODO - ???
if module.params["password"] is not None:
password_method = ["-w", password]

View file

@ -112,7 +112,6 @@ def main():
application_key = module.params.get("application_key")
application_secret = module.params.get("application_secret")
consumer_key = module.params.get("consumer_key")
project = ""
instance = ""
ovh_billing_status = ""
@ -129,7 +128,7 @@ def main():
# Check that the instance exists
try:
project = client.get(f"/cloud/project/{project_id}")
client.get(f"/cloud/project/{project_id}")
except ovh.exceptions.ResourceNotFoundError:
module.fail_json(msg=f"project {project_id} does not exist")

View file

@ -73,13 +73,11 @@ def query_package(module, name):
# Assume that if we have pkg_info, we haven't upgraded to pkgng
if pkg_info_path:
pkgng = False
pkg_glob_path = module.get_bin_path("pkg_glob", True)
module.get_bin_path("pkg_glob", True)
# TODO: convert run_comand() argument to list!
rc, out, err = module.run_command(f"{pkg_info_path} -e `pkg_glob {shlex_quote(name)}`", use_unsafe_shell=True)
pkg_info_path = [pkg_info_path]
else:
pkgng = True
pkg_info_path = [module.get_bin_path("pkg", True), "info"]
rc, out, err = module.run_command(pkg_info_path + [name])

View file

@ -1118,11 +1118,11 @@ def main():
password = module.params["password"]
token = module.params["token"]
server_hostname = module.params["server_hostname"]
server_insecure = module.params["server_insecure"]
server_prefix = module.params["server_prefix"]
server_port = module.params["server_port"]
rhsm_baseurl = module.params["rhsm_baseurl"]
rhsm_repo_ca_cert = module.params["rhsm_repo_ca_cert"]
# TODO - no longer used? module.params["server_insecure"]
# TODO - no longer used? module.params["server_prefix"]
# TODO - no longer used? module.params["server_port"]
# TODO - no longer used? module.params["rhsm_baseurl"]
# TODO - no longer used? module.params["rhsm_repo_ca_cert"]
auto_attach = module.params["auto_attach"]
activationkey = module.params["activationkey"]
org_id = module.params["org_id"]
@ -1142,10 +1142,10 @@ def main():
consumer_name = module.params["consumer_name"]
consumer_id = module.params["consumer_id"]
force_register = module.params["force_register"]
server_proxy_hostname = module.params["server_proxy_hostname"]
server_proxy_port = module.params["server_proxy_port"]
server_proxy_user = module.params["server_proxy_user"]
server_proxy_password = module.params["server_proxy_password"]
# TODO - no longer used? module.params["server_proxy_hostname"]
# TODO - no longer used? module.params["server_proxy_port"]
# TODO - no longer used? module.params["server_proxy_user"]
# TODO - no longer used? module.params["server_proxy_password"]
release = module.params["release"]
syspurpose = module.params["syspurpose"]

View file

@ -128,7 +128,7 @@ def main():
res = redis.connection.get(key)
if res is not None:
value = float(res)
except ValueError as e:
except ValueError:
msg = f"Value: {res} of key: {key} is not incrementable(int or float)"
result["msg"] = msg
module.fail_json(**result)

View file

@ -120,7 +120,7 @@ def core(module):
present_sshkeys = []
try:
present_sshkeys = extract_present_sshkeys(organization_json)
except (KeyError, IndexError) as e:
except (KeyError, IndexError):
module.fail_json(changed=False, data="Error while extracting present SSH keys from API")
if state in ("present",):

View file

@ -506,7 +506,7 @@ xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../x
self.result["msg"] = self.success_msg
self.result["changed"] = True
continue
resp = self.update_model(Model_Handle, {req_name: req_val})
self.update_model(Model_Handle, {req_name: req_val})
self.module.exit_json(**self.result)

View file

@ -906,7 +906,7 @@ def handle_elastigroup(client, module):
grace_period=roll_config.get("grace_period"),
health_check_type=roll_config.get("health_check_type"),
)
roll_response = client.roll_group(group_roll=eg_roll, group_id=group_id)
client.roll_group(group_roll=eg_roll, group_id=group_id)
message = "Updated and started rolling the group successfully."
except SpotinstClientException as exc:

View file

@ -264,7 +264,7 @@ def main():
svc = Svc(module)
changed = False
orig_state = svc.report()
dummy_orig_state = svc.report() # TODO - is this not needed?
if enabled is not None and enabled != svc.enabled:
changed = True

View file

@ -560,7 +560,7 @@ def create_payload(module, uuid):
try:
vmdef_json = json.dumps(vmdef)
except Exception as e:
except Exception:
module.fail_json(msg="Could not create valid JSON payload", exception=traceback.format_exc())
# Create the temporary file that contains our payload, and set tight

View file

@ -1370,7 +1370,7 @@ class XenServerVM(XenServerObject):
# do not support subargument specs.
try:
num_cpus = int(num_cpus)
except ValueError as e:
except ValueError:
self.module.fail_json(msg="VM check hardware.num_cpus: parameter should be an integer value!")
if num_cpus < 1:
@ -1392,7 +1392,7 @@ class XenServerVM(XenServerObject):
# do not support subargument specs.
try:
num_cpu_cores_per_socket = int(num_cpu_cores_per_socket)
except ValueError as e:
except ValueError:
self.module.fail_json(
msg="VM check hardware.num_cpu_cores_per_socket: parameter should be an integer value!"
)
@ -1423,7 +1423,7 @@ class XenServerVM(XenServerObject):
# do not support subargument specs.
try:
memory_mb = int(memory_mb)
except ValueError as e:
except ValueError:
self.module.fail_json(msg="VM check hardware.memory_mb: parameter should be an integer value!")
if memory_mb < 1:

View file

@ -222,7 +222,7 @@ def main():
)
try:
pwd.getpwnam(name)
except KeyError as e:
except KeyError:
module.fail_json(msg=f"User '{name}' does not exist.", **result)
elif quota_type == "group":
@ -238,7 +238,7 @@ def main():
)
try:
grp.getgrnam(name)
except KeyError as e:
except KeyError:
module.fail_json(msg=f"User '{name}' does not exist.", **result)
elif quota_type == "project":

View file

@ -920,7 +920,6 @@ def main():
input_type = module.params["input_type"]
print_match = module.params["print_match"]
count = module.params["count"]
backup = module.params["backup"]
strip_cdata_tags = module.params["strip_cdata_tags"]
insertbefore = module.params["insertbefore"]
insertafter = module.params["insertafter"]