diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-12-05 18:51:58 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-12-05 18:51:58 +0000 |
| commit | 2804b01a6bb404d3e120289680a3cfa4e4c3e380 (patch) | |
| tree | c9b6aa55a51bb2d37c7932ffc779d95d10149654 /nova/db | |
| parent | f9245c8353f1f9a89a2f578c2b53264c0ea3b3a5 (diff) | |
| parent | 82042ac2766b892d561836cd312656940522734a (diff) | |
Merge "Add agent build API support for list/create/delete/modify agent build"
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/api.py | 4 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 25 |
2 files changed, 19 insertions, 10 deletions
diff --git a/nova/db/api.py b/nova/db/api.py index ad928f585..cfa6a6487 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -1372,9 +1372,9 @@ def agent_build_get_by_triple(context, hypervisor, os, architecture): architecture) -def agent_build_get_all(context): +def agent_build_get_all(context, hypervisor=None): """Get all agent builds.""" - return IMPL.agent_build_get_all(context) + return IMPL.agent_build_get_all(context, hypervisor) def agent_build_destroy(context, agent_update_id): diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index f2d804985..f7c0373e6 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -3968,8 +3968,13 @@ def agent_build_get_by_triple(context, hypervisor, os, architecture, @require_admin_context -def agent_build_get_all(context): - return model_query(context, models.AgentBuild, read_deleted="no").\ +def agent_build_get_all(context, hypervisor=None): + if hypervisor: + return model_query(context, models.AgentBuild, read_deleted="no").\ + filter_by(hypervisor=hypervisor).\ + all() + else: + return model_query(context, models.AgentBuild, read_deleted="no").\ all() @@ -3977,12 +3982,15 @@ def agent_build_get_all(context): def agent_build_destroy(context, agent_build_id): session = get_session() with session.begin(): - model_query(context, models.AgentBuild, session=session, - read_deleted="yes").\ + agent_build_ref = model_query(context, models.AgentBuild, + session=session, read_deleted="yes").\ filter_by(id=agent_build_id).\ - update({'deleted': True, - 'deleted_at': timeutils.utcnow(), - 'updated_at': literal_column('updated_at')}) + first() + if not agent_build_ref: + raise exception.AgentBuildNotFound(id=agent_build_id) + agent_build_ref.update({'deleted': True, + 'deleted_at': timeutils.utcnow(), + 'updated_at': literal_column('updated_at')}) @require_admin_context @@ -3993,7 +4001,8 @@ def agent_build_update(context, agent_build_id, values): session=session, read_deleted="yes").\ filter_by(id=agent_build_id).\ first() - + if not agent_build_ref: + raise exception.AgentBuildNotFound(id=agent_build_id) agent_build_ref.update(values) agent_build_ref.save(session=session) |
