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
d4dcf187
Commit
d4dcf187
authored
Jul 20, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3502 from bryanlarsen/digital_ocean_no_ip
digital_ocean: don't run update_attr if wait=no
parents
cac5e7d1
cea812c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
library/cloud/digital_ocean
+7
-10
No files found.
library/cloud/digital_ocean
View file @
d4dcf187
...
@@ -59,7 +59,7 @@ options:
...
@@ -59,7 +59,7 @@ options:
- Optional, comma separated list of ssh_key_ids that you would like to be added to the server
- Optional, comma separated list of ssh_key_ids that you would like to be added to the server
wait:
wait:
description:
description:
- Wait for the droplet to be in state 'running' before returning.
- Wait for the droplet to be in state 'running' before returning.
If wait is "no" an ip_address may not be returned.
default: "yes"
default: "yes"
choices: [ "yes", "no" ]
choices: [ "yes", "no" ]
wait_timeout:
wait_timeout:
...
@@ -101,6 +101,8 @@ EXAMPLES = '''
...
@@ -101,6 +101,8 @@ EXAMPLES = '''
region_id=2
region_id=2
image_id=3
image_id=3
wait_timeout=500
wait_timeout=500
register: my_droplet
- debug: msg="ID: {{ my_droplet.droplet.id }} IP: {{ my_droplet.droplet.ip_address }}"
# Ensure a droplet is present
# Ensure a droplet is present
# If droplet id already exist, will return the droplet details and changed = False
# If droplet id already exist, will return the droplet details and changed = False
...
@@ -187,19 +189,13 @@ class Droplet(JsonfyMixIn):
...
@@ -187,19 +189,13 @@ class Droplet(JsonfyMixIn):
def
is_powered_on
(
self
):
def
is_powered_on
(
self
):
return
self
.
status
==
'active'
return
self
.
status
==
'active'
def
update_attr
(
self
,
attrs
=
None
,
times
=
5
):
def
update_attr
(
self
,
attrs
=
None
):
if
attrs
:
if
attrs
:
for
k
,
v
in
attrs
.
iteritems
():
for
k
,
v
in
attrs
.
iteritems
():
setattr
(
self
,
k
,
v
)
setattr
(
self
,
k
,
v
)
else
:
else
:
json
=
self
.
manager
.
show_droplet
(
self
.
id
)
json
=
self
.
manager
.
show_droplet
(
self
.
id
)
if
not
json
[
'ip_address'
]:
if
json
[
'ip_address'
]:
if
times
>
0
:
time
.
sleep
(
2
)
self
.
update_attr
(
times
=
times
-
1
)
else
:
raise
TimeoutError
(
'No ip is found.'
,
self
.
id
)
else
:
self
.
update_attr
(
json
)
self
.
update_attr
(
json
)
def
power_on
(
self
):
def
power_on
(
self
):
...
@@ -219,6 +215,8 @@ class Droplet(JsonfyMixIn):
...
@@ -219,6 +215,8 @@ class Droplet(JsonfyMixIn):
time
.
sleep
(
min
(
20
,
end_time
-
time
.
time
()))
time
.
sleep
(
min
(
20
,
end_time
-
time
.
time
()))
self
.
update_attr
()
self
.
update_attr
()
if
self
.
is_powered_on
():
if
self
.
is_powered_on
():
if
not
self
.
ip_address
:
raise
TimeoutError
(
'No ip is found.'
,
self
.
id
)
return
return
raise
TimeoutError
(
'Wait for droplet running timeout'
,
self
.
id
)
raise
TimeoutError
(
'Wait for droplet running timeout'
,
self
.
id
)
...
@@ -233,7 +231,6 @@ class Droplet(JsonfyMixIn):
...
@@ -233,7 +231,6 @@ class Droplet(JsonfyMixIn):
def
add
(
cls
,
name
,
size_id
,
image_id
,
region_id
,
ssh_key_ids
=
None
):
def
add
(
cls
,
name
,
size_id
,
image_id
,
region_id
,
ssh_key_ids
=
None
):
json
=
cls
.
manager
.
new_droplet
(
name
,
size_id
,
image_id
,
region_id
,
ssh_key_ids
)
json
=
cls
.
manager
.
new_droplet
(
name
,
size_id
,
image_id
,
region_id
,
ssh_key_ids
)
droplet
=
cls
(
json
)
droplet
=
cls
(
json
)
droplet
.
update_attr
()
return
droplet
return
droplet
@classmethod
@classmethod
...
...
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