7359b981d6
Change-Id: I357b26fb585d68d2fbe9bbf21bbf9bfc52ac5050 Closes-Bug: #1893790
31 lines
900 B
Python
Executable File
31 lines
900 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, config, action_set, action_get, action_fail
|
|
|
|
if __name__ == '__main__':
|
|
name = action_get('pool-name')
|
|
key = action_get('key')
|
|
try:
|
|
out = check_output(['ceph', '--id', config('admin-user'),
|
|
'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)))
|