Implement cluster maintenance mode
Implements a "maintenance mode" for PVC clusters. For now, the only thing this mode does is disable node fencing while the state is true. This allows the administrator to tell PVC that network connectivity, etc. might be interrupted and to avoid fencing nodes. Closes #70
This commit is contained in:
@ -47,6 +47,7 @@ def initialize_cluster():
|
||||
transaction = zk_conn.transaction()
|
||||
transaction.create('/primary_node', 'none'.encode('ascii'))
|
||||
transaction.create('/upstream_ip', 'none'.encode('ascii'))
|
||||
transaction.create('/maintenance', 'False'.encode('ascii'))
|
||||
transaction.create('/nodes', ''.encode('ascii'))
|
||||
transaction.create('/domains', ''.encode('ascii'))
|
||||
transaction.create('/networks', ''.encode('ascii'))
|
||||
@ -69,7 +70,7 @@ def initialize_cluster():
|
||||
return True
|
||||
|
||||
#
|
||||
# Status function
|
||||
# Cluster functions
|
||||
#
|
||||
def cluster_status():
|
||||
"""
|
||||
@ -81,6 +82,24 @@ def cluster_status():
|
||||
|
||||
return retdata, 200
|
||||
|
||||
def cluster_maintenance(maint_state='false'):
|
||||
"""
|
||||
Set the cluster in or out of maintenance state
|
||||
"""
|
||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
||||
retflag, retdata = pvc_cluster.set_maintenance(zk_conn, maint_state)
|
||||
pvc_common.stopZKConnection(zk_conn)
|
||||
|
||||
retdata = {
|
||||
'message': retdata
|
||||
}
|
||||
if retflag:
|
||||
retcode = 200
|
||||
else:
|
||||
retcode = 400
|
||||
|
||||
return retdata, retcode
|
||||
|
||||
#
|
||||
# Node functions
|
||||
#
|
||||
|
@ -390,6 +390,37 @@ class API_Status(Resource):
|
||||
description: Bad request
|
||||
"""
|
||||
return api_helper.cluster_status()
|
||||
|
||||
@RequestParser([
|
||||
{ 'name': 'state', 'choices': ('true', 'false'), 'required': True, 'helpmsg': "A valid state must be specified" }
|
||||
])
|
||||
@Authenticator
|
||||
def post(self, reqargs):
|
||||
"""
|
||||
Set the cluster maintenance mode
|
||||
---
|
||||
tags:
|
||||
- node
|
||||
parameters:
|
||||
- in: query
|
||||
name: state
|
||||
type: boolean
|
||||
required: true
|
||||
description: The cluster maintenance state
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
schema:
|
||||
type: object
|
||||
id: Message
|
||||
400:
|
||||
description: Bad request
|
||||
schema:
|
||||
type: object
|
||||
id: Message
|
||||
"""
|
||||
return api_helper.cluster_maintenance(reqargs.get('state', 'false'))
|
||||
|
||||
api.add_resource(API_Status, '/status')
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user