Fixes 30786 - add server response to the failure (#39371)
* Fixes 30786 - add server response to the failure * replace str(e) with to_native(e) according to code review
This commit is contained in:
parent
d39b1ff664
commit
59b9c5f119
1 changed files with 10 additions and 3 deletions
|
@ -149,6 +149,7 @@ stack:
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
|
from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
|
||||||
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
|
|
||||||
def _create_stack(module, stack, cloud, shade):
|
def _create_stack(module, stack, cloud, shade):
|
||||||
|
@ -168,7 +169,10 @@ def _create_stack(module, stack, cloud, shade):
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg="Failure in creating stack: {0}".format(stack))
|
module.fail_json(msg="Failure in creating stack: {0}".format(stack))
|
||||||
except shade.OpenStackCloudException as e:
|
except shade.OpenStackCloudException as e:
|
||||||
module.fail_json(msg=str(e))
|
if hasattr(e, 'response'):
|
||||||
|
module.fail_json(msg=to_native(e), response=e.response.json())
|
||||||
|
else:
|
||||||
|
module.fail_json(msg=to_native(e))
|
||||||
|
|
||||||
|
|
||||||
def _update_stack(module, stack, cloud, shade):
|
def _update_stack(module, stack, cloud, shade):
|
||||||
|
@ -188,7 +192,10 @@ def _update_stack(module, stack, cloud, shade):
|
||||||
module.fail_json(msg="Failure in updating stack: %s" %
|
module.fail_json(msg="Failure in updating stack: %s" %
|
||||||
stack['stack_status_reason'])
|
stack['stack_status_reason'])
|
||||||
except shade.OpenStackCloudException as e:
|
except shade.OpenStackCloudException as e:
|
||||||
module.fail_json(msg=str(e))
|
if hasattr(e, 'response'):
|
||||||
|
module.fail_json(msg=to_native(e), response=e.response.json())
|
||||||
|
else:
|
||||||
|
module.fail_json(msg=to_native(e))
|
||||||
|
|
||||||
|
|
||||||
def _system_state_change(module, stack, cloud):
|
def _system_state_change(module, stack, cloud):
|
||||||
|
@ -260,7 +267,7 @@ def main():
|
||||||
module.fail_json(msg='delete stack failed for stack: %s' % name)
|
module.fail_json(msg='delete stack failed for stack: %s' % name)
|
||||||
module.exit_json(changed=changed)
|
module.exit_json(changed=changed)
|
||||||
except shade.OpenStackCloudException as e:
|
except shade.OpenStackCloudException as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=to_native(e))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue