Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory
cvs-int.fedora.redhat.com:/tmp/cvs-serv6311/ldapserver/ldap/admin/src/scripts
Modified Files:
DSDialogs.pm DSMigration.pm.in Migration.pm.in Util.pm.in
Log Message:
Resolves: bug 252190
Bug Description: 7.1 to 8.0 Migration Bug
Reviewed by: nhosoi (Thanks!)
Fix Description: Lots of issues
1) Instead of using Net::Domain::hostname() for the hostname to use for server
identifiers, we must use the leftmost component of the FullMachineName specified by the
user. One of the reasons is that hostname() and hostfqdn() can give different results
such that hostname() is not the leftmost component of hostfqdn(). And we should just use
whatever the user specifies. This required several changes to the mapfiles, and a change
to the maptable processing, to process the perl code to eval last, so that we can use
token substitutions from the inf file and from hard coded strings.
2) We need to add the global preferences stuff, during migration, in order for the console
to function. We cannot rely on the migrated o=NetscapeRoot data because we have to make
sure we specify the new jar files to use. In addition, we need to migrate over any
customizations that the user has made to these preferences. This is handled by the new
updateConsoleInfo function called during admin server migration.
3) There were several resources for messages missing. These have been added.
4) With the new perl only ds instance creation code, there will actually be data in the
database even though the server is not started. This is what I believe was causing the
error_removing_temp_db_files error. So now, the code will only attempt to remove plain
files, not directories that could be globbed.
5) Use /opt/brand-ds for the old server root instead of /opt/pkgname.
6) The migration log should use [Migration} not [Setup]
7) migration should not report a fatal error upon success
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: DSDialogs.pm
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSDialogs.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DSDialogs.pm 25 Jul 2007 22:05:26 -0000 1.4
+++ DSDialogs.pm 15 Aug 2007 22:04:31 -0000 1.5
@@ -86,10 +86,10 @@
if (!defined($serverid)) {
$serverid =
$self->{manager}->{inf}->{General}->{FullMachineName};
if (!defined($serverid)) {
- $serverid = hostname;
- } else { # strip out the leftmost domain component
- $serverid =~ s/\..*$//;
+ $serverid = hostfqdn;
}
+ # strip out the leftmost domain component
+ $serverid =~ s/\..*$//;
}
return $serverid;
},
Index: DSMigration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSMigration.pm.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DSMigration.pm.in 13 Jul 2007 18:35:32 -0000 1.4
+++ DSMigration.pm.in 15 Aug 2007 22:04:31 -0000 1.5
@@ -191,9 +191,12 @@
debug(1, "The destination directory $destdir already exists, copying
files/dirs individually\n");
$! = 0;
debug(1, "Removing any existing db files in $destdir\n");
- unlink glob("$destdir/*");
- if ($!) {
- return ("error_removing_temp_db_files", $destdir, $!);
+ foreach my $file (glob("$destdir/*")) {
+ next if (! -f $file);
+ unlink($file);
+ if ($!) {
+ return ("error_removing_temp_db_files", $destdir, $!);
+ }
}
foreach my $file (glob("$srcdir/*")) {
if (-f $file) {
Index: Migration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Migration.pm.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Migration.pm.in 15 Aug 2007 02:51:50 -0000 1.4
+++ Migration.pm.in 15 Aug 2007 22:04:31 -0000 1.5
@@ -213,7 +213,7 @@
if ($pkgname =~ /-(core|base)$/) {
$pkgname =~ s/-(core|base)$//;
}
- my $oldpkgname = $pkgname;
+ my $oldpkgname = "@brand@-ds";
$self->{pkgname} = $pkgname;
$self->{oldsroot} = $oldsroot || "/opt/$oldpkgname";
@@ -274,10 +274,26 @@
$self->{instances} = \@instances;
}
+# log only goes the the logfile
+sub log {
+ my $self = shift;
+ my $level = shift;
+ $self->{log}->logMessage($level, "Migration", @_);
+}
+
sub doExit {
my $self = shift;
- $self->msg($FATAL, 'migration_exiting', $self->{log}->{filename});
- exit 1;
+ my $code = shift;
+ if (!defined($code)) {
+ $code = 1;
+ }
+
+ if ($code) {
+ $self->msg($FATAL, 'migration_exiting',
$self->{log}->{filename});
+ } else {
+ $self->msg($SUCCESS, 'migration_exiting',
$self->{log}->{filename});
+ }
+ exit $code;
}
sub migrateSecurityFiles {
Index: Util.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Util.pm.in,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Util.pm.in 19 Jul 2007 00:23:40 -0000 1.10
+++ Util.pm.in 15 Aug 2007 22:04:31 -0000 1.11
@@ -697,6 +697,7 @@
sub process_maptbl
{
my ($mapper, $errs, @infdata) = @_;
+ my @deferredkeys = ();
if (defined($mapper->{""})) {
$mapper = $mapper->{""}; # side effect of Inf with no sections
@@ -712,10 +713,7 @@
}
elsif ($value =~ /^\`/)
{
- $value =~ tr/\`//d; # value is a perl expression to eval
- my $returnvalue; # set in eval expression
- eval $value;
- $mapper->{$key} = $returnvalue; # perl expression sets $returnvalue
+ push @deferredkeys, $key; # process these last
}
else
{
@@ -751,6 +749,18 @@
}
}
}
+
+ # we have to process the perl expressions to eval last, because those
+ # expressions may use mappings defined elsewhere in the file, and we are not
+ # guaranteed of the order in which hash keys are enumerated
+ foreach my $key (@deferredkeys) {
+ my $value = $mapper->{$key};
+ $value =~ tr/\`//d; # value is a perl expression to eval
+ my $returnvalue; # set in eval expression
+ eval $value;
+ $mapper->{$key} = $returnvalue; # perl expression sets $returnvalue
+ }
+
return $mapper;
}