[CalendarServer-changes] [8052] CalendarServer/branches/release/CalendarServer-3.1-dev/contrib/ migration
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 6 16:28:35 PDT 2011
Revision: 8052
http://trac.macosforge.org/projects/calendarserver/changeset/8052
Author: sagen at apple.com
Date: 2011-09-06 16:28:34 -0700 (Tue, 06 Sep 2011)
Log Message:
-----------
Copy external data store change from trunk
Modified Paths:
--------------
CalendarServer/branches/release/CalendarServer-3.1-dev/contrib/migration/calendarmigrator.py
CalendarServer/branches/release/CalendarServer-3.1-dev/contrib/migration/test/test_migrator.py
Modified: CalendarServer/branches/release/CalendarServer-3.1-dev/contrib/migration/calendarmigrator.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-3.1-dev/contrib/migration/calendarmigrator.py 2011-09-06 21:19:52 UTC (rev 8051)
+++ CalendarServer/branches/release/CalendarServer-3.1-dev/contrib/migration/calendarmigrator.py 2011-09-06 23:28:34 UTC (rev 8052)
@@ -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"
@@ -157,7 +158,7 @@
SSLPort
""".split()
-ignoredKkeys = """
+ignoredKeys = """
ControlSocket
EnableAnonymousReadRoot
EnableFindSharedReport
@@ -654,7 +655,6 @@
log("RelocateData: sourceRoot=%s, targetRoot=%s, oldServerRootValue=%s, oldCalDocumentRootValue=%s, oldCalDataRootValue=%s, oldABDocumentRootValue=%s, uid=%d, gid=%d" % (sourceRoot, targetRoot, oldServerRootValue, oldCalDocumentRootValue, oldCalDataRootValue, oldABDocumentRootValue, uid, gid))
-
if oldServerRootValue:
newServerRootValue = oldServerRootValue
# Source is Lion; see if ServerRoot refers to an external volume
@@ -697,9 +697,31 @@
# Old Calendar DocumentRoot
if oldCalDocumentRootValueProcessed:
if diskAccessor.exists(oldCalDocumentRootValueProcessed):
- # Must be on an external volume if we see it existing at the point
- # so don't copy it
- newDocumentRoot = newDocumentRootValue = oldCalDocumentRootValueProcessed
+ # Must be on an external volume if we see it existing at this point
+
+ # 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),
@@ -710,7 +732,7 @@
# Old Calendar DataRoot
if oldCalDataRootValueProcessed:
if diskAccessor.exists(oldCalDataRootValueProcessed):
- # Must be on an external volume if we see it existing at the point
+ # Must be on an external volume if we see it existing at this point
# so don't copy it
newDataRootValue = oldCalDataRootValueProcessed
elif diskAccessor.exists(
Modified: CalendarServer/branches/release/CalendarServer-3.1-dev/contrib/migration/test/test_migrator.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-3.1-dev/contrib/migration/test/test_migrator.py 2011-09-06 21:19:52 UTC (rev 8051)
+++ CalendarServer/branches/release/CalendarServer-3.1-dev/contrib/migration/test/test_migrator.py 2011-09-06 23:28:34 UTC (rev 8052)
@@ -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),
]
),
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110906/aaafb6d8/attachment-0001.html>
More information about the calendarserver-changes
mailing list