]> git.proxmox.com Git - pve-storage.git/commitdiff
esxi: add 'port' config parameter
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 28 Mar 2024 13:18:34 +0000 (14:18 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 28 Mar 2024 13:34:24 +0000 (14:34 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/Storage/ESXiPlugin.pm
src/PVE/Storage/PBSPlugin.pm

index 06da280375de7180a3a946c8c06b6f7628cc6f0c..b3522f59a46d60231a177e247cef3e159c7da99e 100644 (file)
@@ -4,9 +4,10 @@ use strict;
 use warnings;
 
 use Fcntl qw(F_GETFD F_SETFD FD_CLOEXEC);
+use File::Path qw(mkpath remove_tree);
 use JSON qw(from_json);
+use Net::IP;
 use POSIX ();
-use File::Path qw(mkpath remove_tree);
 
 use PVE::Network;
 use PVE::Systemd;
@@ -54,6 +55,7 @@ sub options {
        username => {},
        password => { optional => 1},
        'skip-cert-verification' => { optional => 1},
+       port => { optional => 1 },
    };
 }
 
@@ -136,6 +138,9 @@ sub get_manifest : prototype($$$;$) {
 
     my @extra_params;
     push @extra_params, '--skip-cert-verification' if $scfg->{'skip-cert-verification'};
+    if (my $port = $scfg->{port}) {
+       push @extra_params, '--port', $port;
+    }
     my $host = $scfg->{server};
     my $user = $scfg->{username};
     my $pwfile = esxi_cred_file_name($storeid);
@@ -191,6 +196,12 @@ sub esxi_mount : prototype($$$;$) {
     my $host = $scfg->{server};
     my $pwfile = esxi_cred_file_name($storeid);
 
+    my $hostport = $host;
+    $hostport = "[$hostport]" if Net::IP::ip_is_ipv6($host);
+    if (my $port = $scfg->{port}) {
+       $hostport .= ":$port";
+    }
+
     pipe(my $rd, my $wr) or die "failed to create pipe: $!\n";
 
     my $pid = fork();
@@ -221,7 +232,7 @@ sub esxi_mount : prototype($$$;$) {
                '--ready-fd', fileno($wr),
                '--user', $user,
                '--password-file', $pwfile,
-               $host,
+               $hostport,
                $manifest_file,
                $mount_dir;
            die "exec failed: $!\n";
@@ -387,7 +398,8 @@ sub deactivate_volume {
 sub check_connection {
     my ($class, $storeid, $scfg) = @_;
 
-    return PVE::Network::tcp_ping($scfg->{server}, 443, 2);
+    my $port = $scfg->{port} || 443;
+    return PVE::Network::tcp_ping($scfg->{server}, $port, 2);
 }
 
 sub status {
index 4320974b6b9c03c6ce4b722fb6b7d06550c7f359..08ceb88e84205946065a67e9c9298436327c1a15 100644 (file)
@@ -54,7 +54,6 @@ sub properties {
            type => 'integer',
            minimum => 1,
            maximum => 65535,
-           default => 8007,
        },
     };
 }