RESTify the API removing specific list endpoints
This commit is contained in:
parent
c7269a092e
commit
e31e1264e5
|
@ -29,6 +29,8 @@ import client_lib.vm as pvc_vm
|
|||
import client_lib.network as pvc_network
|
||||
import client_lib.ceph as pvc_ceph
|
||||
|
||||
import api_lib.api as api
|
||||
|
||||
zk_host = "hv1:2181,hv2:2181,hv3:2181"
|
||||
|
||||
pvcapi = flask.Flask(__name__)
|
||||
|
@ -44,9 +46,23 @@ def api_root():
|
|||
@pvcapi.route('/api/v1/node', methods=['GET'])
|
||||
def api_node():
|
||||
"""
|
||||
Manage the state of a node in the PVC cluster.
|
||||
Return a list of nodes with limit LIMIT.
|
||||
"""
|
||||
return "Manage the state of a node in the PVC cluster.\n", 209
|
||||
# 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
|
||||
|
||||
@pvcapi.route('/api/v1/node/secondary', methods=['POST'])
|
||||
def api_node_secondary():
|
||||
|
@ -145,19 +161,34 @@ def api_node_ready():
|
|||
}
|
||||
return flask.jsonify(output), retcode
|
||||
|
||||
@pvcapi.route('/api/v1/node/list', methods=['GET'])
|
||||
def api_node_list():
|
||||
#
|
||||
# VM endpoints
|
||||
#
|
||||
@pvcapi.route('/api/v1/vm', methods=['GET'])
|
||||
def api_vm():
|
||||
"""
|
||||
Return a list of nodes with limit LIMIT.
|
||||
Return a list of VMs with limit LIMIT.
|
||||
"""
|
||||
# Get limit
|
||||
# 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
|
||||
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)
|
||||
retflag, retdata = pvc_vm.get_list(zk_conn, node, state, limit)
|
||||
if retflag:
|
||||
retcode = 200
|
||||
else:
|
||||
|
@ -166,16 +197,6 @@ def api_node_list():
|
|||
pvc_common.stopZKConnection(zk_conn)
|
||||
return flask.jsonify(retdata), retcode
|
||||
|
||||
#
|
||||
# VM endpoints
|
||||
#
|
||||
@pvcapi.route('/api/v1/vm', methods=['GET'])
|
||||
def api_vm():
|
||||
"""
|
||||
Manage the state of a VM in the PVC cluster.
|
||||
"""
|
||||
return "Manage the state of a VM in the PVC cluster.\n", 209
|
||||
|
||||
@pvcapi.route('/api/v1/vm/add', methods=['POST'])
|
||||
def api_vm_add():
|
||||
"""
|
||||
|
@ -260,23 +281,14 @@ def api_vm_unmigrate():
|
|||
"""
|
||||
pass
|
||||
|
||||
@pvcapi.route('/api/v1/vm/list', methods=['GET'])
|
||||
def api_vm_list():
|
||||
#
|
||||
# Network endpoints
|
||||
#
|
||||
@pvcapi.route('/api/v1/network', methods=['GET'])
|
||||
def api_net():
|
||||
"""
|
||||
Return a list of VMs with limit LIMIT.
|
||||
Return a list of client networks with limit LIMIT.
|
||||
"""
|
||||
# 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
|
||||
if 'limit' in flask.request.values:
|
||||
limit = flask.request.values['limit']
|
||||
|
@ -284,7 +296,7 @@ def api_vm_list():
|
|||
limit = None
|
||||
|
||||
zk_conn = pvc_common.startZKConnection(zk_host)
|
||||
retflag, retdata = pvc_vm.get_list(zk_conn, node, state, limit)
|
||||
retflag, retdata = pvc_network.get_list(zk_conn, limit)
|
||||
if retflag:
|
||||
retcode = 200
|
||||
else:
|
||||
|
@ -293,16 +305,6 @@ def api_vm_list():
|
|||
pvc_common.stopZKConnection(zk_conn)
|
||||
return flask.jsonify(retdata), retcode
|
||||
|
||||
#
|
||||
# Network endpoints
|
||||
#
|
||||
@pvcapi.route('/api/v1/network', methods=['GET'])
|
||||
def api_net():
|
||||
"""
|
||||
Manage the state of a client network in the PVC cluster.
|
||||
"""
|
||||
return "Manage the state of a VM in the PVC cluster.\n", 209
|
||||
|
||||
@pvcapi.route('/api/v1/network/add', methods=['POST'])
|
||||
def api_net_add():
|
||||
"""
|
||||
|
@ -324,36 +326,8 @@ def api_net_remove():
|
|||
"""
|
||||
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.values:
|
||||
limit = flask.request.values['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.
|
||||
"""
|
||||
|
@ -381,27 +355,6 @@ def api_net_dhcp_list():
|
|||
|
||||
@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.
|
||||
"""
|
||||
|
@ -427,29 +380,22 @@ def api_net_dhcp_static_list():
|
|||
pvc_common.stopZKConnection(zk_conn)
|
||||
return flask.jsonify(retdata), retcode
|
||||
|
||||
@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/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.
|
||||
"""
|
||||
|
@ -483,18 +429,25 @@ def api_net_acl_list():
|
|||
pvc_common.stopZKConnection(zk_conn)
|
||||
return flask.jsonify(retdata), retcode
|
||||
|
||||
@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
|
||||
|
||||
#
|
||||
# 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.
|
||||
"""
|
||||
|
@ -511,9 +464,23 @@ def api_ceph_status():
|
|||
@pvcapi.route('/api/v1/ceph/osd', methods=['GET'])
|
||||
def api_ceph_osd():
|
||||
"""
|
||||
Manage the state of OSDs in the Ceph storage cluster.
|
||||
Get the list of OSDs in the Ceph storage cluster.
|
||||
"""
|
||||
return "Manage the state of OSDs in the Ceph storage cluster.\n", 209
|
||||
# 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
|
||||
|
||||
@pvcapi.route('/api/v1/ceph/osd/add', methods=['POST'])
|
||||
def api_ceph_osd_add():
|
||||
|
@ -557,50 +524,8 @@ def api_ceph_osd_unset():
|
|||
"""
|
||||
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.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
|
||||
|
||||
@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.
|
||||
"""
|
||||
|
@ -620,29 +545,22 @@ def api_ceph_pool_list():
|
|||
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
|
||||
|
||||
@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.
|
||||
"""
|
||||
|
@ -668,29 +586,22 @@ def api_ceph_volume_list():
|
|||
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
|
||||
|
||||
@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.
|
||||
"""
|
||||
|
@ -722,6 +633,20 @@ def api_ceph_volume_snapshot_list():
|
|||
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
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue