diff options
| author | Chris Behrens <cbehrens@codestud.com> | 2013-01-14 02:06:39 +0000 |
|---|---|---|
| committer | Chris Behrens <cbehrens@codestud.com> | 2013-01-14 18:28:37 +0000 |
| commit | 7e7bcc4f080c824c94c41485e29e365473661fa3 (patch) | |
| tree | 40659e8a41af38e7304234f5a03b7639a2a04226 /nova/db | |
| parent | ca4b1303804e94f10f0e4e6c4a9e09c049efd1ee (diff) | |
Fix uses of service_get_all_compute_by_host
There should never be more than 1 service entry for the same topic and
host, however this method returns a list of services. All callers of
this method except for 1 already account for there being only 1 service
entry for a particular 'compute' host and only use the first entry in the
return list.
This patch renames the DB API call to be 'service_get_by_compute_host'
and returns a single entry. All uses of the old method are adjusted
accordingly.
Change-Id: I0e0ef62f5d2e71efe756940d9fdd98aa02fef216
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/api.py | 9 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/nova/db/api.py b/nova/db/api.py index b1552b480..d7d9bd0d2 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -151,9 +151,12 @@ def service_get_all_by_host(context, host): return IMPL.service_get_all_by_host(context, host) -def service_get_all_compute_by_host(context, host): - """Get all compute services for a given host.""" - return IMPL.service_get_all_compute_by_host(context, host) +def service_get_by_compute_host(context, host): + """Get the service entry for a given compute host. + + Returns the service entry joined with the compute_node entry. + """ + return IMPL.service_get_by_compute_host(context, host) def service_get_all_compute_sorted(context): diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 8930f6ccc..e51d7b685 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -370,12 +370,12 @@ def service_get_all_by_host(context, host): @require_admin_context -def service_get_all_compute_by_host(context, host): +def service_get_by_compute_host(context, host): result = model_query(context, models.Service, read_deleted="no").\ options(joinedload('compute_node')).\ filter_by(host=host).\ filter_by(topic=CONF.compute_topic).\ - all() + first() if not result: raise exception.ComputeHostNotFound(host=host) |
