From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id DC7E461983 for ; Thu, 3 Dec 2020 12:43:42 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DA97A28DE3 for ; Thu, 3 Dec 2020 12:43:42 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 37D8428DC9 for ; Thu, 3 Dec 2020 12:43:41 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id F3B0244E30 for ; Thu, 3 Dec 2020 12:43:40 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Thu, 3 Dec 2020 12:43:39 +0100 Message-Id: <20201203114340.23733-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201203114340.23733-1-d.csapak@proxmox.com> References: <20201203114340.23733-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.296 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pbsplugin.pm] Subject: [pve-devel] [PATCH storage 1/1] PBSPlugin: use get_repository from PVE::PBSClient X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Dec 2020 11:43:42 -0000 Signed-off-by: Dominik Csapak --- PVE/Storage/PBSPlugin.pm | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/PVE/Storage/PBSPlugin.pm b/PVE/Storage/PBSPlugin.pm index 43bd72f..4d00472 100644 --- a/PVE/Storage/PBSPlugin.pm +++ b/PVE/Storage/PBSPlugin.pm @@ -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); } -- 2.20.1