Skip to content

Commit

Permalink
Merge pull request #17 from Huawei/2.2.RC2
Browse files Browse the repository at this point in the history
2.2.RC2
  • Loading branch information
doubletao318 authored Nov 15, 2020
2 parents 1cf0753 + af844bf commit 698997d
Show file tree
Hide file tree
Showing 43 changed files with 4,178 additions and 68 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions Manila/Pike/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
ERROR_USER_OR_GROUP_NOT_EXIST = 1077939723
ERROR_REPLICATION_PAIR_NOT_EXIST = 1077937923
ERROR_HYPERMETRO_NOT_EXIST = 1077674242
LIF_ALREADY_EXISTS = 1077948993

PORT_TYPE_ETH = '1'
PORT_TYPE_BOND = '7'
Expand Down
9 changes: 9 additions & 0 deletions Manila/Pike/huawei_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ def get_logical_ips(helper):
return [i.strip() for i in config.split(';') if i.strip()]


def get_dns(helper):
root = helper._read_xml()
config = root.findtext('Storage/DNS')
if not config:
return []

return [i.strip() for i in config.split(';') if i.strip()]


def wait_fs_online(helper, fs_id, wait_interval, timeout):
def _wait_fs_online():
fs = helper._get_fs_info_by_id(fs_id)
Expand Down
24 changes: 19 additions & 5 deletions Manila/Pike/v3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, configuration, **kwargs):
self.rpc_client = v3_rpcapi.HuaweiV3API()
self.private_storage = kwargs.get('private_storage')
self.qos_support = False
self.snapshot_support = False
self.snapshot_support = True
self.replication_support = False
self.metro_domain = None
self.remote_backend = None
Expand Down Expand Up @@ -95,7 +95,10 @@ def check_storage_pools(self):
all_pool_info = self.helper._find_all_pool_info()
for pool in all_pool_info['data']:
if pool.get('USAGETYPE') in (constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE):
constants.DORADO_V6_POOL_TYPE) or \
pool.get('NEWUSAGETYPE') in \
(constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE):
s_pools.append(pool['NAME'])

pool_name_list = root.findtext('Filesystem/StoragePool')
Expand Down Expand Up @@ -228,6 +231,10 @@ def _get_share_ip(self, share_server, fs_info, vstore_id=None):
else:
ips = huawei_utils.get_logical_ips(self.helper)

dnses = huawei_utils.get_dns(self.helper)
if dnses:
ips = dnses

return ips

def _update_filesystem(self, fs_info, size):
Expand Down Expand Up @@ -1314,7 +1321,10 @@ def manage_existing(self, share, driver_options):
share_size = int(fs['CAPACITY']) / units.Mi / 2
self.helper._change_fs_name(fs_id, share_name)

locations = self._get_location_path(share_name, share_proto)
if share_proto == 'CIFS':
locations = self._get_location_path(old_share_name, share_proto)
else:
locations = self._get_location_path(share_name, share_proto)
return share_size, locations

def unmanage(self, share):
Expand Down Expand Up @@ -1611,6 +1621,7 @@ def check_conf_file(self):
pwd = root.findtext('Storage/UserPassword')
pool_node = root.findtext('Filesystem/StoragePool')
logical_port_ip = root.findtext('Storage/LogicalPortIP')
dns = root.findtext('Storage/DNS')

if not (resturl and username and pwd):
err_msg = (_(
Expand All @@ -1630,10 +1641,13 @@ def check_conf_file(self):
if logical_port_ip:
logical_ips = [i.strip() for i in logical_port_ip.split(';')
if i.strip()]
dnses = []
if dns:
dnses = [i.strip() for i in dns.split(';') if i.strip()]
if not (self.configuration.driver_handles_share_servers
or logical_ips):
or logical_ips or dnses):
err_msg = (_(
'check_conf_file: Config file invalid. LogicalPortIP '
'check_conf_file: Config file invalid. LogicalPortIP or DNS '
'must be set when driver_handles_share_servers is False.'))
LOG.error(err_msg)
raise exception.InvalidInput(reason=err_msg)
Expand Down
31 changes: 20 additions & 11 deletions Manila/Pike/v3/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def login(self):
result = self.do_call(url, data,
calltimeout=constants.LOGIN_SOCKET_TIMEOUT)

if((result['error']['code'] != 0)
or ("data" not in result)
or (result['data']['deviceid'] is None)):
if ((result['error']['code'] != 0)
or ("data" not in result)
or (result['data']['deviceid'] is None)):
LOG.error("Login to %s failed, try another.", item_url)
continue

Expand Down Expand Up @@ -159,8 +159,8 @@ def call(self, url, data=None, method=None):
old_url = self.url
result = self.do_call(url, data, method)
error_code = result['error']['code']
if(error_code == constants.ERROR_CONNECT_TO_SERVER
or error_code == constants.ERROR_UNAUTHORIZED_TO_SERVER):
if (error_code == constants.ERROR_CONNECT_TO_SERVER
or error_code == constants.ERROR_UNAUTHORIZED_TO_SERVER):
LOG.error("Can't open the recent url, re-login.")
deviceid = self.login()

Expand Down Expand Up @@ -297,8 +297,12 @@ def _find_pool_info(self, pool_name, result):
poolinfo = {}
pool_name = pool_name.strip()
for item in result.get('data', []):
if pool_name == item['NAME'] and item['USAGETYPE'] in (constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE):
if pool_name == item['NAME'] and (item['USAGETYPE'] in
(constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE) or
item.get('NEWUSAGETYPE') in
(constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE)):
poolinfo['name'] = pool_name
poolinfo['ID'] = item['ID']
poolinfo['CAPACITY'] = item['USERFREECAPACITY']
Expand Down Expand Up @@ -790,7 +794,8 @@ def _get_share_name_by_export_location(self, export_location, share_proto):
% export_location))

target_ips = huawei_utils.get_logical_ips(self)
if share_ip not in target_ips:
dnses = huawei_utils.get_dns(self)
if share_ip not in target_ips and share_ip not in dnses:
raise exception.InvalidInput(
reason=_('The share IP %s is not configured.') % share_ip)

Expand Down Expand Up @@ -1250,10 +1255,14 @@ def get_logical_port_by_id(self, logical_port_id):

def modify_logical_port(self, logical_port_id, vstore_id):
logical_port_info = self.get_logical_port_by_id(logical_port_id)
logical_port_info.update({'vstoreId': vstore_id,
'dnsZoneName': ""})
data = {'vstoreId': vstore_id,
'dnsZoneName': "",
'NAME': logical_port_info.get('NAME'),
'ID': logical_port_info.get('ID')}
url = "/LIF/%s" % logical_port_id
result = self.call(url, jsonutils.dumps(logical_port_info), 'PUT')
result = self.call(url, jsonutils.dumps(data), 'PUT')
if result['error']['code'] == constants.LIF_ALREADY_EXISTS:
return
self._assert_rest_result(result, _('Modify logical port error.'))

def delete_logical_port(self, logical_port_id):
Expand Down
1 change: 1 addition & 0 deletions Manila/Queens/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
ERROR_USER_OR_GROUP_NOT_EXIST = 1077939723
ERROR_REPLICATION_PAIR_NOT_EXIST = 1077937923
ERROR_HYPERMETRO_NOT_EXIST = 1077674242
LIF_ALREADY_EXISTS = 1077948993

PORT_TYPE_ETH = '1'
PORT_TYPE_BOND = '7'
Expand Down
9 changes: 9 additions & 0 deletions Manila/Queens/huawei_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ def get_logical_ips(helper):
return [i.strip() for i in config.split(';') if i.strip()]


def get_dns(helper):
root = helper._read_xml()
config = root.findtext('Storage/DNS')
if not config:
return []

return [i.strip() for i in config.split(';') if i.strip()]


def wait_fs_online(helper, fs_id, wait_interval, timeout):
def _wait_fs_online():
fs = helper._get_fs_info_by_id(fs_id)
Expand Down
24 changes: 19 additions & 5 deletions Manila/Queens/v3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, configuration, **kwargs):
self.rpc_client = v3_rpcapi.HuaweiV3API()
self.private_storage = kwargs.get('private_storage')
self.qos_support = False
self.snapshot_support = False
self.snapshot_support = True
self.replication_support = False
self.metro_domain = None
self.remote_backend = None
Expand Down Expand Up @@ -95,7 +95,10 @@ def check_storage_pools(self):
all_pool_info = self.helper._find_all_pool_info()
for pool in all_pool_info['data']:
if pool.get('USAGETYPE') in (constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE):
constants.DORADO_V6_POOL_TYPE) or \
pool.get('NEWUSAGETYPE') in \
(constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE):
s_pools.append(pool['NAME'])

pool_name_list = root.findtext('Filesystem/StoragePool')
Expand Down Expand Up @@ -228,6 +231,10 @@ def _get_share_ip(self, share_server, fs_info, vstore_id=None):
else:
ips = huawei_utils.get_logical_ips(self.helper)

dnses = huawei_utils.get_dns(self.helper)
if dnses:
ips = dnses

return ips

def _update_filesystem(self, fs_info, size):
Expand Down Expand Up @@ -1314,7 +1321,10 @@ def manage_existing(self, share, driver_options):
share_size = int(fs['CAPACITY']) / units.Mi / 2
self.helper._change_fs_name(fs_id, share_name)

locations = self._get_location_path(share_name, share_proto)
if share_proto == 'CIFS':
locations = self._get_location_path(old_share_name, share_proto)
else:
locations = self._get_location_path(share_name, share_proto)
return share_size, locations

def unmanage(self, share):
Expand Down Expand Up @@ -1611,6 +1621,7 @@ def check_conf_file(self):
pwd = root.findtext('Storage/UserPassword')
pool_node = root.findtext('Filesystem/StoragePool')
logical_port_ip = root.findtext('Storage/LogicalPortIP')
dns = root.findtext('Storage/DNS')

if not (resturl and username and pwd):
err_msg = (_(
Expand All @@ -1630,10 +1641,13 @@ def check_conf_file(self):
if logical_port_ip:
logical_ips = [i.strip() for i in logical_port_ip.split(';')
if i.strip()]
dnses = []
if dns:
dnses = [i.strip() for i in dns.split(';') if i.strip()]
if not (self.configuration.driver_handles_share_servers
or logical_ips):
or logical_ips or dnses):
err_msg = (_(
'check_conf_file: Config file invalid. LogicalPortIP '
'check_conf_file: Config file invalid. LogicalPortIP or DNS '
'must be set when driver_handles_share_servers is False.'))
LOG.error(err_msg)
raise exception.InvalidInput(reason=err_msg)
Expand Down
31 changes: 20 additions & 11 deletions Manila/Queens/v3/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def login(self):
result = self.do_call(url, data,
calltimeout=constants.LOGIN_SOCKET_TIMEOUT)

if((result['error']['code'] != 0)
or ("data" not in result)
or (result['data']['deviceid'] is None)):
if ((result['error']['code'] != 0)
or ("data" not in result)
or (result['data']['deviceid'] is None)):
LOG.error("Login to %s failed, try another.", item_url)
continue

Expand Down Expand Up @@ -159,8 +159,8 @@ def call(self, url, data=None, method=None):
old_url = self.url
result = self.do_call(url, data, method)
error_code = result['error']['code']
if(error_code == constants.ERROR_CONNECT_TO_SERVER
or error_code == constants.ERROR_UNAUTHORIZED_TO_SERVER):
if (error_code == constants.ERROR_CONNECT_TO_SERVER
or error_code == constants.ERROR_UNAUTHORIZED_TO_SERVER):
LOG.error("Can't open the recent url, re-login.")
deviceid = self.login()

Expand Down Expand Up @@ -297,8 +297,12 @@ def _find_pool_info(self, pool_name, result):
poolinfo = {}
pool_name = pool_name.strip()
for item in result.get('data', []):
if pool_name == item['NAME'] and item['USAGETYPE'] in (constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE):
if pool_name == item['NAME'] and (item['USAGETYPE'] in
(constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE) or
item.get('NEWUSAGETYPE') in
(constants.FILE_SYSTEM_POOL_TYPE,
constants.DORADO_V6_POOL_TYPE)):
poolinfo['name'] = pool_name
poolinfo['ID'] = item['ID']
poolinfo['CAPACITY'] = item['USERFREECAPACITY']
Expand Down Expand Up @@ -790,7 +794,8 @@ def _get_share_name_by_export_location(self, export_location, share_proto):
% export_location))

target_ips = huawei_utils.get_logical_ips(self)
if share_ip not in target_ips:
dnses = huawei_utils.get_dns(self)
if share_ip not in target_ips and share_ip not in dnses:
raise exception.InvalidInput(
reason=_('The share IP %s is not configured.') % share_ip)

Expand Down Expand Up @@ -1250,10 +1255,14 @@ def get_logical_port_by_id(self, logical_port_id):

def modify_logical_port(self, logical_port_id, vstore_id):
logical_port_info = self.get_logical_port_by_id(logical_port_id)
logical_port_info.update({'vstoreId': vstore_id,
'dnsZoneName': ""})
data = {'vstoreId': vstore_id,
'dnsZoneName': "",
'NAME': logical_port_info.get('NAME'),
'ID': logical_port_info.get('ID')}
url = "/LIF/%s" % logical_port_id
result = self.call(url, jsonutils.dumps(logical_port_info), 'PUT')
result = self.call(url, jsonutils.dumps(data), 'PUT')
if result['error']['code'] == constants.LIF_ALREADY_EXISTS:
return
self._assert_rest_result(result, _('Modify logical port error.'))

def delete_logical_port(self, logical_port_id):
Expand Down
1 change: 1 addition & 0 deletions Manila/Rocky/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
ERROR_HYPERMETRO_NOT_EXIST = 1077674242
SNAPSHOT_NOT_EXIST = 1073754118
SHARE_PATH_INVALID = 1077939729
LIF_ALREADY_EXISTS = 1077948993

PORT_TYPE_ETH = '1'
PORT_TYPE_BOND = '7'
Expand Down
14 changes: 9 additions & 5 deletions Manila/Rocky/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ def do_call(self, postfix_url, method, data=None,

def _get_user_info(self):
if self.nas_username.startswith('!$$$'):
username = base64.b64decode(self.nas_username[4:])
username = base64.b64decode(self.nas_username[4:]).decode()
else:
username = self.nas_username

if self.nas_password.startswith('!$$$'):
password = base64.b64decode(self.nas_password[4:])
password = base64.b64decode(self.nas_password[4:]).decode()
else:
password = self.nas_password

Expand Down Expand Up @@ -647,10 +647,14 @@ def get_logical_port_by_id(self, logical_port_id):

def modify_logical_port(self, logical_port_id, vstore_id):
logical_port_info = self.get_logical_port_by_id(logical_port_id)
logical_port_info.update({'vstoreId': vstore_id,
'dnsZoneName': ""})
data = {'vstoreId': vstore_id,
'dnsZoneName': "",
'NAME': logical_port_info.get('NAME'),
'ID': logical_port_info.get('ID')}
url = "/LIF/%s" % logical_port_id
result = self.call(url, 'PUT', logical_port_info)
result = self.call(url, 'PUT', data)
if result['error']['code'] == constants.LIF_ALREADY_EXISTS:
return
_assert_result(result, 'Modify logical port error.')

def delete_logical_port(self, logical_port_id):
Expand Down
15 changes: 13 additions & 2 deletions Manila/Rocky/huawei_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def update_configs(self):
self._cifs_client,
self._snapshot_reserve,
self._logical_ip,
self._dns,
)

for f in attr_funcs:
Expand All @@ -71,11 +72,13 @@ def _encode_authentication(self, tree, xml_root):

need_encode = False
if name_node is not None and not name_node.text.startswith('!$$$'):
name_node.text = '!$$$' + base64.b64encode(name_node.text)
name_node.text = '!$$$' + base64.b64encode(
name_node.text.encode()).decode()
need_encode = True

if pwd_node is not None and not pwd_node.text.startswith('!$$$'):
pwd_node.text = '!$$$' + base64.b64encode(pwd_node.text)
pwd_node.text = '!$$$' + base64.b64encode(
pwd_node.text.encode()).decode()
need_encode = True

if need_encode:
Expand Down Expand Up @@ -179,6 +182,14 @@ def _logical_ip(self, xml_root):

setattr(self.config, 'logical_ip', logical_ip)

def _dns(self, xml_root):
dns = []
text = xml_root.findtext('Storage/DNS')
if text:
dns = [i.strip() for i in text.split(";") if i.strip()]

setattr(self.config, 'dns', dns)

def _ports(self, xml_root):
ports = []
text = xml_root.findtext('Storage/Port')
Expand Down
Loading

0 comments on commit 698997d

Please sign in to comment.