ec2_vpc_igw - Exit with fail_json when boto is unavailable.
This commit is contained in:
parent
9f0ee40b42
commit
829759fba7
1 changed files with 7 additions and 3 deletions
|
@ -83,15 +83,17 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys # noqa
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import boto.ec2
|
import boto.ec2
|
||||||
import boto.vpc
|
import boto.vpc
|
||||||
from boto.exception import EC2ResponseError
|
from boto.exception import EC2ResponseError
|
||||||
|
HAS_BOTO = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print "failed=True msg='boto required for this module'"
|
HAS_BOTO = False
|
||||||
sys.exit(1)
|
if __name__ != '__main__':
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
class IGWExcepton(Exception):
|
class IGWExcepton(Exception):
|
||||||
|
@ -153,6 +155,8 @@ def main():
|
||||||
argument_spec=argument_spec,
|
argument_spec=argument_spec,
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
if not HAS_BOTO:
|
||||||
|
module.fail_json(msg='boto is required for this module')
|
||||||
|
|
||||||
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
||||||
if not region:
|
if not region:
|
||||||
|
|
Loading…
Reference in a new issue