mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-16 13:51:09 +00:00
Fix OpenStack module failure output
The exception message, when shade fails, will contain much more specific information about the failure if the exception is treated as a string. The 'message' attribute alone is usually not helpful.
This commit is contained in:
committed by
Matt Clay
parent
18ff22348a
commit
aed44e8886
@@ -57,7 +57,7 @@ def main():
|
||||
auth_token=cloud.auth_token,
|
||||
service_catalog=cloud.service_catalog))
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -176,7 +176,7 @@ def main():
|
||||
module.exit_json(changed=True, floating_ip=f_ip)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message, extra_data=e.extra_data)
|
||||
module.fail_json(msg=str(e), extra_data=e.extra_data)
|
||||
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
|
||||
@@ -183,7 +183,7 @@ def main():
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message, extra_data=e.extra_data)
|
||||
module.fail_json(msg=str(e), extra_data=e.extra_data)
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -148,7 +148,7 @@ def main():
|
||||
openstack_image=image))
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -336,7 +336,7 @@ def main():
|
||||
module.exit_json(changed=False, result="Server not found")
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
|
||||
@@ -323,7 +323,7 @@ def main():
|
||||
"maintenance, off")
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
|
||||
@@ -162,7 +162,7 @@ def main():
|
||||
module.exit_json(changed=False)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -159,7 +159,7 @@ def main():
|
||||
module.exit_json(changed=True)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
|
||||
@@ -132,7 +132,7 @@ def main():
|
||||
openstack_networks=networks))
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -232,7 +232,7 @@ def main():
|
||||
module.exit_json(changed=False)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
|
||||
@@ -117,7 +117,7 @@ def main():
|
||||
|
||||
module.exit_json(changed=changed)
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -383,7 +383,7 @@ def main():
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -352,7 +352,7 @@ def main():
|
||||
module.exit_json(changed=True)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
|
||||
@@ -133,7 +133,7 @@ def main():
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -320,7 +320,7 @@ def main():
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -606,7 +606,7 @@ def main():
|
||||
_get_server_state(module, cloud)
|
||||
_delete_server(module, cloud)
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message, extra_data=e.extra_data)
|
||||
module.fail_json(msg=str(e), extra_data=e.extra_data)
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -204,7 +204,7 @@ def main():
|
||||
module.exit_json(changed=True)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message, extra_data=e.extra_data)
|
||||
module.fail_json(msg=str(e), extra_data=e.extra_data)
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -89,7 +89,7 @@ def main():
|
||||
openstack_servers=openstack_servers))
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -144,7 +144,7 @@ def main():
|
||||
)
|
||||
|
||||
except (shade.OpenStackCloudException, shade.OpenStackCloudTimeout) as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_utils/common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -315,7 +315,7 @@ def main():
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
|
||||
@@ -145,7 +145,7 @@ def main():
|
||||
openstack_subnets=subnets))
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -202,7 +202,7 @@ def main():
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message, extra_data=e.extra_data)
|
||||
module.fail_json(msg=str(e), extra_data=e.extra_data)
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.openstack import *
|
||||
|
||||
@@ -106,7 +106,7 @@ def main():
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message, extra_data=e.extra_data)
|
||||
module.fail_json(msg=str(e), extra_data=e.extra_data)
|
||||
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
@@ -152,7 +152,7 @@ def main():
|
||||
if state == 'absent':
|
||||
_absent_volume(module, cloud)
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
Reference in New Issue
Block a user