Further work on API client
Add list and info endpoints for all areas; add dummy endpoints for all remaining endpoints.
This commit is contained in:
parent
d755a80fe8
commit
193567f965
|
@ -36,14 +36,15 @@ pvcapi.config["DEBUG"] = True
|
||||||
|
|
||||||
@pvcapi.route('/api/v1', methods=['GET'])
|
@pvcapi.route('/api/v1', methods=['GET'])
|
||||||
def api_root():
|
def api_root():
|
||||||
print(flask.request)
|
return "PVC API version 1", 209
|
||||||
print(flask.request.args)
|
|
||||||
return "", 200
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Node endpoints
|
||||||
|
#
|
||||||
@pvcapi.route('/api/v1/node', methods=['GET'])
|
@pvcapi.route('/api/v1/node', methods=['GET'])
|
||||||
def api_node():
|
def api_node():
|
||||||
"""
|
"""
|
||||||
Manage the state of a node in the PVC cluster
|
Manage the state of a node in the PVC cluster.
|
||||||
"""
|
"""
|
||||||
return "Manage the state of a node in the PVC cluster.\n", 209
|
return "Manage the state of a node in the PVC cluster.\n", 209
|
||||||
|
|
||||||
|
@ -165,26 +166,100 @@ def api_node_list():
|
||||||
pvc_common.stopZKConnection(zk_conn)
|
pvc_common.stopZKConnection(zk_conn)
|
||||||
return flask.jsonify(retdata), retcode
|
return flask.jsonify(retdata), retcode
|
||||||
|
|
||||||
|
#
|
||||||
# VM endpoints
|
# VM endpoints
|
||||||
|
#
|
||||||
@pvcapi.route('/api/v1/vm', methods=['GET'])
|
@pvcapi.route('/api/v1/vm', methods=['GET'])
|
||||||
def api_vm():
|
def api_vm():
|
||||||
"""
|
"""
|
||||||
Manage the state of a VM in the PVC cluster
|
Manage the state of a VM in the PVC cluster.
|
||||||
"""
|
"""
|
||||||
return "Manage the state of a VM in the PVC cluster.\n", 209
|
return "Manage the state of a VM in the PVC cluster.\n", 209
|
||||||
|
|
||||||
#@pvcapi.route('/api/v1/vm/add', methods=['POST'])
|
@pvcapi.route('/api/v1/vm/add', methods=['POST'])
|
||||||
#@pvcapi.route('/api/v1/vm/define', methods=['POST'])
|
def api_vm_add():
|
||||||
#@pvcapi.route('/api/v1/vm/modify', methods=['POST'])
|
"""
|
||||||
#@pvcapi.route('/api/v1/vm/undefine', methods=['POST'])
|
Add a VM to the PVC cluster.
|
||||||
#@pvcapi.route('/api/v1/vm/dump', methods=['GET'])
|
"""
|
||||||
#@pvcapi.route('/api/v1/vm/start', methods=['POST'])
|
pass
|
||||||
#@pvcapi.route('/api/v1/vm/restart', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/vm/shutdown', methods=['POST'])
|
@pvcapi.route('/api/v1/vm/define', methods=['POST'])
|
||||||
#@pvcapi.route('/api/v1/vm/stop', methods=['POST'])
|
def api_vm_define():
|
||||||
#@pvcapi.route('/api/v1/vm/move', methods=['POST'])
|
"""
|
||||||
#@pvcapi.route('/api/v1/vm/migrate', methods=['POST'])
|
Define a VM from Libvirt XML in the PVC cluster.
|
||||||
#@pvcapi.route('/api/v1/vm/unmigrate', methods=['POST'])
|
"""
|
||||||
|
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
|
||||||
|
|
||||||
@pvcapi.route('/api/v1/vm/list', methods=['GET'])
|
@pvcapi.route('/api/v1/vm/list', methods=['GET'])
|
||||||
def api_vm_list():
|
def api_vm_list():
|
||||||
"""
|
"""
|
||||||
|
@ -218,36 +293,436 @@ def api_vm_list():
|
||||||
pvc_common.stopZKConnection(zk_conn)
|
pvc_common.stopZKConnection(zk_conn)
|
||||||
return flask.jsonify(retdata), retcode
|
return flask.jsonify(retdata), retcode
|
||||||
|
|
||||||
|
#
|
||||||
# Network endpoints
|
# Network endpoints
|
||||||
#@pvcapi.route('/api/v1/network', methods=['GET'])
|
#
|
||||||
#@pvcapi.route('/api/v1/network/add', methods=['POST'])
|
@pvcapi.route('/api/v1/network', methods=['GET'])
|
||||||
#@pvcapi.route('/api/v1/network/modify', methods=['POST'])
|
def api_net():
|
||||||
#@pvcapi.route('/api/v1/network/remove', methods=['POST'])
|
"""
|
||||||
#@pvcapi.route('/api/v1/network/list', methods=['GET'])
|
Manage the state of a client network in the PVC cluster.
|
||||||
#@pvcapi.route('/api/v1/network/dhcp', methods=['GET'])
|
"""
|
||||||
#@pvcapi.route('/api/v1/network/dhcp/list', methods=['GET'])
|
return "Manage the state of a VM in the PVC cluster.\n", 209
|
||||||
#@pvcapi.route('/api/v1/network/dhcp/static', methods=['GET'])
|
|
||||||
#@pvcapi.route('/api/v1/network/dhcp/static/add', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/network/dhcp/static/remove', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/network/dhcp/static/list', methods=['GET'])
|
|
||||||
#@pvcapi.route('/api/v1/network/acl', methods=['GET'])
|
|
||||||
#@pvcapi.route('/api/v1/network/acl/add', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/network/acl/remove', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/network/acl/list', methods=['GET'])
|
|
||||||
# Ceph endpoints
|
|
||||||
#@pvcapi.route('/api/v1/ceph', methods=['GET'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/status', methods=['GET'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/osd', methods=['GET'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/osd/add', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/osd/remove', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/osd/in', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/osd/out', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/osd/set', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/osd/unset', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/osd/list', methods=['GET'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/pool', methods=['GET'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/pool/add', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/pool/remove', methods=['POST'])
|
|
||||||
#@pvcapi.route('/api/v1/ceph/pool/list', methods=['GET'])
|
|
||||||
|
|
||||||
|
@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/list', methods=['GET'])
|
||||||
|
def api_net_list():
|
||||||
|
"""
|
||||||
|
Return a list of client networks with limit LIMIT.
|
||||||
|
"""
|
||||||
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.args:
|
||||||
|
limit = flask.request.args['limit']
|
||||||
|
else:
|
||||||
|
limit = None
|
||||||
|
|
||||||
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
||||||
|
retflag, retdata = pvc_network.get_list(zk_conn, limit)
|
||||||
|
if retflag:
|
||||||
|
retcode = 200
|
||||||
|
else:
|
||||||
|
retcode = 510
|
||||||
|
|
||||||
|
pvc_common.stopZKConnection(zk_conn)
|
||||||
|
return flask.jsonify(retdata), retcode
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/network/dhcp', methods=['GET'])
|
||||||
|
def api_net_dhcp():
|
||||||
|
"""
|
||||||
|
Manage the state of a client network DHCP in the PVC cluster.
|
||||||
|
"""
|
||||||
|
return "Manage the state of a VM in the PVC cluster.\n", 209
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/network/dhcp/list', methods=['GET'])
|
||||||
|
def api_net_dhcp_list():
|
||||||
|
"""
|
||||||
|
Return a list of DHCP leases in network NETWORK with limit LIMIT.
|
||||||
|
"""
|
||||||
|
# Get network
|
||||||
|
if 'network' in flask.request.args:
|
||||||
|
network = flask.request.args['network']
|
||||||
|
else:
|
||||||
|
return "Error: No network provided. Please specify a network.\n", 510
|
||||||
|
|
||||||
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.args:
|
||||||
|
limit = flask.request.args['limit']
|
||||||
|
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():
|
||||||
|
"""
|
||||||
|
Manage the state of a client network static DHCP lease in the PVC cluster.
|
||||||
|
"""
|
||||||
|
return "Manage the state of a VM in the PVC cluster.\n", 209
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/network/dhcp/static/add', methods=['POST'])
|
||||||
|
def api_net_dhcp_static_add():
|
||||||
|
"""
|
||||||
|
Add a static DHCP lease to a virtual client network.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/network/dhcp/static/remove', methods=['POST'])
|
||||||
|
def api_net_dhcp_static_remove():
|
||||||
|
"""
|
||||||
|
Remove a static DHCP lease from a virtual client network.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/network/dhcp/static/list', methods=['GET'])
|
||||||
|
def api_net_dhcp_static_list():
|
||||||
|
"""
|
||||||
|
Return a list of static DHCP leases in network NETWORK with limit LIMIT.
|
||||||
|
"""
|
||||||
|
# Get network
|
||||||
|
if 'network' in flask.request.args:
|
||||||
|
network = flask.request.args['network']
|
||||||
|
else:
|
||||||
|
return "Error: No network provided. Please specify a network.\n", 510
|
||||||
|
|
||||||
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.args:
|
||||||
|
limit = flask.request.args['limit']
|
||||||
|
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
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/network/acl', methods=['GET'])
|
||||||
|
def api_net_acl():
|
||||||
|
"""
|
||||||
|
Manage the state of a client network ACL in the PVC cluster.
|
||||||
|
"""
|
||||||
|
return "Manage the state of a VM in the PVC cluster.\n", 209
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/network/acl/list', methods=['GET'])
|
||||||
|
def api_net_acl_list():
|
||||||
|
"""
|
||||||
|
Return a list of network ACLs in network NETWORK with limit LIMIT.
|
||||||
|
"""
|
||||||
|
# Get network
|
||||||
|
if 'network' in flask.request.args:
|
||||||
|
network = flask.request.args['network']
|
||||||
|
else:
|
||||||
|
return "Error: No network provided. Please specify a network.\n", 510
|
||||||
|
|
||||||
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.args:
|
||||||
|
limit = flask.request.args['limit']
|
||||||
|
else:
|
||||||
|
limit = None
|
||||||
|
|
||||||
|
# Get direction limit
|
||||||
|
if 'direction' in flask.request.args:
|
||||||
|
direction = flask.request.args['direction']
|
||||||
|
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
|
||||||
|
|
||||||
|
#
|
||||||
|
# Ceph endpoints
|
||||||
|
#
|
||||||
|
@pvcapi.route('/api/v1/ceph', methods=['GET'])
|
||||||
|
def api_ceph():
|
||||||
|
"""
|
||||||
|
Manage the state of the Ceph storage cluster.
|
||||||
|
"""
|
||||||
|
return "Manage the state of the Ceph storage cluster.\n", 209
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/ceph/status', methods=['GET'])
|
||||||
|
def api_ceph_status():
|
||||||
|
"""
|
||||||
|
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():
|
||||||
|
"""
|
||||||
|
Manage the state of OSDs in the Ceph storage cluster.
|
||||||
|
"""
|
||||||
|
return "Manage the state of OSDs in the Ceph storage cluster.\n", 209
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/ceph/osd/list', methods=['GET'])
|
||||||
|
def api_ceph_osd_list():
|
||||||
|
"""
|
||||||
|
Get the list of OSDs in the Ceph storage cluster.
|
||||||
|
"""
|
||||||
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.args:
|
||||||
|
limit = flask.request.args['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
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/ceph/pool', methods=['GET'])
|
||||||
|
def api_ceph_pool():
|
||||||
|
"""
|
||||||
|
Manage the state of RBD pools in the Ceph storage cluster.
|
||||||
|
"""
|
||||||
|
return "Manage the state of RBD pools in the Ceph storage cluster.\n", 209
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/ceph/pool/list', methods=['GET'])
|
||||||
|
def api_ceph_pool_list():
|
||||||
|
"""
|
||||||
|
Get the list of RBD pools in the Ceph storage cluster.
|
||||||
|
"""
|
||||||
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.args:
|
||||||
|
limit = flask.request.args['limit']
|
||||||
|
else:
|
||||||
|
limit = None
|
||||||
|
|
||||||
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
||||||
|
retflag, retdata = pvc_ceph.get_list_pool(zk_conn, limit)
|
||||||
|
if retflag:
|
||||||
|
retcode = 200
|
||||||
|
else:
|
||||||
|
retcode = 510
|
||||||
|
|
||||||
|
pvc_common.stopZKConnection(zk_conn)
|
||||||
|
return flask.jsonify(retdata), retcode
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/ceph/volume', methods=['GET'])
|
||||||
|
def api_ceph_volume():
|
||||||
|
"""
|
||||||
|
Manage the state of RBD volumes in the Ceph storage cluster.
|
||||||
|
"""
|
||||||
|
return "Manage the state of RBD volumes in the Ceph storage cluster.\n", 209
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/ceph/volume/list', methods=['GET'])
|
||||||
|
def api_ceph_volume_list():
|
||||||
|
"""
|
||||||
|
Get the list of RBD volumes in the Ceph storage cluster.
|
||||||
|
"""
|
||||||
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.args:
|
||||||
|
limit = flask.request.args['limit']
|
||||||
|
else:
|
||||||
|
limit = None
|
||||||
|
|
||||||
|
# Get pool limit
|
||||||
|
if 'pool' in flask.request.args:
|
||||||
|
pool = flask.request.args['pool']
|
||||||
|
else:
|
||||||
|
pool = 'all'
|
||||||
|
|
||||||
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
||||||
|
retflag, retdata = pvc_ceph.get_list_volume(zk_conn, pool, limit)
|
||||||
|
if retflag:
|
||||||
|
retcode = 200
|
||||||
|
else:
|
||||||
|
retcode = 510
|
||||||
|
|
||||||
|
pvc_common.stopZKConnection(zk_conn)
|
||||||
|
return flask.jsonify(retdata), retcode
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/ceph/volume/snapshot', methods=['GET'])
|
||||||
|
def api_ceph_volume_snapshot():
|
||||||
|
"""
|
||||||
|
Manage the state of RBD volume snapshots in the Ceph storage cluster.
|
||||||
|
"""
|
||||||
|
return "Manage the state of RBD volume snapshots in the Ceph storage cluster.\n", 209
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@pvcapi.route('/api/v1/ceph/volume/snapshot/list', methods=['GET'])
|
||||||
|
def api_ceph_volume_snapshot_list():
|
||||||
|
"""
|
||||||
|
Get the list of RBD volume snapshots in the Ceph storage cluster.
|
||||||
|
"""
|
||||||
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.args:
|
||||||
|
limit = flask.request.args['limit']
|
||||||
|
else:
|
||||||
|
limit = None
|
||||||
|
|
||||||
|
# Get volume limit
|
||||||
|
if 'volume' in flask.request.args:
|
||||||
|
volume = flask.request.args['volume']
|
||||||
|
else:
|
||||||
|
volume = 'all'
|
||||||
|
|
||||||
|
# Get pool limit
|
||||||
|
if 'pool' in flask.request.args:
|
||||||
|
pool = flask.request.args['pool']
|
||||||
|
else:
|
||||||
|
pool = 'all'
|
||||||
|
|
||||||
|
zk_conn = pvc_common.startZKConnection(zk_host)
|
||||||
|
retflag, retdata = pvc_ceph.get_list_snapshot(zk_conn, pool, volume, limit)
|
||||||
|
if retflag:
|
||||||
|
retcode = 200
|
||||||
|
else:
|
||||||
|
retcode = 510
|
||||||
|
|
||||||
|
pvc_common.stopZKConnection(zk_conn)
|
||||||
|
return flask.jsonify(retdata), retcode
|
||||||
|
|
||||||
|
#
|
||||||
|
# Entrypoint
|
||||||
|
#
|
||||||
pvcapi.run()
|
pvcapi.run()
|
||||||
|
|
Loading…
Reference in New Issue