Exemple #1
0
def directoryFromConfig(config, store=None, serversDB=None):
    """
    Return a directory service based on the config.  If you want to go through
    AMP to talk to one of these as a client, instantiate
    txdav.dps.client.DirectoryService
    """

    # Note: Currently the directory needs a store, and the store needs a
    # directory.  Originally the directory's store was going to be different
    # from the calendar and contacts store, but we're not doing that, maybe
    # ever, since it brings more headaches (managing multiple schema upgrades,
    # etc.) You can pass store=None in here and the store will be created for
    # you, but don't pass store=None if you already have called storeFromConfig()
    # within this same process; pass that store in instead.

    # TODO: use proxyForInterface to ensure we're only using the DPS related
    # store API.  Also define an IDirectoryProxyStore Interface
    if store is None:
        _ignore_pool, txnFactory = getDBPool(config)
        store = storeFromConfig(config, txnFactory, None)

    return buildDirectory(
        store,
        config.DataRoot,
        [config.DirectoryService, config.ResourceService],
        config.AugmentService,
        config.Authentication.Wiki,
        serversDB=serversDB
    )
Exemple #2
0
def directoryFromConfig(config, store=None, serversDB=None):
    """
    Return a directory service based on the config.  If you want to go through
    AMP to talk to one of these as a client, instantiate
    txdav.dps.client.DirectoryService
    """

    # Note: Currently the directory needs a store, and the store needs a
    # directory.  Originally the directory's store was going to be different
    # from the calendar and contacts store, but we're not doing that, maybe
    # ever, since it brings more headaches (managing multiple schema upgrades,
    # etc.) You can pass store=None in here and the store will be created for
    # you, but don't pass store=None if you already have called storeFromConfig()
    # within this same process; pass that store in instead.

    # TODO: use proxyForInterface to ensure we're only using the DPS related
    # store API.  Also define an IDirectoryProxyStore Interface
    if store is None:
        _ignore_pool, txnFactory = getDBPool(config)
        store = storeFromConfig(config, txnFactory, None)

    return buildDirectory(store,
                          config.DataRoot,
                          [config.DirectoryService, config.ResourceService],
                          config.AugmentService,
                          config.Authentication.Wiki,
                          serversDB=serversDB)
Exemple #3
0
    def makeService(self, options):
        """
        Return a service
        """
        try:
            from setproctitle import setproctitle
        except ImportError:
            pass
        else:
            setproctitle("CalendarServer Directory Proxy Service")

        # Setup default logging behavior
        multiService = ErrorLoggingMultiService(False, "", 0, 0, False)

        try:
            pool, txnFactory = getDBPool(config)
            store = storeFromConfigWithDPSServer(config, txnFactory)
            pool.setServiceParent(multiService)
        except Exception as e:
            log.error("Failed to create directory service", error=e)
            raise

        #
        # Configure Memcached Client Pool
        #
        memcachepool.installPools(
            config.Memcached.Pools,
            config.Memcached.MaxClients,
        )

        log.info("Created directory service")

        dpsService = strPortsService(
            "unix:{path}:mode=660".format(
                path=config.DirectoryProxy.SocketPath),
            DirectoryProxyAMPFactory(store.directoryService()))
        dpsService.setServiceParent(multiService)

        if config.Manhole.Enabled:
            try:
                from twisted.conch.manhole_tap import (makeService as
                                                       manholeMakeService)
                portString = "tcp:{:d}:interface=127.0.0.1".format(
                    config.Manhole.DPSPortNumber)
                manholeService = manholeMakeService({
                    "sshPort":
                    portString if config.Manhole.UseSSH is True else None,
                    "telnetPort":
                    portString if config.Manhole.UseSSH is False else None,
                    "sshKeyDir":
                    config.DataRoot,
                    "sshKeyName":
                    "manhole.key",
                    "sshKeySize":
                    4096,
                    "passwd":
                    config.Manhole.PasswordFilePath,
                    "namespace": {
                        "config": config,
                        "service": dpsService,
                        "store": store,
                        "directory": store.directoryService(),
                    },
                })
                manholeService.setServiceParent(multiService)
                # Using print(because logging isn't ready at this point)
                print("Manhole access enabled:", portString)

            except ImportError:
                print("Manhole access could not enabled because "
                      "manhole_tap could not be imported")

        return multiService
Exemple #4
0
    def makeService(self, options):
        """
        Return a service
        """
        try:
            from setproctitle import setproctitle
        except ImportError:
            pass
        else:
            setproctitle("CalendarServer Directory Proxy Service")

        multiService = MultiService()

        try:
            pool, txnFactory = getDBPool(config)
            store = storeFromConfigWithDPSServer(config, txnFactory)
            pool.setServiceParent(multiService)
        except Exception as e:
            log.error("Failed to create directory service", error=e)
            raise


        #
        # Configure Memcached Client Pool
        #
        memcachepool.installPools(
            config.Memcached.Pools,
            config.Memcached.MaxClients,
        )

        log.info("Created directory service")

        dpsService = strPortsService(
            "unix:{path}:mode=660".format(
                path=config.DirectoryProxy.SocketPath
            ),
            DirectoryProxyAMPFactory(store.directoryService())
        )
        dpsService.setServiceParent(multiService)

        if config.Manhole.Enabled:
            try:
                from twisted.conch.manhole_tap import (
                    makeService as manholeMakeService
                )
                portString = "tcp:{:d}:interface=127.0.0.1".format(
                    config.Manhole.DPSPortNumber
                )
                manholeService = manholeMakeService({
                    "sshPort": None,
                    "telnetPort": portString,
                    "namespace": {
                        "config": config,
                        "service": dpsService,
                        "store": store,
                        "directory": store.directoryService(),
                    },
                    "passwd": config.Manhole.PasswordFilePath,
                })
                manholeService.setServiceParent(multiService)
                # Using print(because logging isn't ready at this point)
                print("Manhole access enabled:", portString)

            except ImportError:
                print(
                    "Manhole access could not enabled because "
                    "manhole_tap could not be imported"
                )

        return multiService