[pve-devel] [PATCH manager 13/20] pveceph: add lsstorages CLI command

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Aug 25 10:48:15 CEST 2017


Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 PVE/CLI/pveceph.pm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm
index 00e45763..16df2584 100755
--- a/PVE/CLI/pveceph.pm
+++ b/PVE/CLI/pveceph.pm
@@ -167,6 +167,26 @@ our $cmddef = {
     createpool => [ 'PVE::API2::Ceph', 'createpool', ['name'], { node => $nodename }],
     destroypool => [ 'PVE::API2::Ceph', 'destroypool', ['name'], { node => $nodename } ],
     addstorage => [ 'PVE::API2::Ceph', 'addstorage', ['name', 'storage'], { node => $nodename } ],
+    lsstorages => [ 'PVE::API2::Ceph', 'lsstorages', ['name'], { node => $nodename }, sub {
+	my $res = shift;
+
+	if (@$res == 0) {
+	    print "No pve-ceph managed storages defined on this pool\n";
+	    return;
+	}
+
+	my $maxlen = 0;
+	foreach my $res (@$res) {
+	    my $storeid = $res->{storage};
+	    $maxlen = length ($storeid) if length ($storeid) > $maxlen;
+	}
+	$maxlen+=1;
+
+	printf "%-${maxlen}s %s\n", 'Storage', 'Monitor hosts';
+	foreach my $p (sort {$a->{storage} cmp $b->{storage}} @$res) {
+	    printf "%-${maxlen}s %s\n", $p->{storage}, $p->{monhost};
+	}
+    }],
     createosd => [ 'PVE::API2::CephOSD', 'createosd', ['dev'], { node => $nodename }, $upid_exit],
     destroyosd => [ 'PVE::API2::CephOSD', 'destroyosd', ['osdid'], { node => $nodename }, $upid_exit],
     createmon => [ 'PVE::API2::Ceph', 'createmon', [], { node => $nodename }, $upid_exit],
-- 
2.11.0





More information about the pve-devel mailing list