From 6970cc233fdb661fc4d1838df1f91600182abc4a 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. --- cloud/openstack/os_client_config.py | 3 ++- cloud/openstack/os_image.py | 4 +++- cloud/openstack/os_ironic.py | 4 +++- cloud/openstack/os_ironic_node.py | 4 +++- cloud/openstack/os_object.py | 4 +++- cloud/openstack/os_security_group.py | 4 +++- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cloud/openstack/os_client_config.py b/cloud/openstack/os_client_config.py index 252f085c53b..1627bdfe322 100644 --- a/cloud/openstack/os_client_config.py +++ b/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/cloud/openstack/os_image.py b/cloud/openstack/os_image.py index 846cfaf50b7..3aa49583f11 100644 --- a/cloud/openstack/os_image.py +++ b/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/cloud/openstack/os_ironic.py b/cloud/openstack/os_ironic.py index d1074caae58..79751347615 100644 --- a/cloud/openstack/os_ironic.py +++ b/cloud/openstack/os_ironic.py @@ -344,4 +344,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/cloud/openstack/os_ironic_node.py b/cloud/openstack/os_ironic_node.py index bd2f3b6a027..17e3b1578eb 100644 --- a/cloud/openstack/os_ironic_node.py +++ b/cloud/openstack/os_ironic_node.py @@ -365,4 +365,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/cloud/openstack/os_object.py b/cloud/openstack/os_object.py index 8e5d65690e0..d5d77e1318c 100644 --- a/cloud/openstack/os_object.py +++ b/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/cloud/openstack/os_security_group.py b/cloud/openstack/os_security_group.py index 63311b536a6..f2a2bb6ac1e 100644 --- a/cloud/openstack/os_security_group.py +++ b/cloud/openstack/os_security_group.py @@ -139,4 +139,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()