Remove some unused code
These methods and tasks are no longer used in the code, so this patch proposes to remove them. Change-Id: Ic7813d3a9073e4b3c1bc6a7839242df34a16d348
This commit is contained in:
parent
30ce858564
commit
ffc9d83197
@ -478,53 +478,6 @@ class HandleNetworkDeltas(BaseNetworkTask):
|
||||
LOG.exception("Unable to delete port %s", port_id)
|
||||
|
||||
|
||||
class PlugVIP(BaseNetworkTask):
|
||||
"""Task to plumb a VIP."""
|
||||
|
||||
def execute(self, loadbalancer):
|
||||
"""Plumb a vip to an amphora."""
|
||||
|
||||
LOG.debug("Plumbing VIP for loadbalancer id: %s",
|
||||
loadbalancer[constants.LOADBALANCER_ID])
|
||||
session = db_apis.get_session()
|
||||
with session.begin():
|
||||
db_lb = self.loadbalancer_repo.get(
|
||||
session,
|
||||
id=loadbalancer[constants.LOADBALANCER_ID])
|
||||
amps_data = self.network_driver.plug_vip(db_lb,
|
||||
db_lb.vip)
|
||||
return [amp.to_dict() for amp in amps_data]
|
||||
|
||||
def revert(self, result, loadbalancer, *args, **kwargs):
|
||||
"""Handle a failure to plumb a vip."""
|
||||
|
||||
if isinstance(result, failure.Failure):
|
||||
return
|
||||
LOG.warning("Unable to plug VIP for loadbalancer id %s",
|
||||
loadbalancer[constants.LOADBALANCER_ID])
|
||||
|
||||
session = db_apis.get_session()
|
||||
with session.begin():
|
||||
db_lb = self.loadbalancer_repo.get(
|
||||
session,
|
||||
id=loadbalancer[constants.LOADBALANCER_ID])
|
||||
try:
|
||||
# Make sure we have the current port IDs for cleanup
|
||||
for amp_data in result:
|
||||
for amphora in filter(
|
||||
# pylint: disable=cell-var-from-loop
|
||||
lambda amp: amp.id == amp_data['id'],
|
||||
db_lb.amphorae):
|
||||
amphora.vrrp_port_id = amp_data['vrrp_port_id']
|
||||
amphora.ha_port_id = amp_data['ha_port_id']
|
||||
|
||||
self.network_driver.unplug_vip(db_lb, db_lb.vip)
|
||||
except Exception as e:
|
||||
LOG.error("Failed to unplug VIP. Resources may still "
|
||||
"be in use from vip: %(vip)s due to error: %(except)s",
|
||||
{'vip': loadbalancer['vip_address'], 'except': str(e)})
|
||||
|
||||
|
||||
class UpdateVIPSecurityGroup(BaseNetworkTask):
|
||||
"""Task to setup SG for LB."""
|
||||
|
||||
@ -791,19 +744,6 @@ class GetAmphoraeNetworkConfigs(BaseNetworkTask):
|
||||
return provider_dict
|
||||
|
||||
|
||||
class FailoverPreparationForAmphora(BaseNetworkTask):
|
||||
"""Task to prepare an amphora for failover."""
|
||||
|
||||
def execute(self, amphora):
|
||||
session = db_apis.get_session()
|
||||
with session.begin():
|
||||
db_amp = self.amphora_repo.get(session,
|
||||
id=amphora[constants.ID])
|
||||
LOG.debug("Prepare amphora %s for failover.", amphora[constants.ID])
|
||||
|
||||
self.network_driver.failover_preparation(db_amp)
|
||||
|
||||
|
||||
class RetrievePortIDsOnAmphoraExceptLBNetwork(BaseNetworkTask):
|
||||
"""Task retrieving all the port ids on an amphora, except lb network."""
|
||||
|
||||
|
@ -141,21 +141,6 @@ class AbstractNetworkDriver(object, metaclass=abc.ABCMeta):
|
||||
:returns: None
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def plug_vip(self, load_balancer, vip):
|
||||
"""Plugs a virtual ip as the frontend connection of a load balancer.
|
||||
|
||||
Sets up the routing of traffic from the vip to the load balancer
|
||||
and its amphorae.
|
||||
|
||||
:param load_balancer: octavia.common.data_models.LoadBalancer instance
|
||||
:param vip: octavia.common.data_models.VIP instance
|
||||
:return: dict consisting of amphora_id as key and bind_ip as value.
|
||||
bind_ip is the ip that the amphora should listen on to
|
||||
receive traffic to load balance.
|
||||
:raises: PlugVIPException, PortNotFound
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def unplug_vip(self, load_balancer, vip):
|
||||
"""Unplugs a virtual ip as the frontend connection of a load balancer.
|
||||
|
@ -443,18 +443,6 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
|
||||
vrrp_port_id=interface.port_id,
|
||||
ha_port_id=vip.port_id)
|
||||
|
||||
# todo (xgerman): Delete later
|
||||
def plug_vip(self, load_balancer, vip):
|
||||
self.update_vip_sg(load_balancer, vip)
|
||||
plugged_amphorae = []
|
||||
subnet = self.get_subnet(vip.subnet_id)
|
||||
for amphora in filter(
|
||||
lambda amp: amp.status == constants.AMPHORA_ALLOCATED,
|
||||
load_balancer.amphorae):
|
||||
plugged_amphorae.append(self.plug_aap_port(load_balancer, vip,
|
||||
amphora, subnet))
|
||||
return plugged_amphorae
|
||||
|
||||
def _validate_fixed_ip(self, fixed_ips, subnet_id, ip_address):
|
||||
"""Validate an IP address exists in a fixed_ips dict
|
||||
|
||||
|
@ -73,19 +73,6 @@ class NoopManager(object):
|
||||
self.networkconfigconfig[vip.ip_address] = (vip,
|
||||
'deallocate_vip')
|
||||
|
||||
def plug_vip(self, loadbalancer, vip):
|
||||
LOG.debug("Network %s no-op, plug_vip loadbalancer %s, vip %s",
|
||||
self.__class__.__name__,
|
||||
loadbalancer.id, vip.ip_address)
|
||||
self.update_vip_sg(loadbalancer, vip)
|
||||
amps = []
|
||||
for amphora in loadbalancer.amphorae:
|
||||
amps.append(self.plug_aap_port(loadbalancer, vip, amphora, None))
|
||||
self.networkconfigconfig[(loadbalancer.id,
|
||||
vip.ip_address)] = (loadbalancer, vip,
|
||||
'plug_vip')
|
||||
return amps
|
||||
|
||||
def update_vip_sg(self, load_balancer, vip):
|
||||
LOG.debug("Network %s no-op, update_vip_sg loadbalancer %s, vip %s",
|
||||
self.__class__.__name__,
|
||||
@ -461,9 +448,6 @@ class NoopNetworkDriver(driver_base.AbstractNetworkDriver):
|
||||
def deallocate_vip(self, vip):
|
||||
self.driver.deallocate_vip(vip)
|
||||
|
||||
def plug_vip(self, loadbalancer, vip):
|
||||
return self.driver.plug_vip(loadbalancer, vip)
|
||||
|
||||
def unplug_vip(self, loadbalancer, vip):
|
||||
self.driver.unplug_vip(loadbalancer, vip)
|
||||
|
||||
|
@ -1115,36 +1115,6 @@ class TestNetworkTasks(base.TestCase):
|
||||
net.revert(None, None, None)
|
||||
mock_driver.unplug_network.assert_not_called()
|
||||
|
||||
@mock.patch('octavia.db.repositories.LoadBalancerRepository.get')
|
||||
@mock.patch('octavia.db.api.get_session', return_value=_session_mock)
|
||||
def test_plug_vip(self, mock_get_session, mock_get_lb,
|
||||
mock_get_net_driver):
|
||||
mock_driver = mock.MagicMock()
|
||||
mock_get_net_driver.return_value = mock_driver
|
||||
LB.amphorae = AMPS_DATA
|
||||
mock_get_lb.return_value = LB
|
||||
LB.amphorae = AMPS_DATA
|
||||
net = network_tasks.PlugVIP()
|
||||
amp = mock.MagicMock()
|
||||
amp.to_dict.return_value = 'vip'
|
||||
mock_driver.plug_vip.return_value = [amp]
|
||||
|
||||
data = net.execute(self.load_balancer_mock)
|
||||
mock_driver.plug_vip.assert_called_once_with(LB, LB.vip)
|
||||
self.assertEqual(["vip"], data)
|
||||
|
||||
# revert
|
||||
net.revert([o_data_models.Amphora().to_dict()],
|
||||
self.load_balancer_mock)
|
||||
mock_driver.unplug_vip.assert_called_once_with(LB, LB.vip)
|
||||
|
||||
# revert with exception
|
||||
mock_driver.reset_mock()
|
||||
mock_driver.unplug_vip.side_effect = Exception('UnplugVipException')
|
||||
net.revert([o_data_models.Amphora().to_dict()],
|
||||
self.load_balancer_mock)
|
||||
mock_driver.unplug_vip.assert_called_once_with(LB, LB.vip)
|
||||
|
||||
@mock.patch('octavia.controller.worker.task_utils.TaskUtils.'
|
||||
'get_current_loadbalancer_from_db')
|
||||
@mock.patch('octavia.db.repositories.LoadBalancerRepository.get')
|
||||
@ -1434,18 +1404,6 @@ class TestNetworkTasks(base.TestCase):
|
||||
net_task.execute(self.load_balancer_mock)
|
||||
mock_driver.get_network_configs.assert_called_once_with(lb)
|
||||
|
||||
@mock.patch('octavia.db.repositories.AmphoraRepository.get')
|
||||
@mock.patch('octavia.db.api.get_session', return_value=mock.MagicMock())
|
||||
def test_failover_preparation_for_amphora(self, mock_session, mock_get,
|
||||
mock_get_net_driver):
|
||||
mock_driver = mock.MagicMock()
|
||||
mock_get.return_value = self.db_amphora_mock
|
||||
mock_get_net_driver.return_value = mock_driver
|
||||
failover = network_tasks.FailoverPreparationForAmphora()
|
||||
failover.execute(self.amphora_mock)
|
||||
mock_driver.failover_preparation.assert_called_once_with(
|
||||
self.db_amphora_mock)
|
||||
|
||||
def test_retrieve_portids_on_amphora_except_lb_network(
|
||||
self, mock_get_net_driver):
|
||||
mock_driver = mock.MagicMock()
|
||||
|
@ -317,25 +317,6 @@ class TestAllowedAddressPairsDriver(base.TestCase):
|
||||
self.driver.plug_aap_port, lb, lb.vip,
|
||||
lb.amphorae[0], subnet)
|
||||
|
||||
@mock.patch('octavia.network.drivers.neutron.allowed_address_pairs.'
|
||||
'AllowedAddressPairsDriver.update_vip_sg')
|
||||
@mock.patch('octavia.network.drivers.neutron.allowed_address_pairs.'
|
||||
'AllowedAddressPairsDriver.get_subnet')
|
||||
@mock.patch('octavia.network.drivers.neutron.allowed_address_pairs.'
|
||||
'AllowedAddressPairsDriver.plug_aap_port')
|
||||
def test_plug_vip(self, mock_plug_aap, mock_get_subnet,
|
||||
mock_update_vip_sg):
|
||||
lb = dmh.generate_load_balancer_tree()
|
||||
subnet = mock.MagicMock()
|
||||
mock_get_subnet.return_value = subnet
|
||||
mock_plug_aap.side_effect = lb.amphorae
|
||||
amps = self.driver.plug_vip(lb, lb.vip)
|
||||
|
||||
mock_update_vip_sg.assert_called_with(lb, lb.vip)
|
||||
mock_get_subnet.assert_called_with(lb.vip.subnet_id)
|
||||
for amp in amps:
|
||||
mock_plug_aap.assert_any_call(lb, lb.vip, amp, subnet)
|
||||
|
||||
@mock.patch('octavia.common.utils.get_vip_security_group_name')
|
||||
def test_update_vip_sg(self, mock_get_sg_name):
|
||||
LB_ID = uuidutils.generate_uuid()
|
||||
|
@ -88,13 +88,6 @@ class TestNoopNetworkDriver(base.TestCase):
|
||||
self.driver.driver.networkconfigconfig[
|
||||
self.vip.ip_address])
|
||||
|
||||
def test_plug_vip(self):
|
||||
self.driver.plug_vip(self.load_balancer, self.vip)
|
||||
self.assertEqual((self.load_balancer, self.vip,
|
||||
'plug_vip'),
|
||||
self.driver.driver.networkconfigconfig[(
|
||||
self.load_balancer.id, self.vip.ip_address)])
|
||||
|
||||
def test_update_vip_sg(self):
|
||||
self.driver.update_vip_sg(self.load_balancer, self.vip)
|
||||
self.assertEqual((self.load_balancer, self.vip,
|
||||
|
Loading…
x
Reference in New Issue
Block a user