Implement wait for node coordinator transition

References #72
This commit is contained in:
2020-02-19 10:33:22 -05:00
parent 6db4df51c0
commit 0aefafa7f7
5 changed files with 48 additions and 15 deletions

View File

@ -26,7 +26,7 @@ from cli_lib.common import call_api
#
# Primary functions
#
def node_coordinator_state(config, node, action):
def node_coordinator_state(config, node, action, wait):
"""
Set node coordinator state state (primary/secondary)
@ -35,7 +35,8 @@ def node_coordinator_state(config, node, action):
API schema: {"message": "{data}"}
"""
params={
'state': action
'state': action,
'wait': str(wait).lower()
}
response = call_api(config, 'post', '/node/{node}/coordinator-state'.format(node=node), params=params)

View File

@ -348,7 +348,11 @@ def cli_node():
@click.argument(
'node'
)
def node_secondary(node):
@click.option(
'-w', '--wait', 'wait', is_flag=True, default=False,
help='Wait for transition to complete before returning.'
)
def node_secondary(node, wait):
"""
Take NODE out of primary router mode.
"""
@ -360,7 +364,7 @@ def node_secondary(node):
click.echo(" node returns to primary state.")
click.echo()
retcode, retmsg = pvc_node.node_coordinator_state(config, node, 'secondary')
retcode, retmsg = pvc_node.node_coordinator_state(config, node, 'secondary', wait)
cleanup(retcode, retmsg)
###############################################################################
@ -370,7 +374,11 @@ def node_secondary(node):
@click.argument(
'node'
)
def node_primary(node):
@click.option(
'-w', '--wait', 'wait', is_flag=True, default=False,
help='Wait for transition to complete before returning.'
)
def node_primary(node, wait):
"""
Put NODE into primary router mode.
"""
@ -382,7 +390,7 @@ def node_primary(node):
click.echo(" node returns to primary state.")
click.echo()
retcode, retmsg = pvc_node.node_coordinator_state(config, node, 'primary')
retcode, retmsg = pvc_node.node_coordinator_state(config, node, 'primary', wait)
cleanup(retcode, retmsg)
###############################################################################