当前位置: 首页>>代码示例>>Python>>正文


Python PluginRegistry.getInstance方法代码示例

本文整理汇总了Python中gosa.common.components.PluginRegistry.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python PluginRegistry.getInstance方法的具体用法?Python PluginRegistry.getInstance怎么用?Python PluginRegistry.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gosa.common.components.PluginRegistry的用法示例。


在下文中一共展示了PluginRegistry.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __dbus_proxy_monitor

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def __dbus_proxy_monitor(self, bus_name):
        """
        This method monitors the DBus service 'org.gosa' and whenever there is a
        change in the status (dbus closed/startet) we will take notice.
        And can register or unregister methods to the dbus
        """
        if "org.gosa" in self.bus.list_names():
            if self.gosa_dbus:
                del self.gosa_dbus

            # Trigger resend of capapability event
            self.gosa_dbus = self.bus.get_object('org.gosa', '/org/gosa/inventory')
            ccr = PluginRegistry.getInstance('ClientCommandRegistry')
            ccr.register("request_inventory", 'Inventory.request_inventory', [], ['old_checksum=None'], 'Request client inventory information')
            mqtt = PluginRegistry.getInstance('MQTTClientService')
            mqtt.reAnnounce()
            self.log.info("established dbus connection")

        else:
            if self.gosa_dbus:
                del(self.gosa_dbus)

                # Trigger resend of capapability event
                ccr = PluginRegistry.getInstance('ClientCommandRegistry')
                ccr.unregister("request_inventory")
                mqtt = PluginRegistry.getInstance('MQTTClientService')
                mqtt.reAnnounce()
                self.log.info("lost dbus connection")
            else:
                self.log.info("no dbus connection")
开发者ID:peuter,项目名称:gosa,代码行数:32,代码来源:main.py

示例2: setSambaPassword

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def setSambaPassword(self, user, object_dn, password):
        """
        Set a new samba-password for a user
        """

        # Do we have read permissions for the requested attribute
        env = Environment.getInstance()
        topic = "%s.objects.%s.attributes.%s" % (env.domain, "User", "sambaNTPassword")
        aclresolver = PluginRegistry.getInstance("ACLResolver")
        if not aclresolver.check(user, topic, "w", base=object_dn):
            self.__log.debug("user '%s' has insufficient permissions to write %s on %s, required is %s:%s" % (
                user, "isLocked", object_dn, topic, "w"))
            raise ACLException(C.make_error('PERMISSION_ACCESS', topic, target=object_dn))

        topic = "%s.objects.%s.attributes.%s" % (env.domain, "User", "sambaLMPassword")
        aclresolver = PluginRegistry.getInstance("ACLResolver")
        if not aclresolver.check(user, topic, "w", base=object_dn):
            self.__log.debug("user '%s' has insufficient permissions to write %s on %s, required is %s:%s" % (
                user, "isLocked", object_dn, topic, "w"))
            raise ACLException(C.make_error('PERMISSION_ACCESS', topic, target=object_dn))

        # Set the password and commit the changes
        user = ObjectProxy(object_dn)
        user.sambaNTPassword = nthash.encrypt(password)
        user.sambaLMPassword = lmhash.encrypt(password)
        user.commit()
开发者ID:gonicus,项目名称:gosa,代码行数:28,代码来源:domain.py

示例3: serve

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def serve(self):
        """ Start JSONRPC service for this GOsa service provider. """

        # Get http service instance
        self.__http = PluginRegistry.getInstance("HTTPService")
        cr = PluginRegistry.getInstance("CommandRegistry")

        # Register ourselves
        app = JsonRpcApp(cr)
        self.__http.app.register(
            self.path,
            AuthCookieHandler(
                app,
                timeout=self.env.config.get("jsonrpc.cookie-lifetime", default=1800),
                cookie_name="GOsaRPC",
                secret=self.env.config.get("http.cookie_secret", default="TecloigJink4"),
            ),
        )

        # Announce service
        self.__zeroconf = ZeroconfService(
            name="GOsa JSONRPC command service",
            port=self.__http.port,
            stype="_%s._tcp" % self.__http.scheme,
            text="path=%s\001service=gosa" % self.path,
        )
        self.__zeroconf.publish()

        self.log.info("ready to process incoming requests")
开发者ID:lhm-limux,项目名称:gosa,代码行数:31,代码来源:jsonrpc_service.py

示例4: serve

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def serve(self):
        """ Start AMQP service for this GOsa service provider. """
        # Load AMQP and Command registry instances
        amqp = PluginRegistry.getInstance('AMQPHandler')
        self.__cr = PluginRegistry.getInstance('CommandRegistry')

        # Create a list of queues we need here
        queues = {}
        for dsc in self.__cr.commands.values():
            queues[dsc['target']] = True

        # Finally create the queues
        for queue in queues:
            # Add round robin processor for queue
            self.__cmdWorker = AMQPWorker(self.env, connection=amqp.getConnection(),
                r_address='%s.command.%s; { create:always, node:{ type:queue, x-bindings:[ { exchange:"amq.direct", queue:"%s.command.%s" } ] } }' % (self.env.domain, queue, self.env.domain, queue),
                workers=self.env.config.get('amqp.command-worker', default=1),
                callback=self.commandReceived)

            # Add private processor for queue
            self.__cmdWorker = AMQPWorker(self.env, connection=amqp.getConnection(),
                    r_address='%s.command.%s.%s; { create:always, delete:receiver, node:{ type:queue, x-bindings:[ { exchange:"amq.direct", queue:"%s.command.%s.%s" } ] } }' % (self.env.domain, queue, self.env.id, self.env.domain, queue, self.env.id),
                workers=self.env.config.get('amqp.command-worker', default=1),
                callback=self.commandReceived)

        # Announce service
        url = parseURL(self.env.config.get("amqp.url"))
        self.__zeroconf = ZeroconfService(name="GOsa AMQP command service",
                port=url['port'],
                stype="_%s._tcp" % url['scheme'],
                text="path=%s\001service=gosa" % url['path'])
        self.__zeroconf.publish()

        self.log.info("ready to process incoming requests")
开发者ID:lhm-limux,项目名称:gosa,代码行数:36,代码来源:amqp_service.py

示例5: accountUnlockable

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def accountUnlockable(self, user, object_dn):
        index = PluginRegistry.getInstance("ObjectIndex")

        # Do we have read permissions for the requested attribute
        env = Environment.getInstance()
        topic = "%s.objects.%s.attributes.%s" % (env.domain, "User", "isLocked")
        aclresolver = PluginRegistry.getInstance("ACLResolver")
        if not aclresolver.check(user, topic, "r", base=object_dn):

            self.__log.debug("user '%s' has insufficient permissions to read %s on %s, required is %s:%s" % (
                user, "isLocked", object_dn, topic, "r"))
            raise ACLException(C.make_error('PERMISSION_ACCESS', topic, target=object_dn))

        res = index.search({'dn': object_dn, 'userPassword': '%'}, {'userPassword': 1})
        if len(res):
            hsh = res[0]['userPassword'][0]
        else:
            # No password hash -> cannot lock/unlock account
            return False

        # Try to detect the responsible password method-class
        pwd_o = self.detect_method_by_hash(hsh)
        if not pwd_o:

            # Could not identify password method
            return False

        return pwd_o.isUnlockable(hsh)
开发者ID:peuter,项目名称:gosa,代码行数:30,代码来源:manager.py

示例6: test_handle_backend_message

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def test_handle_backend_message(self):
        e = EventMaker()

        # send client poll
        with mock.patch.object(self.service.proxy_mqtt, "send_message") as mps:

            # send ACLChanged
            m_resolver = PluginRegistry.getInstance("ACLResolver")
            self.service._handle_backend_message("%s/proxy" % self.env.domain,
                                                 etree.tostring(e.Event(e.Trigger(e.Type("ACLChanged"))),
                                                                pretty_print=True).decode())
            assert m_resolver.load_acls.called
            assert not mps.called

            m_index = PluginRegistry.getInstance("ObjectIndex")
            self.service._handle_backend_message("%s/client/broadcast" % self.env.domain,
                                                 etree.tostring(e.Event(e.ClientPoll()),
                                                                pretty_print=True).decode())
            assert m_index.registerProxy.called
            assert mps.called
            mps.reset_mock()

            # send client RPC
            payload = dumps({"id": "mqttrpc", "method": "test", "params": []})
            topic = "%s/client/client_id/request_id/request" % self.env.domain
            self.service._handle_backend_message(topic, payload)
            mps.assert_called_with(payload, topic, qos=1, proxied=True)
开发者ID:gonicus,项目名称:gosa,代码行数:29,代码来源:test_mqtt_relay.py

示例7: mainLoop

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
def mainLoop(env):
    """
    Main event loop which will process all registerd threads in a loop.
    It will run as long env.active is set to True.
    """
    log = logging.getLogger(__name__)

    try:
        # Load plugins
        oreg = ObjectRegistry.getInstance() #@UnusedVariable
        pr = PluginRegistry() #@UnusedVariable
        cr = PluginRegistry.getInstance("CommandRegistry")

        httpd = PluginRegistry.getInstance("HTTPService")
        if not hasattr(sys, "_called_from_test") or sys._called_from_test is False:
            httpd.thread.join()

    # Catchall, pylint: disable=W0703
    except Exception as detail:
        log.critical("unexpected error in mainLoop")
        log.exception(detail)

    except KeyboardInterrupt:
        log.info("console requested shutdown")

    finally:
        if not hasattr(sys, "_called_from_test") or sys._called_from_test is False:
            shutdown()
开发者ID:peuter,项目名称:gosa,代码行数:30,代码来源:main.py

示例8: serve

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def serve(self):
        # Collect value extenders
        self.__value_extender = gosa.backend.objects.renderer.get_renderers()
        self.__search_aid = PluginRegistry.getInstance("ObjectIndex").get_search_aid()
        self.__oi = PluginRegistry.getInstance("ObjectIndex")

        # Load DB session
        self.__session = self.env.getDatabaseSession('backend-database')
开发者ID:peuter,项目名称:gosa,代码行数:10,代码来源:methods.py

示例9: test_clientLeave

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def test_clientLeave(self):
        service = PluginRegistry.getInstance("MQTTRPCService")
        e = EventMaker()
        goodbye = e.Event(e.ClientLeave(e.Id("fake_uuid")))
        data = etree.tostring(goodbye).decode('utf-8')

        with mock.patch.object(PluginRegistry.getInstance("BackendRegistry"), "unregisterBackend") as m:
            service.handle_request("%s/proxy" % Environment.getInstance().domain, data)
            m.assert_called_with("fake_uuid")
开发者ID:gonicus,项目名称:gosa,代码行数:11,代码来源:test_mqttrpc_service.py

示例10: initialize

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def initialize(self):
        self.dispatcher = PluginRegistry.getInstance('CommandRegistry')
        self.env = Environment.getInstance()
        self.log = logging.getLogger(__name__)
        self.ident = "GOsa JSON-RPC service (%s)" % VERSION
        self.executor = PluginRegistry.getInstance('ExecutorWrapper').executor

        if JsonRpcHandler.__gc_job is None:
            sched = PluginRegistry.getInstance('SchedulerService').getScheduler()
            JsonRpcHandler.__gc_job = sched.add_interval_job(self.__gc_sessions, minutes=180, tag='_internal', jobstore="ram")
开发者ID:gonicus,项目名称:gosa,代码行数:12,代码来源:jsonrpc_service.py

示例11: post

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def post(self, uuid):
        try:
            self.ps.data_complete() # You MUST call this to close the incoming stream.
            # Here can use self.ps to access the fields and the corresponding ``StreamedPart`` objects.
            self.upload_handler.handle_upload(self.ps.get_parts_by_name('file')[0], self.request)

            # cleanup
            PluginRegistry.getInstance("UploadManager").unregisterUploadPath(uuid)
            self.upload_handler = None

        finally:
            # When ready, don't forget to release resources.
            self.ps.release_parts()
            self.finish() # And of course, you MUST call finish()
开发者ID:gonicus,项目名称:gosa,代码行数:16,代码来源:main.py

示例12: process

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def process(self, all_props, key, value, objectType, attribute, comp=None):
        errors = []
        index = PluginRegistry.getInstance("ObjectIndex")
        factory = ObjectFactory.getInstance()
        query = {attribute: ""}
        if factory.isBaseType(objectType):
            query["_type"] = objectType
        else:
            query["extension"] = objectType

        for val in value:
            if val in all_props[key]['value']:
                # do not check existing values
                continue
            in_creation = False
            for obj in index.currently_in_creation:
                if hasattr(obj, attribute) and val == getattr(obj, attribute) and objectType == obj.get_type():
                    # this object has been created but is not in the DB yet
                    in_creation = True
                    break

            if in_creation is True:
                continue

            query[attribute] = val
            if not len(index.search(query, {'dn': 1})):
                errors.append(dict(index=value.index(val),
                                   detail=N_("no '%(type)s' object with '%(attribute)s' property matching '%(value)s' found"),
                                   type=objectType,
                                   attribute=attribute,
                                   value=val))

        return len(errors) == 0, errors
开发者ID:gonicus,项目名称:gosa,代码行数:35,代码来源:filter_validators.py

示例13: getObjectSearchItem

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def getObjectSearchItem(self, user, dn):
        """
        This method returns the search result for one specific object.
        It is used to gain some useful information about the object like title and icon.

        :param dn: string - Object DN
        :return: dict
        """
        # Start the query and bring the result in a usable form
        index = PluginRegistry.getInstance("ObjectIndex")

        item = index.find(user, {'dn': dn})
        if len(item) == 1:
            item = item[0]
        else:
            return None

        if item['_type'] not in self.__search_aid['mapping']:
            return None

        entry = {'tag': item['_type']}
        for k, v in self.__search_aid['mapping'][item['_type']].items():
            if k:
                if v in item and item[v]:
                    if v == "dn":
                        entry[k] = item[v]
                    else:
                        entry[k] = item[v][0]
                else:
                    entry[k] = self.__build_value(v, item)

        return entry
开发者ID:gonicus,项目名称:gosa,代码行数:34,代码来源:methods.py

示例14: shutdown

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def shutdown(self, force=False):
        """
        In case of HTTP connections, this command will shut down the node you're currently
        logged in.

        ================= ==========================
        Parameter         Description
        ================= ==========================
        force             force global shut down
        ================= ==========================

        ``Return``: True when shutting down
        """
        self.log.debug("received shutdown signal - waiting for threads to terminate")
        PluginRegistry.getInstance('HTTPService').stop()
        return True
开发者ID:peuter,项目名称:gosa,代码行数:18,代码来源:command.py

示例15: getMethods

# 需要导入模块: from gosa.common.components import PluginRegistry [as 别名]
# 或者: from gosa.common.components.PluginRegistry import getInstance [as 别名]
    def getMethods(self, locale=None):
        """
        Lists the all methods that are available in the domain.

        ================= ==========================
        Parameter         Description
        ================= ==========================
        locale            Translate __help__ strings to the desired language
        ================= ==========================

        ``Return``: dict describing all methods
        """
        res = {}
        for name, info in self.commands.items():

            # Only list local methods
            res[name] = info

            # Adapt to locale if required
            if locale:
                mod = PluginRegistry.getInstance(info['path'].split(".")[0]).get_locale_module()
                t = gettext.translation('messages',
                        resource_filename(mod, "locale"),
                        fallback=True,
                        languages=[locale])
                res[name]['doc'] = t.gettext(info['doc'])

        return res
开发者ID:peuter,项目名称:gosa,代码行数:30,代码来源:command.py


注:本文中的gosa.common.components.PluginRegistry.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。