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
f79c9fb6
Commit
f79c9fb6
authored
Sep 03, 2013
by
Serge van Ginderachter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve changed result for race conditions
parent
0c2e376d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
library/net_infrastructure/bigip_monitor_http
+16
-6
No files found.
library/net_infrastructure/bigip_monitor_http
View file @
f79c9fb6
...
@@ -182,10 +182,11 @@ def create_monitor(api, monitor, template_attributes):
...
@@ -182,10 +182,11 @@ def create_monitor(api, monitor, template_attributes):
api
.
LocalLB
.
Monitor
.
create_template
(
templates
=
[{
'template_name'
:
monitor
,
'template_type'
:
TEMPLATE_TYPE
}],
template_attributes
=
[
template_attributes
])
api
.
LocalLB
.
Monitor
.
create_template
(
templates
=
[{
'template_name'
:
monitor
,
'template_type'
:
TEMPLATE_TYPE
}],
template_attributes
=
[
template_attributes
])
except
bigsuds
.
OperationFailed
,
e
:
except
bigsuds
.
OperationFailed
,
e
:
if
"already exists"
in
str
(
e
):
if
"already exists"
in
str
(
e
):
pass
return
False
else
:
else
:
# genuine exception
# genuine exception
raise
raise
return
True
def
delete_monitor
(
api
,
monitor
):
def
delete_monitor
(
api
,
monitor
):
...
@@ -194,9 +195,12 @@ def delete_monitor(api, monitor):
...
@@ -194,9 +195,12 @@ def delete_monitor(api, monitor):
api
.
LocalLB
.
Monitor
.
delete_template
(
template_names
=
[
monitor
])
api
.
LocalLB
.
Monitor
.
delete_template
(
template_names
=
[
monitor
])
except
bigsuds
.
OperationFailed
,
e
:
except
bigsuds
.
OperationFailed
,
e
:
# maybe it was deleted since we checked
# maybe it was deleted since we checked
if
not
"was not found"
in
str
(
e
):
if
"was not found"
in
str
(
e
):
return
False
else
:
# genuine exception
# genuine exception
raise
raise
return
True
def
check_string_property
(
api
,
monitor
,
str_property
):
def
check_string_property
(
api
,
monitor
,
str_property
):
...
@@ -307,8 +311,11 @@ def main():
...
@@ -307,8 +311,11 @@ def main():
if
state
==
'absent'
:
if
state
==
'absent'
:
if
monitor_exists
:
if
monitor_exists
:
if
not
module
.
check_mode
:
if
not
module
.
check_mode
:
delete_monitor
(
api
,
monitor
)
# possible race condition if same task
result
[
'changed'
]
=
True
# on other node deleted it first
result
[
'changed'
]
=
delete_monitor
(
api
,
monitor
)
else
:
result
[
'changed'
]
=
True
else
:
else
:
ipport
=
{
'address_type'
:
address_type
,
ipport
=
{
'address_type'
:
address_type
,
...
@@ -353,10 +360,13 @@ def main():
...
@@ -353,10 +360,13 @@ def main():
result
[
'changed'
]
=
True
result
[
'changed'
]
=
True
elif
not
module
.
check_mode
:
elif
not
module
.
check_mode
:
create_monitor
(
api
,
monitor
,
template_attributes
)
# possible race condition if same task
# on other node deleted it first
result
[
'changed'
]
=
create_monitor
(
api
,
monitor
,
template_attributes
)
for
str_property
in
template_string_properties
:
for
str_property
in
template_string_properties
:
set_string_property
(
api
,
monitor
,
str_property
)
set_string_property
(
api
,
monitor
,
str_property
)
result
[
'changed'
]
=
True
for
int_property
in
template_integer_properties
:
set_integer_property
(
api
,
monitor
,
int_property
)
else
:
# monitor does not exist and check mode
else
:
# monitor does not exist and check mode
result
[
'changed'
]
=
True
result
[
'changed'
]
=
True
...
...
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