'Configure the given node as an agent node for the given cluster.
:param reactor: The reactor.
:param reactor: The cluster.
:param Node node: The node.
:param int index: The index of the ndoe in the cluster.
:return: Deferred that fires with the :param:`node` when it is
configured.'

def _add_node_to_cluster(self, reactor, cluster, node, index):

    node_cert_and_key = cluster.certificates.add_node(index)
    commands = configure_node(cluster, node, node_cert_and_key, self.dataset_backend_configuration, 'libcloud', logging_config=self.config.get('logging'))
    d = perform(make_dispatcher(reactor), commands)
    def add_node(ignored):
        if (node is not cluster.control_node):
            cluster.all_nodes.append(node)
        cluster.agent_nodes.append(node)
        return node
    def configure_failed(failure):
        print 'Failed    to    configure    node    {}'.format(node.name)
        write_failure(failure)
        if (node is not cluster.control_node):
            self._destroy_node(node)
        return failure
    d.addCallbacks(add_node, errback=configure_failed)
    return d
