mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-24 13:04:00 -07:00
[PR #9323/1d8f0b29 backport][stable-10] inventory plugins: use f-strings (#9332)
inventory plugins: use f-strings (#9323)
* inventory plugins: use f-strings
* add changelog frag
(cherry picked from commit 1d8f0b2942)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
3fe559b88f
commit
2499c1132d
14 changed files with 148 additions and 149 deletions
|
|
@ -128,9 +128,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
|||
authstring = fp.read().rstrip()
|
||||
username, password = authstring.split(":")
|
||||
except (OSError, IOError):
|
||||
raise AnsibleError("Could not find or read ONE_AUTH file at '{e}'".format(e=authfile))
|
||||
raise AnsibleError(f"Could not find or read ONE_AUTH file at '{authfile}'")
|
||||
except Exception:
|
||||
raise AnsibleError("Error occurs when reading ONE_AUTH file at '{e}'".format(e=authfile))
|
||||
raise AnsibleError(f"Error occurs when reading ONE_AUTH file at '{authfile}'")
|
||||
|
||||
auth_params = namedtuple('auth', ('url', 'username', 'password'))
|
||||
|
||||
|
|
@ -166,13 +166,13 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
|||
if not (auth.username and auth.password):
|
||||
raise AnsibleError('API Credentials missing. Check OpenNebula inventory file.')
|
||||
else:
|
||||
one_client = pyone.OneServer(auth.url, session=auth.username + ':' + auth.password)
|
||||
one_client = pyone.OneServer(auth.url, session=f"{auth.username}:{auth.password}")
|
||||
|
||||
# get hosts (VMs)
|
||||
try:
|
||||
vm_pool = one_client.vmpool.infoextended(-2, -1, -1, 3)
|
||||
except Exception as e:
|
||||
raise AnsibleError("Something happened during XML-RPC call: {e}".format(e=to_native(e)))
|
||||
raise AnsibleError(f"Something happened during XML-RPC call: {to_native(e)}")
|
||||
|
||||
return vm_pool
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue