charm-ceph-proxy/actions/pool-get

31 lines
879 B
Python
Executable File

#!/usr/bin/env python3
__author__ = 'chris'
import os
from subprocess import check_output, CalledProcessError
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 charmhelpers.core.hookenv import log, action_set, action_get, action_fail
if __name__ == '__main__':
name = action_get('pool-name')
key = action_get('key')
try:
out = check_output(['ceph', '--id', 'admin',
'osd', 'pool', 'get', name, key]).decode('UTF-8')
action_set({'message': out})
except CalledProcessError as e:
log(str(e))
action_fail("Pool get failed with message: {}".format(str(e)))