Add formatting param for disk usage
Pass formatting option to ceph for easier postprocessing. Constrain to values accepted by ceph, default to plain format. Change-Id: I0bb8cfcd8d8962988e786d2d083b1489161b2ff6 Closes-Bug: #1724880
This commit is contained in:
parent
1061abfdc5
commit
d45ab82589
@ -230,6 +230,12 @@ crushmap-update:
|
|||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
show-disk-free:
|
show-disk-free:
|
||||||
description: Show disk utilization by host and OSD.
|
description: Show disk utilization by host and OSD.
|
||||||
|
params:
|
||||||
|
format:
|
||||||
|
type: string
|
||||||
|
enum: [json, json-pretty, xml, xml-pretty, plain]
|
||||||
|
default: "plain"
|
||||||
|
description: Output format, either json, json-pretty, xml, xml-pretty, plain; defaults to plain
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
set-noout:
|
set-noout:
|
||||||
description: Set ceph noout across the cluster.
|
description: Set ceph noout across the cluster.
|
||||||
|
@ -18,12 +18,14 @@ import sys
|
|||||||
|
|
||||||
sys.path.append('hooks')
|
sys.path.append('hooks')
|
||||||
from subprocess import check_output, CalledProcessError
|
from subprocess import check_output, CalledProcessError
|
||||||
from charmhelpers.core.hookenv import log, action_set, action_fail
|
from charmhelpers.core.hookenv import log, action_get, action_set, action_fail
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# constrained to enum: json,json-pretty,xml,xml-pretty,plain
|
||||||
|
fmt = action_get("format")
|
||||||
try:
|
try:
|
||||||
out = check_output(['ceph', '--id', 'admin',
|
out = check_output(['ceph', '--id', 'admin',
|
||||||
'osd', 'df', 'tree']).decode('UTF-8')
|
'osd', 'df', 'tree', '-f', fmt]).decode('UTF-8')
|
||||||
action_set({'message': out})
|
action_set({'message': out})
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
log(e)
|
log(e)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import amulet
|
import amulet
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
import json
|
||||||
|
|
||||||
from charmhelpers.contrib.openstack.amulet.deployment import (
|
from charmhelpers.contrib.openstack.amulet.deployment import (
|
||||||
OpenStackAmuletDeployment
|
OpenStackAmuletDeployment
|
||||||
@ -117,7 +118,7 @@ class CephBasicDeployment(OpenStackAmuletDeployment):
|
|||||||
# Include a non-existent device as osd-devices is a whitelist,
|
# Include a non-existent device as osd-devices is a whitelist,
|
||||||
# and this will catch cases where proposals attempt to change that.
|
# and this will catch cases where proposals attempt to change that.
|
||||||
ceph_osd_config = {
|
ceph_osd_config = {
|
||||||
'osd-reformat': 'yes',
|
'osd-reformat': True,
|
||||||
'ephemeral-unmount': '/mnt',
|
'ephemeral-unmount': '/mnt',
|
||||||
'osd-devices': '/dev/vdb /srv/ceph /dev/test-non-existent'
|
'osd-devices': '/dev/vdb /srv/ceph /dev/test-non-existent'
|
||||||
}
|
}
|
||||||
@ -716,6 +717,27 @@ class CephBasicDeployment(OpenStackAmuletDeployment):
|
|||||||
action_id = u.run_action(sentry_unit, 'get-health')
|
action_id = u.run_action(sentry_unit, 'get-health')
|
||||||
assert u.wait_on_action(action_id), "HEALTH_OK"
|
assert u.wait_on_action(action_id), "HEALTH_OK"
|
||||||
|
|
||||||
|
def test_420_show_disk_free_action(self):
|
||||||
|
"""Verify show-disk-free"""
|
||||||
|
u.log.debug("Testing show-disk-free")
|
||||||
|
if self._get_openstack_release() < self.trusty_kilo:
|
||||||
|
u.log.info(
|
||||||
|
"show-disk-free only supported in >=kilo, skipping")
|
||||||
|
return
|
||||||
|
sentry_unit = self.ceph0_sentry
|
||||||
|
action_id = u.run_action(sentry_unit,
|
||||||
|
'show-disk-free',
|
||||||
|
params={'format': 'json'})
|
||||||
|
assert u.wait_on_action(action_id), "Show-disk-free action failed."
|
||||||
|
data = amulet.actions.get_action_output(action_id, full_output=True)
|
||||||
|
assert data.get(u"status") == "completed", "Show-disk-free failed"
|
||||||
|
message = data.get(u"results").get(u"message")
|
||||||
|
assert message is not None
|
||||||
|
jsonout = json.loads(message.strip())
|
||||||
|
nodes = jsonout.get(u"nodes")
|
||||||
|
assert nodes is not None, "Show-disk-free: no 'nodes' elem"
|
||||||
|
assert len(nodes) > 0, "Show-disk-free action: 0 nodes"
|
||||||
|
|
||||||
def test_499_ceph_cmds_exit_zero(self):
|
def test_499_ceph_cmds_exit_zero(self):
|
||||||
"""Check basic functionality of ceph cli commands against
|
"""Check basic functionality of ceph cli commands against
|
||||||
all ceph units."""
|
all ceph units."""
|
||||||
|
Loading…
Reference in New Issue
Block a user