manila/manila/tests/fake_service_instance.py
yanjun.fu 7422aef799 Fix tap device disappear after node restart
When use driver_handles_share_servers driver, the tap device will
down and the tap device  mac address is changed after restart the
node, that will caused manila can not manage share that created
by this service.
This path fix this issue. When restart manila-share service,
call setup_connectivity_with_service_instances() to create host port
and check the the mac address.

Change-Id: Ibcdd4f58f15a53c69d35db06bc42283859349758
Closes-Bug:#1688155
2018-03-13 09:57:04 +08:00

60 lines
1.9 KiB
Python

# Copyright 2014 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from manila.tests import fake_compute
class FakeServiceInstanceManager(object):
def __init__(self, *args, **kwargs):
self.db = mock.Mock()
self._helpers = {
'CIFS': mock.Mock(),
'NFS': mock.Mock(),
}
self.share_networks_locks = {}
self.share_networks_servers = {}
self.fake_server = fake_compute.FakeServer()
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):
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,
share_network_id, old_server_ip):
return self.fake_server
def _delete_server(self, context, server):
pass
def _get_service_instance_name(self, share_network_id):
return self.service_instance_name_template % share_network_id
class FakeNeutronNetworkHelper(object):
def setup_connectivity_with_service_instances(self):
pass