Skip to content

Commit

Permalink
Ocata Support Dorado V6 fastclone && Support Ussuri
Browse files Browse the repository at this point in the history
  • Loading branch information
doubletao318 committed Sep 30, 2020
1 parent 181c210 commit 1cf0753
Show file tree
Hide file tree
Showing 15 changed files with 7,502 additions and 16 deletions.
30 changes: 16 additions & 14 deletions Cinder/Ocata/huawei_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ def _add_extend_type_to_volume(self, volume, volume_type, opts, lun_params,
def _create_volume_from_src(self, volume, src_obj, src_type, lun_params,
clone_pair_flag=None):
metadata = huawei_utils.get_volume_metadata(volume)
expect_size = int(volume.size) * constants.CAPACITY_UNIT
if (strutils.bool_from_string(metadata.get('fastclone')) or
(metadata.get('fastclone') is None and
self.configuration.clone_mode == "fastclone")):
Expand All @@ -517,7 +518,8 @@ def _create_volume_from_src(self, volume, src_obj, src_type, lun_params,
src_id = self._check_snapshot_exist_on_array(
src_obj, constants.SNAPSHOT_NOT_EXISTS_RAISE)

lun_info = self._create_volume_by_clone(src_id, lun_params)
lun_info = self._create_volume_by_clone(
src_id, lun_params, expect_size, clone_pair_flag)
elif clone_pair_flag:
clone_speed = self.configuration.lun_copy_speed
if src_type == objects.Volume:
Expand Down Expand Up @@ -570,7 +572,6 @@ def _create_volume_from_src(self, volume, src_obj, src_type, lun_params,
self._delete_snapshot(src_id)

try:
expect_size = int(volume.size) * constants.CAPACITY_UNIT
if int(lun_info['CAPACITY']) < expect_size:
self.client.extend_lun(lun_info["ID"], expect_size)
lun_info = self.client.get_lun_info(lun_info["ID"])
Expand Down Expand Up @@ -598,15 +599,18 @@ def _delete_snapshot(self, snapshot_id):
self.client.stop_snapshot(snapshot_id)
self.client.delete_snapshot(snapshot_id)

def _create_volume_by_clone(self, src_id, lun_params):
def _create_volume_by_clone(self, src_id, lun_params, expected_size,
clone_pair_flag):
LOG.info('Create volume %s by clone from source %s.',
lun_params['NAME'], src_id)

lun_info = self.client.create_clone_lun(src_id, lun_params['NAME'])
lun_id = lun_info['ID']

try:
expected_size = int(lun_params['CAPACITY'])
if clone_pair_flag:
self.client.stop_clone_pair(lun_id)

if int(lun_info['CAPACITY']) < expected_size:
self.client.extend_lun(lun_id, expected_size)

Expand Down Expand Up @@ -815,11 +819,10 @@ def delete_volume(self, volume):
if not lun_id:
return

if self.support_func.get('QoS_support'):
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)

self._delete_volume(volume, lun_id)

Expand All @@ -828,11 +831,10 @@ def _delete_lun_with_check(self, lun_id, lun_wwn=None):
return

if self.client.check_lun_exist(lun_id, lun_wwn):
if self.support_func.get('QoS_support'):
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)

self.client.delete_lun(lun_id)

Expand Down
11 changes: 9 additions & 2 deletions Cinder/Ocata/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2754,8 +2754,15 @@ def sync_clone_pair(self, pair_id):
url = "/clonepair/synchronize"
data = {"ID": pair_id, "copyAction": 0}
result = self.call(url, data, "PUT")
self._assert_rest_result(result, 'Sync ClonePair error, pair is '
'is %s.' % pair_id)
self._assert_rest_result(result, 'Sync ClonePair error, pair is %s.'
% pair_id)

def stop_clone_pair(self, pair_id):
url = "/clonepair/synchronize"
data = {"ID": pair_id, "copyAction": 2}
result = self.call(url, data, "PUT")
self._assert_rest_result(
result, 'Stop ClonePair error, pair is %s.' % pair_id)

def get_clone_pair_info(self, pair_id):
url = "/clonepair/%s" % pair_id
Expand Down
1 change: 1 addition & 0 deletions Cinder/Ussuri/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Version: 2.2.4"""
165 changes: 165 additions & 0 deletions Cinder/Ussuri/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# Copyright (c) 2016 Huawei Technologies Co., Ltd.
# 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.

STATUS_INITIALIZE = '0'
STATUS_HEALTH = '1'
LUN_TYPE = '11'
SNAPSHOT_TYPE = '27'
BLOCK_POOL_TYPE = '1'
DORADO_V6_POOL_TYPE = '0'

HOSTGROUP_PREFIX = 'OpenStack_HostGroup_'
LUNGROUP_PREFIX = 'OpenStack_LunGroup_'
MAPPING_VIEW_PREFIX = 'OpenStack_Mapping_View_'
PORTGROUP_PREFIX = 'OpenStack_PortGroup_'
QOS_NAME_PREFIX = 'OpenStack_'

FC_PORT_CONNECTED = '10'
CAPACITY_UNIT = 1024 * 1024 * 2
DEFAULT_WAIT_TIMEOUT = 3600 * 24 * 30
DEFAULT_WAIT_INTERVAL = 5
MAX_NAME_LENGTH = 31
SOCKET_TIMEOUT = 52
LOGIN_SOCKET_TIMEOUT = 4
PWD_EXPIRED_OR_INITIAL = (3, 4)

LUN_STATUS = (LUN_ONLINE, LUN_INITIALIZING, LUN_OFFLINE) = ('27', '53', '28')
SNAPSHOT_STATUS = (
SNAPSHOT_INITIALIZING, SNAPSHOT_ACTIVATED, SNAPSHOT_UNACTIVATED
) = ('53', '43', '45')

MIGRATION_STATUS_IN_PROCESS = (
MIGRATION_NORMAL, MIGRATION_QUEUING, MIGRATION_MIGRATING
) = ('1', '37', '75')
MIGRATION_STATUS_COMPLETE = (MIGRATION_COMPLETE,) = ('76',)
LUNCOPY_STATUS_COMPLETE = (LUNCOPY_COMPLETE,) = ('40',)

ERROR_CONNECT_TO_SERVER = -403
ERROR_UNAUTHORIZED_TO_SERVER = -401
OBJECT_NAME_ALREADY_EXIST = 1077948993
OBJECT_ID_NOT_UNIQUE = 1077948997
ERROR_VOLUME_NOT_EXIST = 1077939726
ERROR_LUN_NOT_EXIST = 1077936859
SNAPSHOT_NOT_EXIST = 1077937880
OBJECT_NOT_EXIST = 1077948996
HYPERMETRO_NOT_EXIST = 1077674242
HYPERMETRO_NOT_IN_GROUP = 1077675021
HYPERMETROGROUP_NOT_EXIST = 1077675010
HYPERMETRO_ALREADY_IN_GROUP = 1077675038
NO_HYPERMETRO_EXIST_IN_GROUP = 1077675022
HOSTGROUP_NOT_IN_MAPPINGVIEW = 1073804552
PORTGROUP_NOT_IN_MAPPINGVIEW = 1073804553
LUNGROUP_NOT_IN_MAPPINGVIEW = 1073804554
MIGRATION_NOT_EXIST = 1073806607
LUNCOPY_NOT_EXIST = 50338560
LUNCOPY_ALREADY_STOPPED = 1077950178
LUNCOPY_COMPLETED = 1077950180
PORTGROUP_NOT_EXIST = 1077951832
HOSTGROUP_NOT_EXIST = 1077937500
HOST_NOT_IN_HOSTGROUP = 1073745412
PORT_NOT_IN_PORTGROUP = 1073807618
INITIATOR_NOT_IN_HOST = 1077950342
HOST_NOT_EXIST = 1077937498
MAPPINGVIEW_NOT_EXIST = 1077951819
HOST_ALREADY_IN_HOSTGROUP = 1077937501
PORT_ALREADY_IN_PORTGROUP = 1077951833
HOSTGROUP_ALREADY_IN_MAPPINGVIEW = 1073804556
PORTGROUP_ALREADY_IN_MAPPINGVIEW = 1073804558
LUNGROUP_ALREADY_IN_MAPPINGVIEW = 1073804560

METRO_RUNNING_STATUS = (METRO_RUNNING_NORMAL, METRO_RUNNING_SYNC,
METRO_RUNNING_STOP, RUNNING_TO_BE_SYNC
) = ('1', '23', '41', '100')
METRO_HEALTH_NORMAL = '1'

THICK_LUNTYPE = '0'
THIN_LUNTYPE = '1'
LUN_TYPE_MAP = {'Thick': THICK_LUNTYPE,
'Thin': THIN_LUNTYPE}

QOS_INACTIVATED = '45'
LOWER_LIMIT_KEYS = ('MINIOPS', 'LATENCY', 'MINBANDWIDTH')
UPPER_LIMIT_KEYS = ('MAXIOPS', 'MAXBANDWIDTH')

REPLICA_SYNC_MODEL = '1'
REPLICA_ASYNC_MODEL = '2'
REPLICA_SPEED = '2'
REPLICA_PERIOD = '3600'
REPLICA_SECOND_RO = '2'
REPLICA_SECOND_RW = '3'
REPLICA_CG_PERIOD = '60'

REPLICA_RUNNING_STATUS_SYNC = '23'
REPLICA_RUNNING_STATUS_NORMAL = '1'
REPLICA_RUNNING_STATUS_SPLIT = '26'
REPLICA_RUNNING_STATUS_INTERRUPTED = '34'
REPLICA_SECRES_DATA_SYNC = '1'
REPLICA_SECRES_DATA_COMPLETE = '2'
REPLICA_HEALTH_STATUS_NORMAL = '1'

REPLICATION_PAIR_NOT_EXIST = 1077937923
REPLICATION_GROUP_NOT_EXIST = 1077937924
REPLICATION_PAIR_NOT_GROUP_MEMBER = 1077937927
REPLICATION_GROUP_IS_EMPTY = 1077937960

VALID_PRODUCT = ('V3', 'V5', '18000', 'Dorado')
TIER_DISK_TYPES = ('ssd', 'sas', 'nl_sas')

AVAILABLE_FEATURE_STATUS = (1, 2)
CHECK_FEATURES = {
'SmartTier': None,
'SmartThin': None,
'SmartQoS': 'ioclass',
'SmartPartition': 'cachepartition',
'SmartCache': 'smartcachepartition',
'SmartMigration': 'LUN_MIGRATION',
'HyperMetro': 'HyperMetroPair',
'HyperReplication': 'REPLICATIONPAIR',
'HyperSnap': 'snapshot',
'HyperCopy': 'LUNCOPY',
'SmartDedupe[\s\S]*LUN': None,
'SmartCompression[\s\S]*LUN': None,
'Effective Capacity': None,
}

LUN_COPY_SPEED_TYPES = (
LUN_COPY_SPEED_LOW,
LUN_COPY_SPEED_MEDIUM,
LUN_COPY_SPEED_HIGH,
LUN_COPY_SPEED_HIGHEST
) = ('1', '2', '3', '4')
DEFAULT_CLONE_MODE = "luncopy"

HYPER_SYNC_SPEED_TYPES = (
HYPER_SYNC_SPEED_LOW,
HYPER_SYNC_SPEED_MEDIUM,
HYPER_SYNC_SPEED_HIGH,
HYPER_SYNC_SPEED_HIGHEST
) = ('1', '2', '3', '4')

REPLICA_SYNC_SPEED_TYPES = (
REPLICA_SYNC_SPEED_LOW,
REPLICA_SYNC_SPEED_MEDIUM,
REPLICA_SYNC_SPEED_HIGH,
REPLICA_SYNC_SPEED_HIGHEST
) = ('1', '2', '3', '4')

CLONE_STATUS_HEALTH = '0'
CLONE_STATUS_COMPLETE = (CLONE_COMPLETE,) = ('2',)
CLONE_PAIR_NOT_EXIST = "1073798147"
SUPPORT_CLONE_PAIR_VERSION = "V600R003C00"
GET_PATCH_NUM = 100

DEFAULT_MINIMUM_FC_INITIATOR_ONLINE = 0
Loading

0 comments on commit 1cf0753

Please sign in to comment.