From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 1/1] PBSPlugin: use get_repository from PVE::PBSClient
Date: Thu, 3 Dec 2020 12:43:39 +0100 [thread overview]
Message-ID: <20201203114340.23733-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20201203114340.23733-1-d.csapak@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
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
next prev parent reply other threads:[~2020-12-03 11:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 11:43 [pve-devel] [PATCH common/storage/qemu-server] refactor pbs repo url generation Dominik Csapak
2020-12-03 11:43 ` [pve-devel] [PATCH common 1/1] PBSClient: add get_repository to generate repository urls from configs Dominik Csapak
2020-12-03 15:43 ` [pve-devel] applied: " Thomas Lamprecht
2020-12-03 11:43 ` Dominik Csapak [this message]
2020-12-03 16:23 ` [pve-devel] applied: [PATCH storage 1/1] PBSPlugin: use get_repository from PVE::PBSClient Thomas Lamprecht
2020-12-03 11:43 ` [pve-devel] [PATCH qemu-server 1/1] " Dominik Csapak
2020-12-03 17:04 ` [pve-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201203114340.23733-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox