[pve-devel] [v2 manager 12/27] pveceph: add lsstorages CLI command

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Aug 29 13:04:34 CEST 2017


Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
changes since v1:
- adapt to changes of lsstorages API path

 PVE/CLI/pveceph.pm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm
index 00e45763..01663167 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', 'KRBD';
+	foreach my $p (sort {$a->{storage} cmp $b->{storage}} @$res) {
+	    printf "%-${maxlen}s %s\n", $p->{storage}, $p->{krbd} ? 'Yes' : 'No';
+	}
+    }],
     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