Implement snapshot renaming

[3/2] Implements #44
This commit is contained in:
2019-07-28 23:00:35 -04:00
parent 5873cf6c53
commit 2dbf276e51
4 changed files with 79 additions and 4 deletions

View File

@ -892,6 +892,23 @@ def ceph_volume_snapshot_add(pool, volume, name):
}
return flask.jsonify(output), retcode
def ceph_volume_snapshot_rename(pool, volume, name, new_name):
"""
Rename a Ceph RBD volume snapshot in the PVC Ceph storage cluster.
"""
zk_conn = pvc_common.startZKConnection(config['coordinators'])
retflag, retdata = pvc_ceph.rename_snapshot(zk_conn, pool, volume, name, new_name)
if retflag:
retcode = 200
else:
retcode = 400
pvc_common.stopZKConnection(zk_conn)
output = {
'message': retdata.replace('\"', '\'')
}
return flask.jsonify(output), retcode
def ceph_volume_snapshot_remove(pool, volume, name):
"""
Remove a Ceph RBD volume snapshot from the PVC Ceph storage cluster.

View File

@ -870,8 +870,12 @@ def api_ceph_volume_snapshot_element(pool, volume, snapshot):
return pvcapi.ceph_volume_snapshot_list(pool, volume, snapshot)
if flask.request.method == 'PUT':
# TODO: #44
flask.abort(501)
if 'name' in flask.request.values:
name = flask.request.values['name']
else:
return flask.jsonify({"message":"ERROR: A new name must be specified."}), 400
return pvcapi.ceph_volume_snapshot_rename(pool, volume, snapshot, name)
if flask.request.method == 'DELETE':
return pvcapi.ceph_volume_snapshot_remove(pool, volume, snapshot)