summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py4
-rw-r--r--nova/db/sqlalchemy/api.py25
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)