fixed spelling errors, unused variables and unused import
This commit is contained in:
parent
c8f8f14e59
commit
637a6c562e
1 changed files with 6 additions and 14 deletions
20
library/cloud/ec2_ami
Executable file → Normal file
20
library/cloud/ec2_ami
Executable file → Normal file
|
@ -53,7 +53,7 @@ options:
|
||||||
aliases: []
|
aliases: []
|
||||||
wait:
|
wait:
|
||||||
description:
|
description:
|
||||||
- wait for the instance to be in state 'available' before returning.
|
- wait for the AMI to be in state 'available' before returning.
|
||||||
required: false
|
required: false
|
||||||
default: "no"
|
default: "no"
|
||||||
choices: [ "yes", "no" ]
|
choices: [ "yes", "no" ]
|
||||||
|
@ -75,12 +75,6 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
aliases: []
|
aliases: []
|
||||||
zone:
|
|
||||||
description:
|
|
||||||
- availability zone in which to launch the instance
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
aliases: []
|
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- An optional human-readable string describing the contents and purpose of the AMI.
|
- An optional human-readable string describing the contents and purpose of the AMI.
|
||||||
|
@ -158,14 +152,13 @@ import time
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import boto.ec2
|
import boto.ec2
|
||||||
from boto.exception import EC2ResponseError
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print "failed=True msg='boto required for this module'"
|
print "failed=True msg='boto required for this module'"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def create_image(module, ec2):
|
def create_image(module, ec2):
|
||||||
"""
|
"""
|
||||||
Creates new instances
|
Creates new AMI
|
||||||
|
|
||||||
module : AnsbileModule object
|
module : AnsbileModule object
|
||||||
ec2: authenticated ec2 connection object
|
ec2: authenticated ec2 connection object
|
||||||
|
@ -191,7 +184,7 @@ def create_image(module, ec2):
|
||||||
# wait here until the image is gone
|
# wait here until the image is gone
|
||||||
img = ec2.get_image(image_id)
|
img = ec2.get_image(image_id)
|
||||||
wait_timeout = time.time() + wait_timeout
|
wait_timeout = time.time() + wait_timeout
|
||||||
while wait and wait_timeout > time.time() and (img == None or img.state != 'available'):
|
while wait and wait_timeout > time.time() and (img is None or img.state != 'available'):
|
||||||
img = ec2.get_image(image_id)
|
img = ec2.get_image(image_id)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
if wait and wait_timeout <= time.time():
|
if wait and wait_timeout <= time.time():
|
||||||
|
@ -214,7 +207,7 @@ def deregister_image(module, ec2):
|
||||||
|
|
||||||
img = ec2.get_image(image_id)
|
img = ec2.get_image(image_id)
|
||||||
if img == None:
|
if img == None:
|
||||||
module.fail_json(msg = "Image %s does not exist" % image_id)
|
module.fail_json(msg = "Image %s does not exist" % image_id, changed=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
params = {'image_id': image_id,
|
params = {'image_id': image_id,
|
||||||
|
@ -227,7 +220,7 @@ def deregister_image(module, ec2):
|
||||||
# wait here until the image is gone
|
# wait here until the image is gone
|
||||||
img = ec2.get_image(image_id)
|
img = ec2.get_image(image_id)
|
||||||
wait_timeout = time.time() + wait_timeout
|
wait_timeout = time.time() + wait_timeout
|
||||||
while wait and wait_timeout > time.time() and img != None:
|
while wait and wait_timeout > time.time() and img is not None:
|
||||||
img = ec2.get_image(image_id)
|
img = ec2.get_image(image_id)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
if wait and wait_timeout <= time.time():
|
if wait and wait_timeout <= time.time():
|
||||||
|
@ -291,8 +284,7 @@ def main():
|
||||||
deregister_image(module, ec2)
|
deregister_image(module, ec2)
|
||||||
|
|
||||||
elif module.params.get('state') == 'present':
|
elif module.params.get('state') == 'present':
|
||||||
# Changed is always set to true when provisioning new instances
|
# Changed is always set to true when provisioning new AMI
|
||||||
changed = True
|
|
||||||
if not module.params.get('instance_id'):
|
if not module.params.get('instance_id'):
|
||||||
module.fail_json(msg='instance_id parameter is required for new image')
|
module.fail_json(msg='instance_id parameter is required for new image')
|
||||||
if not module.params.get('name'):
|
if not module.params.get('name'):
|
||||||
|
|
Loading…
Reference in a new issue