'Create a node and make it ready for Flocker installation
by provisioning it with required software and configuration.
The process is transparently retried if necessary.
:param reactor: The reactor.
:param str name: The name.
:param int retries: Maximum number of retries.
:return: Deferred that fires with the created node when
the provisioning is completed.'

def _create_and_provision(self, reactor, name, retries=10):

    print 're-creating    and    re-trying    node', name
    def create_attempt():
        [d] = self.provisioner.create_nodes(reactor=reactor, names=[name], distribution=self.distribution, metadata=self.metadata)
        def provision(node):
            d = self._provision_node(reactor, node)
            def provisioning_failed(failure):
                self._destroy_node(node)
                return failure
            d.addCallbacks((lambda _: node), errback=provisioning_failed)
            return d
        d.addCallback(provision)
        d.addErrback(write_failure)
        return d
    d = loop_until(reactor, create_attempt, repeat(0, retries))
    def error(failure):
        print 'Failed    to    provision    node    {}'.format(name)
        return failure
    d.addErrback(error)
    return d
