mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00: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:
@@ -487,7 +487,6 @@ EXAMPLES = '''
|
||||
|
||||
'''
|
||||
|
||||
import sys
|
||||
import time
|
||||
from ast import literal_eval
|
||||
|
||||
@@ -496,9 +495,10 @@ try:
|
||||
from boto.ec2.blockdevicemapping import BlockDeviceType, BlockDeviceMapping
|
||||
from boto.exception import EC2ResponseError
|
||||
from boto.vpc import VPCConnection
|
||||
HAS_BOTO = True
|
||||
except ImportError:
|
||||
print "failed=True msg='boto required for this module'"
|
||||
sys.exit(1)
|
||||
HAS_BOTO = False
|
||||
|
||||
|
||||
def find_running_instances_by_count_tag(module, ec2, count_tag, zone=None):
|
||||
|
||||
@@ -782,7 +782,6 @@ def create_instances(module, ec2, vpc, override_count=None):
|
||||
# group_id and group_name are exclusive of each other
|
||||
if group_id and group_name:
|
||||
module.fail_json(msg = str("Use only one type of parameter (group_name) or (group_id)"))
|
||||
sys.exit(1)
|
||||
|
||||
vpc_id = None
|
||||
if vpc_subnet_id:
|
||||
@@ -1203,6 +1202,9 @@ def main():
|
||||
],
|
||||
)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto required for this module')
|
||||
|
||||
ec2 = ec2_connect(module)
|
||||
|
||||
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
||||
|
||||
Reference in New Issue
Block a user