mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-17 02:31:27 +00:00
- Replace a device on a given LUN when applying the configuration instead of removing
the old device and assigning the new one. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1131 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -2,6 +2,8 @@ Changes for 1.0.9
|
||||
|
||||
- Move a user from one group to another when applying the configuration instead
|
||||
of deleting from one and adding to another the same user.
|
||||
- Replace a device on a given LUN when applying the configuration instead of removing
|
||||
the old device and assigning the new one.
|
||||
- Add the ability to specify options (ie: READ_ONLY) in assignments in scst.conf.
|
||||
- Remove unused references to handler IOs that don't exist and cleanup the write
|
||||
configuration function to only write vdisk and vcdrom devices. All other devices
|
||||
|
||||
@@ -915,7 +915,7 @@ sub replaceDeviceInGroup {
|
||||
($options, $valid_opts) = $self->checkOptions($options, 'ASSIGN');
|
||||
|
||||
if (!$valid_opts) {
|
||||
$self->{'error'} = "assignDeviceToGroup(): Invalid option(s) '$options' given for ".
|
||||
$self->{'error'} = "replaceDeviceInGroup(): Invalid option(s) '$options' given for ".
|
||||
"device '$newDevice'";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -703,9 +703,10 @@ sub applyConfiguration {
|
||||
foreach my $device (sort keys %{$_assignments}) {
|
||||
if (!defined($used_assignments{$group}->{$device}) ||
|
||||
($$_assignments{$device} != $used_assignments{$group}->{$device})) {
|
||||
if ($$_assignments{$device} != $used_assignments{$group}->{$device}) {
|
||||
print "\t-> WARNING: Device '$device' assigned to group '$group' is at LUN ".
|
||||
$used_assignments{$group}->{$device}.
|
||||
if (defined($used_assignments{$group}->{$device}) &&
|
||||
($$_assignments{$device} != $used_assignments{$group}->{$device})) {
|
||||
print "\t-> WARNING: Device '$device' assigned to group '$group' ".
|
||||
"is at LUN ".$used_assignments{$group}->{$device}.
|
||||
" whereas working configuration reflects LUN ".$$_assignments{$device};
|
||||
} else {
|
||||
print "\t-> WARNING: Device '$device' is not associated with group ".
|
||||
@@ -713,11 +714,25 @@ sub applyConfiguration {
|
||||
}
|
||||
|
||||
if (!$check) {
|
||||
print ", releasing.\n";
|
||||
if (releaseDevice($group, $device)) {
|
||||
$errs++;
|
||||
my $_lun = $$_assignments{$device};
|
||||
|
||||
my $replace_dev = findAssignedLun($used_assignments{$group}, $_lun);
|
||||
|
||||
if (defined($replace_dev) && ($replace_dev ne $device)) {
|
||||
print ", replacing with device '$replace_dev'.\n";
|
||||
|
||||
if (replaceDevice($group, $replace_dev, $_lun)) {
|
||||
$errs++;
|
||||
} else {
|
||||
$changes++;
|
||||
}
|
||||
} else {
|
||||
$changes++;
|
||||
print ", releasing.\n";
|
||||
if (releaseDevice($group, $device)) {
|
||||
$errs++;
|
||||
} else {
|
||||
$changes++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print ".\n";
|
||||
@@ -953,6 +968,14 @@ sub applyConfiguration {
|
||||
", whereas the working configuration reflects LUN $lun.\n".
|
||||
"\t Use -ForceConfig to force this LUN change.\n" if (!$force && !$check);
|
||||
} else {
|
||||
my $replace_dev = findAssignedLun($_assignments, $lun);
|
||||
|
||||
if (defined($replace_dev) && ($vname ne $replace_dev)) {
|
||||
print "\t-> WARNING: Use -ForceConfig to replace device '$replace_dev' ".
|
||||
"with device '$vname' for group '$group'.\n" if (!$force);
|
||||
next;
|
||||
}
|
||||
|
||||
if ($check) {
|
||||
$lun = 'auto' if (!defined($lun));
|
||||
print "\t-> New device assignment for '$vname' to group '$group' at LUN $lun.\n";
|
||||
@@ -1722,27 +1745,21 @@ sub findUserGroupInCurrent {
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub findDeviceGroup {
|
||||
my $device = shift;
|
||||
my $config = shift;
|
||||
sub findAssignedLun {
|
||||
my $associations = shift;
|
||||
my $lun = shift;
|
||||
|
||||
foreach my $group (keys %{$$config{'ASSIGNMENT'}}) {
|
||||
foreach my $device (@{$$config{'ASSIGNMENT'}->{$group}->{'DEVICE'}}) {
|
||||
my($vname, $arg) = split(/\,/, $device, 2);
|
||||
$vname = cleanupString($vname);
|
||||
return $group if ($vname eq $device);
|
||||
return undef if (!defined($lun));
|
||||
|
||||
foreach my $device (keys %{$associations}) {
|
||||
if ($$associations{$device} == $lun) {
|
||||
return $device;
|
||||
}
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub findDeviceGroupInCurrent {
|
||||
my $device = shift;
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub cleanupString {
|
||||
my $string = shift;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user