Merge "Fix tap device disappear after node restart" into stable/ocata

This commit is contained in:
Zuul 2018-09-05 20:30:52 +00:00 committed by Gerrit Code Review
commit 91ea4b6332
6 changed files with 49 additions and 0 deletions

View File

@ -155,6 +155,9 @@ class OVSInterfaceDriver(LinuxInterfaceDriver):
else: else:
LOG.warning(_LW("Device %s already exists."), device_name) LOG.warning(_LW("Device %s already exists."), device_name)
if ns_dev.link.address != mac_address:
LOG.warning(_LW("Reset mac address to %s"), mac_address)
ns_dev.link.set_address(mac_address)
ns_dev.link.set_up() ns_dev.link.set_up()
@device_name_synchronized @device_name_synchronized

View File

@ -290,6 +290,10 @@ class ShareManager(manager.SchedulerDependentManager):
else: else:
self.driver.initialized = True self.driver.initialized = True
if (self.driver.driver_handles_share_servers and
hasattr(self.driver, 'service_instance_manager')):
(self.driver.service_instance_manager.network_helper.
setup_connectivity_with_service_instances())
share_instances = self.db.share_instances_get_all_by_host(ctxt, share_instances = self.db.share_instances_get_all_by_host(ctxt,
self.host) self.host)
LOG.debug("Re-exporting %s shares", len(share_instances)) LOG.debug("Re-exporting %s shares", len(share_instances))

View File

@ -17,6 +17,7 @@ from oslo_log import log
import six import six
from manila.share import driver from manila.share import driver
from manila.tests import fake_service_instance
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -39,8 +40,13 @@ class FakeShareDriver(driver.ShareDriver):
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self._setup_service_instance_manager()
super(FakeShareDriver, self).__init__([True, False], *args, **kwargs) super(FakeShareDriver, self).__init__([True, False], *args, **kwargs)
def _setup_service_instance_manager(self):
self.service_instance_manager = (
fake_service_instance.FakeServiceInstanceManager())
def manage_existing(self, share, driver_options): def manage_existing(self, share, driver_options):
LOG.debug("Fake share driver: manage") LOG.debug("Fake share driver: manage")
LOG.debug("Fake share driver: driver options: %s", LOG.debug("Fake share driver: driver options: %s",

View File

@ -29,10 +29,19 @@ class FakeServiceInstanceManager(object):
self.share_networks_servers = {} self.share_networks_servers = {}
self.fake_server = fake_compute.FakeServer() self.fake_server = fake_compute.FakeServer()
self.service_instance_name_template = 'manila_fake_service_instance-%s' self.service_instance_name_template = 'manila_fake_service_instance-%s'
self._network_helper = None
def get_service_instance(self, context, share_network_id, create=True): def get_service_instance(self, context, share_network_id, create=True):
return self.fake_server return self.fake_server
@property
def network_helper(self):
return self._get_network_helper()
def _get_network_helper(self):
self._network_helper = FakeNeutronNetworkHelper()
return self._network_helper
def _create_service_instance(self, context, instance_name, def _create_service_instance(self, context, instance_name,
share_network_id, old_server_ip): share_network_id, old_server_ip):
return self.fake_server return self.fake_server
@ -42,3 +51,9 @@ class FakeServiceInstanceManager(object):
def _get_service_instance_name(self, share_network_id): def _get_service_instance_name(self, share_network_id):
return self.service_instance_name_template % share_network_id return self.service_instance_name_template % share_network_id
class FakeNeutronNetworkHelper(object):
def setup_connectivity_with_service_instances(self):
pass

View File

@ -160,6 +160,22 @@ class TestOVSInterfaceDriver(TestBase):
self.ip.assert_has_calls(expected) self.ip.assert_has_calls(expected)
def test_plug_reset_mac(self):
fake_mac_addr = 'aa:bb:cc:dd:ee:ff'
self.device_exists.return_value = True
self.ip().device().link.address = mock.Mock(return_value=fake_mac_addr)
ovs = interface.OVSInterfaceDriver()
ovs.plug('tap0',
'port-1234',
'ff:ee:dd:cc:bb:aa',
bridge='br-int')
expected = [mock.call(),
mock.call().device('tap0'),
mock.call().device().link.set_address('ff:ee:dd:cc:bb:aa'),
mock.call().device().link.set_up()]
self.ip.assert_has_calls(expected)
def test_unplug(self, bridge=None): def test_unplug(self, bridge=None):
if not bridge: if not bridge:
bridge = 'br-int' bridge = 'br-int'

View File

@ -0,0 +1,5 @@
---
fixes:
- When use driver_handles_share_servers driver,
reset the tap device after manila-share service
start.