mirror of
git://git.proxmox.com/git/pve-storage.git
synced 2025-01-11 05:18:01 +03:00
api/cli: add pbs scan endpoint and command
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
11a942a18a
commit
39fc0c77e2
@ -47,6 +47,7 @@ __PACKAGE__->register_method({
|
||||
{ method => 'iscsi' },
|
||||
{ method => 'lvm' },
|
||||
{ method => 'nfs' },
|
||||
{ method => 'pbs' },
|
||||
{ method => 'usb' },
|
||||
{ method => 'zfs' },
|
||||
];
|
||||
@ -174,6 +175,71 @@ __PACKAGE__->register_method({
|
||||
return $data;
|
||||
}});
|
||||
|
||||
__PACKAGE__->register_method({
|
||||
name => 'pbsscan',
|
||||
path => 'pbs',
|
||||
method => 'GET',
|
||||
description => "Scan remote Proxmox Backup Server.",
|
||||
protected => 1,
|
||||
proxyto => "node",
|
||||
permissions => {
|
||||
check => ['perm', '/storage', ['Datastore.Allocate']],
|
||||
},
|
||||
parameters => {
|
||||
additionalProperties => 0,
|
||||
properties => {
|
||||
node => get_standard_option('pve-node'),
|
||||
server => {
|
||||
description => "The server address (name or IP).",
|
||||
type => 'string', format => 'pve-storage-server',
|
||||
},
|
||||
username => {
|
||||
description => "User-name or API token-ID.",
|
||||
type => 'string',
|
||||
},
|
||||
password => {
|
||||
description => "User password or API token secret.",
|
||||
type => 'string',
|
||||
},
|
||||
fingerprint => get_standard_option('fingerprint-sha256', {
|
||||
optional => 1,
|
||||
}),
|
||||
port => {
|
||||
description => "Optional port.",
|
||||
type => 'integer',
|
||||
minimum => 1,
|
||||
maximum => 65535,
|
||||
default => 8007,
|
||||
optional => 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
returns => {
|
||||
type => 'array',
|
||||
items => {
|
||||
type => "object",
|
||||
properties => {
|
||||
store => {
|
||||
description => "The datastore name.",
|
||||
type => 'string',
|
||||
},
|
||||
comment => {
|
||||
description => "Comment from server.",
|
||||
type => 'string',
|
||||
optional => 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
code => sub {
|
||||
my ($param) = @_;
|
||||
|
||||
my $password = delete $param->{password};
|
||||
|
||||
return PVE::Storage::PBSPlugin::scan_datastores($param, $password);
|
||||
}
|
||||
});
|
||||
|
||||
# Note: GlusterFS currently does not have an equivalent of showmount.
|
||||
# As workaround, we simply use nfs showmount.
|
||||
# see http://www.gluster.org/category/volumes/
|
||||
|
@ -54,6 +54,7 @@ sub param_mapping {
|
||||
my $mapping = {
|
||||
'cifsscan' => [ $password_map ],
|
||||
'cifs' => [ $password_map ],
|
||||
'pbs' => [ $password_map ],
|
||||
'create' => [ $password_map, $enc_key_map ],
|
||||
'update' => [ $password_map, $enc_key_map ],
|
||||
};
|
||||
@ -506,6 +507,11 @@ __PACKAGE__->register_method ({
|
||||
};
|
||||
}});
|
||||
|
||||
my $print_api_result = sub {
|
||||
my ($data, $schema, $options) = @_;
|
||||
PVE::CLIFormatter::print_api_result($data, $schema, undef, $options);
|
||||
};
|
||||
|
||||
our $cmddef = {
|
||||
add => [ "PVE::API2::Storage::Config", 'create', ['type', 'storage'] ],
|
||||
set => [ "PVE::API2::Storage::Config", 'update', ['storage'] ],
|
||||
@ -577,6 +583,14 @@ our $cmddef = {
|
||||
printf "$rec->{lv}\n";
|
||||
}
|
||||
}],
|
||||
pbs => [
|
||||
"PVE::API2::Storage::Scan",
|
||||
'pbsscan',
|
||||
['server', 'username'],
|
||||
{ node => $nodename },
|
||||
$print_api_result,
|
||||
$PVE::RESTHandler::standard_output_options,
|
||||
],
|
||||
zfs => [ "PVE::API2::Storage::Scan", 'zfsscan', [], { node => $nodename }, sub {
|
||||
my $res = shift;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user