Merge "Fix URL format in Huawei driver"

This commit is contained in:
Jenkins 2015-09-23 17:49:03 +00:00 committed by Gerrit Code Review
commit 24451969ec
4 changed files with 35 additions and 59 deletions

View File

@ -962,6 +962,7 @@ FAKE_GET_FC_PORT_RESPONSE = """
MAP_COMMAND_TO_FAKE_RESPONSE = {} MAP_COMMAND_TO_FAKE_RESPONSE = {}
MAP_COMMAND_TO_FAKE_RESPONSE['/xx/sessions'] = ( MAP_COMMAND_TO_FAKE_RESPONSE['/xx/sessions'] = (
FAKE_GET_LOGIN_STORAGE_RESPONSE) FAKE_GET_LOGIN_STORAGE_RESPONSE)
MAP_COMMAND_TO_FAKE_RESPONSE['/sessions'] = ( MAP_COMMAND_TO_FAKE_RESPONSE['/sessions'] = (
FAKE_LOGIN_OUT_STORAGE_RESPONSE) FAKE_LOGIN_OUT_STORAGE_RESPONSE)
@ -1112,8 +1113,8 @@ MAP_COMMAND_TO_FAKE_RESPONSE['/iscsidevicename'] = (
MAP_COMMAND_TO_FAKE_RESPONSE['/iscsi_initiator?range=[0-256]/GET'] = ( MAP_COMMAND_TO_FAKE_RESPONSE['/iscsi_initiator?range=[0-256]/GET'] = (
FAKE_COMMON_SUCCESS_RESPONSE) FAKE_COMMON_SUCCESS_RESPONSE)
MAP_COMMAND_TO_FAKE_RESPONSE['/iscsi_initiator'] = ( MAP_COMMAND_TO_FAKE_RESPONSE['/iscsi_initiator/'] = (
FAKE_COMMON_SUCCESS_RESPONSE) FAKE_ISCSI_INITIATOR_RESPONSE)
MAP_COMMAND_TO_FAKE_RESPONSE['/iscsi_initiator/POST'] = ( MAP_COMMAND_TO_FAKE_RESPONSE['/iscsi_initiator/POST'] = (
FAKE_ISCSI_INITIATOR_RESPONSE) FAKE_ISCSI_INITIATOR_RESPONSE)
@ -1257,7 +1258,10 @@ MAP_COMMAND_TO_FAKE_RESPONSE['/fc_initiator/GET'] = (
MAP_COMMAND_TO_FAKE_RESPONSE['/lun/associate/cachepartition/POST'] = ( MAP_COMMAND_TO_FAKE_RESPONSE['/lun/associate/cachepartition/POST'] = (
FAKE_SYSTEM_VERSION_RESPONSE) FAKE_SYSTEM_VERSION_RESPONSE)
MAP_COMMAND_TO_FAKE_RESPONSE['/fc_initiator?range=[0-100]/GET'] = ( MAP_COMMAND_TO_FAKE_RESPONSE['/fc_initiator?range=[0-100]&PARENTID=1/GET'] = (
FAKE_GET_FC_PORT_RESPONSE)
MAP_COMMAND_TO_FAKE_RESPONSE['/fc_initiator?PARENTTYPE=21&PARENTID=1/GET'] = (
FAKE_GET_FC_PORT_RESPONSE) FAKE_GET_FC_PORT_RESPONSE)

View File

@ -868,7 +868,7 @@ class Huawei18000ISCSIDriver(HuaweiBaseDriver, driver.ISCSIDriver):
lun_id = self.restclient.get_lunid(volume, volume_name) lun_id = self.restclient.get_lunid(volume, volume_name)
# Mapping lungroup and hostgroup to view. # Mapping lungroup and hostgroup to view.
self.restclient.do_mapping(volume_name, hostgroup_id, self.restclient.do_mapping(lun_id, hostgroup_id,
host_id, portgroup_id) host_id, portgroup_id)
hostlun_id = self.restclient.find_host_lun_id(host_id, lun_id) hostlun_id = self.restclient.find_host_lun_id(host_id, lun_id)
@ -1085,7 +1085,7 @@ class Huawei18000FCDriver(HuaweiBaseDriver, driver.FibreChannelDriver):
# Add host into hostgroup. # Add host into hostgroup.
hostgroup_id = self.restclient.add_host_into_hostgroup(host_id) hostgroup_id = self.restclient.add_host_into_hostgroup(host_id)
self.restclient.do_mapping(volume_name, hostgroup_id, host_id) self.restclient.do_mapping(lun_id, hostgroup_id, host_id)
host_lun_id = self.restclient.find_host_lun_id(host_id, lun_id) host_lun_id = self.restclient.find_host_lun_id(host_id, lun_id)
# Return FC properties. # Return FC properties.

View File

@ -487,7 +487,7 @@ def check_conf_file(xml_file_path):
resturl = root.findtext('Storage/RestURL') resturl = root.findtext('Storage/RestURL')
username = root.findtext('Storage/UserName') username = root.findtext('Storage/UserName')
pwd = root.findtext('Storage/UserPassword') pwd = root.findtext('Storage/UserPassword')
pool_node = root.findall('Storage/StoragePool') pool_node = root.findall('LUN/StoragePool')
if (not resturl) or (not username) or (not pwd): if (not resturl) or (not username) or (not pwd):
err_msg = (_( err_msg = (_(

View File

@ -177,9 +177,7 @@ class RestClient(object):
def check_lun_exist(self, lun_id): def check_lun_exist(self, lun_id):
url = "/lun/" + lun_id url = "/lun/" + lun_id
data = json.dumps({"TYPE": "11", result = self.call(url, None, "GET")
"ID": lun_id})
result = self.call(url, data, "GET")
error_code = result['error']['code'] error_code = result['error']['code']
if error_code != 0: if error_code != 0:
return False return False
@ -282,9 +280,7 @@ class RestClient(object):
def check_snapshot_exist(self, snapshot_id): def check_snapshot_exist(self, snapshot_id):
url = "/snapshot/%s" % snapshot_id url = "/snapshot/%s" % snapshot_id
data = json.dumps({"TYPE": "27", result = self.call(url, None, "GET")
"ID": snapshot_id})
result = self.call(url, data, "GET")
error_code = result['error']['code'] error_code = result['error']['code']
if error_code != 0: if error_code != 0:
return False return False
@ -305,8 +301,7 @@ class RestClient(object):
def get_snapshotid_by_name(self, name): def get_snapshotid_by_name(self, name):
url = "/snapshot?range=[0-32767]" url = "/snapshot?range=[0-32767]"
data = json.dumps({"TYPE": "27"}) result = self.call(url, None, "GET")
result = self.call(url, data, "GET")
self._assert_rest_result(result, _('Get snapshot id error.')) self._assert_rest_result(result, _('Get snapshot id error.'))
return self._get_id_from_result(result, name, 'NAME') return self._get_id_from_result(result, name, 'NAME')
@ -368,9 +363,8 @@ class RestClient(object):
'view error.')) 'view error.'))
def _portgroup_associated(self, view_id, portgroup_id): def _portgroup_associated(self, view_id, portgroup_id):
url_subfix = ("/mappingview/associate?TYPE=245&" url = ("/mappingview/associate?TYPE=245&"
"ASSOCIATEOBJTYPE=257&ASSOCIATEOBJID=%s" % portgroup_id) "ASSOCIATEOBJTYPE=257&ASSOCIATEOBJID=%s" % portgroup_id)
url = url_subfix
result = self.call(url, None, "GET") result = self.call(url, None, "GET")
self._assert_rest_result(result, _('Check portgroup associate error.')) self._assert_rest_result(result, _('Check portgroup associate error.'))
@ -579,8 +573,7 @@ class RestClient(object):
def find_host(self, host_name): def find_host(self, host_name):
"""Get the given host ID.""" """Get the given host ID."""
url = "/host?range=[0-65535]" url = "/host?range=[0-65535]"
data = json.dumps({"TYPE": "21"}) result = self.call(url, None, "GET")
result = self.call(url, data, "GET")
self._assert_rest_result(result, _('Find host in hostgroup error.')) self._assert_rest_result(result, _('Find host in hostgroup error.'))
return self._get_id_from_result(result, host_name, 'NAME') return self._get_id_from_result(result, host_name, 'NAME')
@ -725,7 +718,7 @@ class RestClient(object):
data = json.dumps({"TYPE": "222", data = json.dumps({"TYPE": "222",
"ID": initiator_name, "ID": initiator_name,
"USECHAP": "false"}) "USECHAP": "false"})
result = self.call(url, data) result = self.call(url, data, "POST")
self._assert_rest_result(result, self._assert_rest_result(result,
_('Add initiator to array error.')) _('Add initiator to array error.'))
@ -829,8 +822,7 @@ class RestClient(object):
def find_mapping_view(self, name): def find_mapping_view(self, name):
"""Find mapping view.""" """Find mapping view."""
url = "/mappingview?range=[0-8191]" url = "/mappingview?range=[0-8191]"
data = json.dumps({"TYPE": "245"}) result = self.call(url, None, "GET")
result = self.call(url, data, "GET")
msg = _('Find mapping view error.') msg = _('Find mapping view error.')
self._assert_rest_result(result, msg) self._assert_rest_result(result, msg)
@ -969,8 +961,7 @@ class RestClient(object):
def get_luncopy_info(self, luncopy_id): def get_luncopy_info(self, luncopy_id):
"""Get LUNcopy information.""" """Get LUNcopy information."""
url = "/LUNCOPY?range=[0-1023]" url = "/LUNCOPY?range=[0-1023]"
data = json.dumps({"TYPE": "219", }) result = self.call(url, None, "GET")
result = self.call(url, data, "GET")
self._assert_rest_result(result, _('Get LUNcopy information error.')) self._assert_rest_result(result, _('Get LUNcopy information error.'))
luncopyinfo = {} luncopyinfo = {}
@ -1099,7 +1090,7 @@ class RestClient(object):
def update_volume_stats(self): def update_volume_stats(self):
root = huawei_utils.parse_xml_file(self.xml_file_path) root = huawei_utils.parse_xml_file(self.xml_file_path)
pool_names = root.findtext('Storage/StoragePool') pool_names = root.findtext('LUN/StoragePool')
if not pool_names: if not pool_names:
msg = _( msg = _(
'Invalid resource pool name. ' 'Invalid resource pool name. '
@ -1301,9 +1292,7 @@ class RestClient(object):
def get_qos_info(self, qos_id): def get_qos_info(self, qos_id):
"""Get QoS information.""" """Get QoS information."""
url = "/ioclass/" + qos_id url = "/ioclass/" + qos_id
data = json.dumps({"TYPE": "230", result = self.call(url, None, "GET")
"ID": qos_id})
result = self.call(url, data, "GET")
self._assert_rest_result(result, _('Get QoS information error.')) self._assert_rest_result(result, _('Get QoS information error.'))
return result['data'] return result['data']
@ -1357,10 +1346,7 @@ class RestClient(object):
def get_qosid_by_lunid(self, lun_id): def get_qosid_by_lunid(self, lun_id):
"""Get QoS id by lun id.""" """Get QoS id by lun id."""
url = "/lun/" + lun_id url = "/lun/" + lun_id
data = json.dumps({"TYPE": "11", result = self.call(url, None, "GET")
"ID": lun_id})
result = self.call(url, data, "GET")
self._assert_rest_result(result, _('Get QoS id by lun id error.')) self._assert_rest_result(result, _('Get QoS id by lun id error.'))
return result['data']['IOCLASSID'] return result['data']['IOCLASSID']
@ -1382,9 +1368,7 @@ class RestClient(object):
def get_lun_info(self, lun_id): def get_lun_info(self, lun_id):
url = "/lun/" + lun_id url = "/lun/" + lun_id
data = json.dumps({"TYPE": "11", result = self.call(url, None, "GET")
"ID": lun_id})
result = self.call(url, data, "GET")
msg = _('Get volume error.') msg = _('Get volume error.')
self._assert_rest_result(result, msg) self._assert_rest_result(result, msg)
@ -1443,10 +1427,7 @@ class RestClient(object):
def get_partition_info_by_id(self, partition_id): def get_partition_info_by_id(self, partition_id):
url = '/cachepartition/' + partition_id url = '/cachepartition/' + partition_id
data = json.dumps({"TYPE": '268', result = self.call(url, None, "GET")
"ID": partition_id})
result = self.call(url, data, "GET")
self._assert_rest_result(result, self._assert_rest_result(result,
_('Get partition by partition id error.')) _('Get partition by partition id error.'))
@ -1502,7 +1483,7 @@ class RestClient(object):
""""Find available QoS on the array.""" """"Find available QoS on the array."""
qos_id = None qos_id = None
lun_list = [] lun_list = []
url = "/ioclass?range=[0-100]" url = "/ioclass"
result = self.call(url, None, "GET") result = self.call(url, None, "GET")
self._assert_rest_result(result, _('Get QoS information error.')) self._assert_rest_result(result, _('Get QoS information error.'))
@ -1584,10 +1565,8 @@ class RestClient(object):
self._assert_rest_result(result, _('Remove iscsi from host error.')) self._assert_rest_result(result, _('Remove iscsi from host error.'))
def get_host_online_fc_initiators(self, host_id): def get_host_online_fc_initiators(self, host_id):
url = "/fc_initiator" url = "/fc_initiator?PARENTTYPE=21&PARENTID=%s" % host_id
data = json.dumps({'PARENTTYPE': 21, result = self.call(url, None, "GET")
'PARENTID': host_id})
result = self.call(url, data, "GET")
initiators = [] initiators = []
if 'data' in result: if 'data' in result:
@ -1599,10 +1578,8 @@ class RestClient(object):
return initiators return initiators
def get_host_fc_initiators(self, host_id): def get_host_fc_initiators(self, host_id):
url = "/fc_initiator" url = "/fc_initiator?PARENTTYPE=21&PARENTID=%s" % host_id
data = json.dumps({'PARENTTYPE': 21, result = self.call(url, None, "GET")
'PARENTID': host_id})
result = self.call(url, data, "GET")
initiators = [] initiators = []
if 'data' in result: if 'data' in result:
@ -1613,10 +1590,8 @@ class RestClient(object):
return initiators return initiators
def get_host_iscsi_initiators(self, host_id): def get_host_iscsi_initiators(self, host_id):
url = "/iscsi_initiator" url = "/iscsi_initiator?PARENTTYPE=21&PARENTID=%s" % host_id
data = json.dumps({'PARENTTYPE': 21, result = self.call(url, None, "GET")
'PARENTID': host_id})
result = self.call(url, data, "GET")
initiators = [] initiators = []
if 'data' in result: if 'data' in result:
@ -1655,9 +1630,8 @@ class RestClient(object):
self._assert_rest_result(result, _('Remove fc from host error.')) self._assert_rest_result(result, _('Remove fc from host error.'))
def check_fc_initiators_exist_in_host(self, host_id): def check_fc_initiators_exist_in_host(self, host_id):
url = '/fc_initiator?range=[0-256]' url = "/fc_initiator?range=[0-100]&PARENTID=%s" % host_id
data = json.dumps({"PARENTID": host_id}) result = self.call(url, None, "GET")
result = self.call(url, data, "GET")
self._assert_rest_result(result, _('Get host initiators info failed.')) self._assert_rest_result(result, _('Get host initiators info failed.'))
if 'data' in result: if 'data' in result:
return True return True
@ -1666,10 +1640,8 @@ class RestClient(object):
def _fc_initiator_is_added_to_array(self, ininame): def _fc_initiator_is_added_to_array(self, ininame):
"""Check whether the fc initiator is already added on the array.""" """Check whether the fc initiator is already added on the array."""
url = '/fc_initiator/' + ininame url = "/fc_initiator/" + ininame
data = json.dumps({"TYPE": '223', result = self.call(url, None, "GET")
"ID": ininame})
result = self.call(url, data, "GET")
error_code = result['error']['code'] error_code = result['error']['code']
if error_code != 0: if error_code != 0:
return False return False