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/scheduler/driver.py | |
parent | ca4b1303804e94f10f0e4e6c4a9e09c049efd1ee (diff) | |
download | nova-7e7bcc4f080c824c94c41485e29e365473661fa3.tar.gz nova-7e7bcc4f080c824c94c41485e29e365473661fa3.tar.xz nova-7e7bcc4f080c824c94c41485e29e365473661fa3.zip |
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/scheduler/driver.py')
-rw-r--r-- | nova/scheduler/driver.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index dc494af8f..d1ae1cd6e 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -192,12 +192,12 @@ class Scheduler(object): # Checking src host exists and compute node src = instance_ref['host'] try: - services = db.service_get_all_compute_by_host(context, src) + service = db.service_get_by_compute_host(context, src) except exception.NotFound: raise exception.ComputeServiceUnavailable(host=src) # Checking src host is alive. - if not self.servicegroup_api.service_is_up(services[0]): + if not self.servicegroup_api.service_is_up(service): raise exception.ComputeServiceUnavailable(host=src) def _live_migration_dest_check(self, context, instance_ref, dest): @@ -209,8 +209,7 @@ class Scheduler(object): """ # Checking dest exists and compute node. - dservice_refs = db.service_get_all_compute_by_host(context, dest) - dservice_ref = dservice_refs[0] + dservice_ref = db.service_get_by_compute_host(context, dest) # Checking dest host is alive. if not self.servicegroup_api.service_is_up(dservice_ref): @@ -290,5 +289,5 @@ class Scheduler(object): :return: value specified by key """ - compute_node_ref = db.service_get_all_compute_by_host(context, host) - return compute_node_ref[0]['compute_node'][0] + service_ref = db.service_get_by_compute_host(context, host) + return service_ref['compute_node'][0] |