Merge "NVP LBaaS: check for association before deleting health monitor"
This commit is contained in:
commit
c677a0a89e
@ -1454,49 +1454,6 @@ class NsxAdvancedPlugin(sr_db.ServiceRouter_mixin,
|
|||||||
"with id: %s!"), id)
|
"with id: %s!"), id)
|
||||||
return hm
|
return hm
|
||||||
|
|
||||||
def delete_health_monitor(self, context, id):
|
|
||||||
with context.session.begin(subtransactions=True):
|
|
||||||
qry = context.session.query(
|
|
||||||
loadbalancer_db.PoolMonitorAssociation
|
|
||||||
).filter_by(monitor_id=id)
|
|
||||||
for assoc in qry:
|
|
||||||
pool_id = assoc['pool_id']
|
|
||||||
super(NsxAdvancedPlugin,
|
|
||||||
self).delete_pool_health_monitor(context,
|
|
||||||
id,
|
|
||||||
pool_id)
|
|
||||||
pool = self.get_pool(context, pool_id)
|
|
||||||
if not pool.get('vip_id'):
|
|
||||||
continue
|
|
||||||
edge_id = self._get_edge_id_by_vip_id(
|
|
||||||
context, pool['vip_id'])
|
|
||||||
self._resource_set_status(
|
|
||||||
context, loadbalancer_db.Pool,
|
|
||||||
pool_id, service_constants.PENDING_UPDATE)
|
|
||||||
try:
|
|
||||||
self._vcns_update_pool(context, pool)
|
|
||||||
except Exception:
|
|
||||||
with excutils.save_and_reraise_exception():
|
|
||||||
LOG.exception(_("Failed to update pool with monitor!"))
|
|
||||||
self._resource_set_status(
|
|
||||||
context, loadbalancer_db.Pool,
|
|
||||||
pool_id, service_constants.ACTIVE)
|
|
||||||
try:
|
|
||||||
self.vcns_driver.delete_health_monitor(
|
|
||||||
context, id, edge_id)
|
|
||||||
except Exception:
|
|
||||||
with excutils.save_and_reraise_exception():
|
|
||||||
LOG.exception(_("Failed to delete monitor "
|
|
||||||
"with id: %s!"), id)
|
|
||||||
super(NsxAdvancedPlugin,
|
|
||||||
self).delete_health_monitor(context, id)
|
|
||||||
self._delete_resource_router_id_binding(
|
|
||||||
context, id, loadbalancer_db.HealthMonitor)
|
|
||||||
|
|
||||||
super(NsxAdvancedPlugin, self).delete_health_monitor(context, id)
|
|
||||||
self._delete_resource_router_id_binding(
|
|
||||||
context, id, loadbalancer_db.HealthMonitor)
|
|
||||||
|
|
||||||
def create_pool_health_monitor(self, context,
|
def create_pool_health_monitor(self, context,
|
||||||
health_monitor, pool_id):
|
health_monitor, pool_id):
|
||||||
monitor_id = health_monitor['health_monitor']['id']
|
monitor_id = health_monitor['health_monitor']['id']
|
||||||
|
@ -19,7 +19,6 @@ from webob import exc as web_exc
|
|||||||
|
|
||||||
from neutron.api.v2 import attributes
|
from neutron.api.v2 import attributes
|
||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron.db.loadbalancer import loadbalancer_db as ldb
|
|
||||||
from neutron.extensions import loadbalancer as lb
|
from neutron.extensions import loadbalancer as lb
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
@ -125,9 +124,9 @@ class TestLoadbalancerPlugin(
|
|||||||
|
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.subnet(),
|
self.subnet(),
|
||||||
self.pool(),
|
self.health_monitor(),
|
||||||
self.health_monitor()
|
self.pool()
|
||||||
) as (subnet, pool, health_mon):
|
) as (subnet, health_mon, pool):
|
||||||
net_id = subnet['subnet']['network_id']
|
net_id = subnet['subnet']['network_id']
|
||||||
self._set_net_external(net_id)
|
self._set_net_external(net_id)
|
||||||
with self.vip(
|
with self.vip(
|
||||||
@ -150,31 +149,6 @@ class TestLoadbalancerPlugin(
|
|||||||
for k, v in keys:
|
for k, v in keys:
|
||||||
self.assertEqual(res['health_monitor'][k], v)
|
self.assertEqual(res['health_monitor'][k], v)
|
||||||
|
|
||||||
def test_delete_healthmonitor(self):
|
|
||||||
ctx = context.get_admin_context()
|
|
||||||
with contextlib.nested(
|
|
||||||
self.subnet(),
|
|
||||||
self.pool(),
|
|
||||||
self.health_monitor(no_delete=True)
|
|
||||||
) as (subnet, pool, health_mon):
|
|
||||||
net_id = subnet['subnet']['network_id']
|
|
||||||
self._set_net_external(net_id)
|
|
||||||
with self.vip(
|
|
||||||
router_id=self._create_and_get_router(),
|
|
||||||
pool=pool, subnet=subnet):
|
|
||||||
self.plugin.create_pool_health_monitor(
|
|
||||||
context.get_admin_context(),
|
|
||||||
health_mon, pool['pool']['id']
|
|
||||||
)
|
|
||||||
|
|
||||||
req = self.new_delete_request('health_monitors',
|
|
||||||
health_mon['health_monitor']['id'])
|
|
||||||
res = req.get_response(self.ext_api)
|
|
||||||
self.assertEqual(res.status_int, 204)
|
|
||||||
qry = ctx.session.query(ldb.HealthMonitor)
|
|
||||||
qry = qry.filter_by(id=health_mon['health_monitor']['id'])
|
|
||||||
self.assertIsNone(qry.first())
|
|
||||||
|
|
||||||
def test_create_vip(self, **extras):
|
def test_create_vip(self, **extras):
|
||||||
expected = {
|
expected = {
|
||||||
'name': 'vip1',
|
'name': 'vip1',
|
||||||
@ -194,9 +168,9 @@ class TestLoadbalancerPlugin(
|
|||||||
|
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.subnet(),
|
self.subnet(),
|
||||||
self.pool(),
|
self.health_monitor(),
|
||||||
self.health_monitor()
|
self.pool()
|
||||||
) as (subnet, pool, monitor):
|
) as (subnet, monitor, pool):
|
||||||
net_id = subnet['subnet']['network_id']
|
net_id = subnet['subnet']['network_id']
|
||||||
self._set_net_external(net_id)
|
self._set_net_external(net_id)
|
||||||
expected['pool_id'] = pool['pool']['id']
|
expected['pool_id'] = pool['pool']['id']
|
||||||
@ -228,9 +202,9 @@ class TestLoadbalancerPlugin(
|
|||||||
|
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.subnet(),
|
self.subnet(),
|
||||||
self.pool(),
|
self.health_monitor(),
|
||||||
self.health_monitor()
|
self.pool()
|
||||||
) as (subnet, pool, monitor):
|
) as (subnet, monitor, pool):
|
||||||
net_id = subnet['subnet']['network_id']
|
net_id = subnet['subnet']['network_id']
|
||||||
self._set_net_external(net_id)
|
self._set_net_external(net_id)
|
||||||
self.plugin.create_pool_health_monitor(
|
self.plugin.create_pool_health_monitor(
|
||||||
@ -257,9 +231,9 @@ class TestLoadbalancerPlugin(
|
|||||||
def test_delete_vip(self):
|
def test_delete_vip(self):
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.subnet(),
|
self.subnet(),
|
||||||
self.pool(),
|
self.health_monitor(),
|
||||||
self.health_monitor()
|
self.pool()
|
||||||
) as (subnet, pool, monitor):
|
) as (subnet, monitor, pool):
|
||||||
net_id = subnet['subnet']['network_id']
|
net_id = subnet['subnet']['network_id']
|
||||||
self._set_net_external(net_id)
|
self._set_net_external(net_id)
|
||||||
self.plugin.create_pool_health_monitor(
|
self.plugin.create_pool_health_monitor(
|
||||||
@ -287,9 +261,9 @@ class TestLoadbalancerPlugin(
|
|||||||
|
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.subnet(),
|
self.subnet(),
|
||||||
self.pool(),
|
self.health_monitor(),
|
||||||
self.health_monitor()
|
self.pool()
|
||||||
) as (subnet, pool, monitor):
|
) as (subnet, monitor, pool):
|
||||||
net_id = subnet['subnet']['network_id']
|
net_id = subnet['subnet']['network_id']
|
||||||
self._set_net_external(net_id)
|
self._set_net_external(net_id)
|
||||||
self.plugin.create_pool_health_monitor(
|
self.plugin.create_pool_health_monitor(
|
||||||
@ -348,9 +322,9 @@ class TestLoadbalancerPlugin(
|
|||||||
'admin_state_up': False}}
|
'admin_state_up': False}}
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.subnet(),
|
self.subnet(),
|
||||||
self.pool(),
|
self.health_monitor(),
|
||||||
self.health_monitor()
|
self.pool()
|
||||||
) as (subnet, pool, monitor):
|
) as (subnet, monitor, pool):
|
||||||
net_id = subnet['subnet']['network_id']
|
net_id = subnet['subnet']['network_id']
|
||||||
self._set_net_external(net_id)
|
self._set_net_external(net_id)
|
||||||
self.plugin.create_pool_health_monitor(
|
self.plugin.create_pool_health_monitor(
|
||||||
@ -371,9 +345,9 @@ class TestLoadbalancerPlugin(
|
|||||||
router_id = self._create_and_get_router()
|
router_id = self._create_and_get_router()
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.subnet(),
|
self.subnet(),
|
||||||
self.pool(),
|
self.health_monitor(),
|
||||||
self.health_monitor()
|
self.pool()
|
||||||
) as (subnet, pool, monitor):
|
) as (subnet, monitor, pool):
|
||||||
pool_id = pool['pool']['id']
|
pool_id = pool['pool']['id']
|
||||||
net_id = subnet['subnet']['network_id']
|
net_id = subnet['subnet']['network_id']
|
||||||
self._set_net_external(net_id)
|
self._set_net_external(net_id)
|
||||||
@ -413,10 +387,10 @@ class TestLoadbalancerPlugin(
|
|||||||
def test_update_member(self):
|
def test_update_member(self):
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.subnet(),
|
self.subnet(),
|
||||||
|
self.health_monitor(),
|
||||||
self.pool(name="pool1"),
|
self.pool(name="pool1"),
|
||||||
self.pool(name="pool2"),
|
self.pool(name="pool2")
|
||||||
self.health_monitor()
|
) as (subnet, monitor, pool1, pool2):
|
||||||
) as (subnet, pool1, pool2, monitor):
|
|
||||||
net_id = subnet['subnet']['network_id']
|
net_id = subnet['subnet']['network_id']
|
||||||
self._set_net_external(net_id)
|
self._set_net_external(net_id)
|
||||||
self.plugin.create_pool_health_monitor(
|
self.plugin.create_pool_health_monitor(
|
||||||
@ -465,9 +439,9 @@ class TestLoadbalancerPlugin(
|
|||||||
def test_delete_member(self):
|
def test_delete_member(self):
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.subnet(),
|
self.subnet(),
|
||||||
self.pool(),
|
self.health_monitor(),
|
||||||
self.health_monitor()
|
self.pool()
|
||||||
) as (subnet, pool, monitor):
|
) as (subnet, monitor, pool):
|
||||||
pool_id = pool['pool']['id']
|
pool_id = pool['pool']['id']
|
||||||
net_id = subnet['subnet']['network_id']
|
net_id = subnet['subnet']['network_id']
|
||||||
self._set_net_external(net_id)
|
self._set_net_external(net_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user