Files
charm-ceph-proxy/actions/set-pool-max-bytes
Chris MacNaughton 7359b981d6 Ensure that the actions use the configured admin user
Change-Id: I357b26fb585d68d2fbe9bbf21bbf9bfc52ac5050
Closes-Bug: #1893790
2020-09-04 16:58:24 +02:00

29 lines
841 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)
from subprocess import CalledProcessError
from charmhelpers.core.hookenv import action_get, config, log, action_fail
from charmhelpers.contrib.storage.linux.ceph import set_pool_quota
if __name__ == '__main__':
max_bytes = action_get("max")
name = action_get("pool-name")
try:
set_pool_quota(service=config('admin-user'), pool_name=name, max_bytes=max_bytes)
except CalledProcessError as e:
log(str(e))
action_fail("Set pool quota failed with message: {}".format(str(e)))