[pve-devel] [PATCH manager 10/20] ceph: implement addstorage API path

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


adds a single storage for the given pool and options, using
the current monitor information

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

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index a49fa9c7..73d885f2 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1582,6 +1582,52 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
+    name => 'addstorage',
+    path => 'pools/{name}/storage',
+    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;
+
+	my $monhash = $get_monitor_hash->();
+	die "could not retrieve monitor information\n"
+	    if (!$monhash || scalar keys %$monhash == 0);
+
+	$add_storage->($monhash, $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