From 8a12867c6f4c505195bc4ecac56c259cb9469c01 Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Thu, 29 Mar 2018 10:02:03 +0100 Subject: [PATCH] mgr/dashboard: rbd: image delete implementation Signed-off-by: Ricardo Dias --- src/pybind/mgr/dashboard/controllers/rbd.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index f05cda281f5..ca33af6d655 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd.py +++ b/src/pybind/mgr/dashboard/controllers/rbd.py @@ -230,3 +230,21 @@ class Rbd(RESTController): stripe_unit, stripe_count, data_pool]) status, value = task.wait(1.0) return {'status': status, 'value': value} + + @classmethod + def _remove_image(cls, pool_name, image_name): + rbd_inst = rbd.RBD() + ioctx = mgr.rados.open_ioctx(pool_name) + try: + rbd_inst.remove(ioctx, image_name) + except rbd.OSError as e: + return {'success': False, 'detail': str(e), 'errno': e.errno} + return {'success': True} + + def delete(self, pool_name, image_name): + task = TaskManager.run('rbd/delete', + {'pool_name': pool_name, 'image_name': image_name}, + self._remove_image, [pool_name, image_name]) + status, value = task.wait(2.0) + cherrypy.response.status = 200 + return {'status': status, 'value': value} -- 2.39.5