mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
linode_v4: correct usage of module.fail_json (#48882)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
652da82558
commit
a32902427c
1 changed files with 7 additions and 13 deletions
|
@ -181,9 +181,7 @@ def create_linode(module, client, **kwargs):
|
|||
try:
|
||||
response = client.linode.instance_create(**kwargs)
|
||||
except Exception as exception:
|
||||
raise module.fail_json(msg=(
|
||||
'Unable to query the Linode API. Saw: %s'
|
||||
) % exception)
|
||||
module.fail_json(msg='Unable to query the Linode API. Saw: %s' % exception)
|
||||
|
||||
try:
|
||||
if isinstance(response, tuple):
|
||||
|
@ -194,11 +192,10 @@ def create_linode(module, client, **kwargs):
|
|||
else:
|
||||
return response._raw_json
|
||||
except TypeError:
|
||||
raise module.fail_json(msg=(
|
||||
'Unable to parse Linode instance creation '
|
||||
'response. Please raise a bug against this '
|
||||
'module on https://github.com/ansible/ansible/issues'
|
||||
))
|
||||
module.fail_json(msg='Unable to parse Linode instance creation'
|
||||
' response. Please raise a bug against this'
|
||||
' module on https://github.com/ansible/ansible/issues'
|
||||
)
|
||||
|
||||
|
||||
def maybe_instance_from_label(module, client):
|
||||
|
@ -210,9 +207,7 @@ def maybe_instance_from_label(module, client):
|
|||
except IndexError:
|
||||
return None
|
||||
except Exception as exception:
|
||||
raise module.fail_json(msg=(
|
||||
'Unable to query the Linode API. Saw: %s'
|
||||
) % exception)
|
||||
module.fail_json(msg='Unable to query the Linode API. Saw: %s' % exception)
|
||||
|
||||
|
||||
def initialise_module():
|
||||
|
@ -262,8 +257,7 @@ def main():
|
|||
module = initialise_module()
|
||||
|
||||
if not HAS_LINODE_DEPENDENCY:
|
||||
msg = 'The linode_v4 module requires the linode_api4 package'
|
||||
raise module.fail_json(msg=msg)
|
||||
module.fail_json(msg='The linode_v4 module requires the linode_api4 package')
|
||||
|
||||
client = build_client(module)
|
||||
instance = maybe_instance_from_label(module, client)
|
||||
|
|
Loading…
Reference in a new issue