Merge "Make floating_ips module use Service object"

This commit is contained in:
Jenkins 2014-02-15 17:07:17 +00:00 committed by Gerrit Code Review
commit fac4532c8f
2 changed files with 8 additions and 7 deletions
nova
network
tests/network

@ -26,6 +26,7 @@ from nova.objects import dns_domain as dns_domain_obj
from nova.objects import fixed_ip as fixed_ip_obj
from nova.objects import instance as instance_obj
from nova.objects import network as network_obj
from nova.objects import service as service_obj
from nova.openstack.common import excutils
from nova.openstack.common.gettextutils import _
from nova.openstack.common import importutils
@ -424,8 +425,8 @@ class FloatingIP(object):
if network.multi_host:
instance = instance_obj.Instance.get_by_uuid(
context, fixed_ip.instance_uuid)
service = self.db.service_get_by_host_and_topic(
context.elevated(), instance.host, CONF.network_topic)
service = service_obj.Service.get_by_host_and_topic(
context.elevated(), instance.host, CONF.network_topic)
if service and self.servicegroup_api.service_is_up(service):
host = instance.host
else:

@ -45,6 +45,7 @@ from nova.tests import fake_network
from nova.tests import matchers
from nova.tests.objects import test_fixed_ip
from nova.tests.objects import test_network
from nova.tests.objects import test_service
from nova import utils
CONF = cfg.CONF
@ -2213,7 +2214,9 @@ 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')
def test_disassociate_floating_ip_multi_host_calls(self, inst_get, net_get,
@mock.patch('nova.db.service_get_by_host_and_topic')
def test_disassociate_floating_ip_multi_host_calls(self, service_get,
inst_get, net_get,
fixed_get):
floating_ip = {
'fixed_ip_id': 12
@ -2242,10 +2245,7 @@ class FloatingIPTestCase(test.TestCase):
fixed_get.return_value = fixed_ip
net_get.return_value = network
inst_get.return_value = instance
self.stubs.Set(self.network.db,
'service_get_by_host_and_topic',
lambda _x, _y, _z: 'service')
service_get.return_value = test_service.fake_service
self.stubs.Set(self.network.servicegroup_api,
'service_is_up',