Fix race condition when deleting a node

In the db api, between checking whether the node is not reserved and
deleting it from the db there was no lock, another request could acquire
that node and start an operation on it. This patch fixes it by locking
the node before it's deleted from the db.

This patch is also a plumbing because we might want to do operations
like changing the node's power state and stopping the console before
deleting a node.

Co-authored-by: Devananda van der Veen <devananda.vdv@gmail.com>

Change-Id: I5fd90f8321812f7636477c03a83038ad42d47817