From f69333b80d9707ef8bfebc4fdf2c5778fb0dcebb Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Fri, 14 Jul 2017 16:22:13 +0200 Subject: [PATCH] circonus_annotation: fix broken import, update requirements --- .../modules/monitoring/circonus_annotation.py | 13 +++++++++---- test/sanity/import/skip.txt | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/monitoring/circonus_annotation.py b/lib/ansible/modules/monitoring/circonus_annotation.py index 9375bbb0204..7fc3a589d12 100644 --- a/lib/ansible/modules/monitoring/circonus_annotation.py +++ b/lib/ansible/modules/monitoring/circonus_annotation.py @@ -22,9 +22,7 @@ description: author: "Nick Harring (@NickatEpic)" version_added: 2.0 requirements: - - urllib3 - - requests - - time + - requests (either >= 2.0.0 for Python 3, or >= 1.0.0 for Python 2) notes: - Check mode isn’t supported. options: @@ -143,7 +141,11 @@ import json import time import traceback -import requests +try: + import requests + HAS_REQUESTS = True +except ImportError: + HAS_REQUESTS = False from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_native @@ -201,6 +203,9 @@ def main(): ) ) + if not HAS_REQUESTS: + module.fail_json(msg='requests is required for this module') + annotation = create_annotation(module) try: resp = post_annotation(annotation, module.params['api_key']) diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index 7c576009ea5..038280bd03c 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -59,7 +59,6 @@ lib/ansible/modules/clustering/consul_kv.py lib/ansible/modules/messaging/rabbitmq_binding.py lib/ansible/modules/messaging/rabbitmq_exchange.py lib/ansible/modules/messaging/rabbitmq_queue.py -lib/ansible/modules/monitoring/circonus_annotation.py lib/ansible/modules/network/cloudengine/ce_file_copy.py lib/ansible/modules/network/cumulus/_cl_img_install.py lib/ansible/modules/network/f5/bigip_command.py