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
|
return output, retcode
|
||||||
|
|
||||||
def node_flush(node):
|
def node_flush(node, wait):
|
||||||
"""
|
"""
|
||||||
Flush NODE of running VMs.
|
Flush NODE of running VMs.
|
||||||
"""
|
"""
|
||||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
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:
|
if retflag:
|
||||||
retcode = 200
|
retcode = 200
|
||||||
else:
|
else:
|
||||||
|
@ -218,12 +218,12 @@ def node_flush(node):
|
||||||
}
|
}
|
||||||
return output, retcode
|
return output, retcode
|
||||||
|
|
||||||
def node_ready(node):
|
def node_ready(node, wait):
|
||||||
"""
|
"""
|
||||||
Restore NODE to active service.
|
Restore NODE to active service.
|
||||||
"""
|
"""
|
||||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
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:
|
if retflag:
|
||||||
retcode = 200
|
retcode = 200
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -567,7 +567,8 @@ class API_Node_DomainState(Resource):
|
||||||
return api_helper.node_domain_state(node)
|
return api_helper.node_domain_state(node)
|
||||||
|
|
||||||
@RequestParser([
|
@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
|
@Authenticator
|
||||||
def post(self, node, reqargs):
|
def post(self, node, reqargs):
|
||||||
|
@ -585,6 +586,10 @@ class API_Node_DomainState(Resource):
|
||||||
enum:
|
enum:
|
||||||
- flush
|
- flush
|
||||||
- ready
|
- ready
|
||||||
|
- in: query
|
||||||
|
name: wait
|
||||||
|
type: boolean
|
||||||
|
description: Whether to block waiting for the full flush/ready state
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: OK
|
description: OK
|
||||||
|
@ -598,9 +603,9 @@ class API_Node_DomainState(Resource):
|
||||||
id: Message
|
id: Message
|
||||||
"""
|
"""
|
||||||
if reqargs['state'] == 'flush':
|
if reqargs['state'] == 'flush':
|
||||||
return api_helper.node_flush(node)
|
return api_helper.node_flush(node, reqargs.get('wait', None))
|
||||||
if reqargs['state'] == 'ready':
|
if reqargs['state'] == 'ready':
|
||||||
return api_helper.node_ready(node)
|
return api_helper.node_ready(node, reqargs.get('wait', None))
|
||||||
abort(400)
|
abort(400)
|
||||||
api.add_resource(API_Node_DomainState, '/node/<node>/domain-state')
|
api.add_resource(API_Node_DomainState, '/node/<node>/domain-state')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue