Allow secondary routers again and handle them better
This reverts commit 07a6ef0fba
.
This commit is contained in:
parent
1527c628af
commit
1483db3c2d
|
@ -158,6 +158,22 @@ def cli_router():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# pvc router secondary
|
||||||
|
###############################################################################
|
||||||
|
@click.command(name='secondary', short_help='Set a router in secondary status.')
|
||||||
|
@click.argument(
|
||||||
|
'router'
|
||||||
|
)
|
||||||
|
def router_secondary(router):
|
||||||
|
"""
|
||||||
|
Take ROUTER out of primary mode handling gateways and into secondary mode.
|
||||||
|
"""
|
||||||
|
|
||||||
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
||||||
|
retcode, retmsg = pvc_router.secondary_router(zk_conn, router)
|
||||||
|
cleanup(retcode, retmsg, zk_conn)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# pvc router primary
|
# pvc router primary
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -874,6 +890,7 @@ cli_node.add_command(node_unflush)
|
||||||
cli_node.add_command(node_info)
|
cli_node.add_command(node_info)
|
||||||
cli_node.add_command(node_list)
|
cli_node.add_command(node_list)
|
||||||
|
|
||||||
|
cli_router.add_command(router_secondary)
|
||||||
cli_router.add_command(router_primary)
|
cli_router.add_command(router_primary)
|
||||||
cli_router.add_command(router_info)
|
cli_router.add_command(router_info)
|
||||||
cli_router.add_command(router_list)
|
cli_router.add_command(router_list)
|
||||||
|
|
|
@ -86,15 +86,38 @@ def getInformationFromRouter(zk_conn, router_name, long_output):
|
||||||
#
|
#
|
||||||
# Direct Functions
|
# Direct Functions
|
||||||
#
|
#
|
||||||
|
def secondary_router(zk_conn, router):
|
||||||
|
# Verify router is valid
|
||||||
|
if not common.verifyRouter(zk_conn, router):
|
||||||
|
return False, 'ERROR: No router named "{}" is present in the cluster.'.format(router)
|
||||||
|
|
||||||
|
# Get current state
|
||||||
|
current_state = zkhandler.readdata(zk_conn, '/routers/{}/networkstate'.format(router))
|
||||||
|
if current_state == 'primary':
|
||||||
|
click.echo('Setting router {} in secondary mode.'.format(router))
|
||||||
|
zkhandler.writedata(zk_conn, {
|
||||||
|
'/routers': 'none'
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
click.echo('Router {} is already in secondary mode.'.format(router))
|
||||||
|
|
||||||
|
return True, ''
|
||||||
|
|
||||||
def primary_router(zk_conn, router):
|
def primary_router(zk_conn, router):
|
||||||
# Verify router is valid
|
# Verify router is valid
|
||||||
if not common.verifyRouter(zk_conn, router):
|
if not common.verifyRouter(zk_conn, router):
|
||||||
return False, 'ERROR: No router named "{}" is present in the cluster.'.format(router)
|
return False, 'ERROR: No router named "{}" is present in the cluster.'.format(router)
|
||||||
|
|
||||||
|
# Get current state
|
||||||
|
current_state = zkhandler.readdata(zk_conn, '/routers/{}/networkstate'.format(router))
|
||||||
|
if current_state == 'secondary':
|
||||||
click.echo('Setting router {} in primary mode.'.format(router))
|
click.echo('Setting router {} in primary mode.'.format(router))
|
||||||
zkhandler.writedata(zk_conn, {
|
zkhandler.writedata(zk_conn, {
|
||||||
'/routers': router
|
'/routers': router
|
||||||
})
|
})
|
||||||
|
else:
|
||||||
|
click.echo('Router {} is already in primary mode.'.format(router))
|
||||||
|
|
||||||
return True, ''
|
return True, ''
|
||||||
|
|
||||||
def get_info(zk_conn, router, long_output):
|
def get_info(zk_conn, router, long_output):
|
||||||
|
|
Loading…
Reference in New Issue