iSCSI ipv6 support
This commit is contained in:
committed by
Dietmar Maurer
parent
b889ca7260
commit
1689e627a6
@ -12,7 +12,7 @@ use File::Path;
|
|||||||
use Cwd 'abs_path';
|
use Cwd 'abs_path';
|
||||||
use Socket;
|
use Socket;
|
||||||
|
|
||||||
use PVE::Tools qw(run_command file_read_firstline);
|
use PVE::Tools qw(run_command file_read_firstline $IPV6RE);
|
||||||
use PVE::Cluster qw(cfs_read_file cfs_lock_file);
|
use PVE::Cluster qw(cfs_read_file cfs_lock_file);
|
||||||
use PVE::Exception qw(raise_param_exc);
|
use PVE::Exception qw(raise_param_exc);
|
||||||
use PVE::JSONSchema;
|
use PVE::JSONSchema;
|
||||||
@ -1008,12 +1008,11 @@ sub scan_zfs {
|
|||||||
sub resolv_portal {
|
sub resolv_portal {
|
||||||
my ($portal, $noerr) = @_;
|
my ($portal, $noerr) = @_;
|
||||||
|
|
||||||
if ($portal =~ m/^([^:]+)(:(\d+))?$/) {
|
my ($server, $port) = PVE::Tools::parse_host_and_port($portal);
|
||||||
my $server = $1;
|
if ($server) {
|
||||||
my $port = $3;
|
|
||||||
|
|
||||||
if (my $ip = resolv_server($server)) {
|
if (my $ip = resolv_server($server)) {
|
||||||
$server = $ip;
|
$server = $ip;
|
||||||
|
$server = "[$server]" if $server =~ /^$IPV6RE$/;
|
||||||
return $port ? "$server:$port" : $server;
|
return $port ? "$server:$port" : $server;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,10 +5,9 @@ use warnings;
|
|||||||
use File::stat;
|
use File::stat;
|
||||||
use IO::Dir;
|
use IO::Dir;
|
||||||
use IO::File;
|
use IO::File;
|
||||||
use PVE::Tools qw(run_command file_read_firstline trim dir_glob_regex dir_glob_foreach);
|
use PVE::Tools qw(run_command file_read_firstline trim dir_glob_regex dir_glob_foreach $IPV4RE $IPV6RE);
|
||||||
use PVE::Storage::Plugin;
|
use PVE::Storage::Plugin;
|
||||||
use PVE::JSONSchema qw(get_standard_option);
|
use PVE::JSONSchema qw(get_standard_option);
|
||||||
use Net::Ping;
|
|
||||||
|
|
||||||
use base qw(PVE::Storage::Plugin);
|
use base qw(PVE::Storage::Plugin);
|
||||||
|
|
||||||
@ -62,10 +61,9 @@ sub iscsi_session_list {
|
|||||||
sub iscsi_test_portal {
|
sub iscsi_test_portal {
|
||||||
my ($portal) = @_;
|
my ($portal) = @_;
|
||||||
|
|
||||||
my ($server, $port) = split(':', $portal);
|
my ($server, $port) = PVE::Tools::parse_host_and_port($portal);
|
||||||
my $p = Net::Ping->new("tcp", 2);
|
return 0 if !$server;
|
||||||
$p->port_number($port || 3260);
|
return PVE::Network::tcp_ping($server, $port || 3260, 2);
|
||||||
return $p->ping($server);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub iscsi_discovery {
|
sub iscsi_discovery {
|
||||||
@ -83,7 +81,7 @@ sub iscsi_discovery {
|
|||||||
run_command($cmd, outfunc => sub {
|
run_command($cmd, outfunc => sub {
|
||||||
my $line = shift;
|
my $line = shift;
|
||||||
|
|
||||||
if ($line =~ m/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+)\,\S+\s+(\S+)\s*$/) {
|
if ($line =~ m/^((?:$IPV4RE|\[$IPV6RE\]):\d+)\,\S+\s+(\S+)\s*$/) {
|
||||||
my $portal = $1;
|
my $portal = $1;
|
||||||
my $target = $2;
|
my $target = $2;
|
||||||
# one target can have more than one portal (multipath).
|
# one target can have more than one portal (multipath).
|
||||||
|
|||||||
@ -57,12 +57,12 @@ my $execute_command = sub {
|
|||||||
$err .= "$line";
|
$err .= "$line";
|
||||||
};
|
};
|
||||||
|
|
||||||
$target = 'root@' . $scfg->{portal};
|
|
||||||
|
|
||||||
if ($exec eq 'scp') {
|
if ($exec eq 'scp') {
|
||||||
$cmd = [@scp_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $method, "$target:$params[0]"];
|
$target = 'root@[' . $scfg->{portal} . ']';
|
||||||
|
$cmd = [@scp_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", '--', $method, "$target:$params[0]"];
|
||||||
} else {
|
} else {
|
||||||
$cmd = [@ssh_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $target, $method, @params];
|
$target = 'root@' . $scfg->{portal};
|
||||||
|
$cmd = [@ssh_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $target, '--', $method, @params];
|
||||||
}
|
}
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
|
|||||||
@ -133,7 +133,7 @@ sub verify_portal_dns {
|
|||||||
my ($portal, $noerr) = @_;
|
my ($portal, $noerr) = @_;
|
||||||
|
|
||||||
# IP or DNS name with optional port
|
# IP or DNS name with optional port
|
||||||
if ($portal !~ m/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[[:alnum:]\-\.]+)(:\d+)?$/) {
|
if (!PVE::Tools::parse_host_and_port($portal)) {
|
||||||
return undef if $noerr;
|
return undef if $noerr;
|
||||||
die "value does not look like a valid portal address\n";
|
die "value does not look like a valid portal address\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user