[pve-devel] [PATCH manager 17/20] ceph/createpool: optionally add storages
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Aug 25 10:48:19 CEST 2017
introduce new API parameter 'add_storages'. if set, one
storage each is configured using the created pool:
- for containers using KRBD
- for VMs using librbd
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
PVE/API2/Ceph.pm | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 918f9dd6..470ff216 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1766,7 +1766,12 @@ __PACKAGE__->register_method ({
type => 'string',
enum => ['rbd', 'cephfs', 'rgw'],
optional => 1,
- }
+ },
+ add_storages => {
+ description => "Configure VM and CT storages using the new pool.",
+ type => 'boolean',
+ optional => 1,
+ },
},
},
returns => { type => 'null' },
@@ -1782,6 +1787,19 @@ __PACKAGE__->register_method ({
my $pool = $param->{name};
+ my $monhash;
+ if ($param->{add_storages}) {
+ $monhash = $get_monitor_hash->();
+ die "could not retrieve monitor information\n"
+ if (!$monhash || scalar keys %$monhash == 0);
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $user = $rpcenv->get_user();
+ $rpcenv->check($user, '/storage', ['Datastore.Allocate']);
+ die "pool name contains characters which are illegal for storage naming\n"
+ if !PVE::JSONSchema::parse_storage_id($pool);
+ }
+
my $pg_num = $param->{pg_num} || 64;
my $size = $param->{size} || 3;
my $min_size = $param->{min_size} || 2;
@@ -1827,6 +1845,13 @@ __PACKAGE__->register_method ({
app => $application,
});
+ if ($param->{add_storages}) {
+ eval { $add_storage->($monhash, $pool, "${pool}_vm", 0); };
+ warn "failed to add VM storage for pool '$pool': $@" if $@;
+ eval { $add_storage->($monhash, $pool, "${pool}_ct", 1); };
+ warn "failed to add CT storage for pool '$pool': $@" if $@;
+ }
+
return undef;
}});
--
2.11.0
More information about the pve-devel
mailing list