'Shuts down and deletes a VM.
@inherits: :class:`NodeDriver.destroy_node`'

def destroy_node(self, node):

    d = self.connection._encode_multipart_formdata({'action': 'stop'})
    self.connection.request(('/rest/hosting/vm/%s' % node.id), method='POST', headers=d[0], data=d[1]).parse_body()
    node.state = NodeState.PENDING
    while (node.state == NodeState.PENDING):
        response = self.connection.request(('/rest/hosting/vm/%s' % node.id)).parse_body()
        if (response['vm']['state'] == 'off'):
            node.state = NodeState.TERMINATED
        else:
            time.sleep(5)
    d = self.connection._encode_multipart_formdata({'action': 'delete'})
    self.connection.request(('/rest/hosting/vm/%s' % node.id), method='POST', headers=d[0], data=d[1]).parse_body()
    return True
