From 607e7688b90e8233ac8c52b896fa11ca44a2b026 Mon Sep 17 00:00:00 2001 From: Shay Halsband Date: Tue, 20 Mar 2018 14:17:09 +0200 Subject: [PATCH] XtremIO: support multiattach - add multiattach to XtremIO driver capabilities. - add handling for volume attachment list and test - add release note Change-Id: I88fe943df753a97684077189c6a13dc1e290968d --- .../volume/drivers/dell_emc/test_xtremio.py | 27 ++++++++++++++----- cinder/volume/drivers/dell_emc/xtremio.py | 24 ++++++++++++++--- ...support-multiattache-20b1882a1216a8b2.yaml | 3 +++ 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/xtremio-support-multiattache-20b1882a1216a8b2.yaml diff --git a/cinder/tests/unit/volume/drivers/dell_emc/test_xtremio.py b/cinder/tests/unit/volume/drivers/dell_emc/test_xtremio.py index c6d3dd09e36..bf698c1f8d3 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/test_xtremio.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/test_xtremio.py @@ -1,4 +1,4 @@ -# Copyright (c) 2012 - 2014 EMC Corporation, Inc. +# Copyright (c) 2018 Dell Inc. or its subsidiaries. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -20,12 +20,15 @@ import time import mock import six +from cinder import context from cinder import exception +from cinder.objects import volume_attachment from cinder import test from cinder.tests.unit.consistencygroup import fake_consistencygroup as fake_cg from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import fake_snapshot from cinder.tests.unit.fake_volume import fake_volume_obj +from cinder.tests.unit.fake_volume import fake_volume_type_obj from cinder.volume.drivers.dell_emc import xtremio typ2id = {'volumes': 'vol-id', @@ -243,7 +246,7 @@ class D(dict): class CommonData(object): - context = {'user': 'admin', } + context = context.RequestContext('admin', 'fake', True) connector = {'ip': '10.0.0.2', 'initiator': 'iqn.1993-08.org.debian:01:222', 'wwpns': ["123456789012345", "123456789054321"], @@ -251,19 +254,25 @@ class CommonData(object): 'host': 'fakehost', } + test_volume_type = fake_volume_type_obj( + context=context + ) + test_volume = fake_volume_obj(context, + volume_type = test_volume_type, name='vol1', - size=1, volume_name='vol1', + display_name='vol1', + display_description='test volume', + size=1, id='192eb39b-6c2f-420c-bae3-3cfd117f0001', provider_auth=None, project_id='project', - display_name='vol1', - display_description='test volume', volume_type_id=None, consistencygroup_id= '192eb39b-6c2f-420c-bae3-3cfd117f0345', ) + test_snapshot = D() test_snapshot.update({'name': 'snapshot1', 'size': 1, @@ -319,6 +328,10 @@ class CommonData(object): 'consistencygroup_id': None, 'group_id': group['id'], } + test_volume_attachment = volume_attachment.VolumeAttachment( + id='2b06255d-f5f0-4520-a953-b029196add6b', volume_id=test_volume.id, + connector=connector) + class BaseXtremIODriverTestCase(test.TestCase): def __init__(self, *args, **kwargs): @@ -697,7 +710,9 @@ class XtremIODriverISCSITestCase(BaseXtremIODriverTestCase): def test_get_ig_indexes_from_initiators_called_once(self, req): req.side_effect = xms_request - self.driver.create_volume(self.data.test_volume) + volume1 = copy.deepcopy(self.data.test_volume) + volume1.volume_attachment.objects = [self.data.test_volume_attachment] + self.driver.create_volume(volume1) map_data = self.driver.initialize_connection(self.data.test_volume, self.data.connector) i1 = xms_data['initiators'][1] diff --git a/cinder/volume/drivers/dell_emc/xtremio.py b/cinder/volume/drivers/dell_emc/xtremio.py index 1de14af0301..08e20d5cada 100644 --- a/cinder/volume/drivers/dell_emc/xtremio.py +++ b/cinder/volume/drivers/dell_emc/xtremio.py @@ -1,4 +1,4 @@ -# Copyright (c) 2012 - 2014 EMC Corporation. +# Copyright (c) 2018 Dell Inc. or its subsidiaries. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -30,6 +30,7 @@ supported XtremIO version 2.4 and up 1.0.8 - support for volume retype, CG fixes 1.0.9 - performance improvements, support force detach, support for X2 1.0.10 - option to clean unused IGs + 1.0.11 - add support for multiattach """ import json @@ -409,7 +410,7 @@ class XtremIOClient42(XtremIOClient4): class XtremIOVolumeDriver(san.SanDriver): """Executes commands relating to Volumes.""" - VERSION = '1.0.10' + VERSION = '1.0.11' # ThirdPartySystems wiki CI_WIKI_NAME = "EMC_XIO_CI" @@ -616,7 +617,7 @@ class XtremIOVolumeDriver(san.SanDriver): 'reserved_percentage': self.configuration.reserved_percentage, 'QoS_support': False, - 'multiattach': False, + 'multiattach': True, } self._stats.update(self.client.get_extra_capabilities()) @@ -725,6 +726,23 @@ class XtremIOVolumeDriver(san.SanDriver): LOG.info('Force detach volume %(vol)s from luns %(luns)s.', {'vol': vol['name'], 'luns': ig_indexes}) else: + host = connector['host'] + attachment_list = volume.volume_attachment + LOG.debug("Volume attachment list: %(atl)s. " + "Attachment type: %(at)s", + {'atl': attachment_list, 'at': type(attachment_list)}) + try: + att_list = attachment_list.objects + except AttributeError: + att_list = attachment_list + if att_list is not None: + host_list = [att.connector['host'] for att in att_list if + att is not None and att.connector is not None] + current_host_occurances = host_list.count(host) + if current_host_occurances > 1: + LOG.info("Volume is attached to multiple instances on " + "this host. Not removing the lun map.") + return vol = self.client.req('volumes', name=volume.id, data={'prop': 'index'})['content'] ig_indexes = self._get_ig_indexes_from_initiators(connector) diff --git a/releasenotes/notes/xtremio-support-multiattache-20b1882a1216a8b2.yaml b/releasenotes/notes/xtremio-support-multiattache-20b1882a1216a8b2.yaml new file mode 100644 index 00000000000..a59773841c0 --- /dev/null +++ b/releasenotes/notes/xtremio-support-multiattache-20b1882a1216a8b2.yaml @@ -0,0 +1,3 @@ +--- +features: + - Dell EMC XtremIO driver has added multiattach support.