diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-03-04 17:04:36 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-03-04 17:04:36 +0000 |
| commit | bcdbe9ba881db8b38525bfc44a182e6b210459cd (patch) | |
| tree | 5a2333a8418dee0e5b654172d2843f6116323d73 /nova/db | |
| parent | 8f3a7f73ffad0c64b89e926e2a672f8333da3636 (diff) | |
| parent | ac0f6eb063fc5a5c0a9410402ecf57fae1faf594 (diff) | |
Merge "Compute manager should remove dead resources"
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/api.py | 10 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 11 |
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").\ |
