LIO: followup: fix indentation
This commit is contained in:
@ -68,18 +68,18 @@ my $execute_remote_command = sub {
|
|||||||
$cmd = [@ssh_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $target, '--', $remote_command, @params];
|
$cmd = [@ssh_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $target, '--', $remote_command, @params];
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
run_command($cmd, outfunc => $output, errfunc => $errfunc, timeout => $timeout);
|
run_command($cmd, outfunc => $output, errfunc => $errfunc, timeout => $timeout);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$res = {
|
$res = {
|
||||||
result => 0,
|
result => 0,
|
||||||
msg => $err,
|
msg => $err,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$res = {
|
$res = {
|
||||||
result => 1,
|
result => 1,
|
||||||
msg => $msg,
|
msg => $msg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
@ -110,14 +110,14 @@ my $read_config = sub {
|
|||||||
$target = 'root@' . $scfg->{portal};
|
$target = 'root@' . $scfg->{portal};
|
||||||
|
|
||||||
foreach my $oneFile (@CONFIG_FILES) {
|
foreach my $oneFile (@CONFIG_FILES) {
|
||||||
my $cmd = [@ssh_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $target, $luncmd, $oneFile];
|
my $cmd = [@ssh_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $target, $luncmd, $oneFile];
|
||||||
eval {
|
eval {
|
||||||
run_command($cmd, outfunc => $output, errfunc => $errfunc, timeout => $timeout);
|
run_command($cmd, outfunc => $output, errfunc => $errfunc, timeout => $timeout);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
die $err if ($err !~ /No such file or directory/);
|
die $err if ($err !~ /No such file or directory/);
|
||||||
}
|
}
|
||||||
return $msg if $msg ne '';
|
return $msg if $msg ne '';
|
||||||
}
|
}
|
||||||
|
|
||||||
die "No configuration found. Install targetcli on $scfg->{portal}\n" if $msg eq '';
|
die "No configuration found. Install targetcli on $scfg->{portal}\n" if $msg eq '';
|
||||||
@ -179,9 +179,9 @@ my $free_lu_name = sub {
|
|||||||
my $new;
|
my $new;
|
||||||
|
|
||||||
foreach my $lun (@{$SETTINGS->{target}->{luns}}) {
|
foreach my $lun (@{$SETTINGS->{target}->{luns}}) {
|
||||||
if ($lun->{storage_object} ne "$BACKSTORE/$lu_name") {
|
if ($lun->{storage_object} ne "$BACKSTORE/$lu_name") {
|
||||||
push @$new, $lun;
|
push @$new, $lun;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$SETTINGS->{target}->{luns} = $new;
|
$SETTINGS->{target}->{luns} = $new;
|
||||||
@ -192,9 +192,9 @@ my $register_lun = sub {
|
|||||||
my ($scfg, $idx, $volname) = @_;
|
my ($scfg, $idx, $volname) = @_;
|
||||||
|
|
||||||
my $conf = {
|
my $conf = {
|
||||||
index => $idx,
|
index => $idx,
|
||||||
storage_object => "$BACKSTORE/$volname",
|
storage_object => "$BACKSTORE/$volname",
|
||||||
is_new => 1,
|
is_new => 1,
|
||||||
};
|
};
|
||||||
push @{$SETTINGS->{target}->{luns}}, $conf;
|
push @{$SETTINGS->{target}->{luns}}, $conf;
|
||||||
|
|
||||||
@ -223,9 +223,9 @@ my $list_view = sub {
|
|||||||
my $volname = $extract_volname->($scfg, $params[0]);
|
my $volname = $extract_volname->($scfg, $params[0]);
|
||||||
|
|
||||||
foreach my $lun (@{$SETTINGS->{target}->{luns}}) {
|
foreach my $lun (@{$SETTINGS->{target}->{luns}}) {
|
||||||
if ($lun->{storage_object} eq "$BACKSTORE/$volname") {
|
if ($lun->{storage_object} eq "$BACKSTORE/$volname") {
|
||||||
return $lun->{index};
|
return $lun->{index};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $lun;
|
return $lun;
|
||||||
@ -240,9 +240,9 @@ my $list_lun = sub {
|
|||||||
my $volname = $extract_volname->($scfg, $params[0]);
|
my $volname = $extract_volname->($scfg, $params[0]);
|
||||||
|
|
||||||
foreach my $lun (@{$SETTINGS->{target}->{luns}}) {
|
foreach my $lun (@{$SETTINGS->{target}->{luns}}) {
|
||||||
if ($lun->{storage_object} eq "$BACKSTORE/$volname") {
|
if ($lun->{storage_object} eq "$BACKSTORE/$volname") {
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $name;
|
return $name;
|
||||||
@ -253,7 +253,7 @@ my $create_lun = sub {
|
|||||||
my ($scfg, $timeout, $method, @params) = @_;
|
my ($scfg, $timeout, $method, @params) = @_;
|
||||||
|
|
||||||
if ($list_lun->($scfg, $timeout, $method, @params)) {
|
if ($list_lun->($scfg, $timeout, $method, @params)) {
|
||||||
die "$params[0]: LUN already exists!";
|
die "$params[0]: LUN already exists!";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $device = $params[0];
|
my $device = $params[0];
|
||||||
@ -276,9 +276,9 @@ my $create_lun = sub {
|
|||||||
# changed without our knowledge, so relying on the number that targetcli returns
|
# changed without our knowledge, so relying on the number that targetcli returns
|
||||||
my $lun_idx;
|
my $lun_idx;
|
||||||
if ($res->{msg} =~ /LUN (\d+)/) {
|
if ($res->{msg} =~ /LUN (\d+)/) {
|
||||||
$lun_idx = $1;
|
$lun_idx = $1;
|
||||||
} else {
|
} else {
|
||||||
die "unable to determine new LUN index: $res->{msg}";
|
die "unable to determine new LUN index: $res->{msg}";
|
||||||
}
|
}
|
||||||
|
|
||||||
$register_lun->($scfg, $lun_idx, $volname);
|
$register_lun->($scfg, $lun_idx, $volname);
|
||||||
@ -341,7 +341,7 @@ my $modify_lun = sub {
|
|||||||
|
|
||||||
$msg = $delete_lun->($scfg, $timeout, $method, @params);
|
$msg = $delete_lun->($scfg, $timeout, $method, @params);
|
||||||
if ($msg) {
|
if ($msg) {
|
||||||
$msg = $create_lun->($scfg, $timeout, $method, @params);
|
$msg = $create_lun->($scfg, $timeout, $method, @params);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $msg;
|
return $msg;
|
||||||
@ -369,9 +369,9 @@ sub run_lun_command {
|
|||||||
# fetch configuration from target if we haven't yet
|
# fetch configuration from target if we haven't yet
|
||||||
# or if our configuration is stale
|
# or if our configuration is stale
|
||||||
my $timediff = time - $SETTINGS_TIMESTAMP;
|
my $timediff = time - $SETTINGS_TIMESTAMP;
|
||||||
if ( ! $SETTINGS || $timediff > $SETTINGS_MAXAGE ) {
|
if (!$SETTINGS || $timediff > $SETTINGS_MAXAGE) {
|
||||||
$SETTINGS_TIMESTAMP = time;
|
$SETTINGS_TIMESTAMP = time;
|
||||||
$parser->($scfg);
|
$parser->($scfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
die "unknown command '$method'" unless exists $lun_cmd_map{$method};
|
die "unknown command '$method'" unless exists $lun_cmd_map{$method};
|
||||||
|
|||||||
Reference in New Issue
Block a user