From 8b336060cb1d1a301c35ed2f3ead93140941a39f Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 3 Jan 2014 10:46:59 +0100 Subject: [PATCH] ceph: return decompiled crush map in text format. This is easier to read. --- PVE/API2/Ceph.pm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm index 8ee46101..8639287e 100644 --- a/PVE/API2/Ceph.pm +++ b/PVE/API2/Ceph.pm @@ -1273,8 +1273,26 @@ __PACKAGE__->register_method ({ &$check_ceph_inited(); - my $txt = &$run_ceph_cmd_text(['osd', 'crush', 'dump'], quiet => 1); + # this produces JSON (difficult to read for the user) + # my $txt = &$run_ceph_cmd_text(['osd', 'crush', 'dump'], quiet => 1); + my $txt = ''; + + my $mapfile = "/var/tmp/ceph-crush.map.$$"; + my $mapdata = "/var/tmp/ceph-crush.txt.$$"; + + eval { + &$run_ceph_cmd(['osd', 'getcrushmap', '-o', $mapfile]); + run_command(['crushtool', '-d', $mapfile, '-o', $mapdata]); + $txt = PVE::Tools::file_get_contents($mapdata); + }; + my $err = $@; + + unlink $mapfile; + unlink $mapdata; + + die $err if $err; + return $txt; }});