use strict;
use warnings;
+
use PVE::Tools qw(run_command file_read_firstline trim dir_glob_regex dir_glob_foreach);
-use Data::Dumper;
my @CONFIG_FILES = (
'/usr/local/etc/istgt/istgt.conf', # FreeBSD, FreeNAS
my @options = ();
my $lun = $get_lu_name->($target);
if ($scfg->{nowritecache}) {
- push @options, "WriteCache Disable";
+ push @options, "WriteCache Disable";
}
my $conf = {
lun => $lun,
} elsif ($lun) {
next if (($_ =~ /^\s*#/) || ($_ =~ /^\s*$/));
if ($_ =~ /^\s*(\w+)\s+(.+)\s*/) {
- next if $2 =~ /^Option.*/;
- $SETTINGS->{$lun}->{$1} = $2;
- $SETTINGS->{$lun}->{$1} =~ s/^\s+|\s+$|"\s*//g;
+ my $arg1 = $1;
+ my $arg2 = $2;
+ $arg2 =~ s/^\s+|\s+$|"\s*//g;
+ if ($arg2 =~ /^Storage\s*(.+)/i) {
+ $SETTINGS->{$lun}->{$arg1}->{storage} = $1;
+ } elsif ($arg2 =~ /^Option\s*(.+)/i) {
+ push @{$SETTINGS->{$lun}->{$arg1}->{options}}, $1;
+ } else {
+ $SETTINGS->{$lun}->{$arg1} = $arg2;
+ }
} else {
die "$line: parse error [$_]";
}
my $lu = ();
while ((my $key, my $val) = each(%{$SETTINGS->{"LogicalUnit$i"}})) {
if ($key =~ /^LUN\d+/) {
- if ($val =~ /^Storage\s+([\w\/\-]+)\s+(\w+)/) {
- my $storage = $1;
- my $size = $parse_size->($2);
- my $conf = undef;
- if ($storage =~ /^$base\/$scfg->{pool}\/([\w\-]+)$/) {
- $conf = {
- lun => $key,
- Storage => $storage,
- Size => $size,
- };
+ $val->{storage} =~ /^([\w\/\-]+)\s+(\w+)/;
+ my $storage = $1;
+ my $size = $parse_size->($2);
+ my $conf = undef;
+ my @options = ();
+ if ($val->{options}) {
+ @options = @{$val->{options}};
+ }
+ if ($storage =~ /^$base\/$scfg->{pool}\/([\w\-]+)$/) {
+ $conf = {
+ lun => $key,
+ Storage => $storage,
+ Size => $size,
+ options => @options,
}
- push @$lu, $conf if $conf;
}
+ push @$lu, $conf if $conf;
delete $SETTINGS->{"LogicalUnit$i"}->{$key};
}
}
my $cmdmap;
if (@params && $params[0] eq 'restart') {
- @params = ('restart', '1>&2', '>', '/dev/null');
+ @params = ('onerestart', '>&', '/dev/null');
$cmdmap = {
cmd => 'ssh',
method => $DAEMON,
params => \@params,
};
} else {
- @params = ('-HUP', '$(cat '. "$SETTINGS->{pidfile})");
+ @params = ('-HUP', '`cat '. "$SETTINGS->{pidfile}`");
$cmdmap = {
cmd => 'ssh',
method => 'kill',