Example #1
0
    def stepWithResult(self, result):
        if self.doPostImport:

            # Load proxy assignments from XML if specified
            if (
                self.config.ProxyLoadFromFile and
                os.path.exists(self.config.ProxyLoadFromFile) and
                not os.path.exists(
                    os.path.join(
                        self.config.DataRoot, "proxies.sqlite"
                    )
                )
            ):
                sqliteProxyService = ProxySqliteDB("proxies.sqlite")
                yield loadDelegatesFromXML(
                    self.config.ProxyLoadFromFile,
                    sqliteProxyService
                )
            else:
                sqliteProxyService = None

            # # Populate the group membership cache
            # if (self.config.GroupCaching.Enabled and
            #     self.config.GroupCaching.EnableUpdater):
            #     proxydb = calendaruserproxy.ProxyDBService
            #     if proxydb is None:
            #         proxydbClass = namedClass(self.config.ProxyDBService.type)
            #         proxydb = proxydbClass(**self.config.ProxyDBService.params)

            #     # MOVE2WHO FIXME: port to new group cacher
            #     updater = GroupMembershipCacheUpdater(proxydb,
            #         directory,
            #         self.config.GroupCaching.UpdateSeconds,
            #         self.config.GroupCaching.ExpireSeconds,
            #         self.config.GroupCaching.LockSeconds,
            #         namespace=self.config.GroupCaching.MemcachedPool,
            #         useExternalProxies=self.config.GroupCaching.UseExternalProxies)
            #     yield updater.updateCache(fast=True)

            uid, gid = getCalendarServerIDs(self.config)
            dbPath = os.path.join(self.config.DataRoot, "proxies.sqlite")
            if os.path.exists(dbPath):
                os.chown(dbPath, uid, gid)

            # Process old inbox items
            self.store.setMigrating(True)
            yield self.processInboxItems()
            self.store.setMigrating(False)

            # Migrate mail tokens from sqlite to store
            yield migrateTokensToStore(self.config.DataRoot, self.store)

            # Migrate delegate assignments from sqlite to store
            if sqliteProxyService is None:
                sqliteProxyService = ProxySqliteDB("proxies.sqlite")
            yield migrateDelegatesToStore(sqliteProxyService, self.store)
 def test_migrate(self):
     self.path = self.mktemp()
     os.mkdir(self.path)
     oldDB = MailGatewayTokensDatabase(self.path)
     oldDB.createToken("urn:uuid:user01", "mailto:[email protected]", "icaluid1", token="token1")
     yield migrateTokensToStore(self.path, self.store)
     txn = self.store.newTransaction()
     records = yield (txn.imipLookupByToken("token1"))
     yield txn.commit()
     self.assertEquals(records[0].organizer, "urn:uuid:user01")
     self.assertEquals(records[0].attendee, "mailto:[email protected]")
     self.assertEquals(records[0].icaluid, "icaluid1")
 def test_migrate(self):
     self.path = self.mktemp()
     os.mkdir(self.path)
     oldDB = MailGatewayTokensDatabase(self.path)
     oldDB.createToken("urn:uuid:user01", "mailto:[email protected]",
         "icaluid1", token="token1")
     yield migrateTokensToStore(self.path, self.store)
     txn = self.store.newTransaction()
     results = yield (txn.imipLookupByToken("token1"))
     organizer, attendee, icaluid = results[0]
     yield txn.commit()
     self.assertEquals(organizer, "urn:uuid:user01")
     self.assertEquals(attendee, "mailto:[email protected]")
     self.assertEquals(icaluid, "icaluid1")
Example #4
0
    def stepWithResult(self, result):
        if self.doPostImport:

            # Migrate any proxyDB file that exists - remove it after migration
            loadDoneFilePath = os.path.join(self.config.DataRoot, "proxies-loaded")
            if os.path.exists(
                os.path.join(self.config.DataRoot, "proxies.sqlite")
            ):
                # Migrate delegate assignments from sqlite to store
                yield migrateDelegatesToStore(
                    self.store
                )

                # If migration happened and the XML load option is on, write a stub file to prevent
                # it being loaded on the next restart
                if (
                    self.config.ProxyLoadFromFile and
                    os.path.exists(self.config.ProxyLoadFromFile) and
                    not os.path.exists(loadDoneFilePath)
                ):
                    # Write stub file as indicator loading is done
                    FilePath(loadDoneFilePath).touch()

            # If no migration, see if there is an XML file to load into the store (once only)
            else:
                if (
                    self.config.ProxyLoadFromFile and
                    os.path.exists(self.config.ProxyLoadFromFile) and
                    not os.path.exists(loadDoneFilePath)
                ):
                    log.warn("Loading delegate assignments from XML")
                    yield loadDelegatesFromXMLintoStore(
                        self.config.ProxyLoadFromFile,
                        self.store
                    )

                    # Write stub file as indicator loading is done
                    FilePath(loadDoneFilePath).touch()

            # Process old inbox items
            self.store.setMigrating(True)
            yield self.processInboxItems()
            self.store.setMigrating(False)

            # Migrate mail tokens from sqlite to store
            yield migrateTokensToStore(self.config.DataRoot, self.store)
Example #5
0
    def stepWithResult(self, result):
        if self.doPostImport:

            directory = directoryFromConfig(self.config)

            # Load proxy assignments from XML if specified
            if self.config.ProxyLoadFromFile:
                proxydbClass = namedClass(self.config.ProxyDBService.type)
                calendaruserproxy.ProxyDBService = proxydbClass(
                    **self.config.ProxyDBService.params)
                loader = XMLCalendarUserProxyLoader(self.config.ProxyLoadFromFile)
                yield loader.updateProxyDB()

            # Populate the group membership cache
            if (self.config.GroupCaching.Enabled and
                self.config.GroupCaching.EnableUpdater):
                proxydb = calendaruserproxy.ProxyDBService
                if proxydb is None:
                    proxydbClass = namedClass(self.config.ProxyDBService.type)
                    proxydb = proxydbClass(**self.config.ProxyDBService.params)

                updater = GroupMembershipCacheUpdater(proxydb,
                    directory,
                    self.config.GroupCaching.UpdateSeconds,
                    self.config.GroupCaching.ExpireSeconds,
                    self.config.GroupCaching.LockSeconds,
                    namespace=self.config.GroupCaching.MemcachedPool,
                    useExternalProxies=self.config.GroupCaching.UseExternalProxies)
                yield updater.updateCache(fast=True)

                uid, gid = getCalendarServerIDs(self.config)
                dbPath = os.path.join(self.config.DataRoot, "proxies.sqlite")
                if os.path.exists(dbPath):
                    os.chown(dbPath, uid, gid)

            # Process old inbox items
            self.store.setMigrating(True)
            yield self.processInboxItems()
            self.store.setMigrating(False)

            # Migrate mail tokens from sqlite to store
            yield migrateTokensToStore(self.config.DataRoot, self.store)