check => ['perm', '/storage', ['Datastore.Allocate']],
},
parameters => PVE::Storage::Plugin->createSchema(),
- returns => { type => 'null' },
+ returns => {
+ type => 'object',
+ properties => {
+ storage => {
+ description => "The ID of the created storage.",
+ type => 'string',
+ },
+ type => {
+ description => "The type of the created storage.",
+ type => 'string',
+ enum => $storage_type_enum,
+ },
+ config => {
+ description => "Partial, possible server generated, configuration properties.",
+ type => 'object',
+ optional => 1,
+ additionalProperties => 1,
+ properties => {
+ 'encryption-key' => {
+ description => "The, possible auto-generated, encryption-key.",
+ optional => 1,
+ type => 'string',
+ },
+ },
+ },
+ },
+ },
code => sub {
my ($param) = @_;
my $plugin = PVE::Storage::Plugin->lookup($type);
my $opts = $plugin->check_config($storeid, $param, 1, 1);
- PVE::Storage::lock_storage_config(sub {
+ my $returned_config;
+ PVE::Storage::lock_storage_config(sub {
my $cfg = PVE::Storage::config();
if (my $scfg = PVE::Storage::storage_config($cfg, $storeid, 1)) {
$cfg->{ids}->{$storeid} = $opts;
- $plugin->on_add_hook($storeid, $opts, %$sensitive);
+ $returned_config = $plugin->on_add_hook($storeid, $opts, %$sensitive);
eval {
# try to activate if enabled on local node,
}, "create storage failed");
- return undef;
+ my $res = {
+ storage => $storeid,
+ type => $type,
+ };
+ $res->{config} = $returned_config if $returned_config;
+ return $res;
}});
__PACKAGE__->register_method ({
check => ['perm', '/storage', ['Datastore.Allocate']],
},
parameters => PVE::Storage::Plugin->updateSchema(),
- returns => { type => 'null' },
+ returns => {
+ type => 'object',
+ properties => {
+ storage => {
+ description => "The ID of the created storage.",
+ type => 'string',
+ },
+ type => {
+ description => "The type of the created storage.",
+ type => 'string',
+ enum => $storage_type_enum,
+ },
+ config => {
+ description => "Partial, possible server generated, configuration properties.",
+ type => 'object',
+ optional => 1,
+ additionalProperties => 1,
+ properties => {
+ 'encryption-key' => {
+ description => "The, possible auto-generated, encryption-key.",
+ optional => 1,
+ type => 'string',
+ },
+ },
+ },
+ },
+ },
code => sub {
my ($param) = @_;
my $storeid = extract_param($param, 'storage');
my $digest = extract_param($param, 'digest');
my $delete = extract_param($param, 'delete');
+ my $type;
if ($delete) {
$delete = [ PVE::Tools::split_list($delete) ];
}
+ my $returned_config;
PVE::Storage::lock_storage_config(sub {
my $cfg = PVE::Storage::config();
PVE::SectionConfig::assert_if_modified($cfg, $digest);
my $scfg = PVE::Storage::storage_config($cfg, $storeid);
- my $type = $scfg->{type};
+ $type = $scfg->{type};
my $sensitive = extract_sensitive_params($param, $delete);
}
}
- $plugin->on_update_hook($storeid, $opts, %$sensitive);
+ $returned_config = $plugin->on_update_hook($storeid, $opts, %$sensitive);
for my $k (keys %$opts) {
$scfg->{$k} = $opts->{$k};
}, "update storage failed");
- return undef;
+ my $res = {
+ storage => $storeid,
+ type => $type,
+ };
+ $res->{config} = $returned_config if $returned_config;
+ return $res;
}});
__PACKAGE__->register_method ({
additionalProperties => 0,
properties => {
storage => get_standard_option('pve-storage-id', {
- completion => \&PVE::Storage::complete_storage,
- }),
+ completion => \&PVE::Storage::complete_storage,
+ }),
},
},
returns => { type => 'null' },