Add wait functionality to API domain-state
This commit is contained in:
parent
b1c19a21ba
commit
e8d8fb161b
|
@ -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:
|
||||
|
|
|
@ -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/<node>/domain-state')
|
||||
|
||||
|
|
Loading…
Reference in New Issue