diff options
author | Rich Megginson <rmeggins@redhat.com> | 2007-09-08 02:16:27 +0000 |
---|---|---|
committer | Rich Megginson <rmeggins@redhat.com> | 2007-09-08 02:16:27 +0000 |
commit | acc1de0bd86da8a13974638f07735b54f80717e0 (patch) | |
tree | 05027f2855e73353bf55efce2e3c077931df5644 /ldap/admin | |
parent | f5ce61231bdc2794b05c4a3dacf2f0e3a1a42082 (diff) | |
download | ds-acc1de0bd86da8a13974638f07735b54f80717e0.tar.gz ds-acc1de0bd86da8a13974638f07735b54f80717e0.tar.xz ds-acc1de0bd86da8a13974638f07735b54f80717e0.zip |
Resolves: bug 282741
Bug Description: Show-Stopper - Migration from DS 6.21 to DS80
Reviewed by: nhosoi (Thanks!)
Fix Description: Added a new function migrateNetscapeRoot which will create a temporary LDIF file from the given NetscapeRoot.ldif file. The function will look for all \bNetscape\b occurances and convert them to @capbrand@ where that is defined as the capitalized brand name in configure. It will then import this temporary LDIF file and delete it.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Diffstat (limited to 'ldap/admin')
-rw-r--r-- | ldap/admin/src/scripts/DSMigration.pm.in | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in index cc0f9b3c..d7a6336e 100644 --- a/ldap/admin/src/scripts/DSMigration.pm.in +++ b/ldap/admin/src/scripts/DSMigration.pm.in @@ -62,6 +62,8 @@ use Mozilla::LDAP::Utils qw(normalizeDN); use Mozilla::LDAP::API qw(ldap_explode_dn); use Mozilla::LDAP::LDIF; +use Carp; + use Exporter; @ISA = qw(Exporter); @EXPORT = qw(migrateDS); @@ -253,6 +255,35 @@ sub copyDatabaseDirs { return (); } +# older versions may use the old Netscape names e.g. Netscape Administration Server +# we have to convert these to the new names e.g. @capbrand@ Administration Server +sub migrateNetscapeRoot { + my $ldiffile = shift; + my ($fh, $tmpldiffile); + # create a temp inf file for writing for other processes + # never overwrite the user supplied inf file + ($fh, $tmpldiffile) = tempfile("nsrootXXXXXX", UNLINK => 0, + SUFFIX => ".ldif", OPEN => 1, + DIR => File::Spec->tmpdir); + open( MYLDIF, "$ldiffile" ) || confess "Can't open $ldiffile: $!"; + my $in = new Mozilla::LDAP::LDIF(*MYLDIF); + while (my $ent = readOneEntry $in) { + my $dn = $ent->getDN(); + $dn =~ s/\bNetscape\b/@capbrand@/g; + $ent->setDN($dn); + foreach my $attr (keys %{$ent}) { + my @vals = $ent->getValues($attr); + map { s/\bNetscape\b/@capbrand@/g } @vals; + $ent->setValues($attr, @vals); + } + Mozilla::LDAP::LDIF::put_LDIF($fh, 78, $ent); + } + close( MYLDIF ); + close( $fh ); + + return $tmpldiffile; +} + # migrate all of the databases in an instance sub migrateDatabases { my $mig = shift; # the Migration object @@ -269,13 +300,22 @@ sub migrateDatabases { # database my $foundldif; for (glob("$mig->{oldsroot}/$inst/db/*.ldif")) { - my $dbname = basename($_, '.ldif'); - my $cmd = "$inst_dir/ldif2db -n \"$dbname\" -i \"$_\""; + my $fname = $_; + my $dbname = basename($fname, '.ldif'); + my $deleteflag = 0; + if ($fname =~ /NetscapeRoot.ldif$/) { + $fname = migrateNetscapeRoot($fname); + $deleteflag = 1; + } + my $cmd = "$inst_dir/ldif2db -n \"$dbname\" -i \"$fname\""; debug(1, "migrateDatabases: executing command $cmd\n"); $? = 0; # clear error condition my $output = `$cmd 2>&1`; + if ($deleteflag) { + unlink($fname); + } if ($?) { - return ('error_importing_migrated_db', $_, $?, $output); + return ('error_importing_migrated_db', $fname, $?, $output); } debug(1, $output); $foundldif = 1; |