Change queries for network services to use binary instead of topic

This makes nova/network bits use get_by_host_and_binary instead of
querying by RPC topic to locate nova-network services.

Change-Id: Id3e61440fab7f774dd62423b072c3c727b4ed853
This commit is contained in:
Dan Smith 2015-02-13 09:12:57 -08:00
parent 30159255bf
commit 97e6e33a25
5 changed files with 13 additions and 11 deletions

View File

@ -436,8 +436,8 @@ class FloatingIP(object):
if network.multi_host:
instance = objects.Instance.get_by_uuid(
context, fixed_ip.instance_uuid)
service = objects.Service.get_by_host_and_topic(
context.elevated(), instance.host, CONF.network_topic)
service = objects.Service.get_by_host_and_binary(
context.elevated(), instance.host, 'nova-network')
if service and self.servicegroup_api.service_is_up(service):
host = instance.host
else:

View File

@ -224,8 +224,8 @@ class RPCAllocateFixedIP(object):
address, instance=instance)
if network.multi_host:
service = objects.Service.get_by_host_and_topic(
context, host, CONF.network_topic)
service = objects.Service.get_by_host_and_binary(
context, host, 'nova-network')
if not service or not self.servicegroup_api.service_is_up(service):
# NOTE(vish): deallocate the fixed ip locally but don't
# teardown network devices

View File

@ -32,9 +32,9 @@ def stub_service_get_all(context, disabled=None):
return fake_hosts.SERVICES_LIST
def stub_service_get_by_host_and_topic(context, host_name, topic):
def stub_service_get_by_host_and_binary(context, host_name, binary):
for service in stub_service_get_all(context):
if service['host'] == host_name and service['topic'] == topic:
if service['host'] == host_name and service['binary'] == binary:
return service
@ -152,8 +152,8 @@ class HostTestCaseV21(test.TestCase):
self.stubs.Set(db, 'service_get_all',
stub_service_get_all)
# Only hosts in our fake DB exist
self.stubs.Set(db, 'service_get_by_host_and_topic',
stub_service_get_by_host_and_topic)
self.stubs.Set(db, 'service_get_by_host_and_binary',
stub_service_get_by_host_and_binary)
# 'host_c1' always succeeds, and 'host_c2'
self.stubs.Set(self.hosts_api, 'set_host_enabled',
stub_set_host_enabled)

View File

@ -33,5 +33,7 @@ HOST_LIST_NOVA_ZONE = [
service_base = test_service.fake_service
SERVICES_LIST = [
dict(service_base, host='host_c1', topic='compute'),
dict(service_base, host='host_c2', topic='compute')]
dict(service_base, host='host_c1', topic='compute',
binary='nova-compute'),
dict(service_base, host='host_c2', topic='compute',
binary='nova-compute')]

View File

@ -2760,7 +2760,7 @@ class FloatingIPTestCase(test.TestCase):
@mock.patch('nova.db.fixed_ip_get')
@mock.patch('nova.db.network_get')
@mock.patch('nova.db.instance_get_by_uuid')
@mock.patch('nova.db.service_get_by_host_and_topic')
@mock.patch('nova.db.service_get_by_host_and_binary')
@mock.patch('nova.db.floating_ip_get_by_address')
def test_disassociate_floating_ip_multi_host_calls(self, floating_get,
service_get,