Skip to content

Commit

Permalink
Merge pull request #30 from yunqifeng/master
Browse files Browse the repository at this point in the history
update huawei driver for openstack
  • Loading branch information
yunqifeng authored Apr 14, 2022
2 parents 8c94f6f + 531f606 commit 80fd8fb
Show file tree
Hide file tree
Showing 143 changed files with 14,281 additions and 788 deletions.
2 changes: 1 addition & 1 deletion Cinder/Mitaka/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Version: 2.3.RC3"""
"""Version: 2.3.RC4"""
3 changes: 2 additions & 1 deletion Cinder/Mitaka/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,12 @@
LUN_TYPE_MAP = {'Thick': THICK_LUNTYPE,
'Thin': THIN_LUNTYPE}

VALID_PRODUCT = ['T', 'TV2', 'V3', 'V5', '18000', 'Dorado']
VALID_PRODUCT = ['T', 'TV2', 'V3', 'V5', '18000', 'Dorado', 'V6']
VALID_PROTOCOL = ['FC', 'iSCSI']
VALID_WRITE_TYPE = ['1', '2']
VOLUME_NOT_EXISTS_WARN = 'warning'
VOLUME_NOT_EXISTS_RAISE = 'raise'
DORADO_V6_AND_V6_PRODUCT = ('Dorado', 'V6')

LUN_COPY_SPEED_TYPES = (
LUN_COPY_SPEED_LOW,
Expand Down
2 changes: 1 addition & 1 deletion Cinder/Mitaka/huawei_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _vstore_name(self, xml_root):

def _set_extra_constants_by_product(self, product):
extra_constants = {}
if product == 'Dorado':
if product in constants.DORADO_V6_AND_V6_PRODUCT:
extra_constants['QOS_SPEC_KEYS'] = (
'maxIOPS', 'maxBandWidth', 'IOType')
extra_constants['QOS_IOTYPES'] = ('2',)
Expand Down
465 changes: 268 additions & 197 deletions Cinder/Mitaka/huawei_driver.py

Large diffs are not rendered by default.

90 changes: 51 additions & 39 deletions Cinder/Mitaka/hypermetro.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,52 +118,38 @@ def _create_hypermetro_pair(self, domain_id, lun_id, remote_lun_id,

return self.client.create_hypermetro(hcp_param)

def connect_volume_fc(self, volume, connector):
"""Create map between a volume and a host for FC."""
wwns = connector['wwpns']
LOG.info(_LI(
'initialize_connection_fc, initiator: %(wwpns)s,'
'volume id: %(id)s.'),
{'wwpns': wwns,
'id': volume.id})

lun_id, _ = huawei_utils.get_volume_lun_id(self.rmt_client, volume)
if not lun_id:
msg = _("Can't get volume id. Volume name: %s.") % volume.id
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
def _check_fc_links(self, host_id, wwns,
online_wwns_in_host, online_free_wwns):
wwns_final = []
for wwn in wwns:
if wwn in online_wwns_in_host or wwn in online_free_wwns:
wwns_final.append(wwn)
continue

original_host_name = connector['host']
lun_info = self.rmt_client.get_lun_info(lun_id)
# Create hostgroup if not exist.
host_id = self.rmt_client.add_host_with_check(original_host_name,
self.is_dorado_v6,
wwns)
if (self.configuration.min_fc_ini_online ==
constants.DEFAULT_MINIMUM_FC_INITIATOR_ONLINE):
wwns_in_host = (
self.rmt_client.get_host_fc_initiators(host_id))
iqns_in_host = (
self.rmt_client.get_host_iscsi_initiators(host_id))
if not (wwns_in_host or iqns_in_host):
self.rmt_client.remove_host(host_id)
msg = (("Can't add FC initiator %(wwn)s to host %(host)s,"
" please check if this initiator has been added "
"to other host or isn't present on array.")
% {"wwn": wwn, "host": host_id})
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
return wwns_final

def _get_connect_map_info(self, host_id, wwns, connector):
online_wwns_in_host = (
self.rmt_client.get_host_online_fc_initiators(host_id))
online_free_wwns = self.rmt_client.get_online_free_wwns()
fc_initiators_on_array = self.rmt_client.get_fc_initiator_on_array()
wwns = [i for i in wwns if i in fc_initiators_on_array]
for wwn in wwns:
if (wwn not in online_wwns_in_host
and wwn not in online_free_wwns):
wwns.remove(wwn)

if (self.configuration.min_fc_ini_online ==
constants.DEFAULT_MINIMUM_FC_INITIATOR_ONLINE):
wwns_in_host = (
self.rmt_client.get_host_fc_initiators(host_id))
iqns_in_host = (
self.rmt_client.get_host_iscsi_initiators(host_id))
if not (wwns_in_host or iqns_in_host):
self.rmt_client.remove_host(host_id)
msg = (("Can't add FC initiator %(wwn)s to host %(host)s,"
" please check if this initiator has been added "
"to other host or isn't present on array.")
% {"wwn": wwn, "host": host_id})
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
wwns = self._check_fc_links(host_id, wwns,
online_wwns_in_host, online_free_wwns)

if len(wwns) < self.configuration.min_fc_ini_online:
msg = (("The number of online fc initiator %(wwns)s less than"
Expand All @@ -179,6 +165,32 @@ def connect_volume_fc(self, volume, connector):

(tgt_port_wwns, init_targ_map) = (
self.rmt_client.get_init_targ_map(wwns))
return tgt_port_wwns, init_targ_map

def connect_volume_fc(self, volume, connector):
"""Create map between a volume and a host for FC."""
wwns = connector['wwpns']
LOG.info(_LI(
'initialize_connection_fc, initiator: %(wwpns)s,'
'volume id: %(id)s.'),
{'wwpns': wwns,
'id': volume.id})

lun_id, _ = huawei_utils.get_volume_lun_id(self.rmt_client, volume)
if not lun_id:
msg = _("Can't get volume id. Volume id: %s.") % volume.id
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)

original_host_name = connector['host']
lun_info = self.rmt_client.get_lun_info(lun_id)
# Create hostgroup if not exist.
host_id = self.rmt_client.add_host_with_check(original_host_name,
self.is_dorado_v6,
wwns)

(tgt_port_wwns, init_targ_map) = \
self._get_connect_map_info(host_id, wwns, connector)

# Add host into hostgroup.
hostgroup_id = self.rmt_client.add_host_to_hostgroup(host_id)
Expand Down
2 changes: 1 addition & 1 deletion Cinder/Ocata-eol/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Version: 2.2.4"""
"""Version: 2.3.RC4"""
17 changes: 17 additions & 0 deletions Cinder/Ocata-eol/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,20 @@
SUPPORT_CLONE_PAIR_VERSION = "V600R003C00"

DEFAULT_MINIMUM_FC_INITIATOR_ONLINE = 0

INBAND_LUN_TYPE = '5'

SNAPSHOT_HEALTH_STATUS = (
SNAPSHOT_HEALTH_STATUS_NORMAL,
SNAPSHOT_HEALTH_STATUS_FAULTY) = ('1', '2')
SNAPSHOT_RUNNING_STATUS = (
SNAPSHOT_RUNNING_STATUS_ACTIVATED,
SNAPSHOT_RUNNING_STATUS_ROLLINGBACK) = ('43', '44')
SNAPSHOT_ROLLBACK_PROGRESS_FINISH = '100'
SNAPSHOT_ROLLBACK_SPEED_TYPES = (
SNAPSHOT_ROLLBACK_SPEED_LOW,
SNAPSHOT_ROLLBACK_SPEED_MEDIUM,
SNAPSHOT_ROLLBACK_SPEED_HIGH,
SNAPSHOT_ROLLBACK_SPEED_HIGHEST
) = ('1', '2', '3', '4')
SNAPSHOT_ROLLBACK_NOT_END = '-1'
52 changes: 51 additions & 1 deletion Cinder/Ocata-eol/huawei_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def update_config_value(self):
self._lun_copy_mode,
self._hyper_pair_sync_speed,
self._replication_pair_sync_speed,
self._get_local_minimum_fc_initiator,)
self._get_local_minimum_fc_initiator,
self._get_local_in_band_or_not,
self._get_local_storage_sn,
self._rollback_speed,)

tree = ET.parse(self.conf.cinder_huawei_conf_file)
xml_root = tree.getroot()
Expand Down Expand Up @@ -464,6 +467,10 @@ def get_hypermetro_devices(self):
dev_config['metro_sync_completed'] = (
dev['metro_sync_completed']
if 'metro_sync_completed' in dev else "True")
dev_config['in_band_or_not'] = (
dev['in_band_or_not'].lower() == 'true'
if 'in_band_or_not' in dev else False)
dev_config['storage_sn'] = dev.get('storage_sn')
devs_config.append(dev_config)

return devs_config
Expand All @@ -490,6 +497,10 @@ def get_replication_devices(self):
dev['iscsi_default_target_ip'].split(';')
if 'iscsi_default_target_ip' in dev
else [])
dev_config['in_band_or_not'] = (
dev['in_band_or_not'].lower() == 'true'
if 'in_band_or_not' in dev else False)
dev_config['storage_sn'] = dev.get('storage_sn')
devs_config.append(dev_config)

return devs_config
Expand All @@ -505,6 +516,8 @@ def get_local_device(self):
'iscsi_info': self.conf.iscsi_info,
'fc_info': self.conf.fc_info,
'iscsi_default_target_ip': self.conf.iscsi_default_target_ip,
'in_band_or_not': self.conf.in_band_or_not,
'storage_sn': self.conf.storage_sn,
}
return dev_config

Expand Down Expand Up @@ -591,3 +604,40 @@ def _get_local_minimum_fc_initiator(self, xml_root):
LOG.error(msg)
raise exception.InvalidInput(reason=msg)
setattr(self.conf, 'min_fc_ini_online', minimum_fc_initiator)

def _get_local_in_band_or_not(self, xml_root):
in_band_or_not = False
text = xml_root.findtext('Storage/InBandOrNot')
if text:
if text.lower() in ('true', 'false'):
in_band_or_not = text.lower() == 'true'
else:
msg = _("InBandOrNot configured error.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)

setattr(self.conf, 'in_band_or_not', in_band_or_not)

def _get_local_storage_sn(self, xml_root):
text = xml_root.findtext('Storage/Storagesn')
storage_sn = text.strip() if text else None

setattr(self.conf, 'storage_sn', storage_sn)

def _rollback_speed(self, xml_root):
text = xml_root.findtext('LUN/SnapshotRollbackSpeed')
if text and text.strip() not in constants.SNAPSHOT_ROLLBACK_SPEED_TYPES:
msg = (_("Invalid SnapshotRollbackSpeed '%(text)s', "
"SnapshotRollbackSpeed must "
"be between %(low)s and %(high)s.")
% {"text": text,
"low": constants.SNAPSHOT_ROLLBACK_SPEED_LOW,
"high": constants.SNAPSHOT_ROLLBACK_SPEED_HIGHEST})
LOG.error(msg)
raise exception.InvalidInput(reason=msg)

if not text:
speed = constants.SNAPSHOT_ROLLBACK_SPEED_HIGH
else:
speed = text.strip()
setattr(self.conf, 'rollback_speed', int(speed))
Loading

0 comments on commit 80fd8fb

Please sign in to comment.