From 235594652bb35786bf4e03c1f7f913c9bf53be3b Mon Sep 17 00:00:00 2001 From: Tom Swanson Date: Tue, 23 Aug 2016 11:23:09 -0500 Subject: [PATCH] Dell SC: Add exclude_domain_ip option If a domain iscsi portal should NOT be returned this allows the user to specify that. Otherwise all domains are returned. DocImpact Closes-Bug: #1616499 Change-Id: Iaec89db402acb759304ea1d3fbb239ee73e4340e (cherry-picked from commit 5fe72f8fb470e5dabcdeb82a2c54134f48d00464) --- .../drivers/dell/dell_storagecenter_api.py | 43 +++++++++++-------- .../drivers/dell/dell_storagecenter_common.py | 7 ++- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/cinder/volume/drivers/dell/dell_storagecenter_api.py b/cinder/volume/drivers/dell/dell_storagecenter_api.py index 03c33f0a8..3fc5ce43d 100644 --- a/cinder/volume/drivers/dell/dell_storagecenter_api.py +++ b/cinder/volume/drivers/dell/dell_storagecenter_api.py @@ -190,6 +190,9 @@ class StorageCenterApiHelper(object): # about. connection.vfname = self.config.dell_sc_volume_folder connection.sfname = self.config.dell_sc_server_folder + connection.excluded_domain_ips = self.config.excluded_domain_ip + if not connection.excluded_domain_ips: + connection.excluded_domain_ips = [] # Set appropriate ssn and failover state. if self.active_backend_id: # active_backend_id is a string. Convert to int. @@ -252,6 +255,7 @@ class StorageCenterApi(object): self.failed_over = False self.vfname = 'openstack' self.sfname = 'openstack' + self.excluded_domain_ips = [] self.legacypayloadfilters = False self.consisgroups = True self.apiversion = apiversion @@ -1502,27 +1506,28 @@ class StorageCenterApi(object): controller or not. :return: Nothing """ - portals.append(address + ':' + - six.text_type(port)) - iqns.append(iqn) - luns.append(lun) + if self.excluded_domain_ips.count(address) == 0: + portals.append(address + ':' + + six.text_type(port)) + iqns.append(iqn) + luns.append(lun) - # We've all the information. We need to find - # the best single portal to return. So check - # this one if it is on the right IP, port and - # if the access and status are correct. - if ((pdata['ip'] is None or pdata['ip'] == address) and - (pdata['port'] is None or pdata['port'] == port)): + # We've all the information. We need to find + # the best single portal to return. So check + # this one if it is on the right IP, port and + # if the access and status are correct. + if ((pdata['ip'] is None or pdata['ip'] == address) and + (pdata['port'] is None or pdata['port'] == port)): - # We need to point to the best link. - # So state active and status up is preferred - # but we don't actually need the state to be - # up at this point. - if pdata['up'] == -1: - if active: - pdata['active'] = len(iqns) - 1 - if status == 'Up': - pdata['up'] = pdata['active'] + # We need to point to the best link. + # So state active and status up is preferred + # but we don't actually need the state to be + # up at this point. + if pdata['up'] == -1: + if active: + pdata['active'] = len(iqns) - 1 + if status == 'Up': + pdata['up'] = pdata['active'] # Start by getting our mappings. mappings = self._find_mappings(scvolume) diff --git a/cinder/volume/drivers/dell/dell_storagecenter_common.py b/cinder/volume/drivers/dell/dell_storagecenter_common.py index 318a80da6..a7ceebf02 100644 --- a/cinder/volume/drivers/dell/dell_storagecenter_common.py +++ b/cinder/volume/drivers/dell/dell_storagecenter_common.py @@ -13,6 +13,7 @@ # under the License. from oslo_config import cfg +from oslo_config import types from oslo_log import log as logging from oslo_utils import excutils @@ -39,7 +40,11 @@ common_opts = [ help='Name of the volume folder to use on the Storage Center'), cfg.BoolOpt('dell_sc_verify_cert', default=False, - help='Enable HTTPS SC certificate verification.') + help='Enable HTTPS SC certificate verification'), + cfg.MultiOpt('excluded_domain_ip', + item_type=types.IPAddress(), + default=None, + help='Domain IP to be excluded from iSCSI returns.') ] LOG = logging.getLogger(__name__)