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
e8217705
Commit
e8217705
authored
Dec 23, 2013
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow respecification of a node without requiring node_id
parent
621fcbb9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
18 deletions
+15
-18
library/cloud/rax_clb_nodes
+15
-18
No files found.
library/cloud/rax_clb_nodes
View file @
e8217705
...
...
@@ -135,11 +135,21 @@ def _activate_virtualenv(path):
execfile
(
activate_this
,
dict
(
__file__
=
activate_this
))
def
_get_node
(
lb
,
node_id
):
"""Return a node with the given `node_id`"""
for
node
in
lb
.
nodes
:
if
node
.
id
==
node_id
:
def
_get_node
(
lb
,
node_id
=
None
,
address
=
None
,
port
=
None
):
"""Return a matching node"""
searches
=
{
'id'
:
node_id
,
'address'
:
address
,
'port'
:
port
}
for
node
in
getattr
(
lb
,
'nodes'
,
[]):
try
:
if
all
(
getattr
(
node
,
attr
)
==
value
for
(
attr
,
value
)
in
searches
.
items
()
if
value
is
not
None
):
return
node
except
AttributeError
:
continue
return
None
...
...
@@ -230,10 +240,7 @@ def main():
except
pyrax
.
exc
.
PyraxException
,
e
:
module
.
fail_json
(
msg
=
'
%
s'
%
e
.
message
)
if
node_id
:
node
=
_get_node
(
lb
,
node_id
)
else
:
node
=
None
node
=
_get_node
(
lb
,
node_id
,
address
,
port
)
result
=
_node_to_dict
(
node
)
...
...
@@ -272,22 +279,12 @@ def main():
except
pyrax
.
exc
.
PyraxException
,
e
:
module
.
fail_json
(
msg
=
'
%
s'
%
e
.
message
)
else
:
# Updating an existing node
immutable
=
{
'address'
:
address
,
'port'
:
port
,
}
mutable
=
{
'condition'
:
condition
,
'type'
:
typ
,
'weight'
:
weight
,
}
for
name
,
value
in
immutable
.
items
():
if
value
:
module
.
fail_json
(
msg
=
'Attribute
%
s cannot be modified'
%
name
)
for
name
,
value
in
mutable
.
items
():
if
value
is
None
or
value
==
getattr
(
node
,
name
):
mutable
.
pop
(
name
)
...
...
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