Exemple #1
0
    def setUp(self):
        self.test_dict = t = PrefixDict()

        t['u01.citrusleaf.local'] = 1
        t['u02.citrusleaf.local'] = 2
        t['u11.citrusleaf.local'] = 3
        t['u12'] = 4
Exemple #2
0
    def setUp(self):
        self.cluster_patch = patch('lib.cluster.Cluster')
        #self.view_patch = patch('lib.view.CliView')

        real_stdoup = sys.stdout
        sys.stdout = StringIO()

        self.addCleanup(patch.stopall)
        self.addCleanup(reset_stdout)

        self.MockCluster = self.cluster_patch.start()
        #self.MockView = self.view_patch.start()
        Cluster._crawl = classmethod(lambda self: None)
        Cluster._callNodeMethod = classmethod(
            lambda self, nodes, method_name, *args, **kwargs:
            {"test":IOError("test error")})

        n = Node("172.99.99.99")
        Cluster.getNode = classmethod(
            lambda self, key: [n])

        pd = PrefixDict()
        pd['test'] = 'test'

        Cluster.getPrefixes = classmethod(lambda self: pd)

        self.rc = RootController()
Exemple #3
0
    def __init__(self, seed_nodes, use_telnet=False, user=None, password=None):
        """
        Want to be able to support multiple nodes on one box (for testing)
        seed_nodes should be the form (address,port) address can be fqdn or ip.
        """

        self.__dict__ = self.cluster_state
        if self.cluster_state != {}:
            return

        # will we connect using telnet port?
        self.use_telnet = use_telnet

        self.user = user
        self.password = password

        # self.nodes is a dict from Node ID -> Node objects
        self.nodes = {}

        # self.node_lookup is a dict of (fqdn, port) -> Node
        # and (ip, port) -> Node, and node.node_id -> Node
        self.node_lookup = PrefixDict()

        self._original_seed_nodes = set(seed_nodes)
        self._seed_nodes = set(seed_nodes)
        self._live_nodes = set()
        # crawl the cluster search for nodes in addition to the seed nodes.
        self._enable_crawler = True
        self._crawl()
Exemple #4
0
    def _initCommands(self):
        command_re = re.compile("^(do_(.*))$")
        commands = map(lambda v: command_re.match(v).groups(),
                       filter(command_re.search, dir(self)))
        self.commands = PrefixDict()

        for command in commands:
            self.commands.add(command[1], getattr(self, command[0]))

        for command, controller in self.controller_map.items():
            try:
                controller = controller()
            except:
                pass

            self.commands.add(command, controller)