[pve-devel] [PATCH manager 12/20] ceph: implement lsstorages API path

Fabian Gr├╝nbichler f.gruenbichler at proxmox.com
Fri Aug 25 10:48:14 CEST 2017


lists storages configured for a pool, as well as their
configured monitors

Signed-off-by: Fabian Gr├╝nbichler <f.gruenbichler at proxmox.com>
---
note: if the given pool name is not correct, this is currently not detected. it
would make the call vastly more expensive, as we would need to ask Ceph for a
list of pools..

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

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 73d885f2..f0414a47 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1582,6 +1582,47 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
+    name => 'lsstorages',
+    path => 'pools/{name}/storage',
+    method => 'GET',
+    description => "List all pveceph-managed storages of a pool.",
+    proxyto => 'node',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    name => {
+		description => "The name of the pool.",
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'array',
+	items => {
+	    type => "object",
+	    properties => {
+		storage => { type => 'string' },
+		monhost => { type => 'string' },
+	    },
+	},
+	links => [ { rel => 'child', href => "{storage}" } ],
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $storages = $get_storages->($param->{name});
+	return [ map { {
+	    storage => $_,
+	    monhost => $storages->{$_}->{monhost},
+	}} keys %$storages];
+    }});
+
+__PACKAGE__->register_method ({
     name => 'addstorage',
     path => 'pools/{name}/storage',
     method => 'POST',
-- 
2.11.0




More information about the pve-devel mailing list