Eliminate wrong ERROR report when service of type LoadBalancer type is deleted
Closes-Bug: #1724495 Change-Id: I844dc779709349c670cf90b30dcec5f20abe8fef
This commit is contained in:
parent
3ebbe5faba
commit
87b2418988
|
@ -444,6 +444,7 @@ class ServicePubIpDriver(DriverBase):
|
|||
"""Release (if needed) based on service_pub_ip_info content
|
||||
|
||||
:param service_pub_ip_info: service loadbalancer IP info
|
||||
:returns True/False
|
||||
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
|
|
@ -92,12 +92,14 @@ class FloatingIpServicePubIPDriver(base.ServicePubIpDriver):
|
|||
|
||||
def release_pub_ip(self, service_pub_ip_info):
|
||||
if not service_pub_ip_info:
|
||||
return
|
||||
return True
|
||||
if service_pub_ip_info.alloc_method == 'pool':
|
||||
retcode = self._drv_pub_ip.free_ip(service_pub_ip_info.ip_id)
|
||||
if not retcode:
|
||||
LOG.error("Failed to delete public_ip_id =%s !",
|
||||
service_pub_ip_info.ip_id)
|
||||
return False
|
||||
return True
|
||||
|
||||
def associate_pub_ip(self, service_pub_ip_info, vip_port_id):
|
||||
if (not service_pub_ip_info or
|
||||
|
|
|
@ -56,6 +56,7 @@ class BasePubIpDriver(object):
|
|||
"""free ip by resource ID
|
||||
|
||||
:param res_id: resource_id
|
||||
:returns True/False
|
||||
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
@ -120,10 +121,11 @@ class FipPubIpDriver(BasePubIpDriver):
|
|||
neutron = clients.get_neutron_client()
|
||||
try:
|
||||
neutron.delete_floatingip(res_id)
|
||||
except n_exc.NeutronClientException as ex:
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.error("Failed to delete floating_ip_id =%s !",
|
||||
res_id)
|
||||
raise ex
|
||||
return False
|
||||
return True
|
||||
|
||||
def _update(self, res_id, vip_port_id):
|
||||
response = None
|
||||
|
|
|
@ -162,8 +162,8 @@ class TestFloatingIpServicePubIPDriverDriver(test_base.TestCase):
|
|||
m_driver = mock.Mock(spec=cls)
|
||||
service_pub_ip_info = None
|
||||
|
||||
self.assertIsNone(cls.release_pub_ip
|
||||
(m_driver, service_pub_ip_info))
|
||||
rc = cls.release_pub_ip(m_driver, service_pub_ip_info)
|
||||
self.assertEqual(rc, True)
|
||||
|
||||
def test_release_pub_ip_alloc_method_non_pool(self):
|
||||
cls = d_lb_public_ip.FloatingIpServicePubIPDriver
|
||||
|
@ -177,8 +177,8 @@ class TestFloatingIpServicePubIPDriverDriver(test_base.TestCase):
|
|||
ip_addr=floating_ip['floating_ip_address'],
|
||||
alloc_method='kk')
|
||||
|
||||
self.assertIsNone(
|
||||
cls.release_pub_ip(m_driver, service_pub_ip_info))
|
||||
rc = cls.release_pub_ip(m_driver, service_pub_ip_info)
|
||||
self.assertEqual(rc, True)
|
||||
|
||||
def test_release_pub_ip_alloc_method_user(self):
|
||||
cls = d_lb_public_ip.FloatingIpServicePubIPDriver
|
||||
|
@ -191,9 +191,8 @@ class TestFloatingIpServicePubIPDriverDriver(test_base.TestCase):
|
|||
obj_lbaas.LBaaSPubIp(ip_id=floating_ip['id'],
|
||||
ip_addr=floating_ip['floating_ip_address'],
|
||||
alloc_method='user')
|
||||
|
||||
self.assertIsNone(cls.release_pub_ip
|
||||
(m_driver, service_pub_ip_info))
|
||||
rc = cls.release_pub_ip(m_driver, service_pub_ip_info)
|
||||
self.assertEqual(rc, True)
|
||||
|
||||
def test_release_pub_ip_alloc_method_pool_neutron_exception(self):
|
||||
cls = d_lb_public_ip.FloatingIpServicePubIPDriver
|
||||
|
@ -209,10 +208,8 @@ class TestFloatingIpServicePubIPDriverDriver(test_base.TestCase):
|
|||
obj_lbaas.LBaaSPubIp(ip_id=floating_ip['id'],
|
||||
ip_addr=floating_ip['floating_ip_address'],
|
||||
alloc_method='pool')
|
||||
|
||||
self.assertRaises(
|
||||
n_exc.NeutronClientException, cls.release_pub_ip,
|
||||
m_driver, service_pub_ip_info)
|
||||
rc = cls.release_pub_ip(m_driver, service_pub_ip_info)
|
||||
self.assertEqual(rc, False)
|
||||
|
||||
def test_release_pub_ip_alloc_method_pool_neutron_succeeded(self):
|
||||
cls = d_lb_public_ip.FloatingIpServicePubIPDriver
|
||||
|
@ -228,9 +225,8 @@ class TestFloatingIpServicePubIPDriverDriver(test_base.TestCase):
|
|||
obj_lbaas.LBaaSPubIp(ip_id=floating_ip['id'],
|
||||
ip_addr=floating_ip['floating_ip_address'],
|
||||
alloc_method='pool')
|
||||
|
||||
self.assertIsNone(cls.release_pub_ip
|
||||
(m_driver, service_pub_ip_info))
|
||||
rc = cls.release_pub_ip(m_driver, service_pub_ip_info)
|
||||
self.assertEqual(rc, True)
|
||||
|
||||
def test_associate_pub_ip_empty_params(self):
|
||||
cls = d_lb_public_ip.FloatingIpServicePubIPDriver
|
||||
|
|
|
@ -127,9 +127,8 @@ class TestFipPubIpDriver(test_base.TestCase):
|
|||
|
||||
neutron = self.useFixture(k_fix.MockNeutronClient()).client
|
||||
neutron.delete_floatingip.side_effect = n_exc.NeutronClientException
|
||||
|
||||
self.assertRaises(
|
||||
n_exc.NeutronClientException, cls.free_ip, m_driver, res_id)
|
||||
rc = cls.free_ip(m_driver, res_id)
|
||||
self.assertEqual(rc, False)
|
||||
|
||||
def test_free_ip_succeeded(self):
|
||||
cls = d_public_ip.FipPubIpDriver
|
||||
|
@ -138,10 +137,14 @@ class TestFipPubIpDriver(test_base.TestCase):
|
|||
|
||||
neutron = self.useFixture(k_fix.MockNeutronClient()).client
|
||||
neutron.delete_floatingip.return_value = None
|
||||
try:
|
||||
cls.free_ip(m_driver, res_id)
|
||||
except Exception:
|
||||
self.fail("Encountered an unexpected exception.")
|
||||
|
||||
rc = cls.free_ip(m_driver, res_id)
|
||||
self.assertEqual(rc, True)
|
||||
|
||||
# try:
|
||||
# cls.free_ip(m_driver, res_id)
|
||||
# except Exception:
|
||||
# self.fail("Encountered an unexpected exception.")
|
||||
|
||||
def test_associate_neutron_exception(self):
|
||||
cls = d_public_ip.FipPubIpDriver
|
||||
|
|
Loading…
Reference in New Issue