It is not correct that you need at least 1 primary node
This commit is contained in:
parent
fbb9dcc69a
commit
b2fd4d18e0
1 changed files with 1 additions and 23 deletions
|
@ -150,21 +150,6 @@ def _get_node(lb, node_id=None, address=None, port=None):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _is_primary(node):
|
|
||||||
"""Return True if node is primary and enabled"""
|
|
||||||
return (node.type.lower() == 'primary' and
|
|
||||||
node.condition.lower() == 'enabled')
|
|
||||||
|
|
||||||
|
|
||||||
def _get_primary_nodes(lb):
|
|
||||||
"""Return a list of primary and enabled nodes"""
|
|
||||||
nodes = []
|
|
||||||
for node in lb.nodes:
|
|
||||||
if _is_primary(node):
|
|
||||||
nodes.append(node)
|
|
||||||
return nodes
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = rax_argument_spec()
|
argument_spec = rax_argument_spec()
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
|
@ -230,13 +215,6 @@ def main():
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
if not node: # Removing a non-existent node
|
if not node: # Removing a non-existent node
|
||||||
module.exit_json(changed=False, state=state)
|
module.exit_json(changed=False, state=state)
|
||||||
|
|
||||||
# The API detects this as well but currently pyrax does not return a
|
|
||||||
# meaningful error message
|
|
||||||
if _is_primary(node) and len(_get_primary_nodes(lb)) == 1:
|
|
||||||
module.fail_json(
|
|
||||||
msg='At least one primary node has to be enabled')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lb.delete_node(node)
|
lb.delete_node(node)
|
||||||
result = {}
|
result = {}
|
||||||
|
@ -299,5 +277,5 @@ def main():
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
from ansible.module_utils.rax import *
|
from ansible.module_utils.rax import *
|
||||||
|
|
||||||
### invoke the module
|
# invoke the module
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue