summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-03-04 17:04:36 +0000
committerGerrit Code Review <review@openstack.org>2013-03-04 17:04:36 +0000
commitbcdbe9ba881db8b38525bfc44a182e6b210459cd (patch)
tree5a2333a8418dee0e5b654172d2843f6116323d73 /nova/db
parent8f3a7f73ffad0c64b89e926e2a672f8333da3636 (diff)
parentac0f6eb063fc5a5c0a9410402ecf57fae1faf594 (diff)
Merge "Compute manager should remove dead resources"
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py10
-rw-r--r--nova/db/sqlalchemy/api.py11
2 files changed, 20 insertions, 1 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index cac96af03..ff5536c49 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -195,11 +195,19 @@ def compute_node_create(context, values):
def compute_node_update(context, compute_id, values, prune_stats=False):
"""Set the given properties on a computeNode and update it.
- Raises NotFound if computeNode does not exist.
+ Raises ComputeHostNotFound if computeNode does not exist.
"""
return IMPL.compute_node_update(context, compute_id, values, prune_stats)
+def compute_node_delete(context, compute_id):
+ """Delete a computeNode from the database.
+
+ Raises ComputeHostNotFound if computeNode does not exist.
+ """
+ return IMPL.compute_node_delete(context, compute_id)
+
+
def compute_node_get_by_host(context, host):
return IMPL.compute_node_get_by_host(context, host)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 71a2a406d..33261f4db 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -536,6 +536,17 @@ def compute_node_update(context, compute_id, values, prune_stats=False):
return compute_ref
+@require_admin_context
+def compute_node_delete(context, compute_id):
+ """Delete a ComputeNode record."""
+ result = model_query(context, models.ComputeNode).\
+ filter_by(id=compute_id).\
+ soft_delete()
+
+ if not result:
+ raise exception.ComputeHostNotFound(host=compute_id)
+
+
def compute_node_get_by_host(context, host):
"""Get all capacity entries for the given host."""
result = model_query(context, models.ComputeNode, read_deleted="no").\