From a13141413a3e963e09cd9c914059236a4ba28bb7 Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Mon, 25 Apr 2016 12:34:18 -0700 Subject: [PATCH] Adds the __main__ conditional check (#2098) As is done in other ansible modules, this adds the __main__ check to the module so that the module code itself can be used as a library. For instance, when testing the code. --- lib/ansible/modules/extras/network/f5/bigip_facts.py | 1 - lib/ansible/modules/extras/network/f5/bigip_monitor_http.py | 3 ++- lib/ansible/modules/extras/network/f5/bigip_monitor_tcp.py | 3 ++- lib/ansible/modules/extras/network/f5/bigip_node.py | 3 ++- lib/ansible/modules/extras/network/f5/bigip_pool.py | 4 +++- lib/ansible/modules/extras/network/f5/bigip_pool_member.py | 4 +++- lib/ansible/modules/extras/network/f5/bigip_virtual_server.py | 1 - 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ansible/modules/extras/network/f5/bigip_facts.py b/lib/ansible/modules/extras/network/f5/bigip_facts.py index 9f30397ea1..06cff65f77 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_facts.py +++ b/lib/ansible/modules/extras/network/f5/bigip_facts.py @@ -1687,4 +1687,3 @@ from ansible.module_utils.f5 import * if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/extras/network/f5/bigip_monitor_http.py b/lib/ansible/modules/extras/network/f5/bigip_monitor_http.py index e0bae5a4f2..d74cf65602 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_monitor_http.py +++ b/lib/ansible/modules/extras/network/f5/bigip_monitor_http.py @@ -445,5 +445,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.f5 import * -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/network/f5/bigip_monitor_tcp.py b/lib/ansible/modules/extras/network/f5/bigip_monitor_tcp.py index 2c81f4b78c..418c2562f8 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_monitor_tcp.py +++ b/lib/ansible/modules/extras/network/f5/bigip_monitor_tcp.py @@ -469,5 +469,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.f5 import * -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/network/f5/bigip_node.py b/lib/ansible/modules/extras/network/f5/bigip_node.py index b6a44b81d0..9cd8d2a3ac 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_node.py +++ b/lib/ansible/modules/extras/network/f5/bigip_node.py @@ -379,5 +379,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.f5 import * -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/network/f5/bigip_pool.py b/lib/ansible/modules/extras/network/f5/bigip_pool.py index 73ea018c27..77d99760a8 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_pool.py +++ b/lib/ansible/modules/extras/network/f5/bigip_pool.py @@ -521,4 +521,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.f5 import * -main() + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/network/f5/bigip_pool_member.py b/lib/ansible/modules/extras/network/f5/bigip_pool_member.py index 58d0be6d69..7245235007 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_pool_member.py +++ b/lib/ansible/modules/extras/network/f5/bigip_pool_member.py @@ -466,4 +466,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.f5 import * -main() + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/network/f5/bigip_virtual_server.py b/lib/ansible/modules/extras/network/f5/bigip_virtual_server.py index d9e2af3eb5..68d6e116b8 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_virtual_server.py +++ b/lib/ansible/modules/extras/network/f5/bigip_virtual_server.py @@ -483,4 +483,3 @@ from ansible.module_utils.f5 import * if __name__ == '__main__': main() -