charm-ceph-proxy/actions/delete-pool
Alex Kavanagh ddd26acc6d Convert the charm to Python3
* Move charmhelpers to the root of the charm
* sync charmhelpers to latest version

Change-Id: Id0b838f0206635cf912d205f2fb6fda7b31d0dfe
2019-03-10 14:16:41 +00:00

40 lines
930 B
Python
Executable File

#!/usr/bin/env python3
import os
import sys
_path = os.path.dirname(os.path.realpath(__file__))
_hooks = os.path.abspath(os.path.join(_path, '../hooks'))
_root = os.path.abspath(os.path.join(_path, '..'))
def _add_path(path):
if path not in sys.path:
sys.path.insert(1, path)
_add_path(_hooks)
_add_path(_root)
import rados
from ceph_ops import connect
from charmhelpers.core.hookenv import action_get, log, action_fail
def remove_pool():
try:
pool_name = action_get("name")
cluster = connect()
log("Deleting pool: {}".format(pool_name))
cluster.delete_pool(str(pool_name)) # Convert from unicode
cluster.shutdown()
except (rados.IOError,
rados.ObjectNotFound,
rados.NoData,
rados.NoSpace,
rados.PermissionError) as e:
log(str(e))
action_fail(str(e))
if __name__ == '__main__':
remove_pool()