def destroy_node(self, node):
        """
        Shuts down and deletes a VM.
        """

        #Shut down first
        #Black magic to make the POST requests work
        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()

        #Ensure there was no applicationl level error
        node.state = NodeState.PENDING
        #Wait for the VM to turn off before continuing
        while node.state == NodeState.PENDING:
            #Check if it's off.
            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)

        #Delete the VM
        #Black magic to make the POST requests work
        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
dataset/ETHPy150Open secondstory/dewpoint/libcloud/drivers/ecp.py/ECPNodeDriver.destroy_node/original