[CalendarServer-changes] [8619] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jan 31 18:54:39 PST 2012
Revision: 8619
http://trac.macosforge.org/projects/calendarserver/changeset/8619
Author: sagen at apple.com
Date: 2012-01-31 18:54:37 -0800 (Tue, 31 Jan 2012)
Log Message:
-----------
Only migrate resource delegation/auto-schedule settings from OD if migrating from .calendarserver_version 0
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
CalendarServer/trunk/twistedcaldav/upgrade.py
Modified: CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_upgrade.py 2012-02-01 00:56:17 UTC (rev 8618)
+++ CalendarServer/trunk/twistedcaldav/test/test_upgrade.py 2012-02-01 02:54:37 UTC (rev 8619)
@@ -1353,7 +1353,11 @@
# XMLDirectoryService.getResourceInfo = _getResourceInfo
self.patch(XMLDirectoryService, "getResourceInfo", _getResourceInfo)
- before = { }
+ before = {
+ "trigger_resource_migration" : {
+ "@contents" : "x",
+ }
+ }
after = {
".calendarserver_version" :
{
@@ -1385,6 +1389,7 @@
root = self.createHierarchy(before)
config.DocumentRoot = root
config.DataRoot = root
+ config.ServerRoot = root
(yield self.doUpgrade(config))
self.assertTrue(self.verifyHierarchy(root, after))
Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py 2012-02-01 00:56:17 UTC (rev 8618)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py 2012-02-01 02:54:37 UTC (rev 8619)
@@ -61,6 +61,7 @@
)
INBOX_ITEMS = "inboxitems.txt"
+TRIGGER_FILE = "trigger_resource_migration"
log = Logger()
@@ -353,12 +354,15 @@
service, because in "v1" that's where this info lived.
"""
- log.info("Fetching delegate assignments and auto-schedule settings from directory")
+ log.warn("Fetching delegate assignments and auto-schedule settings from directory")
resourceInfo = directory.getResourceInfo()
if len(resourceInfo) == 0:
# Nothing to migrate, or else not appleopendirectory
+ log.warn("No resource info found in directory")
return
+ log.warn("Found info for %d resources and locations in directory; applying settings" % (len(resourceInfo),))
+
resourceInfoDatabase = ResourceInfoDatabase(config.DataRoot)
proxydbClass = namedClass(config.ProxyDBService.type)
calendarUserProxyDatabase = proxydbClass(**config.ProxyDBService.params)
@@ -555,7 +559,9 @@
yield spawner.stopService()
log.warn("Done processing calendar homes")
- yield migrateResourceInfo(config, directory, uid, gid)
+ triggerPath = os.path.join(config.ServerRoot, TRIGGER_FILE)
+ if os.path.exists(triggerPath):
+ yield migrateResourceInfo(config, directory, uid, gid)
createMailTokensDatabase(config, uid, gid)
if errorOccurred:
@@ -738,12 +744,14 @@
directory = getDirectory()
- try:
- # Migrate locations/resources now because upgrade_to_1 depends on them
- # being in resources.xml
- (yield migrateFromOD(config, directory))
- except Exception, e:
- raise UpgradeError("Unable to migrate locations and resources from OD: %s" % (e,))
+ triggerPath = os.path.join(config.ServerRoot, TRIGGER_FILE)
+ if os.path.exists(triggerPath):
+ try:
+ # Migrate locations/resources now because upgrade_to_1 depends
+ # on them being in resources.xml
+ (yield migrateFromOD(config, directory))
+ except Exception, e:
+ raise UpgradeError("Unable to migrate locations and resources from OD: %s" % (e,))
docRoot = config.DocumentRoot
@@ -772,6 +780,10 @@
verFile.write(str(version))
os.chown(versionFilePath, uid, gid)
+ # Clean up the resource migration trigger file
+ if os.path.exists(triggerPath):
+ os.remove(triggerPath)
+
class UpgradeError(RuntimeError):
"""
Generic upgrade error.
@@ -907,37 +919,32 @@
#
# Migrates locations and resources from OD
#
- triggerFile = "trigger_resource_migration"
- triggerPath = os.path.join(config.ServerRoot, triggerFile)
- if os.path.exists(triggerPath):
- os.remove(triggerPath)
+ log.warn("Migrating locations and resources")
- log.warn("Migrating locations and resources")
+ userService = directory.serviceForRecordType("users")
+ resourceService = directory.serviceForRecordType("resources")
+ if (
+ not isinstance(userService, OpenDirectoryService) or
+ not isinstance(resourceService, XMLDirectoryService)
+ ):
+ # Configuration requires no migration
+ return succeed(None)
- userService = directory.serviceForRecordType("users")
- resourceService = directory.serviceForRecordType("resources")
- if (
- not isinstance(userService, OpenDirectoryService) or
- not isinstance(resourceService, XMLDirectoryService)
- ):
- # Configuration requires no migration
- return succeed(None)
+ # Create internal copies of resources and locations based on what is
+ # found in OD
+ return migrateResources(userService, resourceService)
- # Create internal copies of resources and locations based on what is
- # found in OD
- return migrateResources(userService, resourceService)
-
@inlineCallbacks
def migrateAutoSchedule(config, directory):
# Fetch the autoSchedule assignments from resourceinfo.sqlite and store
# the values in augments
augmentService = directory.augmentService
if augmentService:
- log.warn("Migrating auto-schedule settings")
augmentRecords = []
dbPath = os.path.join(config.DataRoot, ResourceInfoDatabase.dbFilename)
if os.path.exists(dbPath):
+ log.warn("Migrating auto-schedule settings")
resourceInfoDatabase = ResourceInfoDatabase(config.DataRoot)
results = resourceInfoDatabase._db_execute(
"select GUID, AUTOSCHEDULE from RESOURCEINFO"
@@ -949,8 +956,9 @@
augmentRecord.autoSchedule = autoSchedule
augmentRecords.append(augmentRecord)
- yield augmentService.addAugmentRecords(augmentRecords)
- log.warn("Migrated auto-schedule settings")
+ if augmentRecords:
+ yield augmentService.addAugmentRecords(augmentRecords)
+ log.warn("Migrated %d auto-schedule settings" % (len(augmentRecords),))
class UpgradeFileSystemFormatService(Service, object):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120131/f4626db0/attachment-0001.html>
More information about the calendarserver-changes
mailing list