예제 #1
0
def delete_snapshots(args):
    disk_id = args.disk_id
    try:
        ceph_api = CephAPI()
        image_name = str(ceph_api.conf_api.get_image_name_prefix() + disk_id)
        pool_name = ceph_api.get_pool_bydisk(
            disk_id)  # getting pool_name from disk_id

        confirm = ceph_api.delete_snapshots(pool_name, image_name)

        if not confirm:
            print("Error : Cannot delete all snapshots of disk " + disk_id)
            sys.exit(-1)

        sys.exit(0)

    except CephException as e:
        if e.id == CephException.GENERAL_EXCEPTION:
            print("Error : " + str(e.message) +
                  " , Cannot delete all snapshots of disk " + disk_id)
            sys.exit(-1)

    except Exception as e:
        print("Error : Exception , {}".format(e.message))
        sys.exit(-1)
예제 #2
0
 def delete_snapshots(self, pool_name, disk_id):
     ceph_api = CephAPI()
     image_name = "image-" + disk_id
     confirm = ceph_api.delete_snapshots(pool_name, image_name)
     return confirm