2019-03-21 11:19:28 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# pvcapi.py - PVC HTTP API interface
|
|
|
|
# Part of the Parallel Virtual Cluster (PVC) system
|
|
|
|
#
|
|
|
|
# Copyright (C) 2018 Joshua M. Boniface <joshua@boniface.me>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
import flask
|
2019-04-12 16:59:26 -04:00
|
|
|
import json
|
2019-03-21 11:19:28 -04:00
|
|
|
|
|
|
|
import client_lib.common as pvc_common
|
|
|
|
import client_lib.node as pvc_node
|
|
|
|
import client_lib.vm as pvc_vm
|
|
|
|
import client_lib.network as pvc_network
|
|
|
|
import client_lib.ceph as pvc_ceph
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
import api_lib.api as api
|
|
|
|
|
2019-03-21 11:19:28 -04:00
|
|
|
zk_host = "hv1:2181,hv2:2181,hv3:2181"
|
|
|
|
|
|
|
|
pvcapi = flask.Flask(__name__)
|
|
|
|
pvcapi.config["DEBUG"] = True
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1', methods=['GET'])
|
|
|
|
def api_root():
|
2019-07-05 01:19:39 -04:00
|
|
|
return "PVC API version 1", 209
|
2019-03-21 11:19:28 -04:00
|
|
|
|
2019-07-05 01:19:39 -04:00
|
|
|
#
|
|
|
|
# Node endpoints
|
|
|
|
#
|
2019-03-21 11:19:28 -04:00
|
|
|
@pvcapi.route('/api/v1/node', methods=['GET'])
|
|
|
|
def api_node():
|
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
Return a list of nodes with limit LIMIT.
|
2019-03-21 11:19:28 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
# Get limit
|
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retdata = pvc_node.get_list(zk_conn, limit)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
2019-03-21 11:19:28 -04:00
|
|
|
|
2019-04-12 12:27:49 -04:00
|
|
|
@pvcapi.route('/api/v1/node/secondary', methods=['POST'])
|
2019-03-21 11:19:28 -04:00
|
|
|
def api_node_secondary():
|
|
|
|
"""
|
|
|
|
Take NODE out of primary router mode.
|
|
|
|
"""
|
2019-04-12 16:59:26 -04:00
|
|
|
# Get node
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'node' in flask.request.values:
|
|
|
|
node = flask.request.values['node']
|
2019-03-21 11:19:28 -04:00
|
|
|
else:
|
2019-04-12 16:59:26 -04:00
|
|
|
return "Error: No node provided. Please specify a node.\n", 510
|
2019-03-21 11:19:28 -04:00
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retmsg = pvc_node.secondary_node(zk_conn, node)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
output = {
|
|
|
|
'message': retmsg,
|
|
|
|
}
|
|
|
|
return flask.jsonify(output), retcode
|
|
|
|
|
2019-04-12 12:27:49 -04:00
|
|
|
@pvcapi.route('/api/v1/node/primary', methods=['POST'])
|
2019-03-21 11:19:28 -04:00
|
|
|
def api_node_primary():
|
|
|
|
"""
|
|
|
|
Set NODE to primary router mode.
|
|
|
|
"""
|
2019-04-12 16:59:26 -04:00
|
|
|
# Get node
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'node' in flask.request.values:
|
|
|
|
node = flask.request.values['node']
|
2019-03-21 11:19:28 -04:00
|
|
|
else:
|
2019-04-12 16:59:26 -04:00
|
|
|
return "Error: No node provided. Please specify a node.\n", 510
|
2019-03-21 11:19:28 -04:00
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retmsg = pvc_node.primary_node(zk_conn, node)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
output = {
|
|
|
|
'message': retmsg,
|
|
|
|
}
|
|
|
|
return flask.jsonify(output), retcode
|
|
|
|
|
2019-04-12 16:59:26 -04:00
|
|
|
@pvcapi.route('/api/v1/node/flush', methods=['POST'])
|
|
|
|
def api_node_flush():
|
|
|
|
"""
|
|
|
|
Flush NODE of running VMs.
|
|
|
|
"""
|
|
|
|
# Get node
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'node' in flask.request.values:
|
|
|
|
node = flask.request.values['node']
|
2019-04-12 16:59:26 -04:00
|
|
|
else:
|
|
|
|
return "Error: No node provided. Please specify a node.\n", 510
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retmsg = pvc_node.flush_node(zk_conn, node, False)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
output = {
|
|
|
|
'message': retmsg,
|
|
|
|
}
|
|
|
|
return flask.jsonify(output), retcode
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/node/unflush', methods=['POST'])
|
|
|
|
@pvcapi.route('/api/v1/node/ready', methods=['POST'])
|
|
|
|
def api_node_ready():
|
|
|
|
"""
|
|
|
|
Restore NODE to active service.
|
|
|
|
"""
|
|
|
|
# Get node
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'node' in flask.request.values:
|
|
|
|
node = flask.request.values['node']
|
2019-04-12 16:59:26 -04:00
|
|
|
else:
|
|
|
|
return "Error: No node provided. Please specify a node.\n", 510
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retmsg = pvc_node.ready_node(zk_conn, node)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
output = {
|
|
|
|
'message': retmsg,
|
|
|
|
}
|
|
|
|
return flask.jsonify(output), retcode
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
#
|
|
|
|
# VM endpoints
|
|
|
|
#
|
|
|
|
@pvcapi.route('/api/v1/vm', methods=['GET'])
|
|
|
|
def api_vm():
|
2019-07-04 12:56:17 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
Return a list of VMs with limit LIMIT.
|
2019-07-04 12:56:17 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
# Get node limit
|
|
|
|
if 'node' in flask.request.values:
|
|
|
|
node = flask.request.values['node']
|
|
|
|
else:
|
|
|
|
node = None
|
|
|
|
|
|
|
|
# Get state limit
|
|
|
|
if 'state' in flask.request.values:
|
|
|
|
state = flask.request.values['state']
|
|
|
|
else:
|
|
|
|
state = None
|
|
|
|
|
|
|
|
# Get name limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
2019-07-04 12:56:17 -04:00
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
2019-07-05 13:20:06 -04:00
|
|
|
retflag, retdata = pvc_vm.get_list(zk_conn, node, state, limit)
|
2019-07-04 12:56:17 -04:00
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
2019-04-12 16:59:26 -04:00
|
|
|
|
2019-07-05 01:19:39 -04:00
|
|
|
@pvcapi.route('/api/v1/vm/add', methods=['POST'])
|
|
|
|
def api_vm_add():
|
|
|
|
"""
|
2019-07-05 13:05:33 -04:00
|
|
|
Add a VM named NAME to the PVC cluster.
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/define', methods=['POST'])
|
|
|
|
def api_vm_define():
|
|
|
|
"""
|
|
|
|
Define a VM from Libvirt XML in the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/modify', methods=['POST'])
|
|
|
|
def api_vm_modify():
|
|
|
|
"""
|
|
|
|
Modify a VM Libvirt XML in the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/undefine', methods=['POST'])
|
|
|
|
def api_vm_undefine():
|
|
|
|
"""
|
|
|
|
Undefine a VM from the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/dump', methods=['GET'])
|
|
|
|
def api_vm_dump():
|
|
|
|
"""
|
|
|
|
Dump a VM Libvirt XML configuration.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/start', methods=['POST'])
|
|
|
|
def api_vm_start():
|
|
|
|
"""
|
|
|
|
Start a VM in the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/restart', methods=['POST'])
|
|
|
|
def api_vm_restart():
|
|
|
|
"""
|
|
|
|
Restart a VM in the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/shutdown', methods=['POST'])
|
|
|
|
def api_vm_shutdown():
|
|
|
|
"""
|
|
|
|
Shutdown a VM in the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/stop', methods=['POST'])
|
|
|
|
def api_vm_stop():
|
|
|
|
"""
|
|
|
|
Forcibly stop a VM in the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/move', methods=['POST'])
|
|
|
|
def api_vm_move():
|
|
|
|
"""
|
|
|
|
Move a VM to another node.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/migrate', methods=['POST'])
|
|
|
|
def api_vm_migrate():
|
|
|
|
"""
|
|
|
|
Temporarily migrate a VM to another node.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/vm/unmigrate', methods=['POST'])
|
|
|
|
def api_vm_unmigrate():
|
|
|
|
"""
|
|
|
|
Unmigrate a migrated VM.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
#
|
|
|
|
# Network endpoints
|
|
|
|
#
|
|
|
|
@pvcapi.route('/api/v1/network', methods=['GET'])
|
|
|
|
def api_net():
|
2019-07-04 12:56:17 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
Return a list of client networks with limit LIMIT.
|
2019-07-04 12:56:17 -04:00
|
|
|
"""
|
|
|
|
# Get name limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
2019-07-04 12:56:17 -04:00
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
2019-07-05 13:20:06 -04:00
|
|
|
retflag, retdata = pvc_network.get_list(zk_conn, limit)
|
2019-07-04 12:56:17 -04:00
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
|
|
|
|
2019-07-05 01:19:39 -04:00
|
|
|
@pvcapi.route('/api/v1/network/add', methods=['POST'])
|
|
|
|
def api_net_add():
|
|
|
|
"""
|
|
|
|
Add a virtual client network to the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/network/modify', methods=['POST'])
|
|
|
|
def api_net_modify():
|
|
|
|
"""
|
|
|
|
Modify a virtual client network in the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/network/remove', methods=['POST'])
|
|
|
|
def api_net_remove():
|
|
|
|
"""
|
|
|
|
Remove a virtual client network from the PVC cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/network/dhcp', methods=['GET'])
|
|
|
|
def api_net_dhcp():
|
|
|
|
"""
|
|
|
|
Return a list of DHCP leases in network NETWORK with limit LIMIT.
|
|
|
|
"""
|
|
|
|
# Get network
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'network' in flask.request.values:
|
|
|
|
network = flask.request.values['network']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
return "Error: No network provided. Please specify a network.\n", 510
|
|
|
|
|
|
|
|
# Get name limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retdata = pvc_network.get_list_dhcp(zk_conn, network, limit, False)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/network/dhcp/static', methods=['GET'])
|
|
|
|
def api_net_dhcp_static():
|
|
|
|
"""
|
|
|
|
Return a list of static DHCP leases in network NETWORK with limit LIMIT.
|
|
|
|
"""
|
|
|
|
# Get network
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'network' in flask.request.values:
|
|
|
|
network = flask.request.values['network']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
return "Error: No network provided. Please specify a network.\n", 510
|
|
|
|
|
|
|
|
# Get name limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retdata = pvc_network.get_list_dhcp(zk_conn, network, limit, True)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
@pvcapi.route('/api/v1/network/dhcp/static/add', methods=['POST'])
|
|
|
|
def api_net_dhcp_static_add():
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
Add a static DHCP lease to a virtual client network.
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
@pvcapi.route('/api/v1/network/dhcp/static/remove', methods=['POST'])
|
|
|
|
def api_net_dhcp_static_remove():
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
Remove a static DHCP lease from a virtual client network.
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
@pvcapi.route('/api/v1/network/acl', methods=['GET'])
|
|
|
|
def api_net_acl():
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
|
|
|
Return a list of network ACLs in network NETWORK with limit LIMIT.
|
|
|
|
"""
|
|
|
|
# Get network
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'network' in flask.request.values:
|
|
|
|
network = flask.request.values['network']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
return "Error: No network provided. Please specify a network.\n", 510
|
|
|
|
|
|
|
|
# Get name limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
|
|
|
# Get direction limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'direction' in flask.request.values:
|
|
|
|
direction = flask.request.values['direction']
|
2019-07-05 01:19:39 -04:00
|
|
|
if not 'in' in direction or not 'out' in direction:
|
|
|
|
return "Error: Direction must be either 'in' or 'out'.\n", 510
|
|
|
|
else:
|
|
|
|
direction = None
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retdata = pvc_network.get_list_acl(zk_conn, network, limit, direction)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
@pvcapi.route('/api/v1/network/acl/add', methods=['POST'])
|
|
|
|
def api_net_acl_add():
|
|
|
|
"""
|
|
|
|
Add an ACL to a virtual client network.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/network/acl/remove', methods=['POST'])
|
|
|
|
def api_net_acl_remove():
|
|
|
|
"""
|
|
|
|
Remove an ACL from a virtual client network.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2019-07-05 01:19:39 -04:00
|
|
|
#
|
2019-03-21 11:19:28 -04:00
|
|
|
# Ceph endpoints
|
2019-07-05 01:19:39 -04:00
|
|
|
#
|
|
|
|
@pvcapi.route('/api/v1/ceph', methods=['GET'])
|
|
|
|
def api_ceph():
|
|
|
|
"""
|
|
|
|
Get the current Ceph cluster status.
|
|
|
|
"""
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retdata = pvc_ceph.get_status(zk_conn)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/osd', methods=['GET'])
|
|
|
|
def api_ceph_osd():
|
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
Get the list of OSDs in the Ceph storage cluster.
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
# Get name limit
|
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
|
|
|
retflag, retdata = pvc_ceph.get_list_osd(zk_conn, limit)
|
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
2019-07-05 01:19:39 -04:00
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/osd/add', methods=['POST'])
|
|
|
|
def api_ceph_osd_add():
|
|
|
|
"""
|
|
|
|
Add a Ceph OSD to the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/osd/remove', methods=['POST'])
|
|
|
|
def api_ceph_osd_remove():
|
|
|
|
"""
|
|
|
|
Remove a Ceph OSD from the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/osd/in', methods=['POST'])
|
|
|
|
def api_ceph_osd_in():
|
|
|
|
"""
|
|
|
|
Set in a Ceph OSD in the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/osd/out', methods=['POST'])
|
|
|
|
def api_ceph_osd_out():
|
|
|
|
"""
|
|
|
|
Set out a Ceph OSD in the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/osd/set', methods=['POST'])
|
|
|
|
def api_ceph_osd_set():
|
|
|
|
"""
|
|
|
|
Set options on a Ceph OSD in the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/osd/unset', methods=['POST'])
|
|
|
|
def api_ceph_osd_unset():
|
|
|
|
"""
|
|
|
|
Unset options on a Ceph OSD in the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
2019-03-21 11:19:28 -04:00
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
@pvcapi.route('/api/v1/ceph/pool', methods=['GET'])
|
|
|
|
def api_ceph_pool():
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
Get the list of RBD pools in the Ceph storage cluster.
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
|
|
|
# Get name limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
2019-07-05 13:20:06 -04:00
|
|
|
retflag, retdata = pvc_ceph.get_list_pool(zk_conn, limit)
|
2019-07-05 01:19:39 -04:00
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/pool/add', methods=['POST'])
|
|
|
|
def api_ceph_pool_add():
|
|
|
|
"""
|
|
|
|
Add a Ceph RBD pool to the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/pool/remove', methods=['POST'])
|
|
|
|
def api_ceph_pool_remove():
|
|
|
|
"""
|
|
|
|
Remove a Ceph RBD pool to the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
@pvcapi.route('/api/v1/ceph/volume', methods=['GET'])
|
|
|
|
def api_ceph_volume():
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
Get the list of RBD volumes in the Ceph storage cluster.
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
|
|
|
# Get name limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
# Get pool limit
|
|
|
|
if 'pool' in flask.request.values:
|
|
|
|
pool = flask.request.values['pool']
|
|
|
|
else:
|
|
|
|
pool = 'all'
|
|
|
|
|
2019-07-05 01:19:39 -04:00
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
2019-07-05 13:20:06 -04:00
|
|
|
retflag, retdata = pvc_ceph.get_list_volume(zk_conn, pool, limit)
|
2019-07-05 01:19:39 -04:00
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/volume/add', methods=['POST'])
|
|
|
|
def api_ceph_volume_add():
|
|
|
|
"""
|
|
|
|
Add a Ceph RBD volume to the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/volume/remove', methods=['POST'])
|
|
|
|
def api_ceph_volume_remove():
|
|
|
|
"""
|
|
|
|
Remove a Ceph RBD volume to the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
@pvcapi.route('/api/v1/ceph/volume/snapshot', methods=['GET'])
|
|
|
|
def api_ceph_volume_snapshot():
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
2019-07-05 13:20:06 -04:00
|
|
|
Get the list of RBD volume snapshots in the Ceph storage cluster.
|
2019-07-05 01:19:39 -04:00
|
|
|
"""
|
|
|
|
# Get name limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'limit' in flask.request.values:
|
|
|
|
limit = flask.request.values['limit']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
limit = None
|
|
|
|
|
2019-07-05 13:20:06 -04:00
|
|
|
# Get volume limit
|
|
|
|
if 'volume' in flask.request.values:
|
|
|
|
volume = flask.request.values['volume']
|
|
|
|
else:
|
|
|
|
volume = 'all'
|
|
|
|
|
2019-07-05 01:19:39 -04:00
|
|
|
# Get pool limit
|
2019-07-05 13:05:33 -04:00
|
|
|
if 'pool' in flask.request.values:
|
|
|
|
pool = flask.request.values['pool']
|
2019-07-05 01:19:39 -04:00
|
|
|
else:
|
|
|
|
pool = 'all'
|
|
|
|
|
|
|
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
2019-07-05 13:20:06 -04:00
|
|
|
retflag, retdata = pvc_ceph.get_list_snapshot(zk_conn, pool, volume, limit)
|
2019-07-05 01:19:39 -04:00
|
|
|
if retflag:
|
|
|
|
retcode = 200
|
|
|
|
else:
|
|
|
|
retcode = 510
|
|
|
|
|
|
|
|
pvc_common.stopZKConnection(zk_conn)
|
|
|
|
return flask.jsonify(retdata), retcode
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/volume/snapshot/add', methods=['POST'])
|
|
|
|
def api_ceph_volume_snapshot_add():
|
|
|
|
"""
|
|
|
|
Add a Ceph RBD volume snapshot to the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@pvcapi.route('/api/v1/ceph/volume/snapshot/remove', methods=['POST'])
|
|
|
|
def api_ceph_volume_snapshot_remove():
|
|
|
|
"""
|
|
|
|
Remove a Ceph RBD volume snapshot to the PVC Ceph storage cluster.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
#
|
|
|
|
# Entrypoint
|
|
|
|
#
|
2019-03-21 11:19:28 -04:00
|
|
|
pvcapi.run()
|