29 lines
810 B
Python
Executable File
29 lines
810 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_fail
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
out = check_output(['ceph', '--id', config('admin-user'),
|
|
'osd', 'lspools']).decode('UTF-8')
|
|
action_set({'message': out})
|
|
except CalledProcessError as e:
|
|
log(str(e))
|
|
action_fail("List pools failed with error: {}".format(str(e)))
|