diff --git a/manila/share/drivers/service_instance.py b/manila/share/drivers/service_instance.py index 545606078f..c99a59ad6d 100644 --- a/manila/share/drivers/service_instance.py +++ b/manila/share/drivers/service_instance.py @@ -966,14 +966,13 @@ class NeutronNetworkHelper(BaseNetworkhelper): 'manila-admin-share') interface_name = self.vif_driver.get_device_name(port) device = ip_lib.IPDevice(interface_name) - for fixed_ip in port['fixed_ips']: - subnet = self.neutron_api.get_subnet(fixed_ip['subnet_id']) - device.route.clear_outdated_routes(subnet['cidr']) - self._plug_interface_in_host(interface_name, device, port) + self._plug_interface_in_host(interface_name, device, port, + clear_outdated_routes=True) @utils.synchronized("service_instance_plug_interface_in_host", external=True) - def _plug_interface_in_host(self, interface_name, device, port): + def _plug_interface_in_host(self, interface_name, device, port, + clear_outdated_routes=False): LOG.debug("Plug interface into host - interface_name: %s, " "device: %s, port: %s", interface_name, device, port) @@ -981,6 +980,9 @@ class NeutronNetworkHelper(BaseNetworkhelper): ip_cidrs = [] for fixed_ip in port['fixed_ips']: subnet = self.neutron_api.get_subnet(fixed_ip['subnet_id']) + if clear_outdated_routes: + device.route.clear_outdated_routes(subnet['cidr']) + net = netaddr.IPNetwork(subnet['cidr']) ip_cidr = '%s/%s' % (fixed_ip['ip_address'], net.prefixlen) ip_cidrs.append(ip_cidr) diff --git a/manila/tests/share/drivers/test_service_instance.py b/manila/tests/share/drivers/test_service_instance.py index 90c0a7826d..94bbcaf46a 100644 --- a/manila/tests/share/drivers/test_service_instance.py +++ b/manila/tests/share/drivers/test_service_instance.py @@ -2123,7 +2123,6 @@ class NeutronNetworkHelperTestCase(test.TestCase): fake_admin_port['mac_address'])]) instance.neutron_api.get_subnet.assert_has_calls([ mock.call(fake_subnet_service['id']), - mock.call(fake_subnet_admin['id']), mock.call(fake_subnet_admin['id'])]) instance.vif_driver.init_l3.assert_has_calls([ mock.call(interface_name_service,