def _configure_nodes(self, nodes):
        """Parse and set up the given nodes.

        :param nodes: nodes used to create the continuum (see doc for format).
        """
        if isinstance(nodes, str):
            nodes = [nodes]
        elif not isinstance(nodes, (dict, list)):
            raise ValueError(
                'nodes configuration should be a list or a dict,'
                ' got {}'.format(type(nodes)))

        conf_changed = False
        for node in nodes:
            conf = {
                'hostname': node,
                'instance': None,
                'nodename': node,
                'port': None,
                'vnodes': self._default_vnodes,
                'weight': 1
            }
            current_conf = self.runtime._nodes.get(node, {})
            nodename = node
            # new node, trigger a ring update
            if not current_conf:
                conf_changed = True
            # complex config
            if isinstance(nodes, dict):
                node_conf = nodes[node]
                if isinstance(node_conf, int):
                    conf['weight'] = node_conf
                elif isinstance(node_conf, dict):
                    for k, v in node_conf.items():
                        if k in conf:
                            conf[k] = v
                            # changing those config trigger a ring update
                            if k in ['nodename', 'vnodes', 'weight']:
                                if current_conf.get(k) != v:
                                    conf_changed = True
                else:
                    raise ValueError(
                        'node configuration should be a dict or an int,'
                        ' got {}'.format(type(node_conf)))
            if self._weight_fn:
                conf['weight'] = self._weight_fn(**conf)
            # changing the weight of a node trigger a ring update
            if current_conf.get('weight') != conf['weight']:
                conf_changed = True
            self.runtime._nodes[nodename] = conf
        return conf_changed
def _configure_nodes ( self , nodes ) : if isinstance ( nodes , str ) : nodes = [ nodes ] elif not isinstance ( nodes , ( dict , list ) ) : raise ValueError ( 'nodes configuration should be a list or a dict,' ' got {}' . format ( type ( nodes ) ) ) conf_changed = False for node in nodes : conf = { 'hostname' : node , 'instance' : None , 'nodename' : node , 'port' : None , 'vnodes' : self . _default_vnodes , 'weight' : 1 } current_conf = self . runtime . _nodes . get ( node , { } ) nodename = node if not current_conf : conf_changed = True if isinstance ( nodes , dict ) : node_conf = nodes [ node ] if isinstance ( node_conf , int ) : conf [ 'weight' ] = node_conf elif isinstance ( node_conf , dict ) : for k , v in node_conf . items ( ) : if k in conf : conf [ k ] = v if k in [ 'nodename' , 'vnodes' , 'weight' ] : if current_conf . get ( k ) != v : conf_changed = True else : raise ValueError ( 'node configuration should be a dict or an int,' ' got {}' . format ( type ( node_conf ) ) ) if self . _weight_fn : conf [ 'weight' ] = self . _weight_fn ( ** conf ) if current_conf . get ( 'weight' ) != conf [ 'weight' ] : conf_changed = True self . runtime . _nodes [ nodename ] = conf return conf_changed
Parse and set up the given nodes.

        :param nodes: nodes used to create the continuum (see doc for format).