Example #1
0
    def add_remote(self, remotes, port=None, family=AF_UNSPEC):
        '''
            Adds connections to Elliptics node
            @remotes -- elliptics.Address's of server node

            node.add_remote("host.com:1025:2")
            node.add_remote("host.com", 1025, 2)
            node.add_remote("host.com", 1025)
            node.add_remote(Address.from_host_port("host.com:1025"))

            node.add_remote([
                Address.from_host_port("host.com:1025"),
                Address.from_host_port_family("host.com:1026:2"),
                "host.com:1027:2"
                ])
        '''

        if port is not None:
            remotes = Address(remotes, port, family)

        if type(remotes) in [str, Address]:
            super(Node, self).add_remote((str(remotes), ))
        elif hasattr(remotes, '__iter__'):
            super(Node, self).add_remote(map(str, remotes))
        else:
            raise ValueError("Couldn't convert {0} to [elliptics.Address]".format(repr(remotes)))