Пример #1
0
    def _create(self, plugin_class, **kwargs):
        conn_mgr = kwargs.pop('conn_mgr', None)
        if not conn_mgr:
            raise RuntimeError('Please pass conn_mgr to create discovery!')

        plugin_config = DiscoveryConfig.Create()
        plugin = plugin_class.Create(plugin_config=plugin_config, conn_mgr=conn_mgr, **kwargs)
        return plugin
Пример #2
0
    def _create(self, plugin_class, **kwargs):
        readonly_topo = kwargs.pop('readonly_topo', None)
        if not readonly_topo:
            raise RuntimeError(
                'Please pass readonly_topo to create discovery!')

        plugin_config = DiscoveryConfig.Create()
        plugin = plugin_class.Create(plugin_config=plugin_config,
                                     readonly_topo=readonly_topo,
                                     **kwargs)
        return plugin
Пример #3
0
    class Connect:
        def register(self, name, value):
            logger.error('Register: {} - {}'.format(name, value))

        def unregister(self, name):
            logger.error('Unregister: {}'.format(name))

        @property
        def conn_names(self):
            return set()

    connect_mgr = Connect()

    from discovery import DiscoveryConfig
    settings = DiscoveryConfig(
        DISCOVERY_KUBERNETES_NAMESPACE='xp',
        DISCOVERY_KUBERNETES_POD_PATT=".*-ro-servers-.*",
        DISCOVERY_KUBERNETES_LABEL_SELECTOR='tier=ro-servers',
        DISCOVERY_KUBERNETES_POLL_INTERVAL=5,
        DISCOVERY_KUBERNETES_IN_CLUSTER=False)

    provider_class = KubernetesProvider
    t = provider_class(conn_mgr=connect_mgr, plugin_config=settings)
    t.start()
    cnt = 100
    while cnt > 0:
        time.sleep(2)
        cnt -= 1
    t.stop()