[CalendarServer-changes] [8050] CalendarServer/trunk/contrib/migration
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 6 12:37:25 PDT 2011
Revision: 8050
http://trac.macosforge.org/projects/calendarserver/changeset/8050
Author: sagen at apple.com
Date: 2011-09-06 12:37:25 -0700 (Tue, 06 Sep 2011)
Log Message:
-----------
If pre-Lion DocumentRoot existed on external volume, consolidate DocumentRoot and DataRoot onto that volume so attachments will live there as well.
Modified Paths:
--------------
CalendarServer/trunk/contrib/migration/calendarmigrator.py
CalendarServer/trunk/contrib/migration/test/test_migrator.py
Modified: CalendarServer/trunk/contrib/migration/calendarmigrator.py
===================================================================
--- CalendarServer/trunk/contrib/migration/calendarmigrator.py 2011-09-06 17:41:32 UTC (rev 8049)
+++ CalendarServer/trunk/contrib/migration/calendarmigrator.py 2011-09-06 19:37:25 UTC (rev 8050)
@@ -41,7 +41,8 @@
CARDDAVD_CONFIG_DIR = "private/etc/carddavd"
CALDAVD_PLIST = "caldavd.plist"
CARDDAVD_PLIST = "carddavd.plist"
-NEW_SERVER_ROOT = "/Library/Server/Calendar and Contacts"
+NEW_SERVER_DIR = "Calendar and Contacts"
+NEW_SERVER_ROOT = "/Library/Server/" + NEW_SERVER_DIR
RESOURCE_MIGRATION_TRIGGER = "trigger_resource_migration"
SERVER_ADMIN = "/usr/sbin/serveradmin"
LAUNCHCTL = "/bin/launchctl"
@@ -697,8 +698,30 @@
if oldCalDocumentRootValueProcessed:
if diskAccessor.exists(oldCalDocumentRootValueProcessed):
# Must be on an external volume if we see it existing at this point
- # so don't copy it
- newDocumentRoot = newDocumentRootValue = oldCalDocumentRootValueProcessed
+
+ # If data is pre-lion (no ServerRoot value), and DocumentRoot
+ # is external, let's consolidate everything so that the old
+ # DocumentRoot becomes the new ServerRoot, and Documents and
+ # Data become children
+ if not oldServerRootValue: # pre-lion
+ newServerRoot = newServerRootValue = os.path.join(os.path.dirname(oldCalDocumentRootValue.rstrip("/")), NEW_SERVER_DIR)
+ if diskAccessor.exists(newServerRootValue):
+ diskAccessor.rename(newServerRootValue, newServerRootValue + ".bak")
+ diskAccessor.mkdir(newServerRootValue)
+ newDocumentRoot = newDocumentRootValue = os.path.join(newServerRootValue, "Documents")
+ # Move old DocumentRoot under new ServerRoot
+ diskAccessor.rename(oldCalDocumentRootValue, newDocumentRoot)
+ newDataRoot = newDataRootValue = os.path.join(newServerRootValue, "Data")
+ if diskAccessor.exists(absolutePathWithRoot(sourceRoot, oldCalDataRootValueProcessed)):
+ diskAccessor.ditto(
+ absolutePathWithRoot(sourceRoot, oldCalDataRootValueProcessed),
+ newDataRoot
+ )
+ diskAccessor.chown(newDataRoot, uid, gid, recursive=True)
+ oldCalDataRootValueProcessed = None # to bypass processing below
+
+ else: # Lion or later
+ newDocumentRoot = newDocumentRootValue = oldCalDocumentRootValueProcessed
elif diskAccessor.exists(absolutePathWithRoot(sourceRoot, oldCalDocumentRootValueProcessed)):
diskAccessor.ditto(
absolutePathWithRoot(sourceRoot, oldCalDocumentRootValueProcessed),
Modified: CalendarServer/trunk/contrib/migration/test/test_migrator.py
===================================================================
--- CalendarServer/trunk/contrib/migration/test/test_migrator.py 2011-09-06 17:41:32 UTC (rev 8049)
+++ CalendarServer/trunk/contrib/migration/test/test_migrator.py 2011-09-06 19:37:25 UTC (rev 8050)
@@ -1031,6 +1031,83 @@
),
(
+ "Snow -> Lion Migration, external DocumentRoot",
+ {
+ "/Volumes/old/private/etc/caldavd/caldavd.plist" : """
+ <plist version="1.0">
+ <dict>
+ <key>DocumentRoot</key>
+ <string>/Volumes/External/CalendarServer/Documents</string>
+ <key>DataRoot</key>
+ <string>/Library/CalendarServer/Data</string>
+ <key>UserName</key>
+ <string>calendar</string>
+ <key>GroupName</key>
+ <string>calendar</string>
+ </dict>
+ </plist>
+ """,
+ "/Volumes/old/private/etc/carddavd/carddavd.plist" : """
+ <plist version="1.0">
+ <dict>
+ <key>DocumentRoot</key>
+ <string>/Volumes/External/AddressBookServer/Documents</string>
+ <key>DataRoot</key>
+ <string>/Library/AddressBookServer/Data</string>
+ </dict>
+ </plist>
+ """,
+ "/Volumes/new/private/etc/caldavd/caldavd.plist" : """
+ <plist version="1.0">
+ <dict>
+ <key>ServerRoot</key>
+ <string>/Library/Server/Calendar and Contacts</string>
+ <key>DocumentRoot</key>
+ <string>Documents</string>
+ <key>DataRoot</key>
+ <string>Data</string>
+ <key>UserName</key>
+ <string>calendar</string>
+ <key>GroupName</key>
+ <string>calendar</string>
+ </dict>
+ </plist>
+ """,
+
+ "/Volumes/External/CalendarServer/Documents/calendars/" : True,
+ "/Volumes/External/CalendarServer/Calendar and Contacts/" : True,
+ "/Volumes/old/Library/CalendarServer/Data/" : True,
+ "/Volumes/External/AddressBookServer/Documents/addressbooks/" : True,
+ "/Volumes/old/Library/AddressBookServer/Data/" : True,
+ "/Volumes/new/Library/Server/Calendar and Contacts" : True,
+ },
+ ( # args
+ "/Volumes/old", # sourceRoot
+ "/Volumes/new", # targetRoot
+ None, # oldServerRootValue
+ "/Volumes/External/CalendarServer/Documents", # oldCalDocumentRootValue
+ "/Library/CalendarServer/Data", # oldCalDataRootValue
+ "/Volumes/External/AddressBookServer/Documents", # oldABDocumentRootValue
+ FakeUser.pw_uid, FakeGroup.gr_gid, # user id, group id
+ ),
+ ( # expected return values
+ "/Volumes/External/CalendarServer/Calendar and Contacts",
+ "/Volumes/External/CalendarServer/Calendar and Contacts",
+ "Documents",
+ "Data"
+ ),
+ [ # expected DiskAccessor history
+ ('rename', '/Volumes/External/CalendarServer/Calendar and Contacts', '/Volumes/External/CalendarServer/Calendar and Contacts.bak'),
+ ('mkdir', '/Volumes/External/CalendarServer/Calendar and Contacts'),
+ ('rename', '/Volumes/External/CalendarServer/Documents', '/Volumes/External/CalendarServer/Calendar and Contacts/Documents'),
+ ('ditto', '/Volumes/old/Library/CalendarServer/Data', '/Volumes/External/CalendarServer/Calendar and Contacts/Data'),
+ ('chown-recursive', '/Volumes/External/CalendarServer/Calendar and Contacts/Data', FakeUser.pw_uid, FakeGroup.gr_gid),
+ ('ditto', '/Volumes/External/AddressBookServer/Documents/addressbooks', '/Volumes/External/CalendarServer/Calendar and Contacts/Documents/addressbooks'),
+ ('chown-recursive', '/Volumes/External/CalendarServer/Calendar and Contacts/Documents/addressbooks', FakeUser.pw_uid, FakeGroup.gr_gid),
+ ]
+ ),
+
+ (
"Snow -> Lion Migration, in non-standard locations",
{
"/Volumes/old/private/etc/caldavd/caldavd.plist" : """
@@ -1165,14 +1242,18 @@
FakeUser.pw_uid, FakeGroup.gr_gid, # user id, group id
),
( # expected return values
- "/Volumes/new/Library/Server/Calendar and Contacts",
- "/Library/Server/Calendar and Contacts",
- "/Volumes/External/CalendarServer/Documents",
- "/Volumes/External/CalendarServer/Data"
+ "/Volumes/External/CalendarServer/Calendar and Contacts",
+ "/Volumes/External/CalendarServer/Calendar and Contacts",
+ "Documents",
+ "Data"
),
[
- ('ditto', '/Volumes/old/Library/AddressBookServer/Documents/addressbooks', '/Volumes/External/CalendarServer/Documents/addressbooks'),
- ('chown-recursive', '/Volumes/External/CalendarServer/Documents/addressbooks', FakeUser.pw_uid, FakeGroup.gr_gid),
+ ('mkdir', '/Volumes/External/CalendarServer/Calendar and Contacts'),
+ ('rename', '/Volumes/External/CalendarServer/Documents', '/Volumes/External/CalendarServer/Calendar and Contacts/Documents'),
+ ('ditto', '/Volumes/External/CalendarServer/Data', '/Volumes/External/CalendarServer/Calendar and Contacts/Data'),
+ ('chown-recursive', '/Volumes/External/CalendarServer/Calendar and Contacts/Data', FakeUser.pw_uid, FakeGroup.gr_gid),
+ ('ditto', '/Volumes/old/Library/AddressBookServer/Documents/addressbooks', '/Volumes/External/CalendarServer/Calendar and Contacts/Documents/addressbooks'),
+ ('chown-recursive', '/Volumes/External/CalendarServer/Calendar and Contacts/Documents/addressbooks', FakeUser.pw_uid, FakeGroup.gr_gid),
]
),
@@ -1387,7 +1468,6 @@
]
for description, paths, args, expected, history in info:
- # print "-=-=-=- %s -=-=-=-" % (description,)
accessor = StubDiskAccessor(paths)
actual = relocateData(*args, diskAccessor=accessor)
self.assertEquals(expected, actual)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110906/eff8cc27/attachment-0001.html>
More information about the calendarserver-changes
mailing list