Merge "Fix PlugVIPAmphora revert function in amphorav2"

This commit is contained in:
Zuul 2021-09-08 20:07:56 +00:00 committed by Gerrit Code Review
commit 69d975d623
2 changed files with 10 additions and 5 deletions

View File

@ -452,12 +452,13 @@ class PlugVIPAmphora(BaseNetworkTask):
id=amphora.get(constants.ID)) id=amphora.get(constants.ID))
db_amp.vrrp_port_id = result[constants.VRRP_PORT_ID] db_amp.vrrp_port_id = result[constants.VRRP_PORT_ID]
db_amp.ha_port_id = result[constants.HA_PORT_ID] db_amp.ha_port_id = result[constants.HA_PORT_ID]
db_subnet = self.network_driver.get_subnet(subnet[constants.ID])
db_lb = self.loadbalancer_repo.get( db_lb = self.loadbalancer_repo.get(
db_apis.get_session(), db_apis.get_session(),
id=loadbalancer[constants.LOADBALANCER_ID]) id=loadbalancer[constants.LOADBALANCER_ID])
self.network_driver.unplug_aap_port(db_lb.vip, self.network_driver.unplug_aap_port(db_lb.vip,
db_amp, subnet) db_amp, db_subnet)
except Exception as e: except Exception as e:
LOG.error('Failed to unplug AAP port. Resources may still be in ' LOG.error('Failed to unplug AAP port. Resources may still be in '
'use for VIP: %s due to error: %s', db_lb.vip, str(e)) 'use for VIP: %s due to error: %s', db_lb.vip, str(e))

View File

@ -1015,8 +1015,10 @@ class TestNetworkTasks(base.TestCase):
mock_get.return_value = self.db_amphora_mock mock_get.return_value = self.db_amphora_mock
mock_get_net_driver.return_value = mock_driver mock_get_net_driver.return_value = mock_driver
net = network_tasks.PlugVIPAmphora() net = network_tasks.PlugVIPAmphora()
mockSubnet = mock_driver.get_subnet() subnet = {constants.ID: SUBNET_ID}
net.execute(self.load_balancer_mock, amphora, mockSubnet) mockSubnet = mock.MagicMock()
mock_driver.get_subnet.return_value = mockSubnet
net.execute(self.load_balancer_mock, amphora, subnet)
mock_driver.plug_aap_port.assert_called_once_with( mock_driver.plug_aap_port.assert_called_once_with(
LB, LB.vip, self.db_amphora_mock, mockSubnet) LB, LB.vip, self.db_amphora_mock, mockSubnet)
@ -1030,11 +1032,13 @@ class TestNetworkTasks(base.TestCase):
mock_get.return_value = self.db_amphora_mock mock_get.return_value = self.db_amphora_mock
mock_get_net_driver.return_value = mock_driver mock_get_net_driver.return_value = mock_driver
net = network_tasks.PlugVIPAmphora() net = network_tasks.PlugVIPAmphora()
mockSubnet = mock.MagicMock()
amphora = {constants.ID: AMPHORA_ID, amphora = {constants.ID: AMPHORA_ID,
constants.LB_NETWORK_IP: IP_ADDRESS} constants.LB_NETWORK_IP: IP_ADDRESS}
subnet = {constants.ID: SUBNET_ID}
mockSubnet = mock.MagicMock()
mock_driver.get_subnet.return_value = mockSubnet
net.revert(AMPS_DATA[0].to_dict(), self.load_balancer_mock, net.revert(AMPS_DATA[0].to_dict(), self.load_balancer_mock,
amphora, mockSubnet) amphora, subnet)
mock_driver.unplug_aap_port.assert_called_once_with( mock_driver.unplug_aap_port.assert_called_once_with(
LB.vip, self.db_amphora_mock, mockSubnet) LB.vip, self.db_amphora_mock, mockSubnet)