EMC Manila driver
EMC specific NAS storage driver. This driver is a pluggable driver that allows specific EMC NAS devices to be plugged-in as the underlying backend. Use the Manila configuration variable "share_backend_name" to specify, which backend plugins to use. VNX and Isilon plugins will be submitted later in different patches. partially implements: blueprint emc-driver Change-Id: Ibe174d22a5a63693fa28998459434f9db25fb878
This commit is contained in:
parent
290769f087
commit
5a0e25c36b
0
manila/share/drivers/emc/__init__.py
Normal file
0
manila/share/drivers/emc/__init__.py
Normal file
168
manila/share/drivers/emc/driver.py
Normal file
168
manila/share/drivers/emc/driver.py
Normal file
@ -0,0 +1,168 @@
|
||||
# Copyright (c) 2014 EMC Corporation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
EMC specific NAS storage driver. This driver is a pluggable driver
|
||||
that allows specific EMC NAS devices to be plugged-in as the underlying
|
||||
backend. Use the Manila configuration variable "share_backend_name"
|
||||
to specify, which backend plugins to use.
|
||||
"""
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from manila.openstack.common import log
|
||||
from manila.share import driver
|
||||
from manila.share.drivers.emc.plugins import \
|
||||
registry as emc_plugins_registry
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
EMC_NAS_OPTS = [
|
||||
cfg.StrOpt('emc_nas_login',
|
||||
default=None,
|
||||
help='User name for the EMC server.'),
|
||||
cfg.StrOpt('emc_nas_password',
|
||||
default=None,
|
||||
help='Password for the EMC server.'),
|
||||
cfg.StrOpt('emc_nas_server',
|
||||
default=None,
|
||||
help='EMC server hostname or ip-address.'),
|
||||
cfg.IntOpt('emc_nas_server_port',
|
||||
default=8080,
|
||||
help='Port number for the EMC server.'),
|
||||
cfg.BoolOpt('emc_nas_server_secure',
|
||||
default=True,
|
||||
help='Use secure connection to server.'),
|
||||
cfg.StrOpt('emc_share_backend',
|
||||
default=None,
|
||||
help='Share backend.'),
|
||||
cfg.StrOpt('emc_nas_server_container',
|
||||
default='server_2',
|
||||
help='Container of share servers.'),
|
||||
cfg.StrOpt('emc_nas_pool_name',
|
||||
default=None,
|
||||
help='EMC pool name.'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(EMC_NAS_OPTS)
|
||||
|
||||
|
||||
class EMCShareDriver(driver.ShareDriver):
|
||||
"""EMC specific NAS driver. Allows for NFS and CIFS NAS storage usage."""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EMCShareDriver, self).__init__()
|
||||
self.configuration = kwargs.get('configuration', None)
|
||||
if self.configuration:
|
||||
self.configuration.append_config_values(EMC_NAS_OPTS)
|
||||
|
||||
self._storage_conn = None
|
||||
|
||||
def create_share(self, context, share, share_server=None):
|
||||
"""Is called to create share."""
|
||||
location = self._storage_conn.create_share(self, context, share,
|
||||
share_server)
|
||||
|
||||
return location
|
||||
|
||||
def create_share_from_snapshot(self, context, share, snapshot,
|
||||
share_server=None):
|
||||
"""Is called to create share from snapshot."""
|
||||
location = self._storage_conn.create_share_from_snapshot(
|
||||
self, context, share, snapshot, share_server)
|
||||
|
||||
return location
|
||||
|
||||
def create_snapshot(self, context, snapshot, share_server=None):
|
||||
"""Is called to create snapshot."""
|
||||
self._storage_conn.create_snapshot(self, context, snapshot,
|
||||
share_server)
|
||||
|
||||
def delete_share(self, context, share, share_server=None):
|
||||
"""Is called to remove share."""
|
||||
self._storage_conn.delete_share(self, context, share, share_server)
|
||||
|
||||
def delete_snapshot(self, context, snapshot, share_server=None):
|
||||
"""Is called to remove snapshot."""
|
||||
self._storage_conn.delete_snapshot(self, context, snapshot,
|
||||
share_server)
|
||||
|
||||
def ensure_share(self, context, share, share_server=None):
|
||||
"""Invoked to sure that share is exported."""
|
||||
self._storage_conn.ensure_share(self, context, share, share_server)
|
||||
|
||||
def allow_access(self, context, share, access, share_server=None):
|
||||
"""Allow access to the share."""
|
||||
self._storage_conn.allow_access(self, context, share, access,
|
||||
share_server)
|
||||
|
||||
def deny_access(self, context, share, access, share_server=None):
|
||||
"""Deny access to the share."""
|
||||
self._storage_conn.deny_access(self, context, share, access,
|
||||
share_server)
|
||||
|
||||
def check_for_setup_error(self):
|
||||
"""Check for setup error."""
|
||||
pass
|
||||
|
||||
def do_setup(self, context):
|
||||
"""Any initialization the share driver does while starting."""
|
||||
self._storage_conn = emc_plugins_registry.create_storage_connection(
|
||||
self.configuration.safe_get('emc_share_backend'), LOG)
|
||||
self._storage_conn.connect(self, context)
|
||||
|
||||
def get_share_stats(self, refresh=False):
|
||||
"""Get share stats.
|
||||
|
||||
If 'refresh' is True, run update the stats first.
|
||||
"""
|
||||
if refresh:
|
||||
self._update_share_stats()
|
||||
|
||||
return self._stats
|
||||
|
||||
def _update_share_stats(self):
|
||||
"""Retrieve stats info from share."""
|
||||
|
||||
LOG.debug("Updating share stats.")
|
||||
data = {}
|
||||
backend_name = self.configuration.safe_get(
|
||||
'share_backend_name') or "EMC_NAS_Storage"
|
||||
data["share_backend_name"] = backend_name
|
||||
data["vendor_name"] = 'EMC'
|
||||
data["driver_version"] = '1.0'
|
||||
data["storage_protocol"] = 'NFS_CIFS'
|
||||
|
||||
data['total_capacity_gb'] = 'infinite'
|
||||
data['free_capacity_gb'] = 'infinite'
|
||||
data['reserved_percentage'] = 0
|
||||
data['QoS_support'] = False
|
||||
self._storage_conn.update_share_stats(data)
|
||||
self._stats = data
|
||||
|
||||
def get_network_allocations_number(self):
|
||||
"""Returns number of network allocations for creating VIFs."""
|
||||
return self._storage_conn.get_network_allocations_number(self)
|
||||
|
||||
def setup_server(self, network_info, metadata=None):
|
||||
"""Set up and configures share server with given network parameters."""
|
||||
return self._storage_conn.setup_server(self, network_info, metadata)
|
||||
|
||||
def teardown_server(self, server_details, security_services=None):
|
||||
"""Teardown share server."""
|
||||
return self._storage_conn.teardown_server(self,
|
||||
server_details,
|
||||
security_services)
|
0
manila/share/drivers/emc/plugins/__init__.py
Normal file
0
manila/share/drivers/emc/plugins/__init__.py
Normal file
83
manila/share/drivers/emc/plugins/base.py
Normal file
83
manila/share/drivers/emc/plugins/base.py
Normal file
@ -0,0 +1,83 @@
|
||||
# Copyright (c) 2014 EMC Corporation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
"""EMC Share Driver Base Plugin API """
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class StorageConnection(object):
|
||||
"""Subclasses should implement storage backend specific functionality."""
|
||||
|
||||
def __init__(self, logger):
|
||||
self.logger = logger
|
||||
|
||||
@abc.abstractmethod
|
||||
def create_share(self, emc_share_driver, context, share, share_server):
|
||||
"""Is called to create share."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def create_snapshot(self, emc_share_driver, context,
|
||||
snapshot, share_server):
|
||||
"""Is called to create snapshot."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def delete_share(self, emc_share_driver, context, share, share_server):
|
||||
"""Is called to remove share."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def delete_snapshot(self, emc_share_driver, context,
|
||||
snapshot, share_server):
|
||||
"""Is called to remove snapshot."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def ensure_share(self, emc_share_driver, context, share, share_server):
|
||||
"""Invoked to ensure that share is exported."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def allow_access(self, emc_share_driver, context, share,
|
||||
access, share_server):
|
||||
"""Allow access to the share."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def deny_access(self, emc_share_driver, context, share,
|
||||
access, share_server):
|
||||
"""Deny access to the share."""
|
||||
|
||||
def raise_connect_error(self, emc_share_driver):
|
||||
"""Check for setup error."""
|
||||
pass
|
||||
|
||||
def connect(self, emc_share_driver, context):
|
||||
"""Any initialization the share driver does while starting."""
|
||||
pass
|
||||
|
||||
def update_share_stats(self, stats_dict):
|
||||
"""Add key/values to stats_dict."""
|
||||
pass
|
||||
|
||||
def get_network_allocations_number(self):
|
||||
"""Returns number of network allocations for creating VIFs."""
|
||||
return 0
|
||||
|
||||
@abc.abstractmethod
|
||||
def setup_server(self, network_info, metadata=None):
|
||||
"""Set up and configure share server with given network parameters."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def teardown_server(self, server_details, security_services=None):
|
||||
"""Teardown share server."""
|
31
manila/share/drivers/emc/plugins/registry.py
Normal file
31
manila/share/drivers/emc/plugins/registry.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Copyright (c) 2014 EMC Corporation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""EMC Share Driver Plugin Framework."""
|
||||
|
||||
g_registered_storage_backends = {}
|
||||
|
||||
|
||||
def register_storage_backend(share_backend_name, storage_conn_class):
|
||||
"""register a backend storage plugins."""
|
||||
g_registered_storage_backends[
|
||||
share_backend_name.upper()] = storage_conn_class
|
||||
|
||||
|
||||
def create_storage_connection(share_backend_name, logger):
|
||||
"""create an instance of plugins."""
|
||||
storage_conn_class = g_registered_storage_backends[
|
||||
share_backend_name.upper()]
|
||||
return storage_conn_class(logger)
|
0
manila/tests/share/drivers/__init__.py
Normal file
0
manila/tests/share/drivers/__init__.py
Normal file
0
manila/tests/share/drivers/emc/__init__.py
Normal file
0
manila/tests/share/drivers/emc/__init__.py
Normal file
131
manila/tests/share/drivers/emc/test_driver.py
Normal file
131
manila/tests/share/drivers/emc/test_driver.py
Normal file
@ -0,0 +1,131 @@
|
||||
# Copyright (c) 2014 EMC Corporation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.openstack.common import log as logging
|
||||
from manila.share import configuration as conf
|
||||
from manila.share.drivers.emc import driver as emcdriver
|
||||
from manila.share.drivers.emc.plugins import base
|
||||
from manila.share.drivers.emc.plugins import \
|
||||
registry as emc_plugins_registry
|
||||
from manila import test
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FakeConnection(base.StorageConnection):
|
||||
def __init__(self, logger):
|
||||
self.logger = logger
|
||||
|
||||
def create_share(self, emc_share_driver, context, share, share_server):
|
||||
"""Is called to create share."""
|
||||
pass
|
||||
|
||||
def create_snapshot(self, emc_share_driver, context,
|
||||
snapshot, share_server):
|
||||
"""Is called to create snapshot."""
|
||||
pass
|
||||
|
||||
def delete_share(self, emc_share_driver, context, share, share_server):
|
||||
"""Is called to remove share."""
|
||||
pass
|
||||
|
||||
def delete_snapshot(self, emc_share_driver, context,
|
||||
snapshot, share_server):
|
||||
"""Is called to remove snapshot."""
|
||||
pass
|
||||
|
||||
def ensure_share(self, emc_share_driver, context, share, share_server):
|
||||
"""Invoked to sure that share is exported."""
|
||||
pass
|
||||
|
||||
def allow_access(self, emc_share_driver, context, share,
|
||||
access, share_server):
|
||||
"""Allow access to the share."""
|
||||
pass
|
||||
|
||||
def deny_access(self, emc_share_driver, context, share,
|
||||
access, share_server):
|
||||
"""Deny access to the share."""
|
||||
pass
|
||||
|
||||
def raise_connect_error(self, emc_share_driver):
|
||||
"""Check for setup error."""
|
||||
pass
|
||||
|
||||
def connect(self, emc_share_driver, context):
|
||||
"""Any initialization the share driver does while starting."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def update_share_stats(self, stats_dict):
|
||||
"""Add key/values to stats_dict."""
|
||||
pass
|
||||
|
||||
def get_network_allocations_number(self):
|
||||
"""Returns number of network allocations for creating VIFs."""
|
||||
return 0
|
||||
|
||||
def setup_server(self, network_info, metadata=None):
|
||||
"""Set up and configures share server with given network parameters."""
|
||||
pass
|
||||
|
||||
def teardown_server(self, server_details, security_services=None):
|
||||
"""Teardown share server."""
|
||||
pass
|
||||
|
||||
FAKE_BACKEND = 'fake_backend'
|
||||
|
||||
|
||||
class EMCShareFrameworkTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(EMCShareFrameworkTestCase, self).setUp()
|
||||
self.configuration = conf.Configuration(None)
|
||||
self.configuration.append_config_values = mock.Mock(return_value=0)
|
||||
self.configuration.share_backend_name = FAKE_BACKEND
|
||||
self.stubs.Set(self.configuration, 'safe_get', self._fake_safe_get)
|
||||
self.driver = emcdriver.EMCShareDriver(
|
||||
configuration=self.configuration)
|
||||
|
||||
def test_driver_setup(self):
|
||||
emc_plugins_registry.register_storage_backend(
|
||||
FAKE_BACKEND, FakeConnection)
|
||||
|
||||
FakeConnection.connect = mock.Mock()
|
||||
self.driver.do_setup(None)
|
||||
self.assertIsInstance(self.driver._storage_conn, FakeConnection,
|
||||
"Not an instance of FakeConnection")
|
||||
FakeConnection.connect.assert_called_with(self.driver, None)
|
||||
|
||||
def test_update_share_stats(self):
|
||||
data = {}
|
||||
self.driver._storage_conn = mock.Mock()
|
||||
self.driver._update_share_stats()
|
||||
data["share_backend_name"] = FAKE_BACKEND
|
||||
data["vendor_name"] = 'EMC'
|
||||
data["driver_version"] = '1.0'
|
||||
data["storage_protocol"] = 'NFS_CIFS'
|
||||
data['total_capacity_gb'] = 'infinite'
|
||||
data['free_capacity_gb'] = 'infinite'
|
||||
data['reserved_percentage'] = 0
|
||||
data['QoS_support'] = False
|
||||
self.driver._storage_conn.\
|
||||
update_share_stats.assert_called_with(data)
|
||||
|
||||
def _fake_safe_get(self, value):
|
||||
if value in ['emc_share_backend', 'share_backend_name']:
|
||||
return FAKE_BACKEND
|
||||
return None
|
Loading…
Reference in New Issue
Block a user