Add missing inc/dec of snapshot_count
This commit is contained in:
parent
b33c0ab0e2
commit
0e4bece441
|
@ -715,6 +715,16 @@ def add_snapshot(zk_conn, pool, volume, name):
|
||||||
'/ceph/snapshots/{}/{}/{}/stats'.format(pool, volume, name): '{}'
|
'/ceph/snapshots/{}/{}/{}/stats'.format(pool, volume, name): '{}'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# 3. Update the count of snapshots on this volume
|
||||||
|
volume_stats_raw = zkhandler.readdata(zk_conn, '/ceph/volumes/{}/{}/stats'.format(pool, volume))
|
||||||
|
volume_stats = dict(json.loads(volume_stats_raw))
|
||||||
|
# Format the size to something nicer
|
||||||
|
volume_stats['snapshot_count'] = volume_stats['snapshot_count'] + 1
|
||||||
|
volume_stats_raw = json.dumps(volume_stats)
|
||||||
|
zkhandler.writedata(zk_conn, {
|
||||||
|
'/ceph/volumes/{}/{}/stats'.format(pool, volume): volume_stats_raw
|
||||||
|
})
|
||||||
|
|
||||||
return True, 'Created RBD snapshot "{}" of volume "{}" in pool "{}".'.format(name, volume, pool)
|
return True, 'Created RBD snapshot "{}" of volume "{}" in pool "{}".'.format(name, volume, pool)
|
||||||
|
|
||||||
|
|
||||||
|
@ -751,6 +761,16 @@ def remove_snapshot(zk_conn, pool, volume, name):
|
||||||
# 2. Delete snapshot from Zookeeper
|
# 2. Delete snapshot from Zookeeper
|
||||||
zkhandler.deletekey(zk_conn, '/ceph/snapshots/{}/{}/{}'.format(pool, volume, name))
|
zkhandler.deletekey(zk_conn, '/ceph/snapshots/{}/{}/{}'.format(pool, volume, name))
|
||||||
|
|
||||||
|
# 3. Update the count of snapshots on this volume
|
||||||
|
volume_stats_raw = zkhandler.readdata(zk_conn, '/ceph/volumes/{}/{}/stats'.format(pool, volume))
|
||||||
|
volume_stats = dict(json.loads(volume_stats_raw))
|
||||||
|
# Format the size to something nicer
|
||||||
|
volume_stats['snapshot_count'] = volume_stats['snapshot_count'] - 1
|
||||||
|
volume_stats_raw = json.dumps(volume_stats)
|
||||||
|
zkhandler.writedata(zk_conn, {
|
||||||
|
'/ceph/volumes/{}/{}/stats'.format(pool, volume): volume_stats_raw
|
||||||
|
})
|
||||||
|
|
||||||
return True, 'Removed RBD snapshot "{}" of volume "{}" in pool "{}".'.format(name, volume, pool)
|
return True, 'Removed RBD snapshot "{}" of volume "{}" in pool "{}".'.format(name, volume, pool)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue