[CalendarServer-changes] [8833] CalendarServer/trunk/contrib/migration

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 9 16:46:46 PST 2012


Revision: 8833
          http://trac.macosforge.org/projects/calendarserver/changeset/8833
Author:   sagen at apple.com
Date:     2012-03-09 16:46:45 -0800 (Fri, 09 Mar 2012)
Log Message:
-----------
Fixing migration extra, which wasn't successfully copying data over.

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	2012-03-10 00:40:50 UTC (rev 8832)
+++ CalendarServer/trunk/contrib/migration/calendarmigrator.py	2012-03-10 00:46:45 UTC (rev 8833)
@@ -147,7 +147,7 @@
 
             # Create log directory
             try:
-                logDir = os.path.join(options.targetDir, LOG_DIR)
+                logDir = os.path.join(options.targetRoot, LOG_DIR)
                 os.mkdir(logDir, 0755)
             except OSError:
                 # Already exists
@@ -436,10 +436,6 @@
     newDocumentRootValue = "Documents"
     newDocumentRoot = os.path.join(newDataRoot, newDocumentRootValue)
 
-    if not diskAccessor.exists(newServerRoot):
-        log("Creating calendar server root: %s" % (newServerRoot,))
-        diskAccessor.mkdir(newServerRoot)
-
     if sourceVersion < "10.7":
         # Before 10.7 there was no ServerRoot; DocumentRoot and DataRoot were separate.
         # Reconfigure so DocumentRoot is under DataRoot is under ServerRoot.  DataRoot
@@ -510,6 +506,7 @@
 
         if oldServerRootValue:
             if diskAccessor.exists(oldServerRootValue): # external volume
+                log("Using external calendar server root: %s" % (newServerRoot,))
                 # ServerRoot needs to be /Library/Server/Calendar and Contacts
                 # Since DocumentRoot is now relative to DataRoot, move DocumentRoot into DataRoot
                 newDataRoot = newDataRootValue = os.path.join(oldServerRootValue, "Data")
@@ -522,24 +519,42 @@
                 else:
                     diskAccessor.mkdir(newDocumentRoot)
             elif diskAccessor.exists(absolutePathWithRoot(sourceRoot, oldServerRootValue)):
+                log("Copying calendar server root: %s" % (newServerRoot,))
                 diskAccessor.ditto(
                     absolutePathWithRoot(sourceRoot, oldServerRootValue),
                     newServerRoot
                 )
+            else:
+                log("Creating new calendar server root: %s" % (newServerRoot,))
+                diskAccessor.mkdir(newServerRoot)
+                newDataRoot = os.path.join(newServerRoot, "Data")
+                diskAccessor.mkdir(newDataRoot)
+                newDocumentRoot = os.path.join(newDataRoot, "Documents")
+                diskAccessor.mkdir(newDocumentRoot)
 
+
     else: # 10.8 -> 10.8
 
         if oldServerRootValue:
             if diskAccessor.exists(oldServerRootValue): # external volume
-                pass
+                log("Using external calendar server root: %s" % (oldServerRootValue,))
             elif diskAccessor.exists(absolutePathWithRoot(sourceRoot, oldServerRootValue)):
+                log("Copying calendar server root: %s" % (newServerRoot,))
                 diskAccessor.ditto(
                     absolutePathWithRoot(sourceRoot, oldServerRootValue),
                     newServerRoot
                 )
+            else:
+                log("Creating new calendar server root: %s" % (newServerRoot,))
+                diskAccessor.mkdir(newServerRoot)
+                newDataRoot = os.path.join(newServerRoot, "Data")
+                diskAccessor.mkdir(newDataRoot)
+                newDocumentRoot = os.path.join(newDataRoot, "Documents")
+                diskAccessor.mkdir(newDocumentRoot)
 
-    if diskAccessor.exists(newServerRoot):
-        diskAccessor.chown(newServerRoot, uid, gid, recursive=True)
+    if not diskAccessor.exists(newServerRoot):
+        diskAccessor.mkdir(newServerRoot)
+    diskAccessor.chown(newServerRoot, uid, gid, recursive=True)
 
     newServerRootValue, newDataRootValue = relativize(newServerRootValue,
         newDataRootValue)

Modified: CalendarServer/trunk/contrib/migration/test/test_migrator.py
===================================================================
--- CalendarServer/trunk/contrib/migration/test/test_migrator.py	2012-03-10 00:40:50 UTC (rev 8832)
+++ CalendarServer/trunk/contrib/migration/test/test_migrator.py	2012-03-10 00:46:45 UTC (rev 8833)
@@ -937,7 +937,6 @@
                 "Data"
             ),
             [   # expected DiskAccessor history
-                ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts'),
                 ('ditto', '/Library/Server/Previous/Library/CalendarServer/Data', '/Volumes/new/Library/Server/Calendar and Contacts/Data'),
                 ('ditto', '/Library/Server/Previous/Library/CalendarServer/Documents', '/Volumes/new/Library/Server/Calendar and Contacts/Data/Documents'),
                 ('ditto', '/Library/Server/Previous/Library/AddressBookServer/Documents/addressbooks', '/Volumes/new/Library/Server/Calendar and Contacts/Data/Documents/addressbooks'),
@@ -1011,7 +1010,6 @@
                 "/Volumes/External/CalendarServer/Calendar and Contacts Data",
             ),
             [   # expected DiskAccessor history
-                ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts'),
                 ('rename',
                  '/Volumes/External/CalendarServer/Calendar and Contacts Data',
                  '/Volumes/External/CalendarServer/Calendar and Contacts Data.bak'),
@@ -1019,6 +1017,7 @@
                 ('rename', '/Volumes/External/CalendarServer/Documents', '/Volumes/External/CalendarServer/Calendar and Contacts Data/Documents'),
                 ('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 Data/Documents/addressbooks'),
+                ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts'),
                 ('chown-recursive', '/Volumes/new/Library/Server/Calendar and Contacts', FakeUser.pw_uid, FakeGroup.gr_gid),
             ]
         ),
@@ -1088,7 +1087,6 @@
                 "Data"
             ),
             [
-                ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts'),
                 ('ditto', '/Library/Server/Previous/NonStandard/CalendarServer/Data', '/Volumes/new/Library/Server/Calendar and Contacts/Data'),
                 ('ditto', '/Library/Server/Previous/NonStandard/CalendarServer/Documents', '/Volumes/new/Library/Server/Calendar and Contacts/Data/Documents'),
                 ('ditto', '/Library/Server/Previous/NonStandard/AddressBookServer/Documents/addressbooks', '/Volumes/new/Library/Server/Calendar and Contacts/Data/Documents/addressbooks'),
@@ -1161,13 +1159,13 @@
                 "/Volumes/External/CalendarServer/Calendar and Contacts Data",
             ),
             [
-                ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts'),
                 ('ditto',
                  '/Library/Server/Previous/Library/CalendarServer/Data',
                  '/Volumes/External/CalendarServer/Calendar and Contacts Data'),
                 ('rename', '/Volumes/External/CalendarServer/Documents', '/Volumes/External/CalendarServer/Calendar and Contacts Data/Documents'),
                 ('chown-recursive', '/Volumes/External/CalendarServer/Calendar and Contacts Data', FakeUser.pw_uid, FakeGroup.gr_gid),
                 ('ditto', '/Library/Server/Previous/Library/AddressBookServer/Documents/addressbooks', '/Volumes/External/CalendarServer/Calendar and Contacts Data/Documents/addressbooks'),
+                ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts'),
                 ('chown-recursive', '/Volumes/new/Library/Server/Calendar and Contacts', FakeUser.pw_uid, FakeGroup.gr_gid),
             ]
         ),
@@ -1288,10 +1286,10 @@
                 "/Volumes/External/Library/Server/Calendar and Contacts/Data",
             ),
             [
-            ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts'),
             ('rename',
               '/Volumes/External/Library/Server/Calendar and Contacts/Documents',
               '/Volumes/External/Library/Server/Calendar and Contacts/Data/Documents'),
+            ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts'),
             ('chown-recursive', '/Volumes/new/Library/Server/Calendar and Contacts', FakeUser.pw_uid, FakeGroup.gr_gid),
             ]
         ),
@@ -1350,7 +1348,6 @@
                 "Data"
             ),
             [
-                ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts'),
                 ('ditto', '/Library/Server/Previous/Library/Server/Calendar and Contacts', '/Volumes/new/Library/Server/Calendar and Contacts'),
                 ('chown-recursive', '/Volumes/new/Library/Server/Calendar and Contacts', FakeUser.pw_uid, FakeGroup.gr_gid),
             ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120309/db0fcda2/attachment-0001.html>


More information about the calendarserver-changes mailing list