summaryrefslogtreecommitdiff
path: root/nova/db
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2017-05-01 11:25:13 -0400
committerMatt Riedemann <mriedem.os@gmail.com>2017-05-04 13:27:54 -0400
commit4ebd05d660ebece06ccb7872310127c46b24cb5d (patch)
treea13ac8a6b677695a337d6e73dc50f7ff163ba1f3 /nova/db
parent3a01e33d7e4426426d913b480d202e21cdc83ae3 (diff)
downloadnova-4ebd05d660ebece06ccb7872310127c46b24cb5d.tar.gz
db api: add service_get_by_uuid
This is going to be used by the Service.get_by_uuid method which will later be used by the HostAPI to uniquely lookup a service within a cell. Part of blueprint service-hyper-uuid-in-api Change-Id: Iff58296d5b05670116d4e0dc7846a260c48d84ed
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py7
-rw-r--r--nova/db/sqlalchemy/api.py11
2 files changed, 18 insertions, 0 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index 83d7b10b18..e0e01321f7 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -112,6 +112,13 @@ def service_get(context, service_id):
return IMPL.service_get(context, service_id)
+def service_get_by_uuid(context, service_uuid):
+ """Get a service by it's uuid or raise ServiceNotFound if it does not
+ exist.
+ """
+ return IMPL.service_get_by_uuid(context, service_uuid)
+
+
def service_get_minimum_version(context, binary):
"""Get the minimum service version in the database."""
return IMPL.service_get_minimum_version(context, binary)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index a5c0720d17..f3bb21cd02 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -475,6 +475,17 @@ def service_get(context, service_id):
return result
+@pick_context_manager_reader
+def service_get_by_uuid(context, service_uuid):
+ query = model_query(context, models.Service).filter_by(uuid=service_uuid)
+
+ result = query.first()
+ if not result:
+ raise exception.ServiceNotFound(service_id=service_uuid)
+
+ return result
+
+
@pick_context_manager_reader_allow_async
def service_get_minimum_version(context, binaries):
min_versions = context.session.query(