diff --git a/client-api/api_lib/pvcapi_helper.py b/client-api/api_lib/pvcapi_helper.py index 335737b5..4e2b2da6 100755 --- a/client-api/api_lib/pvcapi_helper.py +++ b/client-api/api_lib/pvcapi_helper.py @@ -201,12 +201,12 @@ def node_primary(node): } return output, retcode -def node_flush(node): +def node_flush(node, wait): """ Flush NODE of running VMs. """ zk_conn = pvc_common.startZKConnection(config['coordinators']) - retflag, retdata = pvc_node.flush_node(zk_conn, node, False) + retflag, retdata = pvc_node.flush_node(zk_conn, node, wait) if retflag: retcode = 200 else: @@ -218,12 +218,12 @@ def node_flush(node): } return output, retcode -def node_ready(node): +def node_ready(node, wait): """ Restore NODE to active service. """ zk_conn = pvc_common.startZKConnection(config['coordinators']) - retflag, retdata = pvc_node.ready_node(zk_conn, node) + retflag, retdata = pvc_node.ready_node(zk_conn, node, wait) if retflag: retcode = 200 else: diff --git a/client-api/pvc-api.py b/client-api/pvc-api.py index 0a537740..c9ff3fe4 100755 --- a/client-api/pvc-api.py +++ b/client-api/pvc-api.py @@ -567,7 +567,8 @@ class API_Node_DomainState(Resource): return api_helper.node_domain_state(node) @RequestParser([ - { 'name': 'state', 'choices': ('ready', 'flush'), 'helptext': "A valid state must be specified", 'required': True } + { 'name': 'state', 'choices': ('ready', 'flush'), 'helptext': "A valid state must be specified", 'required': True }, + { 'name': 'wait' } ]) @Authenticator def post(self, node, reqargs): @@ -585,6 +586,10 @@ class API_Node_DomainState(Resource): enum: - flush - ready + - in: query + name: wait + type: boolean + description: Whether to block waiting for the full flush/ready state responses: 200: description: OK @@ -598,9 +603,9 @@ class API_Node_DomainState(Resource): id: Message """ if reqargs['state'] == 'flush': - return api_helper.node_flush(node) + return api_helper.node_flush(node, reqargs.get('wait', None)) if reqargs['state'] == 'ready': - return api_helper.node_ready(node) + return api_helper.node_ready(node, reqargs.get('wait', None)) abort(400) api.add_resource(API_Node_DomainState, '/node//domain-state')