- Support changing assignment attributes with -force.

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1989 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Mark Buechler
2010-08-25 17:52:35 +00:00
parent 4f6d6ed38d
commit 2de6b5ead6

View File

@@ -1586,7 +1586,7 @@ sub applyConfigDevices {
my $old_create_attrs = $SCST->deviceAttributes($device);
if (compareToKeyAttribute($create_attrs, $old_create_attrs)) {
print "-> Device '$device' is configured for different CREATE attributes.\n";
print "-> Device '$device' is configured differently.\n";
if ($deletions) {
print "\t-> Closing and re-opening with new attributes.\n";
@@ -1647,6 +1647,24 @@ sub applyConfigAssignments {
"for driver/target '$driver/$target'. ".
"Use -force to remove it.\n";
}
} else {
my $c_attrs = configToAttr($$config{'TARGET_DRIVER'}->{$driver}->{'TARGET'}->{$target}->{'LUN'}->{$lun}->{$device});
my $o_attrs = $SCST->lunAttributes($driver, $target, $lun);
filterCreateAttributes($driver, $target, undef, $c_attrs);
if (compareToKeyAttribute($c_attrs, $o_attrs)) {
print "-> Device '$device' at LUN '$lun' is configured differently.\n";
if ($deletions) {
print "\t-> Re-assigning device with new attributes.\n";
removeLun($driver, $target, $lun);
addLun($driver, $target, $device, $lun, $c_attrs);
} else {
print "\t-> Use -force to re-assign device with new attributes. ".
"NOTE: This will disrupt all initiators using this device.\n";
}
}
}
}
@@ -1838,6 +1856,22 @@ sub applyInitiatorAssignments {
}
}
sub filterCreateAttributes {
my $driver = shift;
my $target = shift;
my $group = shift;
my $attrs = shift;
foreach my $attribute (keys %{$attrs}) {
my $bad = $SCST->checkLunCreateAttributes($driver, $target, $attribute, $group);
if ($bad == TRUE) {
delete $$attrs{$attribute};
} elsif ($bad) {
immediateExit($SCST->errorString($bad));
}
}
}
sub compareToKeyAttribute {
my $first = shift;
my $second = shift;