[pve-devel] [v2 manager 07/27] ceph: add get_storages helper

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


Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
rebased v1

 PVE/API2/Ceph.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 04a19524..dfcecbec 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -737,6 +737,24 @@ my $add_storage = sub {
     }
 };
 
+my $get_storages = sub {
+    my ($pool) = @_;
+
+    my $cfg = PVE::Storage::config();
+
+    my $storages = $cfg->{ids};
+    my $res = {};
+    foreach my $storeid (keys %$storages) {
+	my $curr = $storages->{$storeid};
+	$res->{$storeid} = $storages->{$storeid}
+	    if $curr->{type} eq 'rbd' &&
+	       $curr->{pveceph} &&
+	       (!defined($pool) || $pool eq $curr->{pool});
+    }
+
+    return $res;
+};
+
 __PACKAGE__->register_method ({
     name => 'listmon',
     path => 'mon',
-- 
2.11.0





More information about the pve-devel mailing list