[pve-devel] [v2 manager 09/27] ceph: implement addstorage API path

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


adds a single pve-ceph managed storage for the given pool

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
changes since v1:
- storageS in API path
- drop retrieving monitor info hash

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

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 8ba59b1f..85d3159c 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1569,6 +1569,48 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
+    name => 'addstorage',
+    path => 'pools/{name}/storages',
+    method => 'POST',
+    description => "Create storage configuration for pool",
+    proxyto => 'node',
+    protected => 1,
+    permissions => {
+	check => [ 'perm', '/', [ 'Sys.Modify', 'Datastore.Allocate' ] ],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    name => {
+		description => "The name of the pool.",
+		type => 'string',
+	    },
+	    storage => get_standard_option('pve-storage-id'),
+	    krbd => {
+		description => "Access rbd through krbd kernel module.",
+		type => 'boolean',
+		optional => 1,
+	    }
+	},
+    },
+    returns => { type => 'null' },
+    code => sub {
+	my ($param) = @_;
+
+	PVE::CephTools::check_ceph_inited();
+
+	my $pve_ckeyring_path = PVE::CephTools::get_config('pve_ckeyring_path');
+
+	die "not fully configured - missing '$pve_ckeyring_path'\n"
+	    if ! -f $pve_ckeyring_path;
+
+	$add_storage->($param->{name}, $param->{storage}, $param->{krbd});
+
+	return undef;
+    }});
+
+__PACKAGE__->register_method ({
     name => 'createpool',
     path => 'pools',
     method => 'POST',
-- 
2.11.0





More information about the pve-devel mailing list