Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
686d998b
Commit
686d998b
authored
Oct 07, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4368 from sayap/ec2_ami
ec2_ami: Account for AWS's "eventual consistency" with AMI creation.
parents
8604212d
a8f95435
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
library/cloud/ec2_ami
+17
-2
No files found.
library/cloud/ec2_ami
View file @
686d998b
...
...
@@ -165,6 +165,7 @@ AWS_REGIONS = ['ap-northeast-1',
'us-west-2'
]
try
:
import
boto
import
boto.ec2
except
ImportError
:
print
"failed=True msg='boto required for this module'"
...
...
@@ -195,8 +196,22 @@ def create_image(module, ec2):
except
boto
.
exception
.
BotoServerError
,
e
:
module
.
fail_json
(
msg
=
"
%
s:
%
s"
%
(
e
.
error_code
,
e
.
error_message
))
# wait here until the image is gone
img
=
ec2
.
get_image
(
image_id
)
# Wait until the image is recognized. EC2 API has eventual consistency,
# such that a successful CreateImage API call doesn't guarantee the success
# of subsequent DescribeImages API call using the new image id returned.
for
i
in
range
(
30
):
try
:
img
=
ec2
.
get_image
(
image_id
)
break
except
boto
.
exception
.
EC2ResponseError
as
e
:
if
e
.
error_code
==
'InvalidAMIID.NotFound'
:
time
.
sleep
(
1
)
else
:
raise
else
:
module
.
fail_json
(
msg
=
"timed out waiting for image to be recognized"
)
# wait here until the image is created
wait_timeout
=
time
.
time
()
+
wait_timeout
while
wait
and
wait_timeout
>
time
.
time
()
and
(
img
is
None
or
img
.
state
!=
'available'
):
img
=
ec2
.
get_image
(
image_id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment