Merge "NSX|V3: Fix floating IP status"
This commit is contained in:
commit
7b216ebf78
@ -1478,7 +1478,10 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
|
||||
|
||||
def create_floatingip(self, context, floatingip):
|
||||
new_fip = super(NsxV3Plugin, self).create_floatingip(
|
||||
context, floatingip)
|
||||
context, floatingip, initial_status=(
|
||||
const.FLOATINGIP_STATUS_ACTIVE
|
||||
if floatingip['floatingip']['port_id']
|
||||
else const.FLOATINGIP_STATUS_DOWN))
|
||||
router_id = new_fip['router_id']
|
||||
if not router_id:
|
||||
return new_fip
|
||||
@ -1515,6 +1518,9 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
|
||||
def update_floatingip(self, context, fip_id, floatingip):
|
||||
old_fip = self.get_floatingip(context, fip_id)
|
||||
old_port_id = old_fip['port_id']
|
||||
new_status = (const.FLOATINGIP_STATUS_ACTIVE
|
||||
if floatingip['floatingip']['port_id']
|
||||
else const.FLOATINGIP_STATUS_DOWN)
|
||||
new_fip = super(NsxV3Plugin, self).update_floatingip(
|
||||
context, fip_id, floatingip)
|
||||
router_id = new_fip['router_id']
|
||||
@ -1551,8 +1557,11 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
|
||||
with excutils.save_and_reraise_exception():
|
||||
super(NsxV3Plugin, self).update_floatingip(
|
||||
context, fip_id, {'floatingip': {'port_id': old_port_id}})
|
||||
self._set_floatingip_status(
|
||||
context, const.FLOATINGIP_STATUS_ERROR)
|
||||
self.update_floatingip_status(context, fip_id,
|
||||
const.FLOATINGIP_STATUS_ERROR)
|
||||
if new_fip['status'] != new_status:
|
||||
new_fip['status'] = new_status
|
||||
self.update_floatingip_status(context, fip_id, new_status)
|
||||
return new_fip
|
||||
|
||||
def disassociate_floatingips(self, context, port_id):
|
||||
@ -1575,6 +1584,8 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
|
||||
{'fip_id': fip_db.id,
|
||||
'ext_ip': fip_db.floating_ip_address,
|
||||
'int_ip': fip_db.fixed_ip_address})
|
||||
self.update_floatingip_status(context, fip_db.id,
|
||||
const.FLOATINGIP_STATUS_DOWN)
|
||||
|
||||
super(NsxV3Plugin, self).disassociate_floatingips(
|
||||
context, port_id, do_notify=False)
|
||||
|
@ -318,6 +318,10 @@ class TestL3NatTestCase(L3NatTest,
|
||||
def test_create_l3_ext_network_with_default_tier0(self):
|
||||
self._test_create_l3_ext_network()
|
||||
|
||||
def test_floatingip_update(self):
|
||||
super(TestL3NatTestCase, self).test_floatingip_update(
|
||||
expected_status=constants.FLOATINGIP_STATUS_DOWN)
|
||||
|
||||
def test_floatingip_with_invalid_create_port(self):
|
||||
self._test_floatingip_with_invalid_create_port(self._plugin_name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user