summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2007-08-15 22:04:31 +0000
committerRich Megginson <rmeggins@redhat.com>2007-08-15 22:04:31 +0000
commitfadbc2d87d74f3298ade512404d6edfdf0bcf049 (patch)
treeaf699064cc46cf5be7271457cbd65cc191013b24
parenteeded7b8d35523562ac4c93b2261247db26e7fdc (diff)
downloadds-fadbc2d87d74f3298ade512404d6edfdf0bcf049.tar.gz
ds-fadbc2d87d74f3298ade512404d6edfdf0bcf049.tar.xz
ds-fadbc2d87d74f3298ade512404d6edfdf0bcf049.zip
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
-rw-r--r--ldap/admin/src/scripts/DSDialogs.pm6
-rw-r--r--ldap/admin/src/scripts/DSMigration.pm.in9
-rw-r--r--ldap/admin/src/scripts/Migration.pm.in22
-rw-r--r--ldap/admin/src/scripts/Util.pm.in18
4 files changed, 42 insertions, 13 deletions
diff --git a/ldap/admin/src/scripts/DSDialogs.pm b/ldap/admin/src/scripts/DSDialogs.pm
index ee7bf0f3..0af12b14 100644
--- a/ldap/admin/src/scripts/DSDialogs.pm
+++ b/ldap/admin/src/scripts/DSDialogs.pm
@@ -86,10 +86,10 @@ my $dsserverid = new Dialog (
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;
},
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in
index 09f0e034..e3cda816 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -191,9 +191,12 @@ sub copyDatabaseDirs {
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) {
diff --git a/ldap/admin/src/scripts/Migration.pm.in b/ldap/admin/src/scripts/Migration.pm.in
index d61b7a59..b1e6ccde 100644
--- a/ldap/admin/src/scripts/Migration.pm.in
+++ b/ldap/admin/src/scripts/Migration.pm.in
@@ -213,7 +213,7 @@ sub init {
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 @@ sub init {
$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 {
diff --git a/ldap/admin/src/scripts/Util.pm.in b/ldap/admin/src/scripts/Util.pm.in
index b6e3e0ea..ad7347ed 100644
--- a/ldap/admin/src/scripts/Util.pm.in
+++ b/ldap/admin/src/scripts/Util.pm.in
@@ -697,6 +697,7 @@ sub addSuffix {
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 @@ sub process_maptbl
}
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 @@ sub process_maptbl
}
}
}
+
+ # 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;
}