diff --git a/blue-theme/iscsi-client/images/ifaces.gif b/blue-theme/iscsi-client/images/ifaces.gif new file mode 100644 index 000000000..37b534556 Binary files /dev/null and b/blue-theme/iscsi-client/images/ifaces.gif differ diff --git a/iscsi-client/add_conn.cgi b/iscsi-client/add_conn.cgi index 574b65e85..2e6da5239 100755 --- a/iscsi-client/add_conn.cgi +++ b/iscsi-client/add_conn.cgi @@ -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'}, diff --git a/iscsi-client/add_form.cgi b/iscsi-client/add_form.cgi index 7e912dc6c..0b1944265 100755 --- a/iscsi-client/add_form.cgi +++ b/iscsi-client/add_form.cgi @@ -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'} || "$text{'conns_ifacedef'}"); print &ui_table_row($text{'add_target'}, &ui_select("target", undef, diff --git a/iscsi-client/images/ifaces.gif b/iscsi-client/images/ifaces.gif new file mode 100644 index 000000000..8932c3fd0 Binary files /dev/null and b/iscsi-client/images/ifaces.gif differ diff --git a/iscsi-client/index.cgi b/iscsi-client/index.cgi index 0c785b322..cfda56d37 100755 --- a/iscsi-client/index.cgi +++ b/iscsi-client/index.cgi @@ -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 diff --git a/iscsi-client/iscsi-client-lib.pl b/iscsi-client/iscsi-client-lib.pl index 5397ada39..d59a8a83d 100644 --- a/iscsi-client/iscsi-client-lib.pl +++ b/iscsi-client/iscsi-client-lib.pl @@ -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; diff --git a/iscsi-client/lang/en b/iscsi-client/lang/en index 386d62be2..499195ea4 100644 --- a/iscsi-client/lang/en +++ b/iscsi-client/lang/en @@ -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 diff --git a/iscsi-client/list_conns.cgi b/iscsi-client/list_conns.cgi index db1477e2e..8c20b049f 100755 --- a/iscsi-client/list_conns.cgi +++ b/iscsi-client/list_conns.cgi @@ -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'} ] ]); diff --git a/iscsi-client/log_parser.pl b/iscsi-client/log_parser.pl new file mode 100755 index 000000000..506e23011 --- /dev/null +++ b/iscsi-client/log_parser.pl @@ -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}; + } +} +