modifying a target that already exits in tgt, current instance will be delete
and a new one will be created with the new parameters instead.
Signed-off-by: Doron Shoham <[EMAIL PROTECTED]>
---
scripts/tgt-admin | 37 ++++++++++++++++++++-----------------
1 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/scripts/tgt-admin b/scripts/tgt-admin
index 846437a..11e5552 100755
--- a/scripts/tgt-admin
+++ b/scripts/tgt-admin
@@ -103,26 +103,29 @@ sub add_targets {
if ( $tgtadm_output{$k2} eq undef ) {
# We have to find available tid
$next_tid = $next_tid + 1;
-
- execute("# Adding target: $target");
- execute("tgtadm --lld iscsi --op new
--mode target --tid $next_tid -T $target");
+ }
+ else {
+ execute("# Target $target already
exist!");
+ execute("# Updating Target $target");
+ execute("tgtadm --op update --mode
target --tid=$next_tid -n state -v offline");
+ execute("tgtadm --mode target --op
delete --tid=$next_tid");
+ }
+ execute("# Adding target: $target");
+ execute("tgtadm --lld iscsi --op new --mode
target --tid $next_tid -T $target");
- foreach my $k3 (sort keys
%{$conf{$k}{$k2}}) {
- $option = $k3;
- $value = $conf{$k}{$k2}{$k3};
- &process_options;
- # If there was no option called
"initiator-address", it means
- # we want to allow ALL
initiators for this target
- if ( $option eq
"initiator-address" ) {
- $allowall = 0;
- }
+ foreach my $k3 (sort keys %{$conf{$k}{$k2}}) {
+ $option = $k3;
+ $value = $conf{$k}{$k2}{$k3};
+ &process_options;
+ # If there was no option called
"initiator-address", it means
+ # we want to allow ALL initiators for
this target
+ if ( $option eq "initiator-address" ) {
+ $allowall = 0;
}
+ }
- if ( $allowall == 1 ) {
- execute("tgtadm --lld iscsi
--op bind --mode target --tid $next_tid -I ALL");
- }
- } else {
- execute("# Target $target already
exists!");
+ if ( $allowall == 1 ) {
+ execute("tgtadm --lld iscsi --op bind
--mode target --tid $next_tid -I ALL");
}
execute();
}
--
1.5.3.8
_______________________________________________
Stgt-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/stgt-devel