]> git.proxmox.com Git - pve-storage.git/commitdiff
PBSPlugin: use get_repository from PVE::PBSClient
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 3 Dec 2020 11:43:39 +0000 (12:43 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 3 Dec 2020 15:53:53 +0000 (16:53 +0100)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/Storage/PBSPlugin.pm

index bc777f5943565e3bb5f620f33a5a814591e63014..6c6816ee1d7070dcedb2168315efa8d8a3ee0e2b 100644 (file)
@@ -13,6 +13,7 @@ use POSIX qw(strftime ENOENT);
 use PVE::APIClient::LWP;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::Network;
+use PVE::PBSClient;
 use PVE::Storage::Plugin;
 use PVE::Tools qw(run_command file_read_firstline trim dir_glob_regex dir_glob_foreach $IPV6RE);
 
@@ -161,18 +162,6 @@ sub print_volid {
     return "${storeid}:${volname}";
 }
 
-my sub get_server_with_port {
-    my ($scfg) = @_;
-
-    my $server = $scfg->{server};
-    $server = "[$server]" if $server =~ /^$IPV6RE$/;
-
-    if (my $port = $scfg->{port}) {
-       $server .= ":$port" if $port != 8007;
-    }
-    return $server;
-}
-
 my $USE_CRYPT_PARAMS = {
     backup => 1,
     restore => 1,
@@ -188,9 +177,7 @@ my sub do_raw_client_cmd {
     die "executable not found '$client_exe'! Proxmox backup client not installed?\n"
        if ! -x $client_exe;
 
-    my $server = get_server_with_port($scfg);
-    my $datastore = $scfg->{datastore};
-    my $username = $scfg->{username} // 'root@pam';
+    my $repo = PVE::PBSClient::get_repository($scfg);
 
     my $userns_cmd = delete $opts{userns_cmd};
 
@@ -216,7 +203,7 @@ my sub do_raw_client_cmd {
 
     push @$cmd, @$param if defined($param);
 
-    push @$cmd, "--repository", "$username\@$server:$datastore";
+    push @$cmd, "--repository", $repo;
 
     local $ENV{PBS_PASSWORD} = pbs_get_password($scfg, $storeid);
 
@@ -484,12 +471,10 @@ sub path {
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
-    my $server = get_server_with_port($scfg);
-    my $datastore = $scfg->{datastore};
-    my $username = $scfg->{username} // 'root@pam';
+    my $repo = PVE::PBSClient::get_repository($scfg);
 
     # artifical url - we currently do not use that anywhere
-    my $path = "pbs://$username\@$server:$datastore/$name";
+    my $path = "pbs://$repo/$name";
 
     return ($path, $vmid, $vtype);
 }