RESTify the remaining components
This commit is contained in:
parent
d43ced176f
commit
4cf3ade10a
|
@ -137,7 +137,7 @@ def api_auth_logout():
|
||||||
#
|
#
|
||||||
@api.route('/api/v1/node', methods=['GET'])
|
@api.route('/api/v1/node', methods=['GET'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_node():
|
def api_node_root():
|
||||||
# Get name limit
|
# Get name limit
|
||||||
if 'limit' in flask.request.values:
|
if 'limit' in flask.request.values:
|
||||||
limit = flask.request.values['limit']
|
limit = flask.request.values['limit']
|
||||||
|
@ -148,7 +148,7 @@ def api_node():
|
||||||
|
|
||||||
@api.route('/api/v1/node/<node>', methods=['GET'])
|
@api.route('/api/v1/node/<node>', methods=['GET'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_node_root(node):
|
def api_node_element(node):
|
||||||
# Same as specifying /node?limit=NODE
|
# Same as specifying /node?limit=NODE
|
||||||
return pvcapi.node_list(node)
|
return pvcapi.node_list(node)
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ def api_node_domain_state(node):
|
||||||
#
|
#
|
||||||
@api.route('/api/v1/vm', methods=['GET', 'POST'])
|
@api.route('/api/v1/vm', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_vm():
|
def api_vm_root():
|
||||||
if flask.request.method == 'GET':
|
if flask.request.method == 'GET':
|
||||||
# Get node limit
|
# Get node limit
|
||||||
if 'node' in flask.request.values:
|
if 'node' in flask.request.values:
|
||||||
|
@ -235,7 +235,7 @@ def api_vm():
|
||||||
|
|
||||||
@api.route('/api/v1/vm/<vm>', methods=['GET', 'POST', 'PUT', 'DELETE'])
|
@api.route('/api/v1/vm/<vm>', methods=['GET', 'POST', 'PUT', 'DELETE'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_vm_root(vm):
|
def api_vm_element(vm):
|
||||||
if flask.request.method == 'GET':
|
if flask.request.method == 'GET':
|
||||||
# Same as specifying /vm?limit=VM
|
# Same as specifying /vm?limit=VM
|
||||||
return pvcapi.vm_list(None, None, vm, is_fuzzy=False)
|
return pvcapi.vm_list(None, None, vm, is_fuzzy=False)
|
||||||
|
@ -331,7 +331,7 @@ def api_vm_node(vm):
|
||||||
#
|
#
|
||||||
@api.route('/api/v1/network', methods=['GET', 'POST'])
|
@api.route('/api/v1/network', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_net():
|
def api_net_root():
|
||||||
if flask.request.method == 'GET':
|
if flask.request.method == 'GET':
|
||||||
# Get name limit
|
# Get name limit
|
||||||
if 'limit' in flask.request.values:
|
if 'limit' in flask.request.values:
|
||||||
|
@ -416,7 +416,7 @@ def api_net():
|
||||||
|
|
||||||
@api.route('/api/v1/network/<network>', methods=['GET', 'PUT', 'DELETE'])
|
@api.route('/api/v1/network/<network>', methods=['GET', 'PUT', 'DELETE'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_net_root(network):
|
def api_net_element(network):
|
||||||
# Same as specifying /network?limit=NETWORK
|
# Same as specifying /network?limit=NETWORK
|
||||||
if flask.request.method == 'GET':
|
if flask.request.method == 'GET':
|
||||||
return pvcapi.net_list(network)
|
return pvcapi.net_list(network)
|
||||||
|
@ -486,7 +486,7 @@ def api_net_root(network):
|
||||||
|
|
||||||
@api.route('/api/v1/network/<network>/lease', methods=['GET', 'POST'])
|
@api.route('/api/v1/network/<network>/lease', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_net_lease(network):
|
def api_net_lease_root(network):
|
||||||
if flask.request.method == 'GET':
|
if flask.request.method == 'GET':
|
||||||
# Get name limit
|
# Get name limit
|
||||||
if 'limit' in flask.request.values:
|
if 'limit' in flask.request.values:
|
||||||
|
@ -524,7 +524,7 @@ def api_net_lease(network):
|
||||||
|
|
||||||
@api.route('/api/v1/network/<network>/lease/<lease>', methods=['GET', 'DELETE'])
|
@api.route('/api/v1/network/<network>/lease/<lease>', methods=['GET', 'DELETE'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_net_lease_root(network, lease):
|
def api_net_lease_element(network, lease):
|
||||||
if flask.request.method == 'GET':
|
if flask.request.method == 'GET':
|
||||||
# Same as specifying /network?limit=NETWORK
|
# Same as specifying /network?limit=NETWORK
|
||||||
return pvcapi.net_dhcp_list(network, lease, False)
|
return pvcapi.net_dhcp_list(network, lease, False)
|
||||||
|
@ -534,7 +534,7 @@ def api_net_lease_root(network, lease):
|
||||||
|
|
||||||
@api.route('/api/v1/network/<network>/acl', methods=['GET', 'POST'])
|
@api.route('/api/v1/network/<network>/acl', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_net_acl(network):
|
def api_net_acl_root(network):
|
||||||
if flask.request.method == 'GET':
|
if flask.request.method == 'GET':
|
||||||
# Get name limit
|
# Get name limit
|
||||||
if 'limit' in flask.request.values:
|
if 'limit' in flask.request.values:
|
||||||
|
@ -583,7 +583,7 @@ def api_net_acl(network):
|
||||||
|
|
||||||
@api.route('/api/v1/network/<network>/acl/<acl>', methods=['GET', 'DELETE'])
|
@api.route('/api/v1/network/<network>/acl/<acl>', methods=['GET', 'DELETE'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_net_acl_info(network, acl):
|
def api_net_acl_element(network, acl):
|
||||||
if flask.request.method == 'GET':
|
if flask.request.method == 'GET':
|
||||||
# Same as specifying /network?limit=NETWORK
|
# Same as specifying /network?limit=NETWORK
|
||||||
return pvcapi.net_acl_list(network, acl, None)
|
return pvcapi.net_acl_list(network, acl, None)
|
||||||
|
@ -622,196 +622,243 @@ def api_ceph_status():
|
||||||
def api_ceph_radosdf():
|
def api_ceph_radosdf():
|
||||||
return pvcapi.ceph_radosdf()
|
return pvcapi.ceph_radosdf()
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/osd', methods=['GET'])
|
@api.route('/api/v1/storage/ceph/cluster-option', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_osd():
|
def api_ceph_cluster_option():
|
||||||
# Get name limit
|
if flask.request.method == 'GET':
|
||||||
if 'limit' in flask.request.values:
|
pass
|
||||||
limit = flask.request.values['limit']
|
|
||||||
else:
|
|
||||||
limit = None
|
|
||||||
|
|
||||||
return pvcapi.ceph_osd_list(limit)
|
if flask.request.method == 'POST':
|
||||||
|
# Get action
|
||||||
|
if 'action' in flask.request.values:
|
||||||
|
action = flask.request.values['action']
|
||||||
|
if not 'set' in action and not 'unset' in action:
|
||||||
|
return flask.jsonify({"message":"ERROR: Action must be one of: set, unset"}), 400
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: An action must be specified."}), 400
|
||||||
|
# Get option
|
||||||
|
if 'option' in flask.request.values:
|
||||||
|
option = flask.request.values['option']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: An option must be specified."}), 400
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/osd/set', methods=['POST'])
|
if action == 'set':
|
||||||
|
return pvcapi.ceph_osd_set(option)
|
||||||
|
if action == 'unset':
|
||||||
|
return pvcapi.ceph_osd_unset(option)
|
||||||
|
|
||||||
|
@api.route('/api/v1/storage/ceph/osd', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_osd_set():
|
def api_ceph_osd_root():
|
||||||
# Get OSD option
|
if flask.request.method == 'GET':
|
||||||
if 'option' in flask.request.options:
|
# Get name limit
|
||||||
option = flask.request.options['option']
|
if 'limit' in flask.request.values:
|
||||||
else:
|
limit = flask.request.values['limit']
|
||||||
return flask.jsonify({"message":"ERROR: An OSD option must be specified."}), 400
|
else:
|
||||||
|
limit = None
|
||||||
|
|
||||||
return pvcapi.ceph_osd_set(option)
|
return pvcapi.ceph_osd_list(limit)
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/osd/unset', methods=['POST'])
|
if flask.request.method == 'POST':
|
||||||
|
# Get OSD node
|
||||||
|
if 'node' in flask.request.values:
|
||||||
|
node = flask.request.values['node']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A node must be specified."}), 400
|
||||||
|
|
||||||
|
# Get OSD device
|
||||||
|
if 'device' in flask.request.values:
|
||||||
|
device = flask.request.values['device']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A block device must be specified."}), 400
|
||||||
|
|
||||||
|
# Get OSD weight
|
||||||
|
if 'weight' in flask.request.values:
|
||||||
|
weight = flask.request.values['weight']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: An OSD weight must be specified."}), 400
|
||||||
|
|
||||||
|
return pvcapi.ceph_osd_add(node, device, weight)
|
||||||
|
|
||||||
|
@api.route('/api/v1/storage/ceph/osd/<osd>', methods=['GET', 'DELETE'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_osd_unset():
|
def api_ceph_osd_element(osd):
|
||||||
# Get OSD option
|
if flask.request.method == 'GET':
|
||||||
if 'option' in flask.request.options:
|
# Same as specifying /osd?limit=OSD
|
||||||
option = flask.request.options['option']
|
return pvcapi.ceph_osd_list(osd)
|
||||||
else:
|
|
||||||
return flask.jsonify({"message":"ERROR: An OSD option must be specified."}), 400
|
|
||||||
|
|
||||||
return pvcapi.ceph_osd_unset(option)
|
if flask.request.method == 'DELETE':
|
||||||
|
# Verify yes-i-really-mean-it flag
|
||||||
|
if not 'yes_i_really_mean_it' in flask.request.values:
|
||||||
|
return flask.jsonify({"message":"ERROR: This command can have unintended consequences and should not be automated; if you're sure you know what you're doing, resend with the argument 'yes_i_really_mean_it'."}), 400
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/osd/<osd>', methods=['GET'])
|
return pvcapi.ceph_osd_remove(osd)
|
||||||
|
|
||||||
|
@api.route('/api/v1/storage/ceph/osd/<osd>/state', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_osd_info(osd):
|
def api_ceph_osd_state(osd):
|
||||||
# Same as specifying /osd?limit=OSD
|
if flask.request.method == 'GET':
|
||||||
return pvcapi.ceph_osd_list(osd)
|
pass
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/osd/<node>/add', methods=['POST'])
|
if flask.request.method == 'POST':
|
||||||
|
if 'state' in flask.request.values:
|
||||||
|
state = flask.request.values['state']
|
||||||
|
if not 'in' in state and not 'out' in state:
|
||||||
|
return flask.jsonify({"message":"ERROR: State must be one of: in, out."}), 400
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A state must be specified."}), 400
|
||||||
|
|
||||||
|
if state == 'in':
|
||||||
|
return pvcapi.ceph_osd_in(osd)
|
||||||
|
if state == 'out':
|
||||||
|
return pvcapi.ceph_osd_out(osd)
|
||||||
|
|
||||||
|
@api.route('/api/v1/storage/ceph/pool', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_osd_add(node):
|
def api_ceph_pool_root():
|
||||||
# Get OSD device
|
if flask.request.method == 'GET':
|
||||||
if 'device' in flask.request.devices:
|
# Get name limit
|
||||||
device = flask.request.devices['device']
|
if 'limit' in flask.request.values:
|
||||||
else:
|
limit = flask.request.values['limit']
|
||||||
return flask.jsonify({"message":"ERROR: A block device must be specified."}), 400
|
else:
|
||||||
|
limit = None
|
||||||
|
|
||||||
# Get OSD weight
|
return pvcapi.ceph_pool_list(limit)
|
||||||
if 'weight' in flask.request.weights:
|
|
||||||
weight = flask.request.weights['weight']
|
|
||||||
else:
|
|
||||||
return flask.jsonify({"message":"ERROR: An OSD weight must be specified."}), 400
|
|
||||||
|
|
||||||
return pvcapi.ceph_osd_add(node, device, weight)
|
if flask.request.method == 'POST':
|
||||||
|
# Get pool name
|
||||||
|
if 'pool' in flask.request.values:
|
||||||
|
pool = flask.request.values['pool']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A pool name must be specified."}), 400
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/osd/<osd>/remove', methods=['POST'])
|
# Get placement groups
|
||||||
|
if 'pgs' in flask.request.values:
|
||||||
|
pgs = flask.request.values['pgs']
|
||||||
|
else:
|
||||||
|
# We default to a very small number; DOCUMENT THIS
|
||||||
|
pgs = 128
|
||||||
|
|
||||||
|
return pvcapi.ceph_pool_add(pool, pgs)
|
||||||
|
|
||||||
|
@api.route('/api/v1/storage/ceph/pool/<pool>', methods=['GET', 'DELETE'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_osd_remove(osd):
|
def api_ceph_pool_element(pool):
|
||||||
# Verify yes-i-really-mean-it flag
|
if flask.request.method == 'GET':
|
||||||
if not 'flag_yes_i_really_mean_it' in flask.request.values:
|
# Same as specifying /pool?limit=POOL
|
||||||
return flask.jsonify({"message":"ERROR: This command can have unintended consequences and should not be automated; if you're sure you know what you're doing, resend with the argument 'flag_yes_i_really_mean_it'."}), 599
|
return pvcapi.ceph_pool_list(pool)
|
||||||
|
|
||||||
return pvcapi.ceph_osd_remove(osd)
|
if flask.request.method == 'DELETE':
|
||||||
|
# Verify yes-i-really-mean-it flag
|
||||||
|
if not 'yes_i_really_mean_it' in flask.request.values:
|
||||||
|
return flask.jsonify({"message":"ERROR: This command can have unintended consequences and should not be automated; if you're sure you know what you're doing, resend with the argument 'yes_i_really_mean_it'."}), 400
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/osd/<osd>/in', methods=['POST'])
|
return pvcapi.ceph_pool_remove(pool)
|
||||||
|
|
||||||
|
@api.route('/api/v1/storage/ceph/volume', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_osd_in(osd):
|
def api_ceph_volume_root():
|
||||||
return pvcapi.ceph_osd_in(osd)
|
if flask.request.method == 'GET':
|
||||||
|
# Get pool limit
|
||||||
|
if 'pool' in flask.request.values:
|
||||||
|
pool = flask.request.values['pool']
|
||||||
|
else:
|
||||||
|
pool = None
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/osd/<osd>/out', methods=['POST'])
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.values:
|
||||||
|
limit = flask.request.values['limit']
|
||||||
|
else:
|
||||||
|
limit = None
|
||||||
|
|
||||||
|
return pvcapi.ceph_volume_list(pool, limit)
|
||||||
|
|
||||||
|
if flask.request.method == 'POST':
|
||||||
|
# Get volume name
|
||||||
|
if 'volume' in flask.request.values:
|
||||||
|
volume = flask.request.values['volume']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A volume name must be specified."}), 400
|
||||||
|
|
||||||
|
# Get volume pool
|
||||||
|
if 'pool' in flask.request.values:
|
||||||
|
pool = flask.request.values['pool']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A pool name must be spcified."}), 400
|
||||||
|
|
||||||
|
# Get volume size
|
||||||
|
if 'size' in flask.request.values:
|
||||||
|
size = flask.request.values['size']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A volume size in bytes (or with an M/G/T suffix) must be specified."}), 400
|
||||||
|
|
||||||
|
return pvcapi.ceph_volume_add(pool, volume, size)
|
||||||
|
|
||||||
|
@api.route('/api/v1/storage/ceph/volume/<pool>/<volume>', methods=['GET', 'DELETE'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_osd_out(osd):
|
def api_ceph_volume_element(pool, volume):
|
||||||
return pvcapi.ceph_osd_out(osd)
|
if flask.request.method == 'GET':
|
||||||
|
# Same as specifying /volume?limit=VOLUME
|
||||||
|
return pvcapi.ceph_volume_list(pool, volume)
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/pool', methods=['GET'])
|
if flask.request.method == 'DELETE':
|
||||||
|
return pvcapi.ceph_volume_remove(pool, volume)
|
||||||
|
|
||||||
|
@api.route('/api/v1/storage/ceph/volume/snapshot', methods=['GET', 'POST'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_pool():
|
def api_ceph_volume_snapshot_root():
|
||||||
# Get name limit
|
if flask.request.method == 'GET':
|
||||||
if 'limit' in flask.request.values:
|
# Get pool limit
|
||||||
limit = flask.request.values['limit']
|
if 'pool' in flask.request.values:
|
||||||
else:
|
pool = flask.request.values['pool']
|
||||||
limit = None
|
else:
|
||||||
|
pool = None
|
||||||
|
|
||||||
return pvcapi.ceph_pool_list(limit)
|
# Get volume limit
|
||||||
|
if 'volume' in flask.request.values:
|
||||||
|
volume = flask.request.values['volume']
|
||||||
|
else:
|
||||||
|
volume = None
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/pool/<pool>', methods=['GET'])
|
# Get name limit
|
||||||
|
if 'limit' in flask.request.values:
|
||||||
|
limit = flask.request.values['limit']
|
||||||
|
else:
|
||||||
|
limit = None
|
||||||
|
|
||||||
|
return pvcapi.ceph_volume_snapshot_list(pool, volume, limit)
|
||||||
|
|
||||||
|
if flask.request.method == 'POST':
|
||||||
|
# Get snapshot name
|
||||||
|
if 'snapshot' in flask.request.values:
|
||||||
|
snapshot = flask.request.values['snapshot']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A snapshot name must be specified."}), 400
|
||||||
|
|
||||||
|
# Get volume name
|
||||||
|
if 'volume' in flask.request.values:
|
||||||
|
volume = flask.request.values['volume']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A volume name must be specified."}), 400
|
||||||
|
|
||||||
|
# Get volume pool
|
||||||
|
if 'pool' in flask.request.values:
|
||||||
|
pool = flask.request.values['pool']
|
||||||
|
else:
|
||||||
|
return flask.jsonify({"message":"ERROR: A pool name must be spcified."}), 400
|
||||||
|
|
||||||
|
return pvcapi.ceph_volume_snapshot_add(pool, volume, snapshot)
|
||||||
|
|
||||||
|
|
||||||
|
@api.route('/api/v1/storage/ceph/volume/snapshot/<pool>/<volume>/<snapshot>', methods=['GET', 'DELETE'])
|
||||||
@authenticator
|
@authenticator
|
||||||
def api_ceph_pool_info(pool):
|
def api_ceph_volume_snapshot_element(pool, volume, snapshot):
|
||||||
# Same as specifying /pool?limit=POOL
|
if flask.request.method == 'GET':
|
||||||
return pvcapi.ceph_pool_list(pool)
|
# Same as specifying /snapshot?limit=VOLUME
|
||||||
|
return pvcapi.ceph_volume_snapshot_list(pool, volume, snapshot)
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/pool/<pool>/add', methods=['POST'])
|
if flask.request.method == 'DELETE':
|
||||||
@authenticator
|
return pvcapi.ceph_volume_snapshot_remove(pool, volume, snapshot)
|
||||||
def api_ceph_pool_add(pool):
|
|
||||||
# Get placement groups
|
|
||||||
if 'pgs' in flask.request.values:
|
|
||||||
pgs = flask.request.values['pgs']
|
|
||||||
else:
|
|
||||||
# We default to a very small number; DOCUMENT THIS
|
|
||||||
pgs = 128
|
|
||||||
|
|
||||||
return pvcapi.ceph_pool_add(pool, pgs)
|
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/pool/<pool>/remove', methods=['POST'])
|
|
||||||
@authenticator
|
|
||||||
def api_ceph_pool_remove(pool):
|
|
||||||
# Verify yes-i-really-mean-it flag
|
|
||||||
if not 'flag_yes_i_really_mean_it' in flask.request.values:
|
|
||||||
return flask.jsonify({"message":"ERROR: This command can have unintended consequences and should not be automated; if you're sure you know what you're doing, resend with the argument 'flag_yes_i_really_mean_it'."}), 599
|
|
||||||
|
|
||||||
return pvcapi.ceph_pool_remove(pool)
|
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/volume', methods=['GET'])
|
|
||||||
@authenticator
|
|
||||||
def api_ceph_volume():
|
|
||||||
# Get pool limit
|
|
||||||
if 'pool' in flask.request.values:
|
|
||||||
pool = flask.request.values['pool']
|
|
||||||
else:
|
|
||||||
pool = None
|
|
||||||
|
|
||||||
# Get name limit
|
|
||||||
if 'limit' in flask.request.values:
|
|
||||||
limit = flask.request.values['limit']
|
|
||||||
else:
|
|
||||||
limit = None
|
|
||||||
|
|
||||||
return pvcapi.ceph_volume_list(pool, limit)
|
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/volume/<pool>/<volume>', methods=['GET'])
|
|
||||||
@authenticator
|
|
||||||
def api_ceph_volume_info(pool, volume):
|
|
||||||
# Same as specifying /volume?limit=VOLUME
|
|
||||||
return pvcapi.ceph_osd_list(pool, osd)
|
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/volume/<pool>/<volume>/add', methods=['POST'])
|
|
||||||
@authenticator
|
|
||||||
def api_ceph_volume_add(pool, volume):
|
|
||||||
# Get volume size
|
|
||||||
if 'size' in flask.request.values:
|
|
||||||
size = flask.request.values['size']
|
|
||||||
else:
|
|
||||||
return flask.jsonify({"message":"ERROR: A volume size in bytes (or with an M/G/T suffix) must be specified."}), 400
|
|
||||||
|
|
||||||
return pvcapi.ceph_volume_add(pool, volume, size)
|
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/volume/<pool>/<volume>/remove', methods=['POST'])
|
|
||||||
@authenticator
|
|
||||||
def api_ceph_volume_remove(pool, volume):
|
|
||||||
return pvcapi.ceph_volume_remove(pool, volume)
|
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/volume/snapshot', methods=['GET'])
|
|
||||||
@authenticator
|
|
||||||
def api_ceph_volume_snapshot():
|
|
||||||
# Get pool limit
|
|
||||||
if 'pool' in flask.request.values:
|
|
||||||
pool = flask.request.values['pool']
|
|
||||||
else:
|
|
||||||
pool = None
|
|
||||||
|
|
||||||
# Get volume limit
|
|
||||||
if 'volume' in flask.request.values:
|
|
||||||
volume = flask.request.values['volume']
|
|
||||||
else:
|
|
||||||
volume = None
|
|
||||||
|
|
||||||
# Get name limit
|
|
||||||
if 'limit' in flask.request.values:
|
|
||||||
limit = flask.request.values['limit']
|
|
||||||
else:
|
|
||||||
limit = None
|
|
||||||
|
|
||||||
return pvcapi.ceph_volume_snapshot_list(pool, volume, limit)
|
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/volume/snapshot/<pool>/<volume>/<snapshot>', methods=['GET'])
|
|
||||||
@authenticator
|
|
||||||
def api_ceph_volume_snapshot_info(pool, volume, snapshot):
|
|
||||||
# Same as specifying /snapshot?limit=VOLUME
|
|
||||||
return pvcapi.ceph_snapshot_list(pool, volume, snapshot)
|
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/volume/snapshot/<pool>/<volume>/<snapshot>/add', methods=['POST'])
|
|
||||||
@authenticator
|
|
||||||
def api_ceph_volume_snapshot_add(pool, volume, snapshot):
|
|
||||||
return pvcapi.ceph_volume_snapshot_add(pool, volume, snapshot)
|
|
||||||
|
|
||||||
@api.route('/api/v1/storage/ceph/volume/snapshot/<pool>/<volume>/<snapshot>/remove', methods=['POST'])
|
|
||||||
@authenticator
|
|
||||||
def api_ceph_volume_snapshot_remove(pool, volume, snapshot):
|
|
||||||
return pvcapi.ceph_volume_snapshot_remove(pool, volume, snapshot)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Entrypoint
|
# Entrypoint
|
||||||
|
|
|
@ -399,7 +399,7 @@ This endpoint is an alias for `/api/v1/storage/ceph`.
|
||||||
Return a JSON document containing information about the current Ceph cluster utilization. The JSON element `ceph_data` contains the raw output of a `rados df` command.
|
Return a JSON document containing information about the current Ceph cluster utilization. The JSON element `ceph_data` contains the raw output of a `rados df` command.
|
||||||
|
|
||||||
#### `/api/v1/storage/ceph/cluster-option`
|
#### `/api/v1/storage/ceph/cluster-option`
|
||||||
* Methods: `POST`
|
* Methods: `GET`, `POST`
|
||||||
* Mandatory values: `action`, `option`
|
* Mandatory values: `action`, `option`
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ Return a JSON document containing information about all Ceph OSDs in the storage
|
||||||
* Mandatory values: `node`, `device`, `weight`
|
* Mandatory values: `node`, `device`, `weight`
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Add a new Ceph OSD to PVC node with name `<node>`. `device` must be a valid block device on the specified `<node>`, e.g. `/dev/sdb`. `weight` must be a valid Ceph OSD weight, usually `1.0` if all OSD disks are the same size.
|
Add a new Ceph OSD to PVC node `<node>`. `device` must be a valid block device on the specified `<node>`, e.g. `/dev/sdb`. `weight` must be a valid Ceph OSD weight, usually `1.0` if all OSD disks are the same size.
|
||||||
|
|
||||||
#### `/api/v1/storage/ceph/osd/<osd>`
|
#### `/api/v1/storage/ceph/osd/<osd>`
|
||||||
* Methods: `GET`, `DELETE`
|
* Methods: `GET`, `DELETE`
|
||||||
|
@ -467,7 +467,7 @@ Return a JSON document containing information about all Ceph RBD pools in the st
|
||||||
* Mandatory values: `pool`, `pgs`
|
* Mandatory values: `pool`, `pgs`
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Add a new Ceph RBD pool with name `<pool>` to the storage cluster. `pgs` must be a valid number of Placement Groups for the pool, taking into account the number of OSDs and the replication of the pool (`copies=3`). `256` is a safe and sane number of PGs for 3 nodes and 2 disks per node. This value can be grown later via `ceph` commands as required.
|
Add a new Ceph RBD pool `<pool>` to the storage cluster. `pgs` must be a valid number of Placement Groups for the pool, taking into account the number of OSDs and the replication of the pool (`copies=3`). `256` is a safe and sane number of PGs for 3 nodes and 2 disks per node. This value can be grown later via `ceph` commands as required.
|
||||||
|
|
||||||
#### `/api/v1/storage/ceph/pool/<pool>`
|
#### `/api/v1/storage/ceph/pool/<pool>`
|
||||||
* Methods: `GET`, `DELETE`
|
* Methods: `GET`, `DELETE`
|
||||||
|
@ -476,13 +476,13 @@ Add a new Ceph RBD pool with name `<pool>` to the storage cluster. `pgs` must be
|
||||||
* Mandatory values: N/A
|
* Mandatory values: N/A
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Return a JSON document containing information about Ceph RBD pool with name `<pool>`. The output is identical to `/api/v1/storage/ceph/pool?limit=<pool>` without fuzzy regex matching.
|
Return a JSON document containing information about Ceph RBD pool `<pool>`. The output is identical to `/api/v1/storage/ceph/pool?limit=<pool>` without fuzzy regex matching.
|
||||||
|
|
||||||
###### `DELETE`
|
###### `DELETE`
|
||||||
* Mandatory values: `yes_i_really_mean_it`
|
* Mandatory values: `yes_i_really_mean_it`
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Remove a Ceph RBD pool with name `<pool>` from the storage cluster.
|
Remove a Ceph RBD pool `<pool>` from the storage cluster.
|
||||||
|
|
||||||
**NOTE:** This is a command with potentially dangerous unintended consequences that should not be scripted. To acknowledge the danger, the `yes_i_really_mean_it` must be set or the endpoint will return a failure.
|
**NOTE:** This is a command with potentially dangerous unintended consequences that should not be scripted. To acknowledge the danger, the `yes_i_really_mean_it` must be set or the endpoint will return a failure.
|
||||||
|
|
||||||
|
@ -495,13 +495,13 @@ Remove a Ceph RBD pool with name `<pool>` from the storage cluster.
|
||||||
* Mandatory values: N/A
|
* Mandatory values: N/A
|
||||||
* Optional values: `pool`, `limit`
|
* Optional values: `pool`, `limit`
|
||||||
|
|
||||||
Return a JSON document containing information about all Ceph RBD volumes in the storage cluster. If `pool` is specified, return a JSON document containing information about all Ceph RBD volumes in Ceph RBD pool with name `pool`. If `limit` is specified, return a JSON document containing information about all Ceph RBD volumes with names matching `limit` as fuzzy regex.
|
Return a JSON document containing information about all Ceph RBD volumes in the storage cluster. If `pool` is specified, return a JSON document containing information about all Ceph RBD volumes in Ceph RBD pool `pool`. If `limit` is specified, return a JSON document containing information about all Ceph RBD volumes with names matching `limit` as fuzzy regex.
|
||||||
|
|
||||||
###### `POST`
|
###### `POST`
|
||||||
* Mandatory values: `pool`, `size`
|
* Mandatory values: `volume`, `pool`, `size`
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Add a new Ceph RBD volume with name `<volume>` to Ceph RBD pool with name `<pool>`. `size` must be a valid size, in bytes or a single-character metric prefix of bytes, e.g. `1073741824` (1GB), `4096M`, or `20G`.
|
Add a new Ceph RBD volume `<volume>` to Ceph RBD pool `<pool>`. `size` must be a valid size, in bytes or a single-character metric prefix of bytes, e.g. `1073741824` (1GB), `4096M`, or `20G`.
|
||||||
|
|
||||||
#### `/api/v1/storage/ceph/volume/<pool>/<volume>`
|
#### `/api/v1/storage/ceph/volume/<pool>/<volume>`
|
||||||
* Methods: `GET`, `DELETE`
|
* Methods: `GET`, `DELETE`
|
||||||
|
@ -510,13 +510,13 @@ Add a new Ceph RBD volume with name `<volume>` to Ceph RBD pool with name `<pool
|
||||||
* Mandatory values: N/A
|
* Mandatory values: N/A
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Return a JSON document containing information about Ceph RBD volume with name `<volume>` in Ceph RBD pool with name `<pool>`. The output is identical to `/api/v1/storage/ceph/volume?pool=<pool>&limit=<volume>` without fuzzy regex matching.
|
Return a JSON document containing information about Ceph RBD volume `<volume>` in Ceph RBD pool `<pool>`. The output is identical to `/api/v1/storage/ceph/volume?pool=<pool>&limit=<volume>` without fuzzy regex matching.
|
||||||
|
|
||||||
###### `DELETE`
|
###### `DELETE`
|
||||||
* Mandatory values: N/A
|
* Mandatory values: N/A
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Remove a Ceph RBD volume with name `<volume>` from Ceph RBD pool `<pool>`.
|
Remove a Ceph RBD volume `<volume>` from Ceph RBD pool `<pool>`.
|
||||||
|
|
||||||
#### `/api/v1/storage/ceph/volume/snapshot`
|
#### `/api/v1/storage/ceph/volume/snapshot`
|
||||||
* Methods: `GET`, `POST`
|
* Methods: `GET`, `POST`
|
||||||
|
@ -525,15 +525,15 @@ Remove a Ceph RBD volume with name `<volume>` from Ceph RBD pool `<pool>`.
|
||||||
* Mandatory values: N/A
|
* Mandatory values: N/A
|
||||||
* Optional values: `pool`, `volume`, `limit`
|
* Optional values: `pool`, `volume`, `limit`
|
||||||
|
|
||||||
Return a JSON document containing information about all Ceph RBD volume snapshots in the storage cluster. If `pool` is specified, return a JSON document containing information about all Ceph RBD volume snapshots in Ceph RBD pool with name `pool`. If `volume` is specified, return a JSON document containing information about all Ceph RBD volume snapshots of Ceph RBD volume with name `volume`. If `limit` is specified, return a JSON document containing information about all Ceph RBD volume snapshots with names matching `limit` as fuzzy regex.
|
Return a JSON document containing information about all Ceph RBD volume snapshots in the storage cluster. If `pool` is specified, return a JSON document containing information about all Ceph RBD volume snapshots in Ceph RBD pool `pool`. If `volume` is specified, return a JSON document containing information about all Ceph RBD volume snapshots of Ceph RBD volume `volume`. If `limit` is specified, return a JSON document containing information about all Ceph RBD volume snapshots with names matching `limit` as fuzzy regex.
|
||||||
|
|
||||||
The various limit options can be combined freely, e.g. one can specify a `volume` without `pool`, which would match all snapshots of the named volume(s) regardless of pool, or a `pool` and `limit` without a `volume`, which would match all named snapshots on any volume in `pool`.
|
The various limit options can be combined freely, e.g. one can specify a `volume` without `pool`, which would match all snapshots of the named volume(s) regardless of pool, or a `pool` and `limit` without a `volume`, which would match all named snapshots on any volume in `pool`.
|
||||||
|
|
||||||
###### `POST`
|
###### `POST`
|
||||||
* Mandatory values: `snapshot`, `pool`, `volume`
|
* Mandatory values: `snapshot`, `volume`, `pool`
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Add a new Ceph RBD volume snapshot with name `<snapshot>` of Ceph RBD volume with name `<volume>` on Ceph RBD pool with name `<pool>`.
|
Add a new Ceph RBD volume snapshot `snapshot` of Ceph RBD volume `volume` on Ceph RBD pool `pool`.
|
||||||
|
|
||||||
#### `/api/v1/storage/ceph/volume/snapshot/<pool>/<volume>/<snapshot>`
|
#### `/api/v1/storage/ceph/volume/snapshot/<pool>/<volume>/<snapshot>`
|
||||||
* Methods: `GET`, `DELETE`
|
* Methods: `GET`, `DELETE`
|
||||||
|
@ -542,10 +542,10 @@ Add a new Ceph RBD volume snapshot with name `<snapshot>` of Ceph RBD volume wit
|
||||||
* Mandatory values: N/A
|
* Mandatory values: N/A
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Return a JSON document containing information about Ceph RBD volume snapshot with name `<snapshot>` of Ceph RBD volume with name `<volume>` in Ceph RBD pool with name `<pool>`. The output is identical to `/api/v1/storage/ceph/volume?pool=<pool>&volume=<volume>&limit=<snapshot>` without fuzzy regex matching.
|
Return a JSON document containing information about Ceph RBD volume snapshot `<snapshot>` of Ceph RBD volume `<volume>` in Ceph RBD pool `<pool>`. The output is identical to `/api/v1/storage/ceph/volume?pool=<pool>&volume=<volume>&limit=<snapshot>` without fuzzy regex matching.
|
||||||
|
|
||||||
###### `DELETE`
|
###### `DELETE`
|
||||||
* Mandatory values: N/A
|
* Mandatory values: N/A
|
||||||
* Optional values: N/A
|
* Optional values: N/A
|
||||||
|
|
||||||
Remove a Ceph RBD volume snapshot with name `<snapshot>` of Ceph RBD volume with name `<volume>` on Ceph RBD pool with name `<pool>`.
|
Remove a Ceph RBD volume snapshot `<snapshot>` of Ceph RBD volume `<volume>` on Ceph RBD pool `<pool>`.
|
||||||
|
|
Loading…
Reference in New Issue