Skip to content

Commit 698997d

Browse files
authored
Merge pull request #17 from Huawei/2.2.RC2
2.2.RC2
2 parents 1cf0753 + af844bf commit 698997d

Some content is hidden

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

43 files changed

+4178
-68
lines changed
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.

Manila/Pike/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
ERROR_USER_OR_GROUP_NOT_EXIST = 1077939723
5151
ERROR_REPLICATION_PAIR_NOT_EXIST = 1077937923
5252
ERROR_HYPERMETRO_NOT_EXIST = 1077674242
53+
LIF_ALREADY_EXISTS = 1077948993
5354

5455
PORT_TYPE_ETH = '1'
5556
PORT_TYPE_BOND = '7'

Manila/Pike/huawei_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ def get_logical_ips(helper):
104104
return [i.strip() for i in config.split(';') if i.strip()]
105105

106106

107+
def get_dns(helper):
108+
root = helper._read_xml()
109+
config = root.findtext('Storage/DNS')
110+
if not config:
111+
return []
112+
113+
return [i.strip() for i in config.split(';') if i.strip()]
114+
115+
107116
def wait_fs_online(helper, fs_id, wait_interval, timeout):
108117
def _wait_fs_online():
109118
fs = helper._get_fs_info_by_id(fs_id)

Manila/Pike/v3/connection.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(self, configuration, **kwargs):
6666
self.rpc_client = v3_rpcapi.HuaweiV3API()
6767
self.private_storage = kwargs.get('private_storage')
6868
self.qos_support = False
69-
self.snapshot_support = False
69+
self.snapshot_support = True
7070
self.replication_support = False
7171
self.metro_domain = None
7272
self.remote_backend = None
@@ -95,7 +95,10 @@ def check_storage_pools(self):
9595
all_pool_info = self.helper._find_all_pool_info()
9696
for pool in all_pool_info['data']:
9797
if pool.get('USAGETYPE') in (constants.FILE_SYSTEM_POOL_TYPE,
98-
constants.DORADO_V6_POOL_TYPE):
98+
constants.DORADO_V6_POOL_TYPE) or \
99+
pool.get('NEWUSAGETYPE') in \
100+
(constants.FILE_SYSTEM_POOL_TYPE,
101+
constants.DORADO_V6_POOL_TYPE):
99102
s_pools.append(pool['NAME'])
100103

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

234+
dnses = huawei_utils.get_dns(self.helper)
235+
if dnses:
236+
ips = dnses
237+
231238
return ips
232239

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

1317-
locations = self._get_location_path(share_name, share_proto)
1324+
if share_proto == 'CIFS':
1325+
locations = self._get_location_path(old_share_name, share_proto)
1326+
else:
1327+
locations = self._get_location_path(share_name, share_proto)
13181328
return share_size, locations
13191329

13201330
def unmanage(self, share):
@@ -1611,6 +1621,7 @@ def check_conf_file(self):
16111621
pwd = root.findtext('Storage/UserPassword')
16121622
pool_node = root.findtext('Filesystem/StoragePool')
16131623
logical_port_ip = root.findtext('Storage/LogicalPortIP')
1624+
dns = root.findtext('Storage/DNS')
16141625

16151626
if not (resturl and username and pwd):
16161627
err_msg = (_(
@@ -1630,10 +1641,13 @@ def check_conf_file(self):
16301641
if logical_port_ip:
16311642
logical_ips = [i.strip() for i in logical_port_ip.split(';')
16321643
if i.strip()]
1644+
dnses = []
1645+
if dns:
1646+
dnses = [i.strip() for i in dns.split(';') if i.strip()]
16331647
if not (self.configuration.driver_handles_share_servers
1634-
or logical_ips):
1648+
or logical_ips or dnses):
16351649
err_msg = (_(
1636-
'check_conf_file: Config file invalid. LogicalPortIP '
1650+
'check_conf_file: Config file invalid. LogicalPortIP or DNS '
16371651
'must be set when driver_handles_share_servers is False.'))
16381652
LOG.error(err_msg)
16391653
raise exception.InvalidInput(reason=err_msg)

Manila/Pike/v3/helper.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def login(self):
115115
result = self.do_call(url, data,
116116
calltimeout=constants.LOGIN_SOCKET_TIMEOUT)
117117

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

@@ -159,8 +159,8 @@ def call(self, url, data=None, method=None):
159159
old_url = self.url
160160
result = self.do_call(url, data, method)
161161
error_code = result['error']['code']
162-
if(error_code == constants.ERROR_CONNECT_TO_SERVER
163-
or error_code == constants.ERROR_UNAUTHORIZED_TO_SERVER):
162+
if (error_code == constants.ERROR_CONNECT_TO_SERVER
163+
or error_code == constants.ERROR_UNAUTHORIZED_TO_SERVER):
164164
LOG.error("Can't open the recent url, re-login.")
165165
deviceid = self.login()
166166

@@ -297,8 +297,12 @@ def _find_pool_info(self, pool_name, result):
297297
poolinfo = {}
298298
pool_name = pool_name.strip()
299299
for item in result.get('data', []):
300-
if pool_name == item['NAME'] and item['USAGETYPE'] in (constants.FILE_SYSTEM_POOL_TYPE,
301-
constants.DORADO_V6_POOL_TYPE):
300+
if pool_name == item['NAME'] and (item['USAGETYPE'] in
301+
(constants.FILE_SYSTEM_POOL_TYPE,
302+
constants.DORADO_V6_POOL_TYPE) or
303+
item.get('NEWUSAGETYPE') in
304+
(constants.FILE_SYSTEM_POOL_TYPE,
305+
constants.DORADO_V6_POOL_TYPE)):
302306
poolinfo['name'] = pool_name
303307
poolinfo['ID'] = item['ID']
304308
poolinfo['CAPACITY'] = item['USERFREECAPACITY']
@@ -790,7 +794,8 @@ def _get_share_name_by_export_location(self, export_location, share_proto):
790794
% export_location))
791795

792796
target_ips = huawei_utils.get_logical_ips(self)
793-
if share_ip not in target_ips:
797+
dnses = huawei_utils.get_dns(self)
798+
if share_ip not in target_ips and share_ip not in dnses:
794799
raise exception.InvalidInput(
795800
reason=_('The share IP %s is not configured.') % share_ip)
796801

@@ -1250,10 +1255,14 @@ def get_logical_port_by_id(self, logical_port_id):
12501255

12511256
def modify_logical_port(self, logical_port_id, vstore_id):
12521257
logical_port_info = self.get_logical_port_by_id(logical_port_id)
1253-
logical_port_info.update({'vstoreId': vstore_id,
1254-
'dnsZoneName': ""})
1258+
data = {'vstoreId': vstore_id,
1259+
'dnsZoneName': "",
1260+
'NAME': logical_port_info.get('NAME'),
1261+
'ID': logical_port_info.get('ID')}
12551262
url = "/LIF/%s" % logical_port_id
1256-
result = self.call(url, jsonutils.dumps(logical_port_info), 'PUT')
1263+
result = self.call(url, jsonutils.dumps(data), 'PUT')
1264+
if result['error']['code'] == constants.LIF_ALREADY_EXISTS:
1265+
return
12571266
self._assert_rest_result(result, _('Modify logical port error.'))
12581267

12591268
def delete_logical_port(self, logical_port_id):

Manila/Queens/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
ERROR_USER_OR_GROUP_NOT_EXIST = 1077939723
5151
ERROR_REPLICATION_PAIR_NOT_EXIST = 1077937923
5252
ERROR_HYPERMETRO_NOT_EXIST = 1077674242
53+
LIF_ALREADY_EXISTS = 1077948993
5354

5455
PORT_TYPE_ETH = '1'
5556
PORT_TYPE_BOND = '7'

Manila/Queens/huawei_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ def get_logical_ips(helper):
104104
return [i.strip() for i in config.split(';') if i.strip()]
105105

106106

107+
def get_dns(helper):
108+
root = helper._read_xml()
109+
config = root.findtext('Storage/DNS')
110+
if not config:
111+
return []
112+
113+
return [i.strip() for i in config.split(';') if i.strip()]
114+
115+
107116
def wait_fs_online(helper, fs_id, wait_interval, timeout):
108117
def _wait_fs_online():
109118
fs = helper._get_fs_info_by_id(fs_id)

Manila/Queens/v3/connection.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(self, configuration, **kwargs):
6666
self.rpc_client = v3_rpcapi.HuaweiV3API()
6767
self.private_storage = kwargs.get('private_storage')
6868
self.qos_support = False
69-
self.snapshot_support = False
69+
self.snapshot_support = True
7070
self.replication_support = False
7171
self.metro_domain = None
7272
self.remote_backend = None
@@ -95,7 +95,10 @@ def check_storage_pools(self):
9595
all_pool_info = self.helper._find_all_pool_info()
9696
for pool in all_pool_info['data']:
9797
if pool.get('USAGETYPE') in (constants.FILE_SYSTEM_POOL_TYPE,
98-
constants.DORADO_V6_POOL_TYPE):
98+
constants.DORADO_V6_POOL_TYPE) or \
99+
pool.get('NEWUSAGETYPE') in \
100+
(constants.FILE_SYSTEM_POOL_TYPE,
101+
constants.DORADO_V6_POOL_TYPE):
99102
s_pools.append(pool['NAME'])
100103

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

234+
dnses = huawei_utils.get_dns(self.helper)
235+
if dnses:
236+
ips = dnses
237+
231238
return ips
232239

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

1317-
locations = self._get_location_path(share_name, share_proto)
1324+
if share_proto == 'CIFS':
1325+
locations = self._get_location_path(old_share_name, share_proto)
1326+
else:
1327+
locations = self._get_location_path(share_name, share_proto)
13181328
return share_size, locations
13191329

13201330
def unmanage(self, share):
@@ -1611,6 +1621,7 @@ def check_conf_file(self):
16111621
pwd = root.findtext('Storage/UserPassword')
16121622
pool_node = root.findtext('Filesystem/StoragePool')
16131623
logical_port_ip = root.findtext('Storage/LogicalPortIP')
1624+
dns = root.findtext('Storage/DNS')
16141625

16151626
if not (resturl and username and pwd):
16161627
err_msg = (_(
@@ -1630,10 +1641,13 @@ def check_conf_file(self):
16301641
if logical_port_ip:
16311642
logical_ips = [i.strip() for i in logical_port_ip.split(';')
16321643
if i.strip()]
1644+
dnses = []
1645+
if dns:
1646+
dnses = [i.strip() for i in dns.split(';') if i.strip()]
16331647
if not (self.configuration.driver_handles_share_servers
1634-
or logical_ips):
1648+
or logical_ips or dnses):
16351649
err_msg = (_(
1636-
'check_conf_file: Config file invalid. LogicalPortIP '
1650+
'check_conf_file: Config file invalid. LogicalPortIP or DNS '
16371651
'must be set when driver_handles_share_servers is False.'))
16381652
LOG.error(err_msg)
16391653
raise exception.InvalidInput(reason=err_msg)

Manila/Queens/v3/helper.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def login(self):
115115
result = self.do_call(url, data,
116116
calltimeout=constants.LOGIN_SOCKET_TIMEOUT)
117117

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

@@ -159,8 +159,8 @@ def call(self, url, data=None, method=None):
159159
old_url = self.url
160160
result = self.do_call(url, data, method)
161161
error_code = result['error']['code']
162-
if(error_code == constants.ERROR_CONNECT_TO_SERVER
163-
or error_code == constants.ERROR_UNAUTHORIZED_TO_SERVER):
162+
if (error_code == constants.ERROR_CONNECT_TO_SERVER
163+
or error_code == constants.ERROR_UNAUTHORIZED_TO_SERVER):
164164
LOG.error("Can't open the recent url, re-login.")
165165
deviceid = self.login()
166166

@@ -297,8 +297,12 @@ def _find_pool_info(self, pool_name, result):
297297
poolinfo = {}
298298
pool_name = pool_name.strip()
299299
for item in result.get('data', []):
300-
if pool_name == item['NAME'] and item['USAGETYPE'] in (constants.FILE_SYSTEM_POOL_TYPE,
301-
constants.DORADO_V6_POOL_TYPE):
300+
if pool_name == item['NAME'] and (item['USAGETYPE'] in
301+
(constants.FILE_SYSTEM_POOL_TYPE,
302+
constants.DORADO_V6_POOL_TYPE) or
303+
item.get('NEWUSAGETYPE') in
304+
(constants.FILE_SYSTEM_POOL_TYPE,
305+
constants.DORADO_V6_POOL_TYPE)):
302306
poolinfo['name'] = pool_name
303307
poolinfo['ID'] = item['ID']
304308
poolinfo['CAPACITY'] = item['USERFREECAPACITY']
@@ -790,7 +794,8 @@ def _get_share_name_by_export_location(self, export_location, share_proto):
790794
% export_location))
791795

792796
target_ips = huawei_utils.get_logical_ips(self)
793-
if share_ip not in target_ips:
797+
dnses = huawei_utils.get_dns(self)
798+
if share_ip not in target_ips and share_ip not in dnses:
794799
raise exception.InvalidInput(
795800
reason=_('The share IP %s is not configured.') % share_ip)
796801

@@ -1250,10 +1255,14 @@ def get_logical_port_by_id(self, logical_port_id):
12501255

12511256
def modify_logical_port(self, logical_port_id, vstore_id):
12521257
logical_port_info = self.get_logical_port_by_id(logical_port_id)
1253-
logical_port_info.update({'vstoreId': vstore_id,
1254-
'dnsZoneName': ""})
1258+
data = {'vstoreId': vstore_id,
1259+
'dnsZoneName': "",
1260+
'NAME': logical_port_info.get('NAME'),
1261+
'ID': logical_port_info.get('ID')}
12551262
url = "/LIF/%s" % logical_port_id
1256-
result = self.call(url, jsonutils.dumps(logical_port_info), 'PUT')
1263+
result = self.call(url, jsonutils.dumps(data), 'PUT')
1264+
if result['error']['code'] == constants.LIF_ALREADY_EXISTS:
1265+
return
12571266
self._assert_rest_result(result, _('Modify logical port error.'))
12581267

12591268
def delete_logical_port(self, logical_port_id):

Manila/Rocky/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
ERROR_HYPERMETRO_NOT_EXIST = 1077674242
5555
SNAPSHOT_NOT_EXIST = 1073754118
5656
SHARE_PATH_INVALID = 1077939729
57+
LIF_ALREADY_EXISTS = 1077948993
5758

5859
PORT_TYPE_ETH = '1'
5960
PORT_TYPE_BOND = '7'

Manila/Rocky/helper.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ def do_call(self, postfix_url, method, data=None,
107107

108108
def _get_user_info(self):
109109
if self.nas_username.startswith('!$$$'):
110-
username = base64.b64decode(self.nas_username[4:])
110+
username = base64.b64decode(self.nas_username[4:]).decode()
111111
else:
112112
username = self.nas_username
113113

114114
if self.nas_password.startswith('!$$$'):
115-
password = base64.b64decode(self.nas_password[4:])
115+
password = base64.b64decode(self.nas_password[4:]).decode()
116116
else:
117117
password = self.nas_password
118118

@@ -647,10 +647,14 @@ def get_logical_port_by_id(self, logical_port_id):
647647

648648
def modify_logical_port(self, logical_port_id, vstore_id):
649649
logical_port_info = self.get_logical_port_by_id(logical_port_id)
650-
logical_port_info.update({'vstoreId': vstore_id,
651-
'dnsZoneName': ""})
650+
data = {'vstoreId': vstore_id,
651+
'dnsZoneName': "",
652+
'NAME': logical_port_info.get('NAME'),
653+
'ID': logical_port_info.get('ID')}
652654
url = "/LIF/%s" % logical_port_id
653-
result = self.call(url, 'PUT', logical_port_info)
655+
result = self.call(url, 'PUT', data)
656+
if result['error']['code'] == constants.LIF_ALREADY_EXISTS:
657+
return
654658
_assert_result(result, 'Modify logical port error.')
655659

656660
def delete_logical_port(self, logical_port_id):

Manila/Rocky/huawei_config.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def update_configs(self):
6060
self._cifs_client,
6161
self._snapshot_reserve,
6262
self._logical_ip,
63+
self._dns,
6364
)
6465

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

7273
need_encode = False
7374
if name_node is not None and not name_node.text.startswith('!$$$'):
74-
name_node.text = '!$$$' + base64.b64encode(name_node.text)
75+
name_node.text = '!$$$' + base64.b64encode(
76+
name_node.text.encode()).decode()
7577
need_encode = True
7678

7779
if pwd_node is not None and not pwd_node.text.startswith('!$$$'):
78-
pwd_node.text = '!$$$' + base64.b64encode(pwd_node.text)
80+
pwd_node.text = '!$$$' + base64.b64encode(
81+
pwd_node.text.encode()).decode()
7982
need_encode = True
8083

8184
if need_encode:
@@ -179,6 +182,14 @@ def _logical_ip(self, xml_root):
179182

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

185+
def _dns(self, xml_root):
186+
dns = []
187+
text = xml_root.findtext('Storage/DNS')
188+
if text:
189+
dns = [i.strip() for i in text.split(";") if i.strip()]
190+
191+
setattr(self.config, 'dns', dns)
192+
182193
def _ports(self, xml_root):
183194
ports = []
184195
text = xml_root.findtext('Storage/Port')

0 commit comments

Comments
 (0)