rest_api os-initialize_connection 逻辑分析
- 收到nova请求,POST /volumes/{volume_id}/action 初始化连接请求。body:
{
u'os-initialize_connection': {
u'connector': {
u'initiator': u'iqn.1994-05.com.redhat: cce2fc0a8a',
u'ip': u'172.24.2.218',
u'platform': u'x86_64',
u'host': u'localhost.localdomain',
u'do_local_attach': False,
u'os_type': u'linux2',
u'multipath': False
}
}
}
- 通过volume_id获得volume信息。volume:
Volume(_name_id=None,
admin_metadata={
huawei_lun_wwn='6a4c64f1001db63307a4e1700000001e'
},
attach_status='detached',
availability_zone='nova',
bootable=False,
cluster=>,
cluster_name=None,
consistencygroup=>,
consistencygroup_id=None,
created_at=2017-06-28T05: 14: 04Z,
deleted=False,
deleted_at=None,
display_description='',
display_name='wy_iscsi_volume3',
ec2_id=None,
encryption_key_id=None,
glance_metadata=>,
group=>,
group_id=None,
host='localhost.localdomain@huawei-iscsi-20170628104137#StoragePool_Ou',
id=eac3c181-b02b-4982-9d7e-d273ee2738e0,
launched_at=2017-06-28T05: 14: 05Z,
metadata={
},
migration_status=None,
multiattach=False,
previous_status=None,
project_id='65cc87fa19d74acf97bf8f9b76e2e6ea',
provider_auth=None,
provider_geometry=None,
provider_id=None,
provider_location='30',
replication_driver_data=None,
replication_extended_status=None,
replication_status=None,
scheduled_at=2017-06-28T05: 14: 05Z,
size=1,
snapshot_id=None,
snapshots=>,
source_volid=None,
status='attaching',
terminated_at=None,
updated_at=2017-06-28T05: 14: 31Z,
user_id='246152716574416897f936aa058b861b',
volume_attachment=>,
volume_type=VolumeType(6c766d2a-9638-4c3c-ad27-42be7940a8ba),
volume_type_id=6c766d2a-9638-4c3c-ad27-42be7940a8ba)
3.通过rpc api cinder.volume.manager.VolumeManager#initialize_connection做初始化连接。
cinder.volume.manager.VolumeManager#initialize_connection 逻辑分析
def initialize_connection(self, context, volume, connector):
utils.require_driver_initialized(self.driver)
try:
self.driver.validate_connector(connector)
try:
model_update = self.driver.create_export(context.elevated(),
volume, connector)
try:
if model_update:
volume.update(model_update)
volume.save()
try:
conn_info = self.driver.initialize_connection(volume, connector)
conn_info = self._parse_connection_options(context, volume, conn_info)
LOG.info(_LI("Initialize volume connection completed successfully."),
resource=volume)
return conn_info
- utils.require_driver_initialized(self.driver) 初始化driver。==type(driver)待确定==
- self.driver.validate_connector(connector) 判断connector里是否包含键值对'initiator='。
- model_update = self.driver.create_export(context.elevated(),
volume, connector) ==检查cinder.volume.drivers.huawei.huawei_driver.HuaweiBaseDriver#create_export内容是pass,不知道具体实现。待确定== - conn_info = self.driver.initialize_connection(volume, connector) 调用cinder.volume.drivers.huawei.huawei_driver.HuaweiISCSIDriver#initialize_connection获得连接信息。逻辑见下文。
- conn_info = self._parse_connection_options(context, volume, conn_info) 把之前获得的conn_info作进一步解析封装。
cinder.volume.drivers.huawei.huawei_driver.HuaweiISCSIDriver#initialize_connection 逻辑:
- lun_id, lun_type = self.get_lun_id_and_type(volume) 从上文volume信息里解析出lun_id和lun_type:
lun_id = volume.provider_location # provider_location='30',
lun_type = constants.SNAPSHOT_TYPE # SNAPSHOT_TYPE = '27'
- (iscsi_iqns,target_ips,portgroup_id) = self.client.get_iscsi_params(connector) 获取iscsi_iqns,target_ips,portgroup_id。逻辑见下文分析。
- 获取host_name和host_id。 client.add_host_with_check逻辑见下文分析。
original_host_name = connector['host']
host_name = huawei_utils.encode_host_name(original_host_name)
host_id = self.client.add_host_with_check(host_name,
original_host_name)
- 确认initiator已经在华为存储管理端添加。self.client.ensure_initiator_added(initiator_name, host_id)逻辑见下文分析。
- 去华为存储管理端创建一个名为 'OpenStack_HostGroup_'+host_id 的主机组,hostgroup_id = self.client.add_host_to_hostgroup(host_id)。逻辑见下文分析。
- 创建名为 'OpenStack_LunGroup_'+host_id 的lungroup,并对lungroup和hostgroup建立名为 'OpenStack_Mapping_View_'+host_id 的映射关系。client.do_mapping(lun_id, hostgroup_id host_id, portgroup_id, lun_type),逻辑见下文分析。
- 通过Request url='/lun/associate?TYPE=11&ASSOCIATEOBJTYPE=21&ASSOCIATEOBJID=1' 获取 host lun id= Data['ASSOCIATEMETADATA']['HostLUNID']。
- 从华为xml配置文件获得 CHAPinfo。我们没配。
- 返回结果,例如:
{
'driver_volume_type': 'iscsi',
'data': {
'target_lun': 1,
'volume_id': '95528f43-24e3-4dec-89d3-3eb631ea90c1',
'target_iqn': u'iqn.2006-08.com.huawei: oceanstor: 210048fd8e94f16a: : 1022006: 172.24.3.191',
'target_portal': '172.24.3.191: 3260',
'target_discovered': False
}
}
cinder.volume.drivers.huawei.rest_client.RestClient#get_iscsi_params 逻辑:
- 判断connector['multipath'] is True or False, 这是nova那边设置的值,逻辑里判断nova.conf配置里volume_use_multipath的值,因为我们环境里没有配置,所以走默认false。此处不分析connector['multipath'] is True的情况。
- 如果connector['multipath'] is False,
(1) target_ips = self._get_target_ip(initiator)
检查huawei配置文件里有没有设置TargetIP,有则把TargetIP拼成数组存target_ips;没有的话就用iscsi_default_target_ip。
(2) portgroup_id = None
(3)for ip in target_ips: target_iqn = self._get_tgt_iqn_from_rest(ip) 或者target_iqn = self._get_tgt_iqn(ip)
遍历target_ips,过滤解析出target_iqn。
def _get_tgt_iqn_from_rest(self, target_ip):
url = "/iscsi_tgt_port"
result = self.call(url, None, "GET")
target_iqn = None
if result['error']['code'] != 0:
LOG.warning(_LW("Can't find target iqn from rest."))
return target_iqn
ip_pattern = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
if 'data' in result:
for item in result['data']:
ips = re.findall(ip_pattern, item['ID'])
for ip in ips:
if target_ip == ip:
target_iqn = item['ID']
break
if not target_iqn:
LOG.warning(_LW("Can't find target iqn from rest."))
return target_iqn
split_list = target_iqn.split(",")
target_iqn_before = split_list[0]
split_list_new = target_iqn_before.split("+")
target_iqn = split_list_new[1]
return target_iqn
def _get_tgt_iqn(self, iscsi_ip):
"""Get target iSCSI iqn."""
ip_info = self._get_iscsi_port_info(iscsi_ip)
iqn_prefix = self._get_iscsi_tgt_port()
if not ip_info:
err_msg = (_(
'Get iSCSI port info error, please check the target IP '
'configured in huawei conf file.'))
LOG.error(err_msg)
raise exception.VolumeBackendAPIException(data=err_msg)
LOG.debug('Request ip info is: %s.', ip_info)
split_list = ip_info.split(".")
newstr = split_list[1] + split_list[2]
LOG.info(_LI('New str info is: %s.'), newstr)
if ip_info:
if newstr[0] == 'A':
ctr = "0"
elif newstr[0] == 'B':
ctr = "1"
interface = '0' + newstr[1]
port = '0' + newstr[3]
iqn_suffix = ctr + '02' + interface + port
for i in range(0, len(iqn_suffix)):
if iqn_suffix[i] != '0':
iqn_suffix = iqn_suffix[i:]
break
iqn = iqn_prefix + ':' + iqn_suffix + ':' + iscsi_ip
LOG.info(_LI('_get_tgt_iqn: iSCSI target iqn is: %s.'), iqn)
return iqn
/iscsi_tgt_port 例:
https://172.24.1.33:8088/deviceManager/rest/2102350BVB10H2000009/iscsi_tgt_port
Response Data:{"data":[{"ETHPORTID":"549772722179","ID":"1+iqn.2006-08.com.huawei:oceanstor:2100a4c64f1db633::1020003:172.24.3.35,t,0x0004","TPGT":"4","TYPE":249},{"ETHPORTID":"549772722178","ID":
"1+iqn.2006-08.com.huawei:oceanstor:2100a4c64f1db633::1020002:172.24.3.33,t,0x0003","TPGT":"3","TYPE":249}],"error":{"code":0,"description":"0"}}
cinder.volume.drivers.huawei.rest_client.RestClient#add_host_with_check 逻辑:
- host_id = self.get_host_id_by_name(host_name)
访问华为api url = "/host?range=[0-65535]",得到类似如下结果。遍历Data列表,如果item['NAME']和host_name匹配,则返回item['ID']
Response Data:{"data":[{"DESCRIPTION":"","HEALTHSTATUS":"1","ID":"0","INITIATORNUM":"1","IP":"172.24.9.21","ISADD2HOSTGROUP":"true","LOCATION":"","MODEL":"","NAME":"node11","NETWORKNAME":"","OPERA
TIONSYSTEM":"0","PARENTID":"0","PARENTNAME":"0","PARENTTYPE":14,"RUNNINGSTATUS":"1","TYPE":21},{"DESCRIPTION":"","HEALTHSTATUS":"1","ID":"1","INITIATORNUM":"1","IP":"172.24.3.207","ISADD2HOSTGROUP
":"true","LOCATION":"","MODEL":"","NAME":"songteng_host","NETWORKNAME":"","OPERATIONSYSTEM":"0","PARENTID":"1","PARENTNAME":"1","PARENTTYPE":14,"RUNNINGSTATUS":"1","TYPE":21}],"error":{"code":0,"d
escription":"0"}}
- 如果get_host_id_by_name没得到host_id,说明是初次连接存储设备,则传递host_name给华为api url= "/host" 去建一个新的host。url返回结果取出data['ID']存为host_id。
host_id = self._add_host(host_name, host_name_before_hash)
如下:
Request URL: https://172.24.1.33:8088/deviceManager/rest/2102350BVB10H2000009/host
Call Method: None
Request Data: {"DESCRIPTION": "localhost.localdomain", "TYPE": "21", "NAME": "localhost.localdomain", "OPERATIONSYSTEM": "0"}
Response Data:{"data":{"DESCRIPTION":"localhost.localdomain","HEALTHSTATUS":"1","ID":"2","INITIATORNUM":"0","IP":"","ISADD2HOSTGROUP":"false","LOCATION":"","MODEL":"","NAME":"localhost.localdomain
","NETWORKNAME":"","OPERATIONSYSTEM":"0","PARENTID":"","PARENTNAME":"","PARENTTYPE":14,"RUNNINGSTATUS":"1","TYPE":21},"error":{"code":0,"description":"0"}}
cinder.volume.drivers.huawei.rest_client.RestClient#ensure_initiator_added 逻辑:
- 查找存储管理端是否已经存在initiator。_initiator_is_added_to_array(initiator_name) 访问url = "/iscsi_initiator?range=[0-256]",通过connector['initiator']遍历匹配data['ID'],如果匹配成功返回True。如:
Request URL: https://172.24.1.33:8088/deviceManager/rest/2102350BVB10H2000009/iscsi_initiator?range=[0-256]
Call Method: GET
Request Data: None
Response Data:{"data":[{"HEALTHSTATUS":"1","ID":"iqn.1993-08.org.debian:01:47414e5341ea","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RUNNINGSTATUS":"28","TYPE":222,"USECHAP":"fals
e"},{"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redhat:4153902a6cca","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RUNNINGSTATUS":"28","TYPE":222,"USECHAP":"false"},{"HEALTHSTATUS":"1
","ID":"iqn.1994-05.com.redhat:5c4e2fa14484","ISFREE":"false","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","PARENTID":"1","PARENTNAME":"songteng_host","PARENTTYPE":21,"RUNNINGSTATUS":"27","TYPE":22
2,"USECHAP":"false"},{"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redhat:60d84d1e10ef","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RUNNINGSTATUS":"28","TYPE":222,"USECHAP":"false"},{
"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redhat:83feeda2b41d","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RUNNINGSTATUS":"28","TYPE":222,"USECHAP":"false"},{"HEALTHSTATUS":"1","ID
":"iqn.1994-05.com.redhat:c1b24eb3a28","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RUNNINGSTATUS":"28","TYPE":222,"USECHAP":"false"},{"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redh
at:cce2fc0a8a","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RUNNINGSTATUS":"28","TYPE":222,"USECHAP":"false"},{"HEALTHSTATUS":"1","ID":"iqn.2010-10.org.openstack","ISFREE":"true","
MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RUNNINGSTATUS":"28","TYPE":222,"USECHAP":"false"}],"error":{"code":0,"description":"0"}}
- 如果步骤1得到False,则_add_initiator_to_array(initiator_name)调用url = "/iscsi_initiator" data = {"TYPE": "222","ID": initiator_name,"USECHAP": "false"}去在存储管理端建立一个新的initiator。==没有例子==
- is_initiator_associated_to_host(initiator_name) 再一次访问访问url = "/iscsi_initiator?range=[0-256]", if item['ID'] == initiator_name and item['ISFREE'] == "true": return False
- 如果第三步得到False,执行_associate_initiator_to_host(initiator_name, host_id),给initiator和host做关联。程序里 cinder.volume.drivers.huawei.rest_client.RestClient#_add_initiator_to_host 调用url = "/iscsi_initiator/" + initiator_name data = {"TYPE": "222", "ID": initiator_name, "USECHAP": "false", "PARENTTYPE": "21", "PARENTID": host_id} result = self.call(url, data, "PUT")。如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/iscsi_initiator/iqn.1994-05.com.redhat:9aaffb4dfd4f
Call Method: PUT
Request Data: {"USECHAP": "false", "PARENTTYPE": "21", "TYPE": "222", "ID": "iqn.1994-05.com.redhat:9aaffb4dfd4f", "PARENTID": "1"}
Response Data:{"data":{},"error":{"code":0,"description":"0"}}
cinder.volume.drivers.huawei.rest_client.RestClient#add_host_to_hostgroup 逻辑:
- 通过url = "/hostgroup?range=[0-8191]"查询是否已经有主机组,有则返回hostgroup_id。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/hostgroup?range=[0-8191]
Call Method: GET
Request Data: None
Response Data:{"data":[{"DESCRIPTION":"","ID":"0","ISADD2MAPPINGVIEW":"true","NAME":"OpenStack_HostGroup_0","TYPE":14}],"error":{"code":0,"description":"0"}}
- 没查到hostgroup_id,就通过url = "/hostgroup" data = {"TYPE": "14", "NAME": hostgroup_name}去创建一个主机组。返回hostgroup_id = result['data']['ID']。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/hostgroup
Call Method: None
Request Data: {"TYPE": "14", "NAME": "OpenStack_HostGroup_1"}
Response Data:{"data":{"DESCRIPTION":"","ID":"1","ISADD2MAPPINGVIEW":"false","NAME":"OpenStack_HostGroup_1","TYPE":14},"error":{"code":0,"description":"0"}}
- 通过url = ("/host/associate?TYPE=21&ASSOCIATEOBJTYPE=14&ASSOCIATEOBJID=%s" % hostgroup_id)检查hostgroup和host是否已关联。有则返回True。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/host/associate?TYPE=21&ASSOCIATEOBJTYPE=14&ASSOCIATEOBJID=1
Call Method: GET
Request Data: None
Response Data:{"error":{"code":0,"description":"0"}}
- 第3步False,则通过url = "/hostgroup/associate" data = {"TYPE": "14", "ID": hostgroup_id, "ASSOCIATEOBJTYPE": "21", "ASSOCIATEOBJID": host_id} 给hostgroup和host建立关联。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/hostgroup/associate
Call Method: None
Request Data: {"ASSOCIATEOBJID": "1", "TYPE": "14", "ID": "1", "ASSOCIATEOBJTYPE": "21"}
Response Data:{"data":{},"error":{"code":0,"description":"0"}}
cinder.volume.drivers.huawei.rest_client.RestClient#do_mapping 逻辑分析:
- 通过url = "/lungroup?range=[0-8191]" 查找名为 'OpenStack_LunGroup_'+host_id 的lungroup,有则返回lungroup_id。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/lungroup?range=[0-8191]
Call Method: GET
Request Data: None
Response Data:{"data":[{"APPTYPE":"0","CAPCITY":"2097152","CONFIGDATA":"","DESCRIPTION":"","GROUPTYPE":"0","ID":"0","ISADD2MAPPINGVIEW":"false","NAME":"LUNGroup001","TYPE":256},{"APPTYPE":"0","CAP
CITY":"2097152","CONFIGDATA":"","DESCRIPTION":"OpenStack_LunGroup_0","GROUPTYPE":"0","ID":"1","ISADD2MAPPINGVIEW":"true","NAME":"OpenStack_LunGroup_0","TYPE":256}],"error":{"code":0,"description":
"0"}}
- 通过url = "/mappingview?range=[0-8191]" 查找名为 'OpenStack_Mapping_View_'+host_id 的映射关系,有则返回view_id。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/mappingview?range=[0-8191]
Call Method: GET
Request Data: None
Response Data:{"data":[{"DESCRIPTION":"","ENABLEINBANDCOMMAND":"false","ID":"1","INBANDLUNWWN":"","NAME":"OpenStack_Mapping_View_0","TYPE":245}],"error":{"code":0,"description":"0"}}
- 如果没有找到lungroup,则通过 url = "/lungroup" data = {"DESCRIPTION": lungroup_name, "APPTYPE": '0', "GROUPTYPE": '0', "NAME": lungroup_name} 创建一个新的lungroup,并返回lungroup_id。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/lungroup
Call Method: None
Request Data: {"GROUPTYPE": "0", "DESCRIPTION": "OpenStack_LunGroup_1", "APPTYPE": "0", "NAME": "OpenStack_LunGroup_1"}
Response Data:{"data":{"APPTYPE":"0","CONFIGDATA":"","DESCRIPTION":"OpenStack_LunGroup_1","GROUPTYPE":"0","HEALTHSTATUS":"1","ID":"2","ISADD2MAPPINGVIEW":"false","NAME":"OpenStack_LunGroup_1","RUN
NINGSTATUS":"53","TYPE":256},"error":{"code":0,"description":"0"}}
- 通过url = ("/%s/associate?TYPE=%s&ASSOCIATEOBJTYPE=256&ASSOCIATEOBJID=%s" % (cmd_type, lun_type, lungroup_id)) 检查lun和lungroup已关联。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/lun/associate?TYPE=11&ASSOCIATEOBJTYPE=256&ASSOCIATEOBJID=2
Call Method: GET
Request Data: None
Response Data:{"error":{"code":0,"description":"0"}}
- 第4步检查出无关联,则通过 url = "/lungroup/associate" data = {"ID": lungroup_id, "ASSOCIATEOBJTYPE": lun_type, "ASSOCIATEOBJID": lun_id} 将lun 关联至 lungroup。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/lungroup/associate
Call Method: None
Request Data: {"ASSOCIATEOBJID": "4", "ID": "2", "ASSOCIATEOBJTYPE": "11"}
Response Data:{"data":{},"error":{"code":0,"description":"0"}}
- 如果lungourp和hostgroup没有映射,则通过 url = "/mappingview" data = {"NAME": name, "TYPE": "245"} 建立映射,并返回view_id。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/mappingview
Call Method: None
Request Data: {"TYPE": "245", "NAME": "OpenStack_Mapping_View_1"}
Response Data:{"data":{"AVAILABLEHOSTLUNIDLIST":"[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,
113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,
162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,
211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]","DESCRIPTION":
"","ENABLEINBANDCOMMAND":"false","ID":"2","INBANDLUNWWN":"","NAME":"OpenStack_Mapping_View_1","TYPE":245},"error":{"code":0,"description":"0"}}
- 把 hostgroup 关联至 view。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/MAPPINGVIEW/CREATE_ASSOCIATE
Call Method: PUT
Request Data: {"ASSOCIATEOBJID": "1", "TYPE": "245", "ASSOCIATEOBJTYPE": "14", "ID": "2"}
Response Data:{"data":{},"error":{"code":0,"description":"0"}}
- 把 lungroup 关联至 view。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/MAPPINGVIEW/CREATE_ASSOCIATE
Call Method: PUT
Request Data: {"ASSOCIATEOBJID": "2", "TYPE": "245", "ASSOCIATEOBJTYPE": "256", "ID": "2"}
Response Data:{"data":{},"error":{"code":0,"description":"0"}}
- 如果之前有获得 portgroup_id,通过url = "/MAPPINGVIEW/CREATE_ASSOCIATE" data = {"ASSOCIATEOBJTYPE": "257", "ASSOCIATEOBJID": portgroup_id, "TYPE": "245", "ID": view_id} 将portgroup关联至view。由于我们没有配置multipath,之前获得portgroup_id为空,此处无例子。
- 通过url = "/system/" 获得version。如果version大于等于'V300R003C00',通过url = "/MAPPINGVIEW/" + view_id获得data["AVAILABLEHOSTLUNIDLIST"]存给aval_luns。例如:
Request URL: https://172.24.2.32:8088/deviceManager/rest/2102351CAK10GB000007/MAPPINGVIEW/2
/MAPPINGVIEW
Response Data:{"data":[{"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redhat:83feeda2b41d","ISFREE":"false","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","PARENTID":"0","PARENTNAME":"localhost.localdomai
n","PARENTTYPE":21,"RUNNINGSTATUS":"28","TYPE":222,"USECHAP":"false"},{"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redhat:8a94ece3946e","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RU
NNINGSTATUS":"28","TYPE":222,"USECHAP":"false"},{"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redhat:9aaffb4dfd4f","ISFREE":"false","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","PARENTID":"1","PARENTNA
ME":"node16","PARENTTYPE":21,"RUNNINGSTATUS":"27","TYPE":222,"USECHAP":"false"},{"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redhat:c1de51f7e4f","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":
"255","RUNNINGSTATUS":"27","TYPE":222,"USECHAP":"false"},{"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redhat:e08ae3b9ff2","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RUNNINGSTATUS":"
28","TYPE":222,"USECHAP":"false"},{"HEALTHSTATUS":"1","ID":"iqn.1994-05.com.redhat:f4594f80d02f","ISFREE":"true","MULTIPATHTYPE":"0","OPERATIONSYSTEM":"255","RUNNINGSTATUS":"28","TYPE":222,"USECHA
P":"false"}],"error":{"code":0,"description":"0"}}
结论与疑问:
- 对于华为xml配置文件里的配置项
,在初始化连接相关代码里我没有读到对其的读取操作,甚至在驱动代码里都没有捞到HostIP和OSType关键字。目前怀疑这个Host配置项没用处。还需要进一步实验验证。 - 华为xml配置文件里的配置项
。从初始化连接代码里看,如果没有配置TargetIP,但是有配置 ,程序就用DefaultTargetIP作为TargetIP。没有看到对Name配置项的读取使用,target_iqn 是通过TargetIP 去查询华为rest_url后解析封装获得的。