mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Work on interfaces list / selection
This commit is contained in:
BIN
blue-theme/iscsi-client/images/ifaces.gif
Normal file
BIN
blue-theme/iscsi-client/images/ifaces.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -9,7 +9,7 @@ our (%text, %in);
|
||||
&error_setup($text{'add_err'});
|
||||
|
||||
# Re-check the list of targets
|
||||
my $targets = &list_iscsi_targets($in{'host'}, $in{'port'});
|
||||
my $targets = &list_iscsi_targets($in{'host'}, $in{'port'}, $in{'iface'});
|
||||
ref($targets) || &error(&text('add_etargets', $in{'host'}, $targets));
|
||||
my $target = undef;
|
||||
if ($in{'target'}) {
|
||||
@@ -19,7 +19,8 @@ if ($in{'target'}) {
|
||||
}
|
||||
|
||||
# Try to make the connection
|
||||
my $err = &create_iscsi_connection($in{'host'}, $in{'port'}, $target);
|
||||
my $err = &create_iscsi_connection($in{'host'}, $in{'port'},
|
||||
$in{'iface'}, $target);
|
||||
&error($err) if ($err);
|
||||
|
||||
&webmin_log("add", "connection", $in{'host'},
|
||||
|
||||
@@ -18,7 +18,7 @@ $in{'port_def'} || $in{'port'} =~ /^\d+$/ ||
|
||||
|
||||
# Get list of targets from the host
|
||||
my $targets = &list_iscsi_targets(
|
||||
$in{'host'}, $in{'port_def'} ? undef : $in{'port'});
|
||||
$in{'host'}, $in{'port_def'} ? undef : $in{'port'}, $in{'iface'});
|
||||
ref($targets) || &error(&text('add_etargets', $in{'host'}, $targets));
|
||||
@$targets || &error(&text('add_etargets2', $in{'host'}));
|
||||
|
||||
@@ -32,11 +32,14 @@ my %used = map { $_->{'name'}.":".$_->{'target'}, $_ }
|
||||
print &ui_form_start("add_conn.cgi", "post");
|
||||
print &ui_hidden("host", $in{'host'});
|
||||
print &ui_hidden("port", $in{'port_def'} ? undef : $in{'port'});
|
||||
print &ui_hidden("iface", $in{'iface'});
|
||||
print &ui_table_start($text{'conns_header'}, undef, 2);
|
||||
|
||||
print &ui_table_row($text{'conns_host'}, $in{'host'});
|
||||
print &ui_table_row($text{'conns_port'},
|
||||
$in{'port_def'} ? $text{'default'} : $in{'port'});
|
||||
print &ui_table_row($text{'conns_iface'},
|
||||
$in{'iface'} || "<i>$text{'conns_ifacedef'}</i>");
|
||||
|
||||
print &ui_table_row($text{'add_target'},
|
||||
&ui_select("target", undef,
|
||||
|
||||
BIN
iscsi-client/images/ifaces.gif
Normal file
BIN
iscsi-client/images/ifaces.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 362 B |
@@ -15,12 +15,15 @@ if ($err) {
|
||||
}
|
||||
|
||||
my @links = ( "edit_auth.cgi", "edit_timeout.cgi",
|
||||
"edit_iscsi.cgi", "list_conns.cgi" );
|
||||
"edit_iscsi.cgi", "list_ifaces.cgi",
|
||||
"list_conns.cgi" );
|
||||
my @titles = ( $text{'auth_title'}, $text{'timeout_title'},
|
||||
$text{'iscsi_title'}, $text{'conns_title'} );
|
||||
$text{'iscsi_title'}, $text{'ifaces_title'},
|
||||
$text{'conns_title'} );
|
||||
my @icons = ( "images/auth.gif", "images/timeout.gif",
|
||||
"images/iscsi.gif", "images/conns.gif" );
|
||||
&icons_table(\@links, \@titles, \@icons, 4);
|
||||
"images/iscsi.gif", "images/ifaces.gif",
|
||||
"images/conns.gif" );
|
||||
&icons_table(\@links, \@titles, \@icons, 5);
|
||||
|
||||
if ($config{'init_name'}) {
|
||||
# Show start at boot button
|
||||
|
||||
@@ -163,14 +163,15 @@ foreach my $l (@lines) {
|
||||
return \@rv;
|
||||
}
|
||||
|
||||
# list_iscsi_targets(host, [port])
|
||||
# list_iscsi_targets(host, [port], [iface])
|
||||
# Returns an array ref listing available targets on some host, or an error
|
||||
# message string
|
||||
sub list_iscsi_targets
|
||||
{
|
||||
my ($host, $port) = @_;
|
||||
my ($host, $port, $iface) = @_;
|
||||
my $cmd = "$config{'iscsiadm'} -m discovery -t sendtargets -p ".
|
||||
quotemeta($host).($port ? ":".quotemeta($port) : "");
|
||||
quotemeta($host).($port ? ":".quotemeta($port) : "").
|
||||
($iface ? " -I ".quotemeta($iface) : "");
|
||||
&clean_language();
|
||||
my $out = &backquote_command("$cmd 2>&1");
|
||||
&reset_environment();
|
||||
@@ -190,15 +191,16 @@ foreach my $l (@lines) {
|
||||
return \@rv;
|
||||
}
|
||||
|
||||
# create_iscsi_connection(host, [port], [&target])
|
||||
# create_iscsi_connection(host, [port], [iface], [&target])
|
||||
# Attempts to connect to an iscsi server for the given target (or all targets)
|
||||
sub create_iscsi_connection
|
||||
{
|
||||
my ($host, $port, $target) = @_;
|
||||
my ($host, $port, $iface, $target) = @_;
|
||||
my $cmd = "$config{'iscsiadm'} -m node".
|
||||
($target ? " -T ".quotemeta($target->{'name'}).":".
|
||||
quotemeta($target->{'target'}) : "").
|
||||
" -p ".quotemeta($host).($port ? ":".quotemeta($port) : "").
|
||||
($iface ? " -I ".quotemeta($iface) : "").
|
||||
" --login";
|
||||
&clean_language();
|
||||
my $out = &backquote_command("$cmd 2>&1");
|
||||
@@ -269,4 +271,37 @@ $out =~ s/\r?\n//;
|
||||
return $out;
|
||||
}
|
||||
|
||||
# list_iscsi_ifaces()
|
||||
# Returns an array ref of details of all existing interfaces
|
||||
sub list_iscsi_ifaces
|
||||
{
|
||||
&clean_language();
|
||||
my $out = &backquote_command(
|
||||
"$config{'iscsiadm'} -m iface -o show -P 1 2>/dev/null");
|
||||
&reset_environment();
|
||||
my @lines = split(/\r?\n/, $out);
|
||||
if ($?) {
|
||||
return $lines[0];
|
||||
}
|
||||
my @rv;
|
||||
my ($iface, $target);
|
||||
foreach my $l (@lines) {
|
||||
if ($l =~ /^Iface:\s+(\S+)/) {
|
||||
$iface = { 'name' => $1,
|
||||
'targets' => [ ] };
|
||||
push(@rv, $iface);
|
||||
}
|
||||
elsif ($l =~ /Target:\s+(\S+):(\S+)/) {
|
||||
$target = { 'name' => $1,
|
||||
'target' => $2 };
|
||||
push(@{$iface->{'targets'}}, $target);
|
||||
}
|
||||
elsif ($l =~ /Portal:\s+(\S+):(\d+)/) {
|
||||
$target->{'ip'} = $1;
|
||||
$target->{'port'} = $2;
|
||||
}
|
||||
}
|
||||
return \@rv;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -66,6 +66,8 @@ iscsi_eretry=Missing or non-numeric number of times to re-try login
|
||||
iscsi_ecmds=Missing or non-numeric maximum commands queued per session
|
||||
iscsi_equeue=Missing or non-numeric maximum commands queued per device
|
||||
|
||||
ifaces_title=iSCSI Interfaces
|
||||
|
||||
conns_title=iSCSI Connections
|
||||
conns_elist=Failed to list connections : $1
|
||||
conns_ip=Server IP
|
||||
@@ -82,6 +84,9 @@ conns_host=iSCSI server hostname or IP
|
||||
conns_port=iSCSI server port
|
||||
conns_start=Connect..
|
||||
conns_return=list of connections
|
||||
conns_iface=iSCSI interface
|
||||
conns_ifacedef=Choose automatically
|
||||
conns_ifaceerr=Failed to fetch interfaces : $1
|
||||
|
||||
add_title=Add iSCSI Connection
|
||||
add_err=Failed to add iSCSI connection
|
||||
|
||||
@@ -47,6 +47,19 @@ print &ui_table_row($text{'conns_host'},
|
||||
print &ui_table_row($text{'conns_port'},
|
||||
&ui_opt_textbox("port", undef, 5, $text{'default'}." (3260)"));
|
||||
|
||||
# Interface to use
|
||||
my $ifaces = &list_iscsi_ifaces();
|
||||
if (ref($ifaces)) {
|
||||
print &ui_table_row($text{'conns_iface'},
|
||||
&ui_select("iface", undef,
|
||||
[ [ undef, "<".$text{'conns_ifacedef'}.">" ],
|
||||
map { $_->{'name'} } @$ifaces ]));
|
||||
}
|
||||
else {
|
||||
print &ui_table_row($text{'conns_iface'},
|
||||
&text('conns_ifaceerr', $ifaces));
|
||||
}
|
||||
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'conns_start'} ] ]);
|
||||
|
||||
|
||||
22
iscsi-client/log_parser.pl
Executable file
22
iscsi-client/log_parser.pl
Executable file
@@ -0,0 +1,22 @@
|
||||
# log_parser.pl
|
||||
# Functions for parsing this module's logs
|
||||
|
||||
do 'iscsi-client-lib.pl';
|
||||
|
||||
# parse_webmin_log(user, script, action, type, object, ¶ms)
|
||||
# Converts logged information from this module into human-readable form
|
||||
sub parse_webmin_log
|
||||
{
|
||||
my ($user, $script, $action, $type, $object, $p) = @_;
|
||||
if ($type eq "connection") {
|
||||
return &text('log_'.$action.'_'.$type, &html_escape($p->{'host'}),
|
||||
&html_escape($p->{'target'}));
|
||||
}
|
||||
elsif ($type eq "connections") {
|
||||
return &text('log_'.$action.'_'.$type, $object);
|
||||
}
|
||||
else {
|
||||
return $text{'log_'.$action};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user