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
d32d8991
Commit
d32d8991
authored
Mar 07, 2013
by
milan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
waiting enhancements
parent
78d1e248
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
library/ec2
+23
-7
No files found.
library/ec2
View file @
d32d8991
...
...
@@ -71,6 +71,11 @@ options:
required: false
default: false
aliases: []
wait_timeout:
descritption:
- How long before wait gives up. In seconds.
- default: 300
aliases: []
ec2_url:
description:
- url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints)
...
...
@@ -152,6 +157,7 @@ def main():
monitoring
=
dict
(
choices
=
BOOLEANS
,
default
=
False
),
ramdisk
=
dict
(),
wait
=
dict
(
choices
=
BOOLEANS
,
default
=
False
),
wait_timeout
=
dict
(
default
=
300
),
ec2_url
=
dict
(
aliases
=
[
'EC2_URL'
]),
ec2_secret_key
=
dict
(
aliases
=
[
'EC2_SECRET_KEY'
],
no_log
=
True
),
ec2_access_key
=
dict
(
aliases
=
[
'EC2_ACCESS_KEY'
]),
...
...
@@ -171,6 +177,7 @@ def main():
kernel
=
module
.
params
.
get
(
'kernel'
)
ramdisk
=
module
.
params
.
get
(
'ramdisk'
)
wait
=
module
.
params
.
get
(
'wait'
)
wait_timeout
=
int
(
module
.
params
.
get
(
'wait_timeout'
))
ec2_url
=
module
.
params
.
get
(
'ec2_url'
)
ec2_secret_key
=
module
.
params
.
get
(
'ec2_secret_key'
)
ec2_access_key
=
module
.
params
.
get
(
'ec2_access_key'
)
...
...
@@ -221,6 +228,16 @@ def main():
module
.
fail_json
(
msg
=
"
%
s:
%
s"
%
(
e
.
error_code
,
e
.
error_message
))
instids
=
[
i
.
id
for
i
in
res
.
instances
]
while
True
:
try
:
res
.
connection
.
get_all_instances
(
instids
)
break
except
boto
.
exception
.
EC2ResponseError
as
e
:
if
"<Code>InvalidInstanceID.NotFound</Code>"
in
str
(
e
):
# there's a race between start and get an instance
continue
else
:
module
.
fail_json
(
msg
=
str
(
e
))
if
instance_tags
:
try
:
...
...
@@ -228,20 +245,19 @@ def main():
except
boto
.
exception
.
EC2ResponseError
as
e
:
module
.
fail_json
(
msg
=
"
%
s:
%
s"
%
(
e
.
error_code
,
e
.
error_message
))
# wait here until the instances are up
res_list
=
res
.
connection
.
get_all_instances
(
instids
)
this_res
=
res_list
[
0
]
if
wait
:
# there's a race between start and get an instance state
import
time
time
.
sleep
(
5
)
# wait here until the instances are up
num_running
=
0
while
num_running
!=
len
(
instids
):
wait_timeout
=
time
.
time
()
+
wait_timeout
while
wait
and
wait_timeout
>
time
.
time
()
and
num_running
<
len
(
instids
):
res_list
=
res
.
connection
.
get_all_instances
(
instids
)
this_res
=
res_list
[
0
]
num_running
=
len
([
i
for
i
in
this_res
.
instances
if
i
.
state
==
'running'
])
time
.
sleep
(
5
)
if
wait
and
wait_timeout
<=
time
.
time
():
# waiting took too long
module
.
fail_json
(
msg
=
"wait for instances running timeout on
%
s"
%
time
.
asctime
())
instances
=
[]
for
inst
in
this_res
.
instances
:
d
=
{
...
...
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