charm-ceph-proxy/actions/pool-statistics

28 lines
776 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 check_output, CalledProcessError
from charmhelpers.core.hookenv import log, config, action_set, action_fail
if __name__ == '__main__':
try:
out = check_output(['ceph', '--id', config('admin-user'),
'df']).decode('UTF-8')
action_set({'message': out})
except CalledProcessError as e:
log(str(e))
action_fail("ceph df failed with message: {}".format(str(e)))