Skip to content

Commit 80fd8fb

Browse files
authored
Merge pull request #30 from yunqifeng/master
update huawei driver for openstack
2 parents 8c94f6f + 531f606 commit 80fd8fb

File tree

143 files changed

+14281
-788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+14281
-788
lines changed

Cinder/Mitaka/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"""Version: 2.3.RC3"""
1+
"""Version: 2.3.RC4"""

Cinder/Mitaka/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@
139139
LUN_TYPE_MAP = {'Thick': THICK_LUNTYPE,
140140
'Thin': THIN_LUNTYPE}
141141

142-
VALID_PRODUCT = ['T', 'TV2', 'V3', 'V5', '18000', 'Dorado']
142+
VALID_PRODUCT = ['T', 'TV2', 'V3', 'V5', '18000', 'Dorado', 'V6']
143143
VALID_PROTOCOL = ['FC', 'iSCSI']
144144
VALID_WRITE_TYPE = ['1', '2']
145145
VOLUME_NOT_EXISTS_WARN = 'warning'
146146
VOLUME_NOT_EXISTS_RAISE = 'raise'
147+
DORADO_V6_AND_V6_PRODUCT = ('Dorado', 'V6')
147148

148149
LUN_COPY_SPEED_TYPES = (
149150
LUN_COPY_SPEED_LOW,

Cinder/Mitaka/huawei_conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def _vstore_name(self, xml_root):
161161

162162
def _set_extra_constants_by_product(self, product):
163163
extra_constants = {}
164-
if product == 'Dorado':
164+
if product in constants.DORADO_V6_AND_V6_PRODUCT:
165165
extra_constants['QOS_SPEC_KEYS'] = (
166166
'maxIOPS', 'maxBandWidth', 'IOType')
167167
extra_constants['QOS_IOTYPES'] = ('2',)

Cinder/Mitaka/huawei_driver.py

Lines changed: 268 additions & 197 deletions
Large diffs are not rendered by default.

Cinder/Mitaka/hypermetro.py

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -118,52 +118,38 @@ def _create_hypermetro_pair(self, domain_id, lun_id, remote_lun_id,
118118

119119
return self.client.create_hypermetro(hcp_param)
120120

121-
def connect_volume_fc(self, volume, connector):
122-
"""Create map between a volume and a host for FC."""
123-
wwns = connector['wwpns']
124-
LOG.info(_LI(
125-
'initialize_connection_fc, initiator: %(wwpns)s,'
126-
'volume id: %(id)s.'),
127-
{'wwpns': wwns,
128-
'id': volume.id})
129-
130-
lun_id, _ = huawei_utils.get_volume_lun_id(self.rmt_client, volume)
131-
if not lun_id:
132-
msg = _("Can't get volume id. Volume name: %s.") % volume.id
133-
LOG.error(msg)
134-
raise exception.VolumeBackendAPIException(data=msg)
121+
def _check_fc_links(self, host_id, wwns,
122+
online_wwns_in_host, online_free_wwns):
123+
wwns_final = []
124+
for wwn in wwns:
125+
if wwn in online_wwns_in_host or wwn in online_free_wwns:
126+
wwns_final.append(wwn)
127+
continue
135128

136-
original_host_name = connector['host']
137-
lun_info = self.rmt_client.get_lun_info(lun_id)
138-
# Create hostgroup if not exist.
139-
host_id = self.rmt_client.add_host_with_check(original_host_name,
140-
self.is_dorado_v6,
141-
wwns)
129+
if (self.configuration.min_fc_ini_online ==
130+
constants.DEFAULT_MINIMUM_FC_INITIATOR_ONLINE):
131+
wwns_in_host = (
132+
self.rmt_client.get_host_fc_initiators(host_id))
133+
iqns_in_host = (
134+
self.rmt_client.get_host_iscsi_initiators(host_id))
135+
if not (wwns_in_host or iqns_in_host):
136+
self.rmt_client.remove_host(host_id)
137+
msg = (("Can't add FC initiator %(wwn)s to host %(host)s,"
138+
" please check if this initiator has been added "
139+
"to other host or isn't present on array.")
140+
% {"wwn": wwn, "host": host_id})
141+
LOG.error(msg)
142+
raise exception.VolumeBackendAPIException(data=msg)
143+
return wwns_final
142144

145+
def _get_connect_map_info(self, host_id, wwns, connector):
143146
online_wwns_in_host = (
144147
self.rmt_client.get_host_online_fc_initiators(host_id))
145148
online_free_wwns = self.rmt_client.get_online_free_wwns()
146149
fc_initiators_on_array = self.rmt_client.get_fc_initiator_on_array()
147150
wwns = [i for i in wwns if i in fc_initiators_on_array]
148-
for wwn in wwns:
149-
if (wwn not in online_wwns_in_host
150-
and wwn not in online_free_wwns):
151-
wwns.remove(wwn)
152-
153-
if (self.configuration.min_fc_ini_online ==
154-
constants.DEFAULT_MINIMUM_FC_INITIATOR_ONLINE):
155-
wwns_in_host = (
156-
self.rmt_client.get_host_fc_initiators(host_id))
157-
iqns_in_host = (
158-
self.rmt_client.get_host_iscsi_initiators(host_id))
159-
if not (wwns_in_host or iqns_in_host):
160-
self.rmt_client.remove_host(host_id)
161-
msg = (("Can't add FC initiator %(wwn)s to host %(host)s,"
162-
" please check if this initiator has been added "
163-
"to other host or isn't present on array.")
164-
% {"wwn": wwn, "host": host_id})
165-
LOG.error(msg)
166-
raise exception.VolumeBackendAPIException(data=msg)
151+
wwns = self._check_fc_links(host_id, wwns,
152+
online_wwns_in_host, online_free_wwns)
167153

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

180166
(tgt_port_wwns, init_targ_map) = (
181167
self.rmt_client.get_init_targ_map(wwns))
168+
return tgt_port_wwns, init_targ_map
169+
170+
def connect_volume_fc(self, volume, connector):
171+
"""Create map between a volume and a host for FC."""
172+
wwns = connector['wwpns']
173+
LOG.info(_LI(
174+
'initialize_connection_fc, initiator: %(wwpns)s,'
175+
'volume id: %(id)s.'),
176+
{'wwpns': wwns,
177+
'id': volume.id})
178+
179+
lun_id, _ = huawei_utils.get_volume_lun_id(self.rmt_client, volume)
180+
if not lun_id:
181+
msg = _("Can't get volume id. Volume id: %s.") % volume.id
182+
LOG.error(msg)
183+
raise exception.VolumeBackendAPIException(data=msg)
184+
185+
original_host_name = connector['host']
186+
lun_info = self.rmt_client.get_lun_info(lun_id)
187+
# Create hostgroup if not exist.
188+
host_id = self.rmt_client.add_host_with_check(original_host_name,
189+
self.is_dorado_v6,
190+
wwns)
191+
192+
(tgt_port_wwns, init_targ_map) = \
193+
self._get_connect_map_info(host_id, wwns, connector)
182194

183195
# Add host into hostgroup.
184196
hostgroup_id = self.rmt_client.add_host_to_hostgroup(host_id)

Cinder/Ocata-eol/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"""Version: 2.2.4"""
1+
"""Version: 2.3.RC4"""

Cinder/Ocata-eol/constants.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,20 @@
193193
SUPPORT_CLONE_PAIR_VERSION = "V600R003C00"
194194

195195
DEFAULT_MINIMUM_FC_INITIATOR_ONLINE = 0
196+
197+
INBAND_LUN_TYPE = '5'
198+
199+
SNAPSHOT_HEALTH_STATUS = (
200+
SNAPSHOT_HEALTH_STATUS_NORMAL,
201+
SNAPSHOT_HEALTH_STATUS_FAULTY) = ('1', '2')
202+
SNAPSHOT_RUNNING_STATUS = (
203+
SNAPSHOT_RUNNING_STATUS_ACTIVATED,
204+
SNAPSHOT_RUNNING_STATUS_ROLLINGBACK) = ('43', '44')
205+
SNAPSHOT_ROLLBACK_PROGRESS_FINISH = '100'
206+
SNAPSHOT_ROLLBACK_SPEED_TYPES = (
207+
SNAPSHOT_ROLLBACK_SPEED_LOW,
208+
SNAPSHOT_ROLLBACK_SPEED_MEDIUM,
209+
SNAPSHOT_ROLLBACK_SPEED_HIGH,
210+
SNAPSHOT_ROLLBACK_SPEED_HIGHEST
211+
) = ('1', '2', '3', '4')
212+
SNAPSHOT_ROLLBACK_NOT_END = '-1'

Cinder/Ocata-eol/huawei_conf.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ def update_config_value(self):
9292
self._lun_copy_mode,
9393
self._hyper_pair_sync_speed,
9494
self._replication_pair_sync_speed,
95-
self._get_local_minimum_fc_initiator,)
95+
self._get_local_minimum_fc_initiator,
96+
self._get_local_in_band_or_not,
97+
self._get_local_storage_sn,
98+
self._rollback_speed,)
9699

97100
tree = ET.parse(self.conf.cinder_huawei_conf_file)
98101
xml_root = tree.getroot()
@@ -464,6 +467,10 @@ def get_hypermetro_devices(self):
464467
dev_config['metro_sync_completed'] = (
465468
dev['metro_sync_completed']
466469
if 'metro_sync_completed' in dev else "True")
470+
dev_config['in_band_or_not'] = (
471+
dev['in_band_or_not'].lower() == 'true'
472+
if 'in_band_or_not' in dev else False)
473+
dev_config['storage_sn'] = dev.get('storage_sn')
467474
devs_config.append(dev_config)
468475

469476
return devs_config
@@ -490,6 +497,10 @@ def get_replication_devices(self):
490497
dev['iscsi_default_target_ip'].split(';')
491498
if 'iscsi_default_target_ip' in dev
492499
else [])
500+
dev_config['in_band_or_not'] = (
501+
dev['in_band_or_not'].lower() == 'true'
502+
if 'in_band_or_not' in dev else False)
503+
dev_config['storage_sn'] = dev.get('storage_sn')
493504
devs_config.append(dev_config)
494505

495506
return devs_config
@@ -505,6 +516,8 @@ def get_local_device(self):
505516
'iscsi_info': self.conf.iscsi_info,
506517
'fc_info': self.conf.fc_info,
507518
'iscsi_default_target_ip': self.conf.iscsi_default_target_ip,
519+
'in_band_or_not': self.conf.in_band_or_not,
520+
'storage_sn': self.conf.storage_sn,
508521
}
509522
return dev_config
510523

@@ -591,3 +604,40 @@ def _get_local_minimum_fc_initiator(self, xml_root):
591604
LOG.error(msg)
592605
raise exception.InvalidInput(reason=msg)
593606
setattr(self.conf, 'min_fc_ini_online', minimum_fc_initiator)
607+
608+
def _get_local_in_band_or_not(self, xml_root):
609+
in_band_or_not = False
610+
text = xml_root.findtext('Storage/InBandOrNot')
611+
if text:
612+
if text.lower() in ('true', 'false'):
613+
in_band_or_not = text.lower() == 'true'
614+
else:
615+
msg = _("InBandOrNot configured error.")
616+
LOG.error(msg)
617+
raise exception.InvalidInput(reason=msg)
618+
619+
setattr(self.conf, 'in_band_or_not', in_band_or_not)
620+
621+
def _get_local_storage_sn(self, xml_root):
622+
text = xml_root.findtext('Storage/Storagesn')
623+
storage_sn = text.strip() if text else None
624+
625+
setattr(self.conf, 'storage_sn', storage_sn)
626+
627+
def _rollback_speed(self, xml_root):
628+
text = xml_root.findtext('LUN/SnapshotRollbackSpeed')
629+
if text and text.strip() not in constants.SNAPSHOT_ROLLBACK_SPEED_TYPES:
630+
msg = (_("Invalid SnapshotRollbackSpeed '%(text)s', "
631+
"SnapshotRollbackSpeed must "
632+
"be between %(low)s and %(high)s.")
633+
% {"text": text,
634+
"low": constants.SNAPSHOT_ROLLBACK_SPEED_LOW,
635+
"high": constants.SNAPSHOT_ROLLBACK_SPEED_HIGHEST})
636+
LOG.error(msg)
637+
raise exception.InvalidInput(reason=msg)
638+
639+
if not text:
640+
speed = constants.SNAPSHOT_ROLLBACK_SPEED_HIGH
641+
else:
642+
speed = text.strip()
643+
setattr(self.conf, 'rollback_speed', int(speed))

0 commit comments

Comments
 (0)