'Wait for a node to get created and the provision it.
Re-create the node and retry the provisioning if either the node
creation or provisioning fails.
This method is used in conjuction with bulk creation of new nodes,
so that a failure for any single node can be retried individually
(rather than failing all the nodes and starting from scratch).
:param reactor: The reactor.
:param str name: The name of the node.
:param Deferred result: Deferred that fires with the node when it\'s
created.
:return: Deferred that fires with the node when it\'s created and
provisioned.'

def _provision_with_retry(self, reactor, name, result):

    def provision(node):
        print 'created    node', name
        print 'provisioning...'
        self.nodes.append(node)
        d = self._provision_node(reactor, node)
        def provisioning_failed(failure):
            print 'provisioning    failed', name
            self._destroy_node(node)
            return failure
        d.addCallbacks((lambda _: node), errback=provisioning_failed)
        return d
    result.addCallback(provision)
    def retry_on_error(failure):
        print 'bulk    creation    failed', name
        print 'error:', failure
        write_failure(failure)
        return self._create_and_provision(reactor, name)
    result.addErrback(retry_on_error)
    return result
