diff --git a/PVE/API2/Storage/Scan.pm b/PVE/API2/Storage/Scan.pm index bd6c264..76fbd81 100644 --- a/PVE/API2/Storage/Scan.pm +++ b/PVE/API2/Storage/Scan.pm @@ -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/ diff --git a/PVE/CLI/pvesm.pm b/PVE/CLI/pvesm.pm index 8f7740e..3594774 100755 --- a/PVE/CLI/pvesm.pm +++ b/PVE/CLI/pvesm.pm @@ -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;