Merge "Fix failover"

This commit is contained in:
Jenkins 2016-09-11 18:53:58 +00:00 committed by Gerrit Code Review
commit f575024000
2 changed files with 0 additions and 17 deletions

View File

@ -409,27 +409,14 @@ class PlugVIPPort(BaseNetworkTask):
"""Task to plug a VIP into a compute instance."""
def execute(self, amphora, amphorae_network_config):
vip_port = amphorae_network_config.get(amphora.id).vip_port
vrrp_port = amphorae_network_config.get(amphora.id).vrrp_port
LOG.debug('Plugging VIP VRRP port ID: {port_id} into compute '
'instance: {compute_id}.'.format(
port_id=vrrp_port.id, compute_id=amphora.compute_id))
self.network_driver.plug_port(amphora, vrrp_port)
LOG.debug('Plugging VIP port ID: {port_id} into compute instance: '
'{compute_id}.'.format(port_id=vip_port.id,
compute_id=amphora.compute_id))
self.network_driver.plug_port(amphora, vip_port)
def revert(self, result, amphora, amphorae_network_config,
*args, **kwargs):
vip_port = None
try:
vip_port = amphorae_network_config.get(amphora.id).vip_port
self.network_driver.unplug_port(amphora, vip_port)
except Exception:
LOG.warning(_LW('Failed to unplug vip port: {port} '
'from amphora: {amp}').format(port=vip_port.id,
amp=amphora.id))
vrrp_port = None
try:
vrrp_port = amphorae_network_config.get(amphora.id).vrrp_port

View File

@ -494,21 +494,17 @@ class TestNetworkTasks(base.TestCase):
def test_plug_vip_port(self, mock_get_net_driver):
mock_driver = mock.MagicMock()
mock_get_net_driver.return_value = mock_driver
vip_port = mock.MagicMock()
vrrp_port = mock.MagicMock()
amphorae_network_config = mock.MagicMock()
amphorae_network_config.get().vip_port = vip_port
amphorae_network_config.get().vrrp_port = vrrp_port
plugvipport = network_tasks.PlugVIPPort()
plugvipport.execute(self.amphora_mock, amphorae_network_config)
mock_driver.plug_port.assert_any_call(self.amphora_mock, vip_port)
mock_driver.plug_port.assert_any_call(self.amphora_mock, vrrp_port)
# test revert
plugvipport.revert(None, self.amphora_mock, amphorae_network_config)
mock_driver.unplug_port.assert_any_call(self.amphora_mock, vip_port)
mock_driver.unplug_port.assert_any_call(self.amphora_mock, vrrp_port)
def test_wait_for_port_detach(self, mock_get_net_driver):