Pages listing objects

This commit is contained in:
Jamie Cameron
2012-09-03 11:38:51 -07:00
parent aa01a78e33
commit 778cc9bd87
5 changed files with 167 additions and 0 deletions

View File

@@ -76,6 +76,18 @@ close($fh);
return \@rv;
}
# find(&config, type, [number])
# Returns all config objects with the given type and optional number
sub find
{
my ($conf, $type, $num) = @_;
my @t = grep { $_->{'type'} eq $type } @$conf;
if (defined($num)) {
@t = grep { $_->{'num'} eq $num } @t;
}
return wantarray ? @t : $t[0];
}
# parse_bytes(str)
# Converts a string like 100MB into a number of bytes
sub parse_bytes

View File

@@ -11,7 +11,36 @@ index_restart=Click this button to apply the current configuration by restarting
index_restart=Restart iSCSI Server
index_atboot=Start at boot?
index_atbootdesc=Change this option to control whether the iSCSI server is started at boot time or not. If it is not currently started at boot and Yes is chosen, a new init script will be created.
index_return=module index
extents_title=Devices to Share
extents_none=No devices to share have been created yet.
extents_name=Device name
extents_file=File or device path
extents_start=Start of extent
extents_size=Size of extent
extents_add=Add a new device to share.
extents_delete=Delete Selected Devices
devices_title=Devices Combinations
devices_none=No device combinations have been created yet.
devices_name=Combination name
devices_mode=Combination type
devices_mode_raid0=Linear (RAID0)
devices_mode_raid1=Replicted (RAID1)
devices_extents=Member devices
devices_add=Add a new device combination.
devices_delete=Delete Selected Combinations
targets_title=Sharing Targets
targets_none=No sharing targets have been created yet.
targets_name=Target name
targets_flags=Sharing mode
targets_flags_ro=Read-only
targets_flags_rw=Read/write
targets_export=Device to share
targets_network=Share with network
targets_add=Add a new sharing target.
targets_delete=Delete Selected Targets

View File

@@ -0,0 +1,41 @@
#!/usr/local/bin/perl
# List all devices (combined devices)
use strict;
use warnings;
require './iscsi-server-lib.pl';
our (%text);
my $conf = &get_iscsi_config();
&ui_print_header(undef, $text{'devices_title'}, "");
my @devices = &find($conf, "device");
my @links = ( "<a href='edit_device.cgi?new=1'>$text{'devices_add'}</a>" );
if (@devices) {
unshift(@links, &select_all_link("d"), &select_invert_link("d"));
print &ui_form_start("delete_devices.cgi");
print &ui_links_row(\@links);
my @tds = ( "width=5" );
print &ui_columns_start([ undef,
$text{'devices_name'},
$text{'devices_mode'},
$text{'devices_extents'} ], 100, 0, \@tds);
foreach my $e (@devices) {
print &ui_checked_columns_row([
"<a href='edit_device.cgi?num=$e->{'num'}'>".
$e->{'type'}.$e->{'num'}."</a>",
$text{'devices_mode_'.$e->{'mode'}} ||
uc($e->{'mode'}),
join("&nbsp;|&nbsp;", @{$e->{'extents'}}),
], \@tds, "d", $e->{'num'});
}
print &ui_columns_end();
print &ui_links_row(\@links);
print &ui_form_end([ [ undef, $text{'devices_delete'} ] ]);
}
else {
print "<b>$text{'devices_none'}</b><p>\n";
print &ui_links_row(\@links);
}
&ui_print_footer("", $text{'index_return'});

View File

@@ -0,0 +1,42 @@
#!/usr/local/bin/perl
# List all extents
use strict;
use warnings;
require './iscsi-server-lib.pl';
our (%text);
my $conf = &get_iscsi_config();
&ui_print_header(undef, $text{'extents_title'}, "");
my @extents = &find($conf, "extent");
my @links = ( "<a href='edit_extent.cgi?new=1'>$text{'extents_add'}</a>" );
if (@extents) {
unshift(@links, &select_all_link("d"), &select_invert_link("d"));
print &ui_form_start("delete_extents.cgi");
print &ui_links_row(\@links);
my @tds = ( "width=5" );
print &ui_columns_start([ undef,
$text{'extents_name'},
$text{'extents_file'},
$text{'extents_start'},
$text{'extents_size'} ], 100, 0, \@tds);
foreach my $e (@extents) {
print &ui_checked_columns_row([
"<a href='edit_extent.cgi?num=$e->{'num'}'>".
$e->{'type'}.$e->{'num'}."</a>",
$e->{'device'},
&nice_size($e->{'start'}),
&nice_size($e->{'size'}),
], \@tds, "d", $e->{'num'});
}
print &ui_columns_end();
print &ui_links_row(\@links);
print &ui_form_end([ [ undef, $text{'extents_delete'} ] ]);
}
else {
print "<b>$text{'extents_none'}</b><p>\n";
print &ui_links_row(\@links);
}
&ui_print_footer("", $text{'index_return'});

View File

@@ -0,0 +1,43 @@
#!/usr/local/bin/perl
# List all targets (networks exported to)
use strict;
use warnings;
require './iscsi-server-lib.pl';
our (%text);
my $conf = &get_iscsi_config();
&ui_print_header(undef, $text{'targets_title'}, "");
my @targets = &find($conf, "target");
my @links = ( "<a href='edit_target.cgi?new=1'>$text{'targets_add'}</a>" );
if (@targets) {
unshift(@links, &select_all_link("d"), &select_invert_link("d"));
print &ui_form_start("delete_targets.cgi");
print &ui_links_row(\@links);
my @tds = ( "width=5" );
print &ui_columns_start([ undef,
$text{'targets_name'},
$text{'targets_flags'},
$text{'targets_export'},
$text{'targets_network'} ], 100, 0, \@tds);
foreach my $e (@targets) {
print &ui_checked_columns_row([
"<a href='edit_target.cgi?num=$e->{'num'}'>".
$e->{'type'}.$e->{'num'}."</a>",
$text{'targets_flags_'.$e->{'flags'}} ||
uc($e->{'flags'}),
$e->{'export'},
$e->{'network'},
], \@tds, "d", $e->{'num'});
}
print &ui_columns_end();
print &ui_links_row(\@links);
print &ui_form_end([ [ undef, $text{'targets_delete'} ] ]);
}
else {
print "<b>$text{'targets_none'}</b><p>\n";
print &ui_links_row(\@links);
}
&ui_print_footer("", $text{'index_return'});