From e8abea25c74456e6a6f142fdeee09ee2b492b6f7 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. --- cloud/openstack/os_auth.py | 2 +- cloud/openstack/os_floating_ip.py | 2 +- cloud/openstack/os_image.py | 2 +- cloud/openstack/os_image_facts.py | 2 +- cloud/openstack/os_ironic.py | 2 +- cloud/openstack/os_ironic_node.py | 2 +- cloud/openstack/os_keypair.py | 2 +- cloud/openstack/os_network.py | 2 +- cloud/openstack/os_networks_facts.py | 2 +- cloud/openstack/os_nova_flavor.py | 2 +- cloud/openstack/os_object.py | 2 +- cloud/openstack/os_port.py | 2 +- cloud/openstack/os_router.py | 2 +- cloud/openstack/os_security_group.py | 2 +- cloud/openstack/os_security_group_rule.py | 2 +- cloud/openstack/os_server.py | 2 +- cloud/openstack/os_server_actions.py | 2 +- cloud/openstack/os_server_facts.py | 2 +- cloud/openstack/os_server_volume.py | 2 +- cloud/openstack/os_subnet.py | 2 +- cloud/openstack/os_subnets_facts.py | 2 +- cloud/openstack/os_user.py | 2 +- cloud/openstack/os_user_group.py | 2 +- cloud/openstack/os_volume.py | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cloud/openstack/os_auth.py b/cloud/openstack/os_auth.py index a881c217805..4f4d22eac94 100644 --- a/cloud/openstack/os_auth.py +++ b/cloud/openstack/os_auth.py @@ -60,7 +60,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/cloud/openstack/os_floating_ip.py b/cloud/openstack/os_floating_ip.py index b6342f8fa01..5d3ca7efdfb 100644 --- a/cloud/openstack/os_floating_ip.py +++ b/cloud/openstack/os_floating_ip.py @@ -175,7 +175,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/cloud/openstack/os_image.py b/cloud/openstack/os_image.py index b83e98859e7..565bd868c33 100644 --- a/cloud/openstack/os_image.py +++ b/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/cloud/openstack/os_image_facts.py b/cloud/openstack/os_image_facts.py index a54537172eb..fd3b4f3fb50 100644 --- a/cloud/openstack/os_image_facts.py +++ b/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/cloud/openstack/os_ironic.py b/cloud/openstack/os_ironic.py index a6612cf195e..d1074caae58 100644 --- a/cloud/openstack/os_ironic.py +++ b/cloud/openstack/os_ironic.py @@ -338,7 +338,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/cloud/openstack/os_ironic_node.py b/cloud/openstack/os_ironic_node.py index f087581ca0a..8a18fce0832 100644 --- a/cloud/openstack/os_ironic_node.py +++ b/cloud/openstack/os_ironic_node.py @@ -324,7 +324,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/cloud/openstack/os_keypair.py b/cloud/openstack/os_keypair.py index 64ebd8c67be..cf2b0a808ae 100644 --- a/cloud/openstack/os_keypair.py +++ b/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/cloud/openstack/os_network.py b/cloud/openstack/os_network.py index 82863ebd6b5..98ea4495d40 100644 --- a/cloud/openstack/os_network.py +++ b/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/cloud/openstack/os_networks_facts.py b/cloud/openstack/os_networks_facts.py index 6ac8786463d..8b7592beb66 100644 --- a/cloud/openstack/os_networks_facts.py +++ b/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/cloud/openstack/os_nova_flavor.py b/cloud/openstack/os_nova_flavor.py index f7924030461..102b2bf2aee 100644 --- a/cloud/openstack/os_nova_flavor.py +++ b/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/cloud/openstack/os_object.py b/cloud/openstack/os_object.py index 22fcebb76ce..1375cc5a2b4 100644 --- a/cloud/openstack/os_object.py +++ b/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/cloud/openstack/os_port.py b/cloud/openstack/os_port.py index d218e938b10..67bcac7b321 100644 --- a/cloud/openstack/os_port.py +++ b/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/cloud/openstack/os_router.py b/cloud/openstack/os_router.py index d48ed0417f1..f0df8b144cc 100644 --- a/cloud/openstack/os_router.py +++ b/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/cloud/openstack/os_security_group.py b/cloud/openstack/os_security_group.py index fd839755144..63311b536a6 100644 --- a/cloud/openstack/os_security_group.py +++ b/cloud/openstack/os_security_group.py @@ -134,7 +134,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/cloud/openstack/os_security_group_rule.py b/cloud/openstack/os_security_group_rule.py index b2324b097ce..ef63bfacd45 100644 --- a/cloud/openstack/os_security_group_rule.py +++ b/cloud/openstack/os_security_group_rule.py @@ -317,7 +317,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/cloud/openstack/os_server.py b/cloud/openstack/os_server.py index 036d4edded7..c626d503d64 100644 --- a/cloud/openstack/os_server.py +++ b/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/cloud/openstack/os_server_actions.py b/cloud/openstack/os_server_actions.py index 76f34c47079..44ff6afc8a8 100644 --- a/cloud/openstack/os_server_actions.py +++ b/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/cloud/openstack/os_server_facts.py b/cloud/openstack/os_server_facts.py index bd694dbc558..bcda1d4f78f 100644 --- a/cloud/openstack/os_server_facts.py +++ b/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/cloud/openstack/os_server_volume.py b/cloud/openstack/os_server_volume.py index 945a0ce8bf9..e71e0954a20 100644 --- a/cloud/openstack/os_server_volume.py +++ b/cloud/openstack/os_server_volume.py @@ -146,7 +146,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/cloud/openstack/os_subnet.py b/cloud/openstack/os_subnet.py index 1913d95ce7e..19354ccf3f6 100644 --- a/cloud/openstack/os_subnet.py +++ b/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/cloud/openstack/os_subnets_facts.py b/cloud/openstack/os_subnets_facts.py index 0f11fc6bcdc..676daefea7b 100644 --- a/cloud/openstack/os_subnets_facts.py +++ b/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/cloud/openstack/os_user.py b/cloud/openstack/os_user.py index f5baa6fc75a..a3c2cb4ef08 100644 --- a/cloud/openstack/os_user.py +++ b/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/cloud/openstack/os_user_group.py b/cloud/openstack/os_user_group.py index b2be24c74b2..9d21a7f033f 100644 --- a/cloud/openstack/os_user_group.py +++ b/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/cloud/openstack/os_volume.py b/cloud/openstack/os_volume.py index 80ad2adcbb2..5a3d0aacab0 100644 --- a/cloud/openstack/os_volume.py +++ b/cloud/openstack/os_volume.py @@ -153,7 +153,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 *