First, doing such things can make client work slightly easier, as the
submitted values do not need to be made available in any callback
handling the response.
But the actual reason for doing this now is, that this is a
preparatory step for allowing the user to download/print/.. an
autogenerated PBS client encryption key.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
check => ['perm', '/storage', ['Datastore.Allocate']],
},
parameters => PVE::Storage::Plugin->createSchema(),
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) = @_;
code => sub {
my ($param) = @_;
my $plugin = PVE::Storage::Plugin->lookup($type);
my $opts = $plugin->check_config($storeid, $param, 1, 1);
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)) {
my $cfg = PVE::Storage::config();
if (my $scfg = PVE::Storage::storage_config($cfg, $storeid, 1)) {
$cfg->{ids}->{$storeid} = $opts;
$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,
eval {
# try to activate if enabled on local node,
}, "create storage failed");
}, "create storage failed");
+ my $res = {
+ storage => $storeid,
+ type => $type,
+ };
+ $res->{config} = $returned_config if $returned_config;
+ return $res;
}});
__PACKAGE__->register_method ({
}});
__PACKAGE__->register_method ({
check => ['perm', '/storage', ['Datastore.Allocate']],
},
parameters => PVE::Storage::Plugin->updateSchema(),
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');
code => sub {
my ($param) = @_;
my $storeid = extract_param($param, 'storage');
my $digest = extract_param($param, 'digest');
my $delete = extract_param($param, 'delete');
if ($delete) {
$delete = [ PVE::Tools::split_list($delete) ];
}
if ($delete) {
$delete = [ PVE::Tools::split_list($delete) ];
}
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);
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};
my $sensitive = extract_sensitive_params($param, $delete);
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};
for my $k (keys %$opts) {
$scfg->{$k} = $opts->{$k};
}, "update storage failed");
}, "update storage failed");
+ my $res = {
+ storage => $storeid,
+ type => $type,
+ };
+ $res->{config} = $returned_config if $returned_config;
+ return $res;
}});
__PACKAGE__->register_method ({
}});
__PACKAGE__->register_method ({
additionalProperties => 0,
properties => {
storage => get_standard_option('pve-storage-id', {
additionalProperties => 0,
properties => {
storage => get_standard_option('pve-storage-id', {
- completion => \&PVE::Storage::complete_storage,
- }),
+ completion => \&PVE::Storage::complete_storage,
+ }),
},
},
returns => { type => 'null' },
},
},
returns => { type => 'null' },