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
c556e673
Commit
c556e673
authored
Aug 09, 2013
by
Matt Hite
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix to better handle concurrent runs of module against same pool
parent
c4a06d32
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
16 deletions
+48
-16
library/net_infrastructure/bigip_pool
+48
-16
No files found.
library/net_infrastructure/bigip_pool
View file @
c556e673
...
@@ -200,6 +200,10 @@ def pool_exists(api, pool):
...
@@ -200,6 +200,10 @@ def pool_exists(api, pool):
return
result
return
result
def
create_pool
(
api
,
pool
,
lb_method
):
def
create_pool
(
api
,
pool
,
lb_method
):
# create requires lb_method but we don't want to default
# to a value on subsequent runs
if
not
lb_method
:
lb_method
=
'round_robin'
lb_method
=
"LB_METHOD_
%
s"
%
lb_method
.
strip
()
.
upper
()
lb_method
=
"LB_METHOD_
%
s"
%
lb_method
.
strip
()
.
upper
()
api
.
LocalLB
.
Pool
.
create_v2
(
pool_names
=
[
pool
],
lb_methods
=
[
lb_method
],
api
.
LocalLB
.
Pool
.
create_v2
(
pool_names
=
[
pool
],
lb_methods
=
[
lb_method
],
members
=
[[]])
members
=
[[]])
...
@@ -390,29 +394,57 @@ def main():
...
@@ -390,29 +394,57 @@ def main():
elif
pool_exists
(
api
,
pool
):
elif
pool_exists
(
api
,
pool
):
# no host/port supplied, must be pool removal
# no host/port supplied, must be pool removal
if
not
module
.
check_mode
:
if
not
module
.
check_mode
:
remove_pool
(
api
,
pool
)
# hack to handle concurrent runs of module
result
=
{
'changed'
:
True
}
# pool might be gone before we actually remove it
try
:
remove_pool
(
api
,
pool
)
result
=
{
'changed'
:
True
}
except
bigsuds
.
OperationFailed
,
e
:
if
"was not found"
in
str
(
e
):
result
=
{
'changed'
:
False
}
else
:
# genuine exception
raise
else
:
# check-mode return value
result
=
{
'changed'
:
True
}
elif
state
==
'present'
:
elif
state
==
'present'
:
update
=
False
if
not
pool_exists
(
api
,
pool
):
if
not
pool_exists
(
api
,
pool
):
# pool does not exist -- need to create it
# pool does not exist -- need to create it
if
not
module
.
check_mode
:
if
not
module
.
check_mode
:
# create requires lb_method but we don't want to default
# a bit of a hack to handle concurrent runs of this module.
# to a value on subsequent runs
# even though we've checked the pool doesn't exist,
if
not
lb_method
:
# it may exist by the time we run create_pool().
lb_method
=
'round_robin'
# this catches the exception and does something smart
create_pool
(
api
,
pool
,
lb_method
)
# about it!
if
monitors
:
try
:
set_monitors
(
api
,
pool
,
monitor_type
,
quorum
,
monitors
)
create_pool
(
api
,
pool
,
lb_method
)
if
slow_ramp_time
:
result
=
{
'changed'
:
True
}
set_slow_ramp_time
(
api
,
pool
,
slow_ramp_time
)
except
bigsuds
.
OperationFailed
,
e
:
if
service_down_action
:
if
"already exists"
in
str
(
e
):
set_action_on_service_down
(
api
,
pool
,
service_down_action
)
update
=
True
if
host
and
port
:
else
:
add_pool_member
(
api
,
pool
,
address
,
port
)
# genuine exception
result
=
{
'changed'
:
True
}
raise
else
:
if
monitors
:
set_monitors
(
api
,
pool
,
monitor_type
,
quorum
,
monitors
)
if
slow_ramp_time
:
set_slow_ramp_time
(
api
,
pool
,
slow_ramp_time
)
if
service_down_action
:
set_action_on_service_down
(
api
,
pool
,
service_down_action
)
if
host
and
port
:
add_pool_member
(
api
,
pool
,
address
,
port
)
else
:
# check-mode return value
result
=
{
'changed'
:
True
}
else
:
else
:
# pool exists -- potentially modify attributes
# pool exists -- potentially modify attributes
update
=
True
if
update
:
if
lb_method
and
lb_method
!=
get_lb_method
(
api
,
pool
):
if
lb_method
and
lb_method
!=
get_lb_method
(
api
,
pool
):
if
not
module
.
check_mode
:
if
not
module
.
check_mode
:
set_lb_method
(
api
,
pool
,
lb_method
)
set_lb_method
(
api
,
pool
,
lb_method
)
...
...
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