Merge "EMC VNX Direct Driver Update for Juno"

This commit is contained in:
Jenkins
2014-08-07 08:51:51 +00:00
committed by Gerrit Code Review
6 changed files with 4960 additions and 1148 deletions

View File

@@ -740,3 +740,23 @@ class BrocadeZoningCliException(CinderException):
class NetAppDriverException(VolumeDriverException):
message = _("NetApp Cinder Driver exception.")
class EMCVnxCLICmdError(VolumeBackendAPIException):
def __init__(self, cmd=None, rc=None, out='',
log_as_error=True, **kwargs):
self.cmd = cmd
self.rc = rc
self.out = out
msg = _("EMCVnxCLICmdError : %(cmd)s "
"(Return Code: %(rc)s) "
"(Output: %(out)s) ") % \
{'cmd': cmd,
'rc': rc,
'out': out.split('\n')}
kwargs["data"] = msg
super(EMCVnxCLICmdError, self).__init__(**kwargs)
if log_as_error:
LOG.error(msg)
else:
LOG.warn(msg)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,219 @@
# Copyright (c) 2012 - 2014 EMC Corporation, Inc.
# 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.
"""
Fibre Channel Driver for EMC VNX array based on CLI.
"""
from cinder.openstack.common import log as logging
from cinder.volume import driver
from cinder.volume.drivers.emc import emc_vnx_cli
from cinder.zonemanager.utils import AddFCZone
from cinder.zonemanager.utils import RemoveFCZone
LOG = logging.getLogger(__name__)
class EMCCLIFCDriver(driver.FibreChannelDriver):
"""EMC FC Driver for VNX using CLI.
Version history:
1.0.0 - Initial driver
2.0.0 - Thick/thin provisioning, robust enhancement
3.0.0 - Array-based Backend Support, FC Basic Support,
Target Port Selection for MPIO,
Initiator Auto Registration,
Storage Group Auto Deletion,
Multiple Authentication Type Support,
Storage-Assisted Volume Migration,
SP Toggle for HA
3.0.1 - Security File Support
4.0.0 - Advance LUN Features (Compression Support,
Deduplication Support, FAST VP Support,
FAST Cache Support), Storage-assisted Retype,
External Volume Management, Read-only Volume,
FC Auto Zoning
"""
def __init__(self, *args, **kwargs):
super(EMCCLIFCDriver, self).__init__(*args, **kwargs)
self.cli = emc_vnx_cli.getEMCVnxCli(
'FC',
configuration=self.configuration)
self.VERSION = self.cli.VERSION
def check_for_setup_error(self):
pass
def create_volume(self, volume):
"""Creates a volume."""
return self.cli.create_volume(volume)
def create_volume_from_snapshot(self, volume, snapshot):
"""Creates a volume from a snapshot."""
return self.cli.create_volume_from_snapshot(volume, snapshot)
def create_cloned_volume(self, volume, src_vref):
"""Creates a cloned volume."""
return self.cli.create_cloned_volume(volume, src_vref)
def extend_volume(self, volume, new_size):
"""Extend a volume."""
self.cli.extend_volume(volume, new_size)
def delete_volume(self, volume):
"""Deletes a volume."""
self.cli.delete_volume(volume)
def migrate_volume(self, ctxt, volume, host):
"""Migrate volume via EMC migration functionality."""
return self.cli.migrate_volume(ctxt, volume, host)
def retype(self, ctxt, volume, new_type, diff, host):
"""Convert the volume to be of the new type."""
return self.cli.retype(ctxt, volume, new_type, diff, host)
def create_snapshot(self, snapshot):
"""Creates a snapshot."""
self.cli.create_snapshot(snapshot)
def delete_snapshot(self, snapshot):
"""Deletes a snapshot."""
self.cli.delete_snapshot(snapshot)
def ensure_export(self, context, volume):
"""Driver entry point to get the export info for an existing volume."""
pass
def create_export(self, context, volume):
"""Driver entry point to get the export info for a new volume."""
pass
def remove_export(self, context, volume):
"""Driver entry point to remove an export for a volume."""
pass
def check_for_export(self, context, volume_id):
"""Make sure volume is exported."""
pass
@AddFCZone
def initialize_connection(self, volume, connector):
"""Initializes the connection and returns connection info.
Assign any created volume to a compute node/host so that it can be
used from that host.
The driver returns a driver_volume_type of 'fibre_channel'.
The target_wwn can be a single entry or a list of wwns that
correspond to the list of remote wwn(s) that will export the volume.
The initiator_target_map is a map that represents the remote wwn(s)
and a list of wwns which are visiable to the remote wwn(s).
Example return values:
{
'driver_volume_type': 'fibre_channel'
'data': {
'target_discovered': True,
'target_lun': 1,
'target_wwn': '1234567890123',
'access_mode': 'rw'
'initiator_target_map': {
'1122334455667788': ['1234567890123']
}
}
}
or
{
'driver_volume_type': 'fibre_channel'
'data': {
'target_discovered': True,
'target_lun': 1,
'target_wwn': ['1234567890123', '0987654321321'],
'access_mode': 'rw'
'initiator_target_map': {
'1122334455667788': ['1234567890123',
'0987654321321']
}
}
}
"""
conn_info = self.cli.initialize_connection(volume,
connector)
conn_info = self.cli.adjust_fc_conn_info(conn_info, connector)
LOG.debug("Exit initialize_connection"
" - Returning FC connection info: %(conn_info)s."
% {'conn_info': conn_info})
return conn_info
@RemoveFCZone
def terminate_connection(self, volume, connector, **kwargs):
"""Disallow connection from connector."""
remove_zone = self.cli.terminate_connection(volume, connector)
conn_info = {'driver_volume_type': 'fibre_channel',
'data': {}}
conn_info = self.cli.adjust_fc_conn_info(conn_info, connector,
remove_zone)
LOG.debug("Exit terminate_connection"
" - Returning FC connection info: %(conn_info)s."
% {'conn_info': conn_info})
return conn_info
def get_volume_stats(self, refresh=False):
"""Get volume stats.
If 'refresh' is True, run update the stats first.
"""
if refresh:
self.update_volume_stats()
return self._stats
def update_volume_stats(self):
"""Retrieve stats info from volume group."""
LOG.debug("Updating volume stats.")
data = self.cli.update_volume_stats()
backend_name = self.configuration.safe_get('volume_backend_name')
data['volume_backend_name'] = backend_name or 'EMCCLIFCDriver'
data['storage_protocol'] = 'FC'
self._stats = data
def manage_existing(self, volume, existing_ref):
"""Manage an existing lun in the array.
The lun should be in a manageable pool backend, otherwise
error would return.
Rename the backend storage object so that it matches the,
volume['name'] which is how drivers traditionally map between a
cinder volume and the associated backend storage object.
existing_ref:{
'id':lun_id
}
"""
LOG.debug("Reference lun id %s." % existing_ref['id'])
self.cli.manage_existing(volume, existing_ref)
def manage_existing_get_size(self, volume, existing_ref):
"""Return size of volume to be managed by manage_existing.
"""
return self.cli.manage_existing_get_size(volume, existing_ref)

View File

@@ -17,10 +17,7 @@ iSCSI Drivers for EMC VNX array based on CLI.
"""
from cinder import exception
from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder import utils
from cinder.volume import driver
from cinder.volume.drivers.emc import emc_vnx_cli
@@ -28,34 +25,64 @@ LOG = logging.getLogger(__name__)
class EMCCLIISCSIDriver(driver.ISCSIDriver):
"""EMC ISCSI Drivers for VNX using CLI."""
"""EMC ISCSI Drivers for VNX using CLI.
Version history:
1.0.0 - Initial driver
2.0.0 - Thick/thin provisioning, robust enhancement
3.0.0 - Array-based Backend Support, FC Basic Support,
Target Port Selection for MPIO,
Initiator Auto Registration,
Storage Group Auto Deletion,
Multiple Authentication Type Support,
Storage-Assisted Volume Migration,
SP Toggle for HA
3.0.1 - Security File Support
4.0.0 - Advance LUN Features (Compression Support,
Deduplication Support, FAST VP Support,
FAST Cache Support), Storage-assisted Retype,
External Volume Management, Read-only Volume,
FC Auto Zoning
"""
def __init__(self, *args, **kwargs):
super(EMCCLIISCSIDriver, self).__init__(*args, **kwargs)
self.cli = emc_vnx_cli.EMCVnxCli(
self.cli = emc_vnx_cli.getEMCVnxCli(
'iSCSI',
configuration=self.configuration)
self.VERSION = self.cli.VERSION
def check_for_setup_error(self):
pass
def create_volume(self, volume):
"""Creates a EMC(VMAX/VNX) volume."""
self.cli.create_volume(volume)
"""Creates a VNX volume."""
return self.cli.create_volume(volume)
def create_volume_from_snapshot(self, volume, snapshot):
"""Creates a volume from a snapshot."""
self.cli.create_volume_from_snapshot(volume, snapshot)
return self.cli.create_volume_from_snapshot(volume, snapshot)
def create_cloned_volume(self, volume, src_vref):
"""Creates a cloned volume."""
self.cli.create_cloned_volume(volume, src_vref)
return self.cli.create_cloned_volume(volume, src_vref)
def extend_volume(self, volume, new_size):
"""Extend a volume."""
self.cli.extend_volume(volume, new_size)
def delete_volume(self, volume):
"""Deletes an EMC volume."""
"""Deletes a VNX volume."""
self.cli.delete_volume(volume)
def migrate_volume(self, ctxt, volume, host):
return self.cli.migrate_volume(ctxt, volume, host)
def retype(self, ctxt, volume, new_type, diff, host):
"""Convert the volume to be of the new type."""
return self.cli.retype(ctxt, volume, new_type, diff, host)
def create_snapshot(self, snapshot):
"""Creates a snapshot."""
self.cli.create_snapshot(snapshot)
@@ -80,157 +107,30 @@ class EMCCLIISCSIDriver(driver.ISCSIDriver):
"""Make sure volume is exported."""
pass
def extend_volume(self, volume, new_size):
self.cli.extend_volume(volume, new_size)
def initialize_connection(self, volume, connector):
"""Initializes the connection and returns connection info.
The iscsi driver returns a driver_volume_type of 'iscsi'.
the format of the driver data is defined in vnx_get_iscsi_properties.
Example return value::
:param volume: volume to be attached.
:param connector: connector information.
:returns: dictionary containing iscsi_properties.
Example return value:
{
'driver_volume_type': 'iscsi'
'data': {
'target_discovered': True,
'target_iqn': 'iqn.2010-10.org.openstack:volume-00000001',
'target_portal': '127.0.0.0.1:3260',
'volume_id': '12345678-1234-4321-1234-123456789012',
'target_lun': 1,
'access_mode': 'rw'
}
}
"""
@utils.synchronized('emc-connection-' + connector['host'],
external=True)
def do_initialize_connection():
self.cli.initialize_connection(volume, connector)
do_initialize_connection()
iscsi_properties = self.vnx_get_iscsi_properties(volume, connector)
return {
'driver_volume_type': 'iscsi',
'data': {
'target_discovered': True,
'target_iqn': iscsi_properties['target_iqn'],
'target_lun': iscsi_properties['target_lun'],
'target_portal': iscsi_properties['target_portal'],
'volume_id': iscsi_properties['volume_id']
}
}
def _do_iscsi_discovery(self, volume):
LOG.warn(_("iSCSI provider_location not stored for volume %s, "
"using discovery.") % (volume['name']))
(out, _err) = self._execute('iscsiadm', '-m', 'discovery',
'-t', 'sendtargets', '-p',
self.configuration.iscsi_ip_address,
run_as_root=True)
targets = []
for target in out.splitlines():
targets.append(target)
return targets
def vnx_get_iscsi_properties(self, volume, connector):
"""Gets iscsi configuration.
We ideally get saved information in the volume entity, but fall back
to discovery if need be. Discovery may be completely removed in future
The properties are:
:target_discovered: boolean indicating whether discovery was used
:target_iqn: the IQN of the iSCSI target
:target_portal: the portal of the iSCSI target
:target_lun: the lun of the iSCSI target
:volume_id: the UUID of the volume
:auth_method:, :auth_username:, :auth_password:
the authentication details. Right now, either auth_method is not
present meaning no authentication, or auth_method == `CHAP`
meaning use CHAP with the specified credentials.
"""
properties = {}
location = self._do_iscsi_discovery(volume)
if not location:
raise exception.InvalidVolume(_("Could not find iSCSI export "
" for volume %s") %
(volume['name']))
LOG.debug("ISCSI Discovery: Found %s" % (location))
properties['target_discovered'] = True
hostname = connector['host']
storage_group = hostname
device_info = self.cli.find_device_details(volume, storage_group)
if device_info is None or device_info['hostlunid'] is None:
exception_message = (_("Cannot find device number for volume %s")
% volume['name'])
raise exception.VolumeBackendAPIException(data=exception_message)
device_number = device_info['hostlunid']
device_sp = device_info['ownersp']
endpoints = []
if device_sp:
# endpoints example:
# [iqn.1992-04.com.emc:cx.apm00123907237.a8,
# iqn.1992-04.com.emc:cx.apm00123907237.a9]
endpoints = self.cli._find_iscsi_protocol_endpoints(device_sp)
foundEndpoint = False
for loc in location:
results = loc.split(" ")
properties['target_portal'] = results[0].split(",")[0]
properties['target_iqn'] = results[1]
# for VNX, find the target_iqn that matches the endpoint
# target_iqn example: iqn.1992-04.com.emc:cx.apm00123907237.a8
# or iqn.1992-04.com.emc:cx.apm00123907237.b8
if not device_sp:
break
for endpoint in endpoints:
if properties['target_iqn'] == endpoint:
LOG.debug("Found iSCSI endpoint: %s" % endpoint)
foundEndpoint = True
break
if foundEndpoint:
break
if device_sp and not foundEndpoint:
LOG.warn(_("ISCSI endpoint not found for SP %(sp)s ")
% {'sp': device_sp})
properties['target_lun'] = device_number
properties['volume_id'] = volume['id']
auth = volume['provider_auth']
if auth:
(auth_method, auth_username, auth_secret) = auth.split()
properties['auth_method'] = auth_method
properties['auth_username'] = auth_username
properties['auth_password'] = auth_secret
return properties
return self.cli.initialize_connection(volume, connector)
def terminate_connection(self, volume, connector, **kwargs):
"""Disallow connection from connector."""
@utils.synchronized('emc-connection-' + connector['host'],
external=True)
def do_terminate_connection():
self.cli.terminate_connection(volume, connector)
do_terminate_connection()
self.cli.terminate_connection(volume, connector)
def get_volume_stats(self, refresh=False):
"""Get volume status.
@@ -239,16 +139,38 @@ class EMCCLIISCSIDriver(driver.ISCSIDriver):
"""
if refresh:
self.update_volume_stats()
LOG.info(_("update_volume_status:%s"), self._stats)
return self._stats
def update_volume_stats(self):
"""Retrieve status info from volume group."""
LOG.debug("Updating volume status")
LOG.debug("Updating volume status.")
# retrieving the volume update from the VNX
data = self.cli.update_volume_status()
data = self.cli.update_volume_stats()
backend_name = self.configuration.safe_get('volume_backend_name')
data['volume_backend_name'] = backend_name or 'EMCCLIISCSIDriver'
data['storage_protocol'] = 'iSCSI'
self._stats = data
def manage_existing(self, volume, existing_ref):
"""Manage an existing lun in the array.
The lun should be in a manageable pool backend, otherwise
error would return.
Rename the backend storage object so that it matches the,
volume['name'] which is how drivers traditionally map between a
cinder volume and the associated backend storage object.
existing_ref:{
'id':lun_id
}
"""
LOG.debug("Reference lun id %s." % existing_ref['id'])
self.cli.manage_existing(volume, existing_ref)
def manage_existing_get_size(self, volume, existing_ref):
"""Return size of volume to be managed by manage_existing.
"""
return self.cli.manage_existing_get_size(volume, existing_ref)

File diff suppressed because it is too large Load Diff

View File

@@ -1093,19 +1093,41 @@
# Options defined in cinder.volume.drivers.emc.emc_vnx_cli
#
# Naviseccli Path (string value)
# VNX authentication scope type. (string value)
#storage_vnx_authentication_type=global
# Directory path that contains the VNX security file. Make
# sure the security file is generated first. (string value)
#storage_vnx_security_file_dir=<None>
# Naviseccli Path. (string value)
#naviseccli_path=
# ISCSI pool name (string value)
# Storage pool name (string value)
#storage_vnx_pool_name=<None>
# Default Time Out For CLI operations in minutes (integer
# value)
#default_timeout=20
# VNX secondary SP IP Address. (string value)
#san_secondary_ip=<None>
# Default max number of LUNs in a storage group (integer
# value)
#max_luns_per_storage_group=256
# Default Time Out For CLI operations in minutes. By default,
# it is 365 days long. (integer value)
#default_timeout=525600
# Default max number of LUNs in a storage group. By default,
# the value is 255. (integer value)
#max_luns_per_storage_group=255
# To destroy storage group when the last LUN is removed from
# it. By default, the value is False. (boolean value)
#destroy_empty_storage_group=false
# Mapping between hostname and its iSCSI initiator IP
# addresses. (string value)
#iscsi_initiators=
# Automatically register initiators. By default, the value is
# False. (boolean value)
#initiator_auto_registration=false
#