From dcbbd72cfd8acf021f175be715e2468a71e61837 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Wed, 6 Apr 2016 15:18:35 -0400 Subject: [PATCH] Wrap calls to main() with if check A change was merged to the main Ansible core code that can cause a potential hang if any libraries are called that use threading. This change was: https://github.com/ansible/ansible/commit/4b0aa1214ca989c71bb87f7a805b1e3673faefa9 This affected the os_object module by causing a hang on the shade create_object() API call (which in turn calls swiftclient which uses threading). The fix is to make sure all modules have a main() that is wrapped with an "if __name__ == '__main__'" check. --- lib/ansible/modules/cloud/openstack/os_client_config.py | 3 ++- lib/ansible/modules/cloud/openstack/os_image.py | 4 +++- lib/ansible/modules/cloud/openstack/os_ironic.py | 4 +++- lib/ansible/modules/cloud/openstack/os_ironic_node.py | 4 +++- lib/ansible/modules/cloud/openstack/os_object.py | 4 +++- lib/ansible/modules/cloud/openstack/os_security_group.py | 4 +++- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_client_config.py b/lib/ansible/modules/cloud/openstack/os_client_config.py index 252f085c53..1627bdfe32 100644 --- a/lib/ansible/modules/cloud/openstack/os_client_config.py +++ b/lib/ansible/modules/cloud/openstack/os_client_config.py @@ -71,4 +71,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() +if __name__ == "__main__": + main() diff --git a/lib/ansible/modules/cloud/openstack/os_image.py b/lib/ansible/modules/cloud/openstack/os_image.py index 846cfaf50b..3aa49583f1 100644 --- a/lib/ansible/modules/cloud/openstack/os_image.py +++ b/lib/ansible/modules/cloud/openstack/os_image.py @@ -188,4 +188,6 @@ def main(): # this is magic, see lib/ansible/module_common.py from ansible.module_utils.basic import * from ansible.module_utils.openstack import * -main() + +if __name__ == "__main__": + main() diff --git a/lib/ansible/modules/cloud/openstack/os_ironic.py b/lib/ansible/modules/cloud/openstack/os_ironic.py index 942f2fa0c8..9afca3b2e4 100644 --- a/lib/ansible/modules/cloud/openstack/os_ironic.py +++ b/lib/ansible/modules/cloud/openstack/os_ironic.py @@ -342,4 +342,6 @@ def main(): # this is magic, see lib/ansible/module_common.py from ansible.module_utils.basic import * from ansible.module_utils.openstack import * -main() + +if __name__ == "__main__": + main() diff --git a/lib/ansible/modules/cloud/openstack/os_ironic_node.py b/lib/ansible/modules/cloud/openstack/os_ironic_node.py index a18b992abc..d2566fcd0c 100644 --- a/lib/ansible/modules/cloud/openstack/os_ironic_node.py +++ b/lib/ansible/modules/cloud/openstack/os_ironic_node.py @@ -362,4 +362,6 @@ def main(): # this is magic, see lib/ansible/module_common.py from ansible.module_utils.basic import * from ansible.module_utils.openstack import * -main() + +if __name__ == "__main__": + main() diff --git a/lib/ansible/modules/cloud/openstack/os_object.py b/lib/ansible/modules/cloud/openstack/os_object.py index ecd7946819..87d09e73f1 100644 --- a/lib/ansible/modules/cloud/openstack/os_object.py +++ b/lib/ansible/modules/cloud/openstack/os_object.py @@ -122,4 +122,6 @@ def main(): # this is magic, see lib/ansible/module_common.py from ansible.module_utils.basic import * from ansible.module_utils.openstack import * -main() + +if __name__ == "__main__": + main() diff --git a/lib/ansible/modules/cloud/openstack/os_security_group.py b/lib/ansible/modules/cloud/openstack/os_security_group.py index e4a47c2a58..dec8a17e99 100644 --- a/lib/ansible/modules/cloud/openstack/os_security_group.py +++ b/lib/ansible/modules/cloud/openstack/os_security_group.py @@ -138,4 +138,6 @@ def main(): # this is magic, see lib/ansible/module_common.py from ansible.module_utils.basic import * from ansible.module_utils.openstack import * -main() + +if __name__ == "__main__": + main()