From aed44e88867702a80fb5466690d55affa9a5e362 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Wed, 13 Jan 2016 11:00:16 -0500 Subject: [PATCH] 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. --- lib/ansible/modules/cloud/openstack/os_auth.py | 2 +- lib/ansible/modules/cloud/openstack/os_floating_ip.py | 2 +- lib/ansible/modules/cloud/openstack/os_image.py | 2 +- lib/ansible/modules/cloud/openstack/os_image_facts.py | 2 +- lib/ansible/modules/cloud/openstack/os_ironic.py | 2 +- lib/ansible/modules/cloud/openstack/os_ironic_node.py | 2 +- lib/ansible/modules/cloud/openstack/os_keypair.py | 2 +- lib/ansible/modules/cloud/openstack/os_network.py | 2 +- lib/ansible/modules/cloud/openstack/os_networks_facts.py | 2 +- lib/ansible/modules/cloud/openstack/os_nova_flavor.py | 2 +- lib/ansible/modules/cloud/openstack/os_object.py | 2 +- lib/ansible/modules/cloud/openstack/os_port.py | 2 +- lib/ansible/modules/cloud/openstack/os_router.py | 2 +- lib/ansible/modules/cloud/openstack/os_security_group.py | 2 +- lib/ansible/modules/cloud/openstack/os_security_group_rule.py | 2 +- lib/ansible/modules/cloud/openstack/os_server.py | 2 +- lib/ansible/modules/cloud/openstack/os_server_actions.py | 2 +- lib/ansible/modules/cloud/openstack/os_server_facts.py | 2 +- lib/ansible/modules/cloud/openstack/os_server_volume.py | 2 +- lib/ansible/modules/cloud/openstack/os_subnet.py | 2 +- lib/ansible/modules/cloud/openstack/os_subnets_facts.py | 2 +- lib/ansible/modules/cloud/openstack/os_user.py | 2 +- lib/ansible/modules/cloud/openstack/os_user_group.py | 2 +- lib/ansible/modules/cloud/openstack/os_volume.py | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_auth.py b/lib/ansible/modules/cloud/openstack/os_auth.py index f2f18b1a53..7038f3f701 100644 --- a/lib/ansible/modules/cloud/openstack/os_auth.py +++ b/lib/ansible/modules/cloud/openstack/os_auth.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_floating_ip.py b/lib/ansible/modules/cloud/openstack/os_floating_ip.py index 5fb4f05d03..774d9e1676 100644 --- a/lib/ansible/modules/cloud/openstack/os_floating_ip.py +++ b/lib/ansible/modules/cloud/openstack/os_floating_ip.py @@ -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 diff --git a/lib/ansible/modules/cloud/openstack/os_image.py b/lib/ansible/modules/cloud/openstack/os_image.py index b83e98859e..565bd868c3 100644 --- a/lib/ansible/modules/cloud/openstack/os_image.py +++ b/lib/ansible/modules/cloud/openstack/os_image.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 * diff --git a/lib/ansible/modules/cloud/openstack/os_image_facts.py b/lib/ansible/modules/cloud/openstack/os_image_facts.py index a54537172e..fd3b4f3fb5 100644 --- a/lib/ansible/modules/cloud/openstack/os_image_facts.py +++ b/lib/ansible/modules/cloud/openstack/os_image_facts.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_ironic.py b/lib/ansible/modules/cloud/openstack/os_ironic.py index a80a8ce255..942f2fa0c8 100644 --- a/lib/ansible/modules/cloud/openstack/os_ironic.py +++ b/lib/ansible/modules/cloud/openstack/os_ironic.py @@ -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 diff --git a/lib/ansible/modules/cloud/openstack/os_ironic_node.py b/lib/ansible/modules/cloud/openstack/os_ironic_node.py index a50d6897e5..c2843a880f 100644 --- a/lib/ansible/modules/cloud/openstack/os_ironic_node.py +++ b/lib/ansible/modules/cloud/openstack/os_ironic_node.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 diff --git a/lib/ansible/modules/cloud/openstack/os_keypair.py b/lib/ansible/modules/cloud/openstack/os_keypair.py index 64ebd8c67b..cf2b0a808a 100644 --- a/lib/ansible/modules/cloud/openstack/os_keypair.py +++ b/lib/ansible/modules/cloud/openstack/os_keypair.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 * diff --git a/lib/ansible/modules/cloud/openstack/os_network.py b/lib/ansible/modules/cloud/openstack/os_network.py index 82863ebd6b..98ea4495d4 100644 --- a/lib/ansible/modules/cloud/openstack/os_network.py +++ b/lib/ansible/modules/cloud/openstack/os_network.py @@ -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 diff --git a/lib/ansible/modules/cloud/openstack/os_networks_facts.py b/lib/ansible/modules/cloud/openstack/os_networks_facts.py index 6ac8786463..8b7592beb6 100644 --- a/lib/ansible/modules/cloud/openstack/os_networks_facts.py +++ b/lib/ansible/modules/cloud/openstack/os_networks_facts.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 * diff --git a/lib/ansible/modules/cloud/openstack/os_nova_flavor.py b/lib/ansible/modules/cloud/openstack/os_nova_flavor.py index f792403046..102b2bf2ae 100644 --- a/lib/ansible/modules/cloud/openstack/os_nova_flavor.py +++ b/lib/ansible/modules/cloud/openstack/os_nova_flavor.py @@ -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 diff --git a/lib/ansible/modules/cloud/openstack/os_object.py b/lib/ansible/modules/cloud/openstack/os_object.py index fdc28337f0..045d5be659 100644 --- a/lib/ansible/modules/cloud/openstack/os_object.py +++ b/lib/ansible/modules/cloud/openstack/os_object.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 * diff --git a/lib/ansible/modules/cloud/openstack/os_port.py b/lib/ansible/modules/cloud/openstack/os_port.py index d218e938b1..67bcac7b32 100644 --- a/lib/ansible/modules/cloud/openstack/os_port.py +++ b/lib/ansible/modules/cloud/openstack/os_port.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_router.py b/lib/ansible/modules/cloud/openstack/os_router.py index d48ed0417f..f0df8b144c 100644 --- a/lib/ansible/modules/cloud/openstack/os_router.py +++ b/lib/ansible/modules/cloud/openstack/os_router.py @@ -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 diff --git a/lib/ansible/modules/cloud/openstack/os_security_group.py b/lib/ansible/modules/cloud/openstack/os_security_group.py index 478c86e9ee..e4a47c2a58 100644 --- a/lib/ansible/modules/cloud/openstack/os_security_group.py +++ b/lib/ansible/modules/cloud/openstack/os_security_group.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 * diff --git a/lib/ansible/modules/cloud/openstack/os_security_group_rule.py b/lib/ansible/modules/cloud/openstack/os_security_group_rule.py index e15472e105..f25efcecc2 100644 --- a/lib/ansible/modules/cloud/openstack/os_security_group_rule.py +++ b/lib/ansible/modules/cloud/openstack/os_security_group_rule.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_server.py b/lib/ansible/modules/cloud/openstack/os_server.py index db77658e79..446315310c 100644 --- a/lib/ansible/modules/cloud/openstack/os_server.py +++ b/lib/ansible/modules/cloud/openstack/os_server.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_server_actions.py b/lib/ansible/modules/cloud/openstack/os_server_actions.py index 76f34c4707..44ff6afc8a 100644 --- a/lib/ansible/modules/cloud/openstack/os_server_actions.py +++ b/lib/ansible/modules/cloud/openstack/os_server_actions.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_server_facts.py b/lib/ansible/modules/cloud/openstack/os_server_facts.py index bd694dbc55..bcda1d4f78 100644 --- a/lib/ansible/modules/cloud/openstack/os_server_facts.py +++ b/lib/ansible/modules/cloud/openstack/os_server_facts.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_server_volume.py b/lib/ansible/modules/cloud/openstack/os_server_volume.py index 8e3abddb0d..1c0dd9bc93 100644 --- a/lib/ansible/modules/cloud/openstack/os_server_volume.py +++ b/lib/ansible/modules/cloud/openstack/os_server_volume.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_subnet.py b/lib/ansible/modules/cloud/openstack/os_subnet.py index 1913d95ce7..19354ccf3f 100644 --- a/lib/ansible/modules/cloud/openstack/os_subnet.py +++ b/lib/ansible/modules/cloud/openstack/os_subnet.py @@ -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 diff --git a/lib/ansible/modules/cloud/openstack/os_subnets_facts.py b/lib/ansible/modules/cloud/openstack/os_subnets_facts.py index 0f11fc6bcd..676daefea7 100644 --- a/lib/ansible/modules/cloud/openstack/os_subnets_facts.py +++ b/lib/ansible/modules/cloud/openstack/os_subnets_facts.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 * diff --git a/lib/ansible/modules/cloud/openstack/os_user.py b/lib/ansible/modules/cloud/openstack/os_user.py index f5baa6fc75..a3c2cb4ef0 100644 --- a/lib/ansible/modules/cloud/openstack/os_user.py +++ b/lib/ansible/modules/cloud/openstack/os_user.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_user_group.py b/lib/ansible/modules/cloud/openstack/os_user_group.py index b2be24c74b..9d21a7f033 100644 --- a/lib/ansible/modules/cloud/openstack/os_user_group.py +++ b/lib/ansible/modules/cloud/openstack/os_user_group.py @@ -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 * diff --git a/lib/ansible/modules/cloud/openstack/os_volume.py b/lib/ansible/modules/cloud/openstack/os_volume.py index fced3d61e4..96d8e57c2c 100644 --- a/lib/ansible/modules/cloud/openstack/os_volume.py +++ b/lib/ansible/modules/cloud/openstack/os_volume.py @@ -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 *