mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-08 17:34:01 -07:00
issue #994: use HAS_BOTO to determine if import was successful: - removed import of sys module. - HAS_BOTO constant to check if import was successful. - trigger a failure when import fails. - removed unnecessary imports.
This commit is contained in:
parent
0a48d54c1c
commit
67f769d9a6
21 changed files with 121 additions and 74 deletions
|
@ -55,8 +55,6 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.ec2 import *
|
||||
|
||||
|
@ -64,10 +62,9 @@ try:
|
|||
import boto.ec2.autoscale
|
||||
from boto.ec2.autoscale import ScalingPolicy
|
||||
from boto.exception import BotoServerError
|
||||
|
||||
HAS_BOTO = True
|
||||
except ImportError:
|
||||
print "failed=True msg='boto required for this module'"
|
||||
sys.exit(1)
|
||||
HAS_BOTO = False
|
||||
|
||||
|
||||
def create_scaling_policy(connection, module):
|
||||
|
@ -157,6 +154,9 @@ def main():
|
|||
|
||||
module = AnsibleModule(argument_spec=argument_spec)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto required for this module')
|
||||
|
||||
region, ec2_url, aws_connect_params = get_aws_connection_info(module)
|
||||
|
||||
state = module.params.get('state')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue