Skip to content

Commit

Permalink
Merge pull request #35 from bingyanh/master
Browse files Browse the repository at this point in the history
update huawei driver for openstack
  • Loading branch information
yunqifeng authored Jul 18, 2022
2 parents 6a9aec3 + e51696c commit 4045c25
Show file tree
Hide file tree
Showing 112 changed files with 13,866 additions and 210 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.RC4"""
"""Version: 2.5.RC1"""
12 changes: 7 additions & 5 deletions Cinder/Mitaka/huawei_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

import base64
import re
import six
from xml.etree import ElementTree as ET

from oslo_log import log as logging
from lxml import etree as ET
import six

from cinder import exception
from cinder.i18n import _
Expand All @@ -41,7 +41,8 @@ def __init__(self, conf):

def _encode_authentication(self):
need_encode = False
tree = ET.parse(self.conf.cinder_huawei_conf_file)
tree = ET.parse(self.conf.cinder_huawei_conf_file,
ET.XMLParser(resolve_entities=False))
xml_root = tree.getroot()
name_node = xml_root.find('Storage/UserName')
pwd_node = xml_root.find('Storage/UserPassword')
Expand All @@ -64,7 +65,7 @@ def _encode_authentication(self):
'600',
self.conf.cinder_huawei_conf_file,
run_as_root=True)
tree.write(self.conf.cinder_huawei_conf_file, 'UTF-8')
tree.write(self.conf.cinder_huawei_conf_file, encoding='UTF-8')

def update_config_value(self):
self._encode_authentication()
Expand Down Expand Up @@ -95,7 +96,8 @@ def update_config_value(self):
self._get_local_minimum_fc_initiator,
self._hyper_enforce_multipath)

tree = ET.parse(self.conf.cinder_huawei_conf_file)
tree = ET.parse(self.conf.cinder_huawei_conf_file,
ET.XMLParser(resolve_entities=False))
xml_root = tree.getroot()
for f in set_attr_funcs:
f(xml_root)
Expand Down
2 changes: 0 additions & 2 deletions Cinder/Mitaka/replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,6 @@ def unprotect_second(self, replica_id):
self.wait_second_access(replica_id, constants.REPLICA_SECOND_RW)

def sync(self, replica_id, wait_complete=False):
self.protect_second(replica_id)

expect_status = (constants.REPLICA_RUNNING_STATUS_NORMAL,
constants.REPLICA_RUNNING_STATUS_SYNC,
constants.REPLICA_RUNNING_STATUS_INITIAL_SYNC)
Expand Down
11 changes: 6 additions & 5 deletions Cinder/Mitaka/ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

import base64
import re
import six
import socket
import threading
import time
from xml.etree import ElementTree as ET

from lxml import etree as ET
from oslo_log import log as logging
from oslo_utils import excutils
import six

from cinder import context
from cinder import exception
Expand Down Expand Up @@ -160,7 +160,8 @@ def check_storage_pools(self):
def parse_xml_file(self, xml_file_path):
"""Get root of xml file."""
try:
tree = ET.parse(xml_file_path)
tree = ET.parse(xml_file_path,
ET.XMLParser(resolve_entities=False))
root = tree.getroot()
return root
except IOError as err:
Expand Down Expand Up @@ -287,7 +288,7 @@ def _get_login_info(self):
"""Get login IP, username and password from config file."""
logininfo = {}
filename = self.configuration.cinder_huawei_conf_file
tree = ET.parse(filename)
tree = ET.parse(filename, ET.XMLParser(resolve_entities=False))
root = tree.getroot()
logininfo['ControllerIP0'] = (
root.findtext('Storage/ControllerIP0').strip())
Expand All @@ -314,7 +315,7 @@ def _get_login_info(self):
if need_encode:
self._change_file_mode(filename)
try:
tree.write(filename, 'UTF-8')
tree.write(filename, encoding='UTF-8')
except Exception as err:
LOG.info(_LI('_get_login_info: %s'), err)

Expand Down
2 changes: 1 addition & 1 deletion Cinder/Queens-eol/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Version: 2.3.RC1"""
"""Version: 2.5.RC1"""
3 changes: 2 additions & 1 deletion Cinder/Queens-eol/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
14 changes: 8 additions & 6 deletions Cinder/Queens-eol/huawei_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

import base64
import re
import six
from xml.etree import ElementTree as ET

from lxml import etree as ET
from oslo_log import log as logging
import six

from cinder import exception
from cinder.i18n import _
Expand All @@ -41,7 +41,8 @@ def __init__(self, conf):

def _encode_authentication(self):
need_encode = False
tree = ET.parse(self.conf.cinder_huawei_conf_file)
tree = ET.parse(self.conf.cinder_huawei_conf_file,
ET.XMLParser(resolve_entities=False))
xml_root = tree.getroot()
name_node = xml_root.find('Storage/UserName')
pwd_node = xml_root.find('Storage/UserPassword')
Expand All @@ -64,7 +65,7 @@ def _encode_authentication(self):
'600',
self.conf.cinder_huawei_conf_file,
run_as_root=True)
tree.write(self.conf.cinder_huawei_conf_file, 'UTF-8')
tree.write(self.conf.cinder_huawei_conf_file, encoding='UTF-8')

def update_config_value(self):
self._encode_authentication()
Expand Down Expand Up @@ -96,7 +97,8 @@ def update_config_value(self):
self._hyper_enforce_multipath,
self._rollback_speed)

tree = ET.parse(self.conf.cinder_huawei_conf_file)
tree = ET.parse(self.conf.cinder_huawei_conf_file,
ET.XMLParser(resolve_entities=False))
xml_root = tree.getroot()
for f in set_attr_funcs:
f(xml_root)
Expand Down Expand Up @@ -162,7 +164,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
8 changes: 8 additions & 0 deletions Cinder/Queens-eol/huawei_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ def update_support_capability(self, stats):
pool['smarttier'] = False
pool['thick_provisioning_support'] = False
pool['huawei_application_type'] = True
elif self.configuration.san_product == "V6":
pool['smarttier'] = True
pool['thick_provisioning_support'] = False
pool['huawei_application_type'] = True

pool['smarttier'] = (feature_status.get('SmartTier') in
constants.AVAILABLE_FEATURE_STATUS and
Expand Down Expand Up @@ -932,6 +936,10 @@ def update_migrated_volume(self, ctxt, volume, new_volume,
src_lun_name = str(uuid.uuid4())
src_lun_name = huawei_utils.encode_name(src_lun_name)
self.client.rename_lun(src_id, src_lun_name)
if new_metadata.get('hypermetro'):
new_rmt_lun_id, rmt_lun_wwn = huawei_utils.get_volume_lun_id(
self.rmt_client, new_volume)
self.rmt_client.rename_lun(new_rmt_lun_id, original_name, description=volume.name)
self.client.rename_lun(new_lun_id,
original_name,
description=description)
Expand Down
9 changes: 9 additions & 0 deletions Cinder/Queens-eol/huawei_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ def get_volume_lun_id(client, volume):
volume_name = old_encode_name(volume.id)
lun_id = client.get_lun_id_by_name(volume_name)

# Judge whether this volume has experienced data migration or not
if not lun_id:
volume_name = encode_name(volume.name_id)
lun_id = client.get_lun_id_by_name(volume_name)

if not lun_id:
volume_name = old_encode_name(volume.name_id)
lun_id = client.get_lun_id_by_name(volume_name)

if not lun_id:
lun_id = metadata.get('huawei_lun_id')

Expand Down
6 changes: 6 additions & 0 deletions Cinder/Queens-eol/hypermetro.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def delete_hypermetro(self, volume):
"""Delete hypermetro."""
lun_name = huawei_utils.encode_name(volume.id)
hypermetro = self.client.get_hypermetro_by_lun_name(lun_name)

# Judge whether this volume has experienced data migration or not
if not hypermetro:
lun_name = huawei_utils.encode_name(volume.name_id)
hypermetro = self.client.get_hypermetro_by_lun_name(lun_name)

if not hypermetro:
return

Expand Down
2 changes: 0 additions & 2 deletions Cinder/Queens-eol/replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,6 @@ def unprotect_second(self, replica_id):
self.wait_second_access(replica_id, constants.REPLICA_SECOND_RW)

def sync(self, replica_id, wait_complete=False):
self.protect_second(replica_id)

expect_status = (constants.REPLICA_RUNNING_STATUS_NORMAL,
constants.REPLICA_RUNNING_STATUS_SYNC,
constants.REPLICA_RUNNING_STATUS_INITIAL_SYNC)
Expand Down
11 changes: 6 additions & 5 deletions Cinder/Queens-eol/ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

import base64
import re
import six
import socket
import threading
import time
from xml.etree import ElementTree as ET

from lxml import etree as ET
from oslo_log import log as logging
from oslo_utils import excutils
import six

from cinder import context
from cinder import exception
Expand Down Expand Up @@ -157,7 +157,8 @@ def check_storage_pools(self):
def parse_xml_file(self, xml_file_path):
"""Get root of xml file."""
try:
tree = ET.parse(xml_file_path)
tree = ET.parse(xml_file_path,
ET.XMLParser(resolve_entities=False))
root = tree.getroot()
return root
except IOError as err:
Expand Down Expand Up @@ -284,7 +285,7 @@ def _get_login_info(self):
"""Get login IP, username and password from config file."""
logininfo = {}
filename = self.configuration.cinder_huawei_conf_file
tree = ET.parse(filename)
tree = ET.parse(filename, ET.XMLParser(resolve_entities=False))
root = tree.getroot()
logininfo['ControllerIP0'] = (
root.findtext('Storage/ControllerIP0').strip())
Expand All @@ -311,7 +312,7 @@ def _get_login_info(self):
if need_encode:
self._change_file_mode(filename)
try:
tree.write(filename, 'UTF-8')
tree.write(filename, encoding='UTF-8')
except Exception as err:
LOG.info('_get_login_info: %s', err)

Expand Down
1 change: 1 addition & 0 deletions Cinder/Stein-eol/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Version: 2.5.RC1"""
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@


class HuaweiBaseDriver(object):
VERSION = "2.3.RC4"
VERSION = "2.5.RC1"

def __init__(self, *args, **kwargs):
super(HuaweiBaseDriver, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -450,7 +450,8 @@ def retype(self, ctxt, volume, new_type, diff, host):
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)

new_opts = huawei_utils.get_volume_type_params(new_type)
new_opts = huawei_utils.get_volume_type_params(
new_type, self.configuration.is_dorado_v6)
if new_opts['compression'] is None:
new_opts['compression'] = (self.configuration.san_product
== "Dorado")
Expand Down Expand Up @@ -580,7 +581,8 @@ def create_group_from_src(self, context, group, volumes,
return model_update, volumes_model_update

def delete_group(self, context, group, volumes):
opts = huawei_utils.get_group_type_params(group)
opts = huawei_utils.get_group_type_params(
group, self.configuration.is_dorado_v6)

hypermetro_group = any(opt for opt in opts if opt.get('hypermetro'))
if hypermetro_group:
Expand Down Expand Up @@ -614,7 +616,8 @@ def delete_group(self, context, group, volumes):

def update_group(self, context, group,
add_volumes=None, remove_volumes=None):
opts = huawei_utils.get_group_type_params(group)
opts = huawei_utils.get_group_type_params(
group, self.configuration.is_dorado_v6)

hypermetro_group = any(opt for opt in opts if opt.get('hypermetro'))
if hypermetro_group:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"""

import base64
from defusedxml import ElementTree as ET
import os
import re
import six

from defusedxml import ElementTree as ET
from oslo_log import log as logging
import six

from cinder import exception
from cinder.i18n import _
Expand Down Expand Up @@ -105,7 +105,7 @@ def _encode_authentication(self, tree, xml_root):
need_encode = True

if need_encode:
tree.write(self.conf.cinder_huawei_conf_file, 'UTF-8')
tree.write(self.conf.cinder_huawei_conf_file, encoding='UTF-8')

def _san_address(self, xml_root):
text = xml_root.findtext('Storage/RestURL')
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ def manage_existing_snapshot(snapshot, existing_ref, local_cli):

def create_group(group, local_cli, hypermetro_rmt_cli, replication_rmt_cli,
configuration, feature_support):
opts = huawei_utils.get_group_type_params(group)
opts = huawei_utils.get_group_type_params(group, configuration.is_dorado_v6)
store_spec = {'group': group,
'opts': opts}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,10 @@ def get_volume_model_update(volume, **kwargs):
return model_update


def get_group_type_params(group):
def get_group_type_params(group, is_dorado_v6=False):
opts = []
for volume_type in group.volume_types:
opt = get_volume_type_params(volume_type)
opt = get_volume_type_params(volume_type, is_dorado_v6)
opts.append(opt)
return opts

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Cinder/Train/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Version: 2.3.RC4"""
"""Version: 2.5.RC1"""
Loading

0 comments on commit 4045c25

Please sign in to comment.