mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
modules h*: use f-strings (#10959)
* modules h*: use f-strings * add changelog frag
This commit is contained in:
parent
b67e7c83cf
commit
f9b4abf930
24 changed files with 242 additions and 402 deletions
24
changelogs/fragments/10959-mod-fstr-h.yml
Normal file
24
changelogs/fragments/10959-mod-fstr-h.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
minor_changes:
|
||||
- haproxy - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- heroku_collaborator - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- homebrew - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- homebrew_cask - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- homebrew_services - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- homebrew_tap - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- homectl - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- honeybadger_deployment - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hpilo_boot - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hpilo_info - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- htpasswd - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_ecs_instance - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_evs_disk - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_network_vpc - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_smn_topic - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_vpc_eip - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_vpc_peering_connect - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_vpc_port - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_vpc_private_ip - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_vpc_route - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_vpc_security_group - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_vpc_security_group_rule - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
- hwc_vpc_subnet - use f-strings for string templating (https://github.com/ansible-collections/community.general/pull/10959).
|
||||
|
|
@ -264,7 +264,7 @@ class HAProxy(object):
|
|||
"""
|
||||
self.client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
self.client.connect(self.socket)
|
||||
self.client.sendall(to_bytes('%s\n' % cmd))
|
||||
self.client.sendall(to_bytes(f'{cmd}\n'))
|
||||
|
||||
result = b''
|
||||
buf = b''
|
||||
|
|
@ -332,7 +332,7 @@ class HAProxy(object):
|
|||
state = self.get_state_for(backend, svname)
|
||||
if (self.fail_on_not_found) and state is None:
|
||||
self.module.fail_json(
|
||||
msg="The specified backend '%s/%s' was not found!" % (backend, svname))
|
||||
msg=f"The specified backend '{backend}/{svname}' was not found!")
|
||||
|
||||
if state is not None:
|
||||
self.execute(Template(cmd).substitute(pxname=backend, svname=svname))
|
||||
|
|
@ -370,8 +370,7 @@ class HAProxy(object):
|
|||
return True
|
||||
time.sleep(self.wait_interval)
|
||||
|
||||
self.module.fail_json(msg="server %s/%s not status '%s' after %d retries. Aborting." %
|
||||
(pxname, svname, status, self.wait_retries))
|
||||
self.module.fail_json(msg=f"server {pxname}/{svname} not status '{status}' after {self.wait_retries} retries. Aborting.")
|
||||
|
||||
def enabled(self, host, backend, weight):
|
||||
"""
|
||||
|
|
@ -385,7 +384,7 @@ class HAProxy(object):
|
|||
if self.health:
|
||||
cmd += "; enable health $pxname/$svname"
|
||||
if weight:
|
||||
cmd += "; set weight $pxname/$svname %s" % weight
|
||||
cmd += f"; set weight $pxname/$svname {weight}"
|
||||
self.execute_for_backends(cmd, backend, host, 'UP')
|
||||
|
||||
def disabled(self, host, backend, shutdown_sessions):
|
||||
|
|
@ -436,7 +435,7 @@ class HAProxy(object):
|
|||
elif self.state == 'drain':
|
||||
self.drain(self.host, self.backend)
|
||||
else:
|
||||
self.module.fail_json(msg="unknown state specified: '%s'" % self.state)
|
||||
self.module.fail_json(msg=f"unknown state specified: '{self.state}'")
|
||||
|
||||
# Get the state after the run
|
||||
self.command_results['state_after'] = self.get_state_for(self.backend, self.host)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ def add_or_delete_heroku_collaborator(module, client):
|
|||
|
||||
for app in module.params['apps']:
|
||||
if app not in client.apps():
|
||||
module.fail_json(msg='App {0} does not exist'.format(app))
|
||||
module.fail_json(msg=f'App {app} does not exist')
|
||||
|
||||
heroku_app = client.apps()[app]
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class HomebrewException(Exception):
|
|||
def _create_regex_group_complement(s):
|
||||
lines = (line.strip() for line in s.split('\n') if line.strip())
|
||||
chars = [_f for _f in (line.split('#')[0].strip() for line in lines) if _f]
|
||||
group = r'[^' + r''.join(chars) + r']'
|
||||
group = rf"[^{''.join(chars)}]"
|
||||
return re.compile(group)
|
||||
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ class Homebrew(object):
|
|||
if not self.valid_module(module):
|
||||
self._module = None
|
||||
self.failed = True
|
||||
self.message = 'Invalid module: {0}.'.format(module)
|
||||
self.message = f'Invalid module: {module}.'
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
else:
|
||||
|
|
@ -268,7 +268,7 @@ class Homebrew(object):
|
|||
if not HomebrewValidate.valid_path(path):
|
||||
self._path = []
|
||||
self.failed = True
|
||||
self.message = 'Invalid path: {0}.'.format(path)
|
||||
self.message = f'Invalid path: {path}.'
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
else:
|
||||
|
|
@ -288,7 +288,7 @@ class Homebrew(object):
|
|||
if not HomebrewValidate.valid_brew_path(brew_path):
|
||||
self._brew_path = None
|
||||
self.failed = True
|
||||
self.message = 'Invalid brew_path: {0}.'.format(brew_path)
|
||||
self.message = f'Invalid brew_path: {brew_path}.'
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
else:
|
||||
|
|
@ -369,10 +369,7 @@ class Homebrew(object):
|
|||
|
||||
if invalid_packages:
|
||||
self.failed = True
|
||||
self.message = 'Invalid package{0}: {1}'.format(
|
||||
"s" if len(invalid_packages) > 1 else "",
|
||||
", ".join(invalid_packages),
|
||||
)
|
||||
self.message = f"Invalid package{'s' if len(invalid_packages) > 1 else ''}: {', '.join(invalid_packages)}"
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
def _save_package_info(self, package_detail, package_name):
|
||||
|
|
@ -412,17 +409,14 @@ class Homebrew(object):
|
|||
package_names.update(package_detail.get("old_tokens", []))
|
||||
if package_detail['tap']:
|
||||
# names so far, with tap prefix added to each
|
||||
tapped_names = {package_detail["tap"] + "/" + x for x in package_names}
|
||||
tapped_names = {f"{package_detail['tap']}/{x}" for x in package_names}
|
||||
package_names.update(tapped_names)
|
||||
|
||||
# Finally, identify which of all those package names was the one supplied by the user.
|
||||
package_names = package_names & set(self.packages)
|
||||
if len(package_names) != 1:
|
||||
self.failed = True
|
||||
self.message = "Package names for {name} are missing or ambiguous: {packages}".format(
|
||||
name=name,
|
||||
packages=", ".join(str(p) for p in package_names),
|
||||
)
|
||||
self.message = f"Package names for {name} are missing or ambiguous: {', '.join((str(p) for p in package_names))}"
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
# Then make sure the user provided name resurface.
|
||||
|
|
@ -430,7 +424,7 @@ class Homebrew(object):
|
|||
|
||||
def _get_packages_info(self):
|
||||
cmd = [
|
||||
"{brew_path}".format(brew_path=self.brew_path),
|
||||
f"{self.brew_path}",
|
||||
"info",
|
||||
"--json=v2",
|
||||
]
|
||||
|
|
@ -441,7 +435,7 @@ class Homebrew(object):
|
|||
rc, out, err = self.module.run_command(cmd)
|
||||
if rc != 0:
|
||||
self.failed = True
|
||||
self.message = err.strip() or ("Unknown failure with exit code %d" % rc)
|
||||
self.message = err.strip() or (f"Unknown failure with exit code {rc}")
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
data = json.loads(out)
|
||||
|
|
@ -464,10 +458,7 @@ class Homebrew(object):
|
|||
changed_count = len(self.changed_pkgs)
|
||||
unchanged_count = len(self.unchanged_pkgs)
|
||||
if not self.failed and (changed_count + unchanged_count > 1):
|
||||
self.message = "Changed: %d, Unchanged: %d" % (
|
||||
changed_count,
|
||||
unchanged_count,
|
||||
)
|
||||
self.message = f"Changed: {int(changed_count)}, Unchanged: {unchanged_count}"
|
||||
return (self.failed, self.changed, self.message)
|
||||
|
||||
# commands ----------------------------------------------------- {{{
|
||||
|
|
@ -555,18 +546,12 @@ class Homebrew(object):
|
|||
|
||||
if len(packages_to_install) == 0:
|
||||
self.unchanged_pkgs.extend(self.packages)
|
||||
self.message = 'Package{0} already installed: {1}'.format(
|
||||
"s" if len(self.packages) > 1 else "",
|
||||
", ".join(self.packages),
|
||||
)
|
||||
self.message = f"Package{'s' if len(self.packages) > 1 else ''} already installed: {', '.join(self.packages)}"
|
||||
return True
|
||||
|
||||
if self.module.check_mode:
|
||||
self.changed = True
|
||||
self.message = 'Package{0} would be installed: {1}'.format(
|
||||
"s" if len(packages_to_install) > 1 else "",
|
||||
", ".join(packages_to_install)
|
||||
)
|
||||
self.message = f"Package{'s' if len(packages_to_install) > 1 else ''} would be installed: {', '.join(packages_to_install)}"
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
if self.state == 'head':
|
||||
|
|
@ -592,10 +577,7 @@ class Homebrew(object):
|
|||
self.changed_pkgs.extend(packages_to_install)
|
||||
self.unchanged_pkgs.extend(self.installed_packages)
|
||||
self.changed = True
|
||||
self.message = 'Package{0} installed: {1}'.format(
|
||||
"s" if len(packages_to_install) > 1 else "",
|
||||
", ".join(packages_to_install)
|
||||
)
|
||||
self.message = f"Package{'s' if len(packages_to_install) > 1 else ''} installed: {', '.join(packages_to_install)}"
|
||||
return True
|
||||
else:
|
||||
self.failed = True
|
||||
|
|
@ -635,18 +617,12 @@ class Homebrew(object):
|
|||
|
||||
if len(packages_to_install_or_upgrade) == 0:
|
||||
self.unchanged_pkgs.extend(self.packages)
|
||||
self.message = 'Package{0} already upgraded: {1}'.format(
|
||||
"s" if len(self.packages) > 1 else "",
|
||||
", ".join(self.packages),
|
||||
)
|
||||
self.message = f"Package{'s' if len(self.packages) > 1 else ''} already upgraded: {', '.join(self.packages)}"
|
||||
return True
|
||||
|
||||
if self.module.check_mode:
|
||||
self.changed = True
|
||||
self.message = 'Package{0} would be upgraded: {1}'.format(
|
||||
"s" if len(packages_to_install_or_upgrade) > 1 else "",
|
||||
", ".join(packages_to_install_or_upgrade)
|
||||
)
|
||||
self.message = f"Package{'s' if len(packages_to_install_or_upgrade) > 1 else ''} would be upgraded: {', '.join(packages_to_install_or_upgrade)}"
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
for command, packages in [
|
||||
|
|
@ -672,10 +648,7 @@ class Homebrew(object):
|
|||
self.changed_pkgs.extend(packages_to_install_or_upgrade)
|
||||
self.unchanged_pkgs.extend(set(self.packages) - packages_to_install_or_upgrade)
|
||||
self.changed = True
|
||||
self.message = 'Package{0} upgraded: {1}'.format(
|
||||
"s" if len(packages_to_install_or_upgrade) > 1 else "",
|
||||
", ".join(packages_to_install_or_upgrade),
|
||||
)
|
||||
self.message = f"Package{'s' if len(packages_to_install_or_upgrade) > 1 else ''} upgraded: {', '.join(packages_to_install_or_upgrade)}"
|
||||
# /upgraded ------------------------------ }}}
|
||||
|
||||
# uninstalled ---------------------------- {{{
|
||||
|
|
@ -684,18 +657,12 @@ class Homebrew(object):
|
|||
|
||||
if len(packages_to_uninstall) == 0:
|
||||
self.unchanged_pkgs.extend(self.packages)
|
||||
self.message = 'Package{0} already uninstalled: {1}'.format(
|
||||
"s" if len(self.packages) > 1 else "",
|
||||
", ".join(self.packages),
|
||||
)
|
||||
self.message = f"Package{'s' if len(self.packages) > 1 else ''} already uninstalled: {', '.join(self.packages)}"
|
||||
return True
|
||||
|
||||
if self.module.check_mode:
|
||||
self.changed = True
|
||||
self.message = 'Package{0} would be uninstalled: {1}'.format(
|
||||
"s" if len(packages_to_uninstall) > 1 else "",
|
||||
", ".join(packages_to_uninstall)
|
||||
)
|
||||
self.message = f"Package{'s' if len(packages_to_uninstall) > 1 else ''} would be uninstalled: {', '.join(packages_to_uninstall)}"
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
opts = (
|
||||
|
|
@ -710,10 +677,7 @@ class Homebrew(object):
|
|||
self.changed_pkgs.extend(packages_to_uninstall)
|
||||
self.unchanged_pkgs.extend(set(self.packages) - self.installed_packages)
|
||||
self.changed = True
|
||||
self.message = 'Package{0} uninstalled: {1}'.format(
|
||||
"s" if len(packages_to_uninstall) > 1 else "",
|
||||
", ".join(packages_to_uninstall)
|
||||
)
|
||||
self.message = f"Package{'s' if len(packages_to_uninstall) > 1 else ''} uninstalled: {', '.join(packages_to_uninstall)}"
|
||||
return True
|
||||
else:
|
||||
self.failed = True
|
||||
|
|
@ -726,18 +690,12 @@ class Homebrew(object):
|
|||
missing_packages = set(self.packages) - self.installed_packages
|
||||
if missing_packages:
|
||||
self.failed = True
|
||||
self.message = 'Package{0} not installed: {1}.'.format(
|
||||
"s" if len(missing_packages) > 1 else "",
|
||||
", ".join(missing_packages),
|
||||
)
|
||||
self.message = f"Package{'s' if len(missing_packages) > 1 else ''} not installed: {', '.join(missing_packages)}."
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
if self.module.check_mode:
|
||||
self.changed = True
|
||||
self.message = 'Package{0} would be linked: {1}'.format(
|
||||
"s" if len(self.packages) > 1 else "",
|
||||
", ".join(self.packages)
|
||||
)
|
||||
self.message = f"Package{'s' if len(self.packages) > 1 else ''} would be linked: {', '.join(self.packages)}"
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
opts = (
|
||||
|
|
@ -751,17 +709,11 @@ class Homebrew(object):
|
|||
if rc == 0:
|
||||
self.changed_pkgs.extend(self.packages)
|
||||
self.changed = True
|
||||
self.message = 'Package{0} linked: {1}'.format(
|
||||
"s" if len(self.packages) > 1 else "",
|
||||
", ".join(self.packages)
|
||||
)
|
||||
self.message = f"Package{'s' if len(self.packages) > 1 else ''} linked: {', '.join(self.packages)}"
|
||||
return True
|
||||
else:
|
||||
self.failed = True
|
||||
self.message = 'Package{0} could not be linked: {1}.'.format(
|
||||
"s" if len(self.packages) > 1 else "",
|
||||
", ".join(self.packages)
|
||||
)
|
||||
self.message = f"Package{'s' if len(self.packages) > 1 else ''} could not be linked: {', '.join(self.packages)}."
|
||||
raise HomebrewException(self.message)
|
||||
# /linked -------------------------------- }}}
|
||||
|
||||
|
|
@ -770,18 +722,12 @@ class Homebrew(object):
|
|||
missing_packages = set(self.packages) - self.installed_packages
|
||||
if missing_packages:
|
||||
self.failed = True
|
||||
self.message = 'Package{0} not installed: {1}.'.format(
|
||||
"s" if len(missing_packages) > 1 else "",
|
||||
", ".join(missing_packages),
|
||||
)
|
||||
self.message = f"Package{'s' if len(missing_packages) > 1 else ''} not installed: {', '.join(missing_packages)}."
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
if self.module.check_mode:
|
||||
self.changed = True
|
||||
self.message = 'Package{0} would be unlinked: {1}'.format(
|
||||
"s" if len(self.packages) > 1 else "",
|
||||
", ".join(self.packages)
|
||||
)
|
||||
self.message = f"Package{'s' if len(self.packages) > 1 else ''} would be unlinked: {', '.join(self.packages)}"
|
||||
raise HomebrewException(self.message)
|
||||
|
||||
opts = (
|
||||
|
|
@ -795,17 +741,11 @@ class Homebrew(object):
|
|||
if rc == 0:
|
||||
self.changed_pkgs.extend(self.packages)
|
||||
self.changed = True
|
||||
self.message = 'Package{0} unlinked: {1}'.format(
|
||||
"s" if len(self.packages) > 1 else "",
|
||||
", ".join(self.packages)
|
||||
)
|
||||
self.message = f"Package{'s' if len(self.packages) > 1 else ''} unlinked: {', '.join(self.packages)}"
|
||||
return True
|
||||
else:
|
||||
self.failed = True
|
||||
self.message = 'Package{0} could not be unlinked: {1}.'.format(
|
||||
"s" if len(self.packages) > 1 else "",
|
||||
", ".join(self.packages)
|
||||
)
|
||||
self.message = f"Package{'s' if len(self.packages) > 1 else ''} could not be unlinked: {', '.join(self.packages)}."
|
||||
raise HomebrewException(self.message)
|
||||
# /unlinked ------------------------------ }}}
|
||||
# /commands ---------------------------------------------------- }}}
|
||||
|
|
@ -893,11 +833,11 @@ def main():
|
|||
)
|
||||
upgrade_all = p['upgrade_all']
|
||||
p['install_options'] = p['install_options'] or []
|
||||
install_options = ['--{0}'.format(install_option)
|
||||
install_options = [f'--{install_option}'
|
||||
for install_option in p['install_options']]
|
||||
|
||||
p['upgrade_options'] = p['upgrade_options'] or []
|
||||
upgrade_options = ['--{0}'.format(upgrade_option)
|
||||
upgrade_options = [f'--{upgrade_option}'
|
||||
for upgrade_option in p['upgrade_options']]
|
||||
brew = Homebrew(module=module, path=path, packages=packages,
|
||||
state=state, update_homebrew=update_homebrew,
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class HomebrewCaskException(Exception):
|
|||
def _create_regex_group_complement(s):
|
||||
lines = (line.strip() for line in s.split('\n') if line.strip())
|
||||
chars = [_f for _f in (line.split('#')[0].strip() for line in lines) if _f]
|
||||
group = r'[^' + r''.join(chars) + r']'
|
||||
group = rf"[^{''.join(chars)}]"
|
||||
return re.compile(group)
|
||||
# /utils ------------------------------------------------------------------ }}}
|
||||
|
||||
|
|
@ -240,7 +240,7 @@ class HomebrewCask(object):
|
|||
if not self.valid_module(module):
|
||||
self._module = None
|
||||
self.failed = True
|
||||
self.message = 'Invalid module: {0}.'.format(module)
|
||||
self.message = f'Invalid module: {module}.'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
else:
|
||||
|
|
@ -256,7 +256,7 @@ class HomebrewCask(object):
|
|||
if not HomebrewValidate.valid_path(path):
|
||||
self._path = []
|
||||
self.failed = True
|
||||
self.message = 'Invalid path: {0}.'.format(path)
|
||||
self.message = f'Invalid path: {path}.'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
else:
|
||||
|
|
@ -276,7 +276,7 @@ class HomebrewCask(object):
|
|||
if not HomebrewValidate.valid_brew_path(brew_path):
|
||||
self._brew_path = None
|
||||
self.failed = True
|
||||
self.message = 'Invalid brew_path: {0}.'.format(brew_path)
|
||||
self.message = f'Invalid brew_path: {brew_path}.'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
else:
|
||||
|
|
@ -301,7 +301,7 @@ class HomebrewCask(object):
|
|||
if not self.valid_cask(cask):
|
||||
self._current_cask = None
|
||||
self.failed = True
|
||||
self.message = 'Invalid cask: {0}.'.format(cask)
|
||||
self.message = f'Invalid cask: {cask}.'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
else:
|
||||
|
|
@ -384,10 +384,7 @@ class HomebrewCask(object):
|
|||
pass
|
||||
|
||||
if not self.failed and (self.changed_count + self.unchanged_count > 1):
|
||||
self.message = "Changed: %d, Unchanged: %d" % (
|
||||
self.changed_count,
|
||||
self.unchanged_count,
|
||||
)
|
||||
self.message = f"Changed: {self.changed_count}, Unchanged: {self.unchanged_count}"
|
||||
(failed, changed, message) = self._status()
|
||||
|
||||
return (failed, changed, message)
|
||||
|
|
@ -411,7 +408,7 @@ class HomebrewCask(object):
|
|||
def _current_cask_is_installed(self):
|
||||
if not self.valid_cask(self.current_cask):
|
||||
self.failed = True
|
||||
self.message = 'Invalid cask: {0}.'.format(self.current_cask)
|
||||
self.message = f'Invalid cask: {self.current_cask}.'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
if self._brew_cask_command_is_deprecated():
|
||||
|
|
@ -552,21 +549,17 @@ class HomebrewCask(object):
|
|||
def _install_current_cask(self):
|
||||
if not self.valid_cask(self.current_cask):
|
||||
self.failed = True
|
||||
self.message = 'Invalid cask: {0}.'.format(self.current_cask)
|
||||
self.message = f'Invalid cask: {self.current_cask}.'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
if '--force' not in self.install_options and self._current_cask_is_installed():
|
||||
self.unchanged_count += 1
|
||||
self.message = 'Cask already installed: {0}'.format(
|
||||
self.current_cask,
|
||||
)
|
||||
self.message = f'Cask already installed: {self.current_cask}'
|
||||
return True
|
||||
|
||||
if self.module.check_mode:
|
||||
self.changed = True
|
||||
self.message = 'Cask would be installed: {0}'.format(
|
||||
self.current_cask
|
||||
)
|
||||
self.message = f'Cask would be installed: {self.current_cask}'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
if self._brew_cask_command_is_deprecated():
|
||||
|
|
@ -588,13 +581,11 @@ class HomebrewCask(object):
|
|||
if self._current_cask_is_installed():
|
||||
self.changed_count += 1
|
||||
self.changed = True
|
||||
self.message = 'Cask installed: {0}'.format(self.current_cask)
|
||||
self.message = f'Cask installed: {self.current_cask}'
|
||||
return True
|
||||
elif self.accept_external_apps and re.search(r"Error: It seems there is already an App at", err):
|
||||
self.unchanged_count += 1
|
||||
self.message = 'Cask already installed: {0}'.format(
|
||||
self.current_cask,
|
||||
)
|
||||
self.message = f'Cask already installed: {self.current_cask}'
|
||||
return True
|
||||
else:
|
||||
self.failed = True
|
||||
|
|
@ -615,24 +606,20 @@ class HomebrewCask(object):
|
|||
|
||||
if not self.valid_cask(self.current_cask):
|
||||
self.failed = True
|
||||
self.message = 'Invalid cask: {0}.'.format(self.current_cask)
|
||||
self.message = f'Invalid cask: {self.current_cask}.'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
if not self._current_cask_is_installed():
|
||||
command = 'install'
|
||||
|
||||
if self._current_cask_is_installed() and not self._current_cask_is_outdated():
|
||||
self.message = 'Cask is already upgraded: {0}'.format(
|
||||
self.current_cask,
|
||||
)
|
||||
self.message = f'Cask is already upgraded: {self.current_cask}'
|
||||
self.unchanged_count += 1
|
||||
return True
|
||||
|
||||
if self.module.check_mode:
|
||||
self.changed = True
|
||||
self.message = 'Cask would be upgraded: {0}'.format(
|
||||
self.current_cask
|
||||
)
|
||||
self.message = f'Cask would be upgraded: {self.current_cask}'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
if self._brew_cask_command_is_deprecated():
|
||||
|
|
@ -654,7 +641,7 @@ class HomebrewCask(object):
|
|||
if self._current_cask_is_installed() and not self._current_cask_is_outdated():
|
||||
self.changed_count += 1
|
||||
self.changed = True
|
||||
self.message = 'Cask upgraded: {0}'.format(self.current_cask)
|
||||
self.message = f'Cask upgraded: {self.current_cask}'
|
||||
return True
|
||||
else:
|
||||
self.failed = True
|
||||
|
|
@ -673,21 +660,17 @@ class HomebrewCask(object):
|
|||
def _uninstall_current_cask(self):
|
||||
if not self.valid_cask(self.current_cask):
|
||||
self.failed = True
|
||||
self.message = 'Invalid cask: {0}.'.format(self.current_cask)
|
||||
self.message = f'Invalid cask: {self.current_cask}.'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
if not self._current_cask_is_installed():
|
||||
self.unchanged_count += 1
|
||||
self.message = 'Cask already uninstalled: {0}'.format(
|
||||
self.current_cask,
|
||||
)
|
||||
self.message = f'Cask already uninstalled: {self.current_cask}'
|
||||
return True
|
||||
|
||||
if self.module.check_mode:
|
||||
self.changed = True
|
||||
self.message = 'Cask would be uninstalled: {0}'.format(
|
||||
self.current_cask
|
||||
)
|
||||
self.message = f'Cask would be uninstalled: {self.current_cask}'
|
||||
raise HomebrewCaskException(self.message)
|
||||
|
||||
if self._brew_cask_command_is_deprecated():
|
||||
|
|
@ -709,7 +692,7 @@ class HomebrewCask(object):
|
|||
if not self._current_cask_is_installed():
|
||||
self.changed_count += 1
|
||||
self.changed = True
|
||||
self.message = 'Cask uninstalled: {0}'.format(self.current_cask)
|
||||
self.message = f'Cask uninstalled: {self.current_cask}'
|
||||
return True
|
||||
else:
|
||||
self.failed = True
|
||||
|
|
@ -803,7 +786,7 @@ def main():
|
|||
upgrade_all = p['upgrade_all']
|
||||
greedy = p['greedy']
|
||||
p['install_options'] = p['install_options'] or []
|
||||
install_options = ['--{0}'.format(install_option)
|
||||
install_options = [f'--{install_option}'
|
||||
for install_option in p['install_options']]
|
||||
|
||||
accept_external_apps = p['accept_external_apps']
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ def _brew_service_state(args, module):
|
|||
try:
|
||||
data = json.loads(stdout)[0]
|
||||
except json.JSONDecodeError:
|
||||
module.fail_json(msg="Failed to parse JSON output:\n{0}".format(stdout))
|
||||
module.fail_json(msg=f"Failed to parse JSON output:\n{stdout}")
|
||||
|
||||
return HomebrewServiceState(running=data["status"] == "started", pid=data["pid"])
|
||||
|
||||
|
|
@ -140,9 +140,7 @@ def _exit_with_state(args, module, changed=False, message=None):
|
|||
state = _brew_service_state(args, module)
|
||||
if message is None:
|
||||
message = (
|
||||
"Running: {state.running}, Changed: {changed}, PID: {state.pid}".format(
|
||||
state=state, changed=changed
|
||||
)
|
||||
f"Running: {state.running}, Changed: {changed}, PID: {state.pid}"
|
||||
)
|
||||
module.exit_json(msg=message, pid=state.pid, running=state.running, changed=changed)
|
||||
|
||||
|
|
@ -152,11 +150,11 @@ def validate_and_load_arguments(module):
|
|||
"""Reuse the Homebrew module's validation logic to validate these arguments."""
|
||||
package = module.params["name"] # type: ignore
|
||||
if not HomebrewValidate.valid_package(package):
|
||||
module.fail_json(msg="Invalid package name: {0}".format(package))
|
||||
module.fail_json(msg=f"Invalid package name: {package}")
|
||||
|
||||
state = module.params["state"] # type: ignore
|
||||
if state not in ["present", "absent", "restarted"]:
|
||||
module.fail_json(msg="Invalid state: {0}".format(state))
|
||||
module.fail_json(msg=f"Invalid state: {state}")
|
||||
|
||||
brew_path = parse_brew_path(module)
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ def add_tap(module, brew_path, tap, url=None):
|
|||
|
||||
if not a_valid_tap(tap):
|
||||
failed = True
|
||||
msg = 'not a valid tap: %s' % tap
|
||||
msg = f'not a valid tap: {tap}'
|
||||
|
||||
elif not already_tapped(module, brew_path, tap):
|
||||
if module.check_mode:
|
||||
|
|
@ -123,13 +123,13 @@ def add_tap(module, brew_path, tap, url=None):
|
|||
])
|
||||
if rc == 0:
|
||||
changed = True
|
||||
msg = 'successfully tapped: %s' % tap
|
||||
msg = f'successfully tapped: {tap}'
|
||||
else:
|
||||
failed = True
|
||||
msg = 'failed to tap: %s due to %s' % (tap, err)
|
||||
msg = f'failed to tap: {tap} due to {err}'
|
||||
|
||||
else:
|
||||
msg = 'already tapped: %s' % tap
|
||||
msg = f'already tapped: {tap}'
|
||||
|
||||
return (failed, changed, msg)
|
||||
|
||||
|
|
@ -148,13 +148,13 @@ def add_taps(module, brew_path, taps):
|
|||
unchanged += 1
|
||||
|
||||
if failed:
|
||||
msg = 'added: %d, unchanged: %d, error: ' + msg
|
||||
msg = f"added: %d, unchanged: %d, error: {msg}"
|
||||
msg = msg % (added, unchanged)
|
||||
elif added:
|
||||
changed = True
|
||||
msg = 'added: %d, unchanged: %d' % (added, unchanged)
|
||||
msg = f'added: {added}, unchanged: {unchanged}'
|
||||
else:
|
||||
msg = 'added: %d, unchanged: %d' % (added, unchanged)
|
||||
msg = f'added: {added}, unchanged: {unchanged}'
|
||||
|
||||
return (failed, changed, msg)
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ def remove_tap(module, brew_path, tap):
|
|||
|
||||
if not a_valid_tap(tap):
|
||||
failed = True
|
||||
msg = 'not a valid tap: %s' % tap
|
||||
msg = f'not a valid tap: {tap}'
|
||||
|
||||
elif already_tapped(module, brew_path, tap):
|
||||
if module.check_mode:
|
||||
|
|
@ -178,13 +178,13 @@ def remove_tap(module, brew_path, tap):
|
|||
])
|
||||
if not already_tapped(module, brew_path, tap):
|
||||
changed = True
|
||||
msg = 'successfully untapped: %s' % tap
|
||||
msg = f'successfully untapped: {tap}'
|
||||
else:
|
||||
failed = True
|
||||
msg = 'failed to untap: %s due to %s' % (tap, err)
|
||||
msg = f'failed to untap: {tap} due to {err}'
|
||||
|
||||
else:
|
||||
msg = 'already untapped: %s' % tap
|
||||
msg = f'already untapped: {tap}'
|
||||
|
||||
return (failed, changed, msg)
|
||||
|
||||
|
|
@ -203,13 +203,13 @@ def remove_taps(module, brew_path, taps):
|
|||
unchanged += 1
|
||||
|
||||
if failed:
|
||||
msg = 'removed: %d, unchanged: %d, error: ' + msg
|
||||
msg = f"removed: %d, unchanged: %d, error: {msg}"
|
||||
msg = msg % (removed, unchanged)
|
||||
elif removed:
|
||||
changed = True
|
||||
msg = 'removed: %d, unchanged: %d' % (removed, unchanged)
|
||||
msg = f'removed: {removed}, unchanged: {unchanged}'
|
||||
else:
|
||||
msg = 'removed: %d, unchanged: %d' % (removed, unchanged)
|
||||
msg = f'removed: {removed}, unchanged: {unchanged}'
|
||||
|
||||
return (failed, changed, msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -637,7 +637,7 @@ def main():
|
|||
module.fail_json(name=homectl.name, msg=stderr, rc=rc)
|
||||
homectl.result['changed'] = True
|
||||
homectl.result['rc'] = rc
|
||||
homectl.result['msg'] = 'User %s removed!' % homectl.name
|
||||
homectl.result['msg'] = f'User {homectl.name} removed!'
|
||||
else:
|
||||
homectl.result['changed'] = False
|
||||
homectl.result['msg'] = 'User does not exist!'
|
||||
|
|
@ -654,7 +654,7 @@ def main():
|
|||
rc, user_metadata, stderr = homectl.get_user_metadata()
|
||||
homectl.result['data'] = json.loads(user_metadata)
|
||||
homectl.result['rc'] = rc
|
||||
homectl.result['msg'] = 'User %s created!' % homectl.name
|
||||
homectl.result['msg'] = f'User {homectl.name} created!'
|
||||
else:
|
||||
if valid_pwhash:
|
||||
# Run this to see if changed would be True or False which is useful for check_mode
|
||||
|
|
@ -677,7 +677,7 @@ def main():
|
|||
homectl.result['data'] = json.loads(user_metadata)
|
||||
homectl.result['rc'] = rc
|
||||
if homectl.result['changed']:
|
||||
homectl.result['msg'] = 'User %s modified' % homectl.name
|
||||
homectl.result['msg'] = f'User {homectl.name} modified'
|
||||
|
||||
module.exit_json(**homectl.result)
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ import traceback
|
|||
from urllib.parse import urlencode
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
|
||||
|
||||
|
|
@ -120,12 +119,12 @@ def main():
|
|||
data = urlencode(params)
|
||||
response, info = fetch_url(module, url, data=data)
|
||||
except Exception as e:
|
||||
module.fail_json(msg='Unable to notify Honeybadger: %s' % to_native(e), exception=traceback.format_exc())
|
||||
module.fail_json(msg=f'Unable to notify Honeybadger: {e}', exception=traceback.format_exc())
|
||||
else:
|
||||
if info['status'] == 201:
|
||||
module.exit_json(changed=True)
|
||||
else:
|
||||
module.fail_json(msg="HTTP result code: %d connecting to %s" % (info['status'], url))
|
||||
module.fail_json(msg=f"HTTP result code: {info['status']} connecting to {url}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ def main():
|
|||
state = module.params['state']
|
||||
force = module.params['force']
|
||||
idempotent_boot_once = module.params['idempotent_boot_once']
|
||||
ssl_version = getattr(hpilo.ssl, 'PROTOCOL_' + module.params.get('ssl_version').upper().replace('V', 'v'))
|
||||
ssl_version = getattr(hpilo.ssl, f"PROTOCOL_{module.params.get('ssl_version').upper().replace('V', 'v')}")
|
||||
|
||||
ilo = hpilo.Ilo(host, login=login, password=password, ssl_version=ssl_version)
|
||||
changed = False
|
||||
|
|
@ -201,7 +201,7 @@ def main():
|
|||
# version='11.0.0',
|
||||
# collection_name='community.general'
|
||||
# )
|
||||
module.fail_json(msg='HP iLO (%s) reports that the server is already powered on !' % host)
|
||||
module.fail_json(msg=f'HP iLO ({host}) reports that the server is already powered on !')
|
||||
elif not force and idempotent_boot_once:
|
||||
pass
|
||||
elif force:
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ warnings.simplefilter('ignore')
|
|||
|
||||
def parse_flat_interface(entry, non_numeric='hw_eth_ilo'):
|
||||
try:
|
||||
infoname = 'hw_eth' + str(int(entry['Port']) - 1)
|
||||
infoname = f"hw_eth{int(entry['Port']) - 1}"
|
||||
except Exception:
|
||||
infoname = non_numeric
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ def main():
|
|||
host = module.params['host']
|
||||
login = module.params['login']
|
||||
password = module.params['password']
|
||||
ssl_version = getattr(hpilo.ssl, 'PROTOCOL_' + module.params.get('ssl_version').upper().replace('V', 'v'))
|
||||
ssl_version = getattr(hpilo.ssl, f"PROTOCOL_{module.params.get('ssl_version').upper().replace('V', 'v')}")
|
||||
|
||||
ilo = hpilo.Ilo(host, login=login, password=password, ssl_version=ssl_version)
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ def main():
|
|||
for (name, value) in [(e['name'], e['value']) for e in entry['fields']]:
|
||||
if name.startswith('Port'):
|
||||
try:
|
||||
infoname = 'hw_eth' + str(int(value) - 1)
|
||||
infoname = f"hw_eth{int(value) - 1}"
|
||||
except Exception:
|
||||
infoname = 'hw_eth_ilo'
|
||||
elif name.startswith('MAC'):
|
||||
|
|
@ -223,7 +223,7 @@ def main():
|
|||
for (name, value) in [(e['name'], e['value']) for e in entry['fields']]:
|
||||
if name.startswith('Port'):
|
||||
try:
|
||||
infoname = 'hw_iscsi' + str(int(value) - 1)
|
||||
infoname = f"hw_iscsi{int(value) - 1}"
|
||||
except Exception:
|
||||
infoname = 'hw_iscsi_ilo'
|
||||
elif name.startswith('MAC'):
|
||||
|
|
@ -253,7 +253,7 @@ def main():
|
|||
info['hw_memory_total'] = info['hw_memory_total'] + int(ram.group(1))
|
||||
|
||||
# reformat into a text friendly format
|
||||
info['hw_memory_total'] = "{0} GB".format(info['hw_memory_total'])
|
||||
info['hw_memory_total'] = f"{info['hw_memory_total']} GB"
|
||||
|
||||
# Report host state
|
||||
info['host_power_status'] = power_state or 'UNKNOWN'
|
||||
|
|
|
|||
|
|
@ -135,26 +135,26 @@ def present(dest, username, password, hash_scheme, create, check_mode):
|
|||
context = CryptContext(schemes=[hash_scheme] + apache_hashes)
|
||||
if not os.path.exists(dest):
|
||||
if not create:
|
||||
raise ValueError('Destination %s does not exist' % dest)
|
||||
raise ValueError(f'Destination {dest} does not exist')
|
||||
if check_mode:
|
||||
return ("Create %s" % dest, True)
|
||||
return (f"Create {dest}", True)
|
||||
create_missing_directories(dest)
|
||||
ht = HtpasswdFile(dest, new=True, default_scheme=hash_scheme, context=context)
|
||||
ht.set_password(username, password)
|
||||
ht.save()
|
||||
return ("Created %s and added %s" % (dest, username), True)
|
||||
return (f"Created {dest} and added {username}", True)
|
||||
else:
|
||||
ht = HtpasswdFile(dest, new=False, default_scheme=hash_scheme, context=context)
|
||||
|
||||
found = ht.check_password(username, password)
|
||||
|
||||
if found:
|
||||
return ("%s already present" % username, False)
|
||||
return (f"{username} already present", False)
|
||||
else:
|
||||
if not check_mode:
|
||||
ht.set_password(username, password)
|
||||
ht.save()
|
||||
return ("Add/update %s" % username, True)
|
||||
return (f"Add/update {username}", True)
|
||||
|
||||
|
||||
def absent(dest, username, check_mode):
|
||||
|
|
@ -164,12 +164,12 @@ def absent(dest, username, check_mode):
|
|||
ht = HtpasswdFile(dest, new=False)
|
||||
|
||||
if username not in ht.users():
|
||||
return ("%s not present" % username, False)
|
||||
return (f"{username} not present", False)
|
||||
else:
|
||||
if not check_mode:
|
||||
ht.delete(username)
|
||||
ht.save()
|
||||
return ("Remove %s" % username, True)
|
||||
return (f"Remove {username}", True)
|
||||
|
||||
|
||||
def check_file_attrs(module, changed, message):
|
||||
|
|
@ -239,11 +239,11 @@ def main():
|
|||
(msg, changed) = present(path, username, password, hash_scheme, create, check_mode)
|
||||
elif state == 'absent':
|
||||
if not os.path.exists(path):
|
||||
module.warn("%s does not exist" % path)
|
||||
module.exit_json(msg="%s not present" % username, changed=False)
|
||||
module.warn(f"{path} does not exist")
|
||||
module.exit_json(msg=f"{username} not present", changed=False)
|
||||
(msg, changed) = absent(path, username, check_mode)
|
||||
else:
|
||||
module.fail_json(msg="Invalid state: %s" % state)
|
||||
module.fail_json(msg=f"Invalid state: {state}")
|
||||
return # needed to make pylint happy
|
||||
|
||||
(msg, changed) = check_file_attrs(module, changed, msg)
|
||||
|
|
|
|||
|
|
@ -582,10 +582,7 @@ def _init(config):
|
|||
v = search_resource(config)
|
||||
n = len(v)
|
||||
if n > 1:
|
||||
raise Exception("Found more than one resource(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"])
|
||||
for i in v
|
||||
]))
|
||||
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if n == 1:
|
||||
module.params['id'] = navigate_value(v[0], ["id"])
|
||||
|
|
@ -750,16 +747,16 @@ def _build_query_link(opts):
|
|||
v = navigate_value(opts, ["enterprise_project_id"])
|
||||
if v or v in [False, 0]:
|
||||
query_params.append(
|
||||
"enterprise_project_id=" + (str(v) if v else str(v).lower()))
|
||||
f"enterprise_project_id={str(v) if v else str(v).lower()}")
|
||||
|
||||
v = navigate_value(opts, ["name"])
|
||||
if v or v in [False, 0]:
|
||||
query_params.append(
|
||||
"name=" + (str(v) if v else str(v).lower()))
|
||||
f"name={str(v) if v else str(v).lower()}")
|
||||
|
||||
query_link = "?limit=10&offset={offset}"
|
||||
if query_params:
|
||||
query_link += "&" + "&".join(query_params)
|
||||
query_link += f"&{'&'.join(query_params)}"
|
||||
|
||||
return query_link
|
||||
|
||||
|
|
@ -770,7 +767,7 @@ def search_resource(config):
|
|||
opts = user_input_parameters(module)
|
||||
identity_obj = _build_identity_object(opts)
|
||||
query_link = _build_query_link(opts)
|
||||
link = "cloudservers/detail" + query_link
|
||||
link = f"cloudservers/detail{query_link}"
|
||||
|
||||
result = []
|
||||
p = {'offset': 1}
|
||||
|
|
@ -836,8 +833,7 @@ def send_delete_nics_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(delete_nics), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(delete_nics), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -864,8 +860,7 @@ def send_set_auto_recovery_request(module, params, client):
|
|||
try:
|
||||
r = client.put(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(set_auto_recovery), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(set_auto_recovery), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -1052,8 +1047,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -1105,8 +1099,7 @@ def send_attach_nics_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(attach_nics), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(attach_nics), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -1123,8 +1116,7 @@ def send_delete_volume_request(module, params, client, info):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(delete_volume), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(delete_volume), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -1160,8 +1152,7 @@ def send_attach_data_disk_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(attach_data_disk), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(attach_data_disk), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -1211,8 +1202,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -1242,8 +1232,7 @@ def async_wait(config, result, client, timeout):
|
|||
["RUNNING", "INIT"],
|
||||
_query_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_ecs_instance): error "
|
||||
"waiting to be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_ecs_instance): error waiting to be done, error= {ex}")
|
||||
|
||||
|
||||
def multi_invoke_delete_volume(config, opts, client, timeout):
|
||||
|
|
@ -1300,8 +1289,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["server"], None)
|
||||
|
|
@ -1457,8 +1445,7 @@ def send_read_auto_recovery_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(read_auto_recovery), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(read_auto_recovery), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -1878,8 +1865,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_ecs_instance): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_ecs_instance): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["servers"], None)
|
||||
|
|
@ -1978,7 +1964,7 @@ def expand_list_tags(d, array_index):
|
|||
if not v:
|
||||
return None
|
||||
|
||||
return [k + "=" + v1 for k, v1 in v.items()]
|
||||
return [f"{k}={v1}" for k, v1 in v.items()]
|
||||
|
||||
|
||||
def fill_list_resp_body(body):
|
||||
|
|
|
|||
|
|
@ -387,10 +387,7 @@ def _init(config):
|
|||
v = search_resource(config)
|
||||
n = len(v)
|
||||
if n > 1:
|
||||
raise Exception("find more than one resources(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"])
|
||||
for i in v
|
||||
]))
|
||||
raise Exception(f"find more than one resources({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if n == 1:
|
||||
module.params['id'] = navigate_value(v[0], ["id"])
|
||||
|
|
@ -489,21 +486,21 @@ def _build_query_link(opts):
|
|||
v = navigate_value(opts, ["enable_share"])
|
||||
if v or v in [False, 0]:
|
||||
query_params.append(
|
||||
"multiattach=" + (str(v) if v else str(v).lower()))
|
||||
f"multiattach={str(v) if v else str(v).lower()}")
|
||||
|
||||
v = navigate_value(opts, ["name"])
|
||||
if v or v in [False, 0]:
|
||||
query_params.append(
|
||||
"name=" + (str(v) if v else str(v).lower()))
|
||||
f"name={str(v) if v else str(v).lower()}")
|
||||
|
||||
v = navigate_value(opts, ["availability_zone"])
|
||||
if v or v in [False, 0]:
|
||||
query_params.append(
|
||||
"availability_zone=" + (str(v) if v else str(v).lower()))
|
||||
f"availability_zone={str(v) if v else str(v).lower()}")
|
||||
|
||||
query_link = "?limit=10&offset={start}"
|
||||
if query_params:
|
||||
query_link += "&" + "&".join(query_params)
|
||||
query_link += f"&{'&'.join(query_params)}"
|
||||
|
||||
return query_link
|
||||
|
||||
|
|
@ -514,7 +511,7 @@ def search_resource(config):
|
|||
opts = user_input_parameters(module)
|
||||
name = module.params.get("name")
|
||||
query_link = _build_query_link(opts)
|
||||
link = "os-vendor-volumes/detail" + query_link
|
||||
link = f"os-vendor-volumes/detail{query_link}"
|
||||
|
||||
result = []
|
||||
p = {'start': 0}
|
||||
|
|
@ -635,8 +632,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_evs_disk): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_evs_disk): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -667,8 +663,7 @@ def send_update_request(module, params, client):
|
|||
try:
|
||||
r = client.put(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_evs_disk): error running "
|
||||
"api(update), error: %s" % str(ex))
|
||||
msg = f"module(hwc_evs_disk): error running api(update), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -680,8 +675,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_evs_disk): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_evs_disk): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -713,8 +707,7 @@ def send_extend_disk_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_evs_disk): error running "
|
||||
"api(extend_disk), error: %s" % str(ex))
|
||||
msg = f"module(hwc_evs_disk): error running api(extend_disk), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -749,8 +742,7 @@ def async_wait(config, result, client, timeout):
|
|||
["RUNNING", "INIT"],
|
||||
_query_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_evs_disk): error "
|
||||
"waiting to be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_evs_disk): error waiting to be done, error= {ex}")
|
||||
|
||||
|
||||
def send_read_request(module, client):
|
||||
|
|
@ -760,8 +752,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_evs_disk): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_evs_disk): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["volume"], None)
|
||||
|
|
@ -1028,8 +1019,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_evs_disk): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_evs_disk): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["volumes"], None)
|
||||
|
|
|
|||
|
|
@ -214,8 +214,7 @@ def create(config, link):
|
|||
try:
|
||||
r = client.post(link, resource_to_create(module))
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_network_vpc): error creating "
|
||||
"resource, error: %s" % str(ex))
|
||||
msg = f"module(hwc_network_vpc): error creating resource, error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
wait_done = wait_for_operation(config, 'create', r)
|
||||
|
|
@ -237,8 +236,7 @@ def update(config, link):
|
|||
try:
|
||||
r = client.put(link, resource_to_update(module))
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_network_vpc): error updating "
|
||||
"resource, error: %s" % str(ex))
|
||||
msg = f"module(hwc_network_vpc): error updating resource, error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
wait_for_operation(config, 'update', r)
|
||||
|
|
@ -253,8 +251,7 @@ def delete(config, link):
|
|||
try:
|
||||
client.delete(link)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_network_vpc): error deleting "
|
||||
"resource, error: %s" % str(ex))
|
||||
msg = f"module(hwc_network_vpc): error deleting resource, error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
wait_for_delete(module, client, link)
|
||||
|
|
@ -264,8 +261,7 @@ def fetch_resource(module, client, link):
|
|||
try:
|
||||
return client.get(link)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_network_vpc): error fetching "
|
||||
"resource, error: %s" % str(ex))
|
||||
msg = f"module(hwc_network_vpc): error fetching resource, error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -180,8 +180,7 @@ def create(config):
|
|||
try:
|
||||
r = client.post(link, create_resource_opts(module))
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_smn_topic): error creating "
|
||||
"resource, error: %s" % str(ex))
|
||||
msg = f"module(hwc_smn_topic): error creating resource, error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return get_resource(config, r)
|
||||
|
|
@ -195,8 +194,7 @@ def update(config):
|
|||
try:
|
||||
client.put(link, update_resource_opts(module))
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_smn_topic): error updating "
|
||||
"resource, error: %s" % str(ex))
|
||||
msg = f"module(hwc_smn_topic): error updating resource, error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return fetch_resource(module, client, link)
|
||||
|
|
@ -210,8 +208,7 @@ def delete(config):
|
|||
try:
|
||||
client.delete(link)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_smn_topic): error deleting "
|
||||
"resource, error: %s" % str(ex))
|
||||
msg = f"module(hwc_smn_topic): error deleting resource, error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
|
||||
|
|
@ -219,8 +216,7 @@ def fetch_resource(module, client, link):
|
|||
try:
|
||||
return client.get(link)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_smn_topic): error fetching "
|
||||
"resource, error: %s" % str(ex))
|
||||
msg = f"module(hwc_smn_topic): error fetching resource, error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -271,8 +271,7 @@ def main():
|
|||
else:
|
||||
v = search_resource(config)
|
||||
if len(v) > 1:
|
||||
raise Exception("Found more than one resource(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"]) for i in v]))
|
||||
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if len(v) == 1:
|
||||
resource = v[0]
|
||||
|
|
@ -372,9 +371,7 @@ def delete(config):
|
|||
try:
|
||||
wait_to_finish(["Done"], ["Pending"], _refresh_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_eip): error "
|
||||
"waiting for api(delete) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_eip): error waiting for api(delete) to be done, error= {ex}")
|
||||
|
||||
|
||||
def read_resource(config, exclude_output=False):
|
||||
|
|
@ -394,15 +391,15 @@ def _build_query_link(opts):
|
|||
|
||||
v = navigate_value(opts, ["ip_version"])
|
||||
if v:
|
||||
query_params.append("ip_version=" + str(v))
|
||||
query_params.append(f"ip_version={v}")
|
||||
|
||||
v = navigate_value(opts, ["enterprise_project_id"])
|
||||
if v:
|
||||
query_params.append("enterprise_project_id=" + str(v))
|
||||
query_params.append(f"enterprise_project_id={v}")
|
||||
|
||||
query_link = "?marker={marker}&limit=10"
|
||||
if query_params:
|
||||
query_link += "&" + "&".join(query_params)
|
||||
query_link += f"&{'&'.join(query_params)}"
|
||||
|
||||
return query_link
|
||||
|
||||
|
|
@ -413,7 +410,7 @@ def search_resource(config):
|
|||
opts = user_input_parameters(module)
|
||||
identity_obj = _build_identity_object(opts)
|
||||
query_link = _build_query_link(opts)
|
||||
link = "publicips" + query_link
|
||||
link = f"publicips{query_link}"
|
||||
|
||||
result = []
|
||||
p = {'marker': ''}
|
||||
|
|
@ -500,8 +497,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_eip): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_eip): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -536,9 +532,7 @@ def async_wait_create(config, result, client, timeout):
|
|||
None,
|
||||
_query_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_eip): error "
|
||||
"waiting for api(create) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_eip): error waiting for api(create) to be done, error= {ex}")
|
||||
|
||||
|
||||
def build_update_parameters(opts):
|
||||
|
|
@ -566,8 +560,7 @@ def send_update_request(module, params, client):
|
|||
try:
|
||||
r = client.put(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_eip): error running "
|
||||
"api(update), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_eip): error running api(update), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -597,9 +590,7 @@ def async_wait_update(config, result, client, timeout):
|
|||
None,
|
||||
_query_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_eip): error "
|
||||
"waiting for api(update) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_eip): error waiting for api(update) to be done, error= {ex}")
|
||||
|
||||
|
||||
def send_delete_request(module, params, client):
|
||||
|
|
@ -608,8 +599,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_eip): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_eip): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -622,8 +612,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_eip): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_eip): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["publicip"], None)
|
||||
|
|
@ -748,8 +737,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_eip): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_eip): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["publicips"], None)
|
||||
|
|
|
|||
|
|
@ -172,8 +172,7 @@ def main():
|
|||
else:
|
||||
v = search_resource(config)
|
||||
if len(v) > 1:
|
||||
raise Exception("Found more than one resource(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"]) for i in v]))
|
||||
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if len(v) == 1:
|
||||
resource = v[0]
|
||||
|
|
@ -264,9 +263,7 @@ def delete(config):
|
|||
try:
|
||||
wait_to_finish(["Done"], ["Pending"], _refresh_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_peering_connect): error "
|
||||
"waiting for api(delete) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_peering_connect): error waiting for api(delete) to be done, error= {ex}")
|
||||
|
||||
|
||||
def read_resource(config, exclude_output=False):
|
||||
|
|
@ -286,15 +283,15 @@ def _build_query_link(opts):
|
|||
|
||||
v = navigate_value(opts, ["local_vpc_id"])
|
||||
if v:
|
||||
query_params.append("vpc_id=" + str(v))
|
||||
query_params.append(f"vpc_id={v}")
|
||||
|
||||
v = navigate_value(opts, ["name"])
|
||||
if v:
|
||||
query_params.append("name=" + str(v))
|
||||
query_params.append(f"name={v}")
|
||||
|
||||
query_link = "?marker={marker}&limit=10"
|
||||
if query_params:
|
||||
query_link += "&" + "&".join(query_params)
|
||||
query_link += f"&{'&'.join(query_params)}"
|
||||
|
||||
return query_link
|
||||
|
||||
|
|
@ -305,7 +302,7 @@ def search_resource(config):
|
|||
opts = user_input_parameters(module)
|
||||
identity_obj = _build_identity_object(opts)
|
||||
query_link = _build_query_link(opts)
|
||||
link = "v2.0/vpc/peerings" + query_link
|
||||
link = f"v2.0/vpc/peerings{query_link}"
|
||||
|
||||
result = []
|
||||
p = {'marker': ''}
|
||||
|
|
@ -386,8 +383,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_peering_connect): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_peering_connect): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -422,9 +418,7 @@ def async_wait_create(config, result, client, timeout):
|
|||
["PENDING_ACCEPTANCE"],
|
||||
_query_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_peering_connect): error "
|
||||
"waiting for api(create) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_peering_connect): error waiting for api(create) to be done, error= {ex}")
|
||||
|
||||
|
||||
def build_update_parameters(opts):
|
||||
|
|
@ -452,8 +446,7 @@ def send_update_request(module, params, client):
|
|||
try:
|
||||
r = client.put(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_peering_connect): error running "
|
||||
"api(update), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_peering_connect): error running api(update), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -465,8 +458,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_peering_connect): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_peering_connect): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -479,8 +471,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_peering_connect): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_peering_connect): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["peering"], None)
|
||||
|
|
@ -581,8 +572,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_peering_connect): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_peering_connect): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["peerings"], None)
|
||||
|
|
|
|||
|
|
@ -243,8 +243,7 @@ def main():
|
|||
else:
|
||||
v = search_resource(config)
|
||||
if len(v) > 1:
|
||||
raise Exception("Found more than one resource(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"]) for i in v]))
|
||||
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if len(v) == 1:
|
||||
resource = v[0]
|
||||
|
|
@ -338,9 +337,7 @@ def delete(config):
|
|||
try:
|
||||
wait_to_finish(["Done"], ["Pending"], _refresh_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_port): error "
|
||||
"waiting for api(delete) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_port): error waiting for api(delete) to be done, error= {ex}")
|
||||
|
||||
|
||||
def read_resource(config, exclude_output=False):
|
||||
|
|
@ -364,19 +361,19 @@ def _build_query_link(opts):
|
|||
|
||||
v = navigate_value(opts, ["subnet_id"])
|
||||
if v:
|
||||
query_params.append("network_id=" + str(v))
|
||||
query_params.append(f"network_id={v}")
|
||||
|
||||
v = navigate_value(opts, ["name"])
|
||||
if v:
|
||||
query_params.append("name=" + str(v))
|
||||
query_params.append(f"name={v}")
|
||||
|
||||
v = navigate_value(opts, ["admin_state_up"])
|
||||
if v:
|
||||
query_params.append("admin_state_up=" + str(v))
|
||||
query_params.append(f"admin_state_up={v}")
|
||||
|
||||
query_link = "?marker={marker}&limit=10"
|
||||
if query_params:
|
||||
query_link += "&" + "&".join(query_params)
|
||||
query_link += f"&{'&'.join(query_params)}"
|
||||
|
||||
return query_link
|
||||
|
||||
|
|
@ -387,7 +384,7 @@ def search_resource(config):
|
|||
opts = user_input_parameters(module)
|
||||
identity_obj = _build_identity_object(opts)
|
||||
query_link = _build_query_link(opts)
|
||||
link = "ports" + query_link
|
||||
link = f"ports{query_link}"
|
||||
|
||||
result = []
|
||||
p = {'marker': ''}
|
||||
|
|
@ -537,8 +534,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_port): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_port): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -573,9 +569,7 @@ def async_wait_create(config, result, client, timeout):
|
|||
["BUILD"],
|
||||
_query_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_port): error "
|
||||
"waiting for api(create) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_port): error waiting for api(create) to be done, error= {ex}")
|
||||
|
||||
|
||||
def build_update_parameters(opts):
|
||||
|
|
@ -673,8 +667,7 @@ def send_update_request(module, params, client):
|
|||
try:
|
||||
r = client.put(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_port): error running "
|
||||
"api(update), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_port): error running api(update), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -686,8 +679,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_port): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_port): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -700,8 +692,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_port): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_port): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["port"], None)
|
||||
|
|
@ -928,8 +919,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_port): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_port): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["ports"], None)
|
||||
|
|
|
|||
|
|
@ -118,8 +118,7 @@ def main():
|
|||
else:
|
||||
v = search_resource(config)
|
||||
if len(v) > 1:
|
||||
raise Exception("Found more than one resource(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"]) for i in v]))
|
||||
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if len(v) == 1:
|
||||
resource = v[0]
|
||||
|
|
@ -137,8 +136,7 @@ def main():
|
|||
expect = user_input_parameters(module)
|
||||
if are_different_dicts(expect, current):
|
||||
raise Exception(
|
||||
"Cannot change option from (%s) to (%s)of an"
|
||||
" existing resource.(%s)" % (current, expect, module.params.get('id')))
|
||||
f"Cannot change option from ({current}) to ({expect})of an existing resource.({module.params.get('id')})")
|
||||
|
||||
result = read_resource(config)
|
||||
result['id'] = module.params.get('id')
|
||||
|
|
@ -252,8 +250,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_private_ip): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_private_ip): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -265,8 +262,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_private_ip): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_private_ip): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -279,8 +275,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_private_ip): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_private_ip): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["privateip"], None)
|
||||
|
|
@ -316,8 +311,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_private_ip): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_private_ip): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["privateips"], None)
|
||||
|
|
|
|||
|
|
@ -152,15 +152,11 @@ def main():
|
|||
opts = user_input_parameters(module)
|
||||
if are_different_dicts(resource, opts):
|
||||
raise Exception(
|
||||
"Cannot change option from (%s) to (%s) for an"
|
||||
" existing route.(%s)" % (resource, opts,
|
||||
config.module.params.get(
|
||||
'id')))
|
||||
f"Cannot change option from ({resource}) to ({opts}) for an existing route.({config.module.params['id']})")
|
||||
else:
|
||||
v = search_resource(config)
|
||||
if len(v) > 1:
|
||||
raise Exception("Found more than one resource(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"]) for i in v]))
|
||||
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if len(v) == 1:
|
||||
resource = update_properties(module, {"read": v[0]}, None)
|
||||
|
|
@ -237,19 +233,19 @@ def _build_query_link(opts):
|
|||
|
||||
v = navigate_value(opts, ["type"])
|
||||
if v:
|
||||
query_params.append("type=" + str(v))
|
||||
query_params.append(f"type={v}")
|
||||
|
||||
v = navigate_value(opts, ["destination"])
|
||||
if v:
|
||||
query_params.append("destination=" + str(v))
|
||||
query_params.append(f"destination={v}")
|
||||
|
||||
v = navigate_value(opts, ["vpc_id"])
|
||||
if v:
|
||||
query_params.append("vpc_id=" + str(v))
|
||||
query_params.append(f"vpc_id={v}")
|
||||
|
||||
query_link = "?marker={marker}&limit=10"
|
||||
if query_params:
|
||||
query_link += "&" + "&".join(query_params)
|
||||
query_link += f"&{'&'.join(query_params)}"
|
||||
|
||||
return query_link
|
||||
|
||||
|
|
@ -260,7 +256,7 @@ def search_resource(config):
|
|||
opts = user_input_parameters(module)
|
||||
identity_obj = _build_identity_object(opts)
|
||||
query_link = _build_query_link(opts)
|
||||
link = "v2.0/vpc/routes" + query_link
|
||||
link = f"v2.0/vpc/routes{query_link}"
|
||||
|
||||
result = []
|
||||
p = {'marker': ''}
|
||||
|
|
@ -315,8 +311,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_route): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_route): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -328,8 +323,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_route): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_route): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -342,8 +336,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_route): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_route): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["route"], None)
|
||||
|
|
@ -392,8 +385,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_route): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_route): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["routes"], None)
|
||||
|
|
|
|||
|
|
@ -179,8 +179,7 @@ def main():
|
|||
else:
|
||||
v = search_resource(config)
|
||||
if len(v) > 1:
|
||||
raise Exception("Found more than one resource(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"]) for i in v]))
|
||||
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if len(v) == 1:
|
||||
resource = update_properties(module, {"read": v[0]}, None)
|
||||
|
|
@ -230,9 +229,7 @@ def check_resource_option(resource, module):
|
|||
|
||||
if are_different_dicts(resource, opts):
|
||||
raise Exception(
|
||||
"Cannot change option from (%s) to (%s) for an"
|
||||
" existing security group(%s)." % (resource, opts,
|
||||
module.params.get('id')))
|
||||
f"Cannot change option from ({resource}) to ({opts}) for an existing security group({module.params['id']}).")
|
||||
|
||||
|
||||
def create(config):
|
||||
|
|
@ -272,15 +269,15 @@ def _build_query_link(opts):
|
|||
|
||||
v = navigate_value(opts, ["enterprise_project_id"])
|
||||
if v:
|
||||
query_params.append("enterprise_project_id=" + str(v))
|
||||
query_params.append(f"enterprise_project_id={v}")
|
||||
|
||||
v = navigate_value(opts, ["vpc_id"])
|
||||
if v:
|
||||
query_params.append("vpc_id=" + str(v))
|
||||
query_params.append(f"vpc_id={v}")
|
||||
|
||||
query_link = "?marker={marker}&limit=10"
|
||||
if query_params:
|
||||
query_link += "&" + "&".join(query_params)
|
||||
query_link += f"&{'&'.join(query_params)}"
|
||||
|
||||
return query_link
|
||||
|
||||
|
|
@ -291,7 +288,7 @@ def search_resource(config):
|
|||
opts = user_input_parameters(module)
|
||||
identity_obj = _build_identity_object(opts)
|
||||
query_link = _build_query_link(opts)
|
||||
link = "security-groups" + query_link
|
||||
link = f"security-groups{query_link}"
|
||||
|
||||
result = []
|
||||
p = {'marker': ''}
|
||||
|
|
@ -342,8 +339,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_security_group): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_security_group): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -355,8 +351,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_security_group): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_security_group): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -369,8 +364,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_security_group): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_security_group): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["security_group"], None)
|
||||
|
|
@ -545,8 +539,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_security_group): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_security_group): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["security_groups"], None)
|
||||
|
|
|
|||
|
|
@ -202,8 +202,7 @@ def main():
|
|||
else:
|
||||
v = search_resource(config)
|
||||
if len(v) > 1:
|
||||
raise Exception("Found more than one resource(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"]) for i in v]))
|
||||
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if len(v) == 1:
|
||||
resource = v[0]
|
||||
|
|
@ -221,8 +220,7 @@ def main():
|
|||
expect = user_input_parameters(module)
|
||||
if are_different_dicts(expect, current):
|
||||
raise Exception(
|
||||
"Cannot change option from (%s) to (%s) for an"
|
||||
" existing security group(%s)." % (current, expect, module.params.get('id')))
|
||||
f"Cannot change option from ({current}) to ({expect}) for an existing security group({module.params.get('id')}).")
|
||||
result = read_resource(config)
|
||||
result['id'] = module.params.get('id')
|
||||
else:
|
||||
|
|
@ -286,7 +284,7 @@ def _build_query_link(opts):
|
|||
query_link = "?marker={marker}&limit=10"
|
||||
v = navigate_value(opts, ["security_group_id"])
|
||||
if v:
|
||||
query_link += "&security_group_id=" + str(v)
|
||||
query_link += f"&security_group_id={v}"
|
||||
|
||||
return query_link
|
||||
|
||||
|
|
@ -297,7 +295,7 @@ def search_resource(config):
|
|||
opts = user_input_parameters(module)
|
||||
identity_obj = _build_identity_object(opts)
|
||||
query_link = _build_query_link(opts)
|
||||
link = "security-group-rules" + query_link
|
||||
link = f"security-group-rules{query_link}"
|
||||
|
||||
result = []
|
||||
p = {'marker': ''}
|
||||
|
|
@ -372,8 +370,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_security_group_rule): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_security_group_rule): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -385,8 +382,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_security_group_rule): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_security_group_rule): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -399,8 +395,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_security_group_rule): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_security_group_rule): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["security_group_rule"], None)
|
||||
|
|
@ -473,8 +468,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_security_group_rule): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_security_group_rule): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["security_group_rules"], None)
|
||||
|
|
|
|||
|
|
@ -191,8 +191,7 @@ def main():
|
|||
else:
|
||||
v = search_resource(config)
|
||||
if len(v) > 1:
|
||||
raise Exception("Found more than one resource(%s)" % ", ".join([
|
||||
navigate_value(i, ["id"]) for i in v]))
|
||||
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
|
||||
|
||||
if len(v) == 1:
|
||||
resource = v[0]
|
||||
|
|
@ -288,9 +287,7 @@ def delete(config):
|
|||
try:
|
||||
wait_to_finish(["Done"], ["Pending"], _refresh_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_subnet): error "
|
||||
"waiting for api(delete) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_subnet): error waiting for api(delete) to be done, error= {ex}")
|
||||
|
||||
|
||||
def read_resource(config, exclude_output=False):
|
||||
|
|
@ -309,7 +306,7 @@ def _build_query_link(opts):
|
|||
query_link = "?marker={marker}&limit=10"
|
||||
v = navigate_value(opts, ["vpc_id"])
|
||||
if v:
|
||||
query_link += "&vpc_id=" + str(v)
|
||||
query_link += f"&vpc_id={v}"
|
||||
|
||||
return query_link
|
||||
|
||||
|
|
@ -320,7 +317,7 @@ def search_resource(config):
|
|||
opts = user_input_parameters(module)
|
||||
identity_obj = _build_identity_object(opts)
|
||||
query_link = _build_query_link(opts)
|
||||
link = "subnets" + query_link
|
||||
link = f"subnets{query_link}"
|
||||
|
||||
result = []
|
||||
p = {'marker': ''}
|
||||
|
|
@ -410,8 +407,7 @@ def send_create_request(module, params, client):
|
|||
try:
|
||||
r = client.post(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_subnet): error running "
|
||||
"api(create), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_subnet): error running api(create), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -446,9 +442,7 @@ def async_wait_create(config, result, client, timeout):
|
|||
["UNKNOWN"],
|
||||
_query_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_subnet): error "
|
||||
"waiting for api(create) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_subnet): error waiting for api(create) to be done, error= {ex}")
|
||||
|
||||
|
||||
def build_update_parameters(opts):
|
||||
|
|
@ -507,8 +501,7 @@ def send_update_request(module, params, client):
|
|||
try:
|
||||
r = client.put(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_subnet): error running "
|
||||
"api(update), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_subnet): error running api(update), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -543,9 +536,7 @@ def async_wait_update(config, result, client, timeout):
|
|||
["UNKNOWN"],
|
||||
_query_status, timeout)
|
||||
except Exception as ex:
|
||||
module.fail_json(msg="module(hwc_vpc_subnet): error "
|
||||
"waiting for api(update) to "
|
||||
"be done, error= %s" % str(ex))
|
||||
module.fail_json(msg=f"module(hwc_vpc_subnet): error waiting for api(update) to be done, error= {ex}")
|
||||
|
||||
|
||||
def send_delete_request(module, params, client):
|
||||
|
|
@ -554,8 +545,7 @@ def send_delete_request(module, params, client):
|
|||
try:
|
||||
r = client.delete(url, params)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_subnet): error running "
|
||||
"api(delete), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_subnet): error running api(delete), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return r
|
||||
|
|
@ -568,8 +558,7 @@ def send_read_request(module, client):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_subnet): error running "
|
||||
"api(read), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_subnet): error running api(read), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["subnet"], None)
|
||||
|
|
@ -640,8 +629,7 @@ def send_list_request(module, client, url):
|
|||
try:
|
||||
r = client.get(url)
|
||||
except HwcClientException as ex:
|
||||
msg = ("module(hwc_vpc_subnet): error running "
|
||||
"api(list), error: %s" % str(ex))
|
||||
msg = f"module(hwc_vpc_subnet): error running api(list), error: {ex}"
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
return navigate_value(r, ["subnets"], None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue