cinder 初始化卷连接逻辑

rest_api os-initialize_connection 逻辑分析

  1. 收到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
        }
    }
}
  1. 通过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
  1. utils.require_driver_initialized(self.driver) 初始化driver。==type(driver)待确定==
  2. self.driver.validate_connector(connector) 判断connector里是否包含键值对'initiator='。
  3. model_update = self.driver.create_export(context.elevated(),
    volume, connector) ==检查cinder.volume.drivers.huawei.huawei_driver.HuaweiBaseDriver#create_export内容是pass,不知道具体实现。待确定==
  4. conn_info = self.driver.initialize_connection(volume, connector) 调用cinder.volume.drivers.huawei.huawei_driver.HuaweiISCSIDriver#initialize_connection获得连接信息。逻辑见下文。
  5. conn_info = self._parse_connection_options(context, volume, conn_info) 把之前获得的conn_info作进一步解析封装。

cinder.volume.drivers.huawei.huawei_driver.HuaweiISCSIDriver#initialize_connection 逻辑:

  1. 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'
  1. (iscsi_iqns,target_ips,portgroup_id) = self.client.get_iscsi_params(connector) 获取iscsi_iqns,target_ips,portgroup_id。逻辑见下文分析。
  2. 获取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)
  1. 确认initiator已经在华为存储管理端添加。self.client.ensure_initiator_added(initiator_name, host_id)逻辑见下文分析。
  2. 去华为存储管理端创建一个名为 'OpenStack_HostGroup_'+host_id 的主机组,hostgroup_id = self.client.add_host_to_hostgroup(host_id)。逻辑见下文分析。
  3. 创建名为 '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),逻辑见下文分析。
  4. 通过Request url='/lun/associate?TYPE=11&ASSOCIATEOBJTYPE=21&ASSOCIATEOBJID=1' 获取 host lun id= Data['ASSOCIATEMETADATA']['HostLUNID']。
  5. 从华为xml配置文件获得 CHAPinfo。我们没配。
  6. 返回结果,例如:
{
    '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 逻辑:

  1. 判断connector['multipath'] is True or False, 这是nova那边设置的值,逻辑里判断nova.conf配置里volume_use_multipath的值,因为我们环境里没有配置,所以走默认false。此处不分析connector['multipath'] is True的情况。
  2. 如果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 逻辑:

  1. 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"}}
  1. 如果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 逻辑:

  1. 查找存储管理端是否已经存在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. 如果步骤1得到False,则_add_initiator_to_array(initiator_name)调用url = "/iscsi_initiator" data = {"TYPE": "222","ID": initiator_name,"USECHAP": "false"}去在存储管理端建立一个新的initiator。==没有例子==
  2. is_initiator_associated_to_host(initiator_name) 再一次访问访问url = "/iscsi_initiator?range=[0-256]", if item['ID'] == initiator_name and item['ISFREE'] == "true": return False
  3. 如果第三步得到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 逻辑:

  1. 通过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"}}
  1. 没查到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"}}
  1. 通过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"}}
  1. 第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 逻辑分析:

  1. 通过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"}}
  1. 通过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"}}
  1. 如果没有找到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"}}
  1. 通过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"}}
  1. 第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"}}
  1. 如果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"}}
  1. 把 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"}}
  1. 把 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"}}
  1. 如果之前有获得 portgroup_id,通过url = "/MAPPINGVIEW/CREATE_ASSOCIATE" data = {"ASSOCIATEOBJTYPE": "257", "ASSOCIATEOBJID": portgroup_id, "TYPE": "245", "ID": view_id} 将portgroup关联至view。由于我们没有配置multipath,之前获得portgroup_id为空,此处无例子。
  2. 通过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配置文件里的配置项<Host HostIP="172.24.2.218" OSType="Linux" />,在初始化连接相关代码里我没有读到对其的读取操作,甚至在驱动代码里都没有捞到HostIP和OSType关键字。目前怀疑这个Host配置项没用处。还需要进一步实验验证。
  • 华为xml配置文件里的配置项<Initiator Name="iqn.1994-05.com.redhat:cce2fc0a8a" TargetIP="172.24.1.33" />。从初始化连接代码里看,如果没有配置TargetIP,但是有配置<DefaultTargetIP>,程序就用DefaultTargetIP作为TargetIP。没有看到对Name配置项的读取使用,target_iqn 是通过TargetIP 去查询华为rest_url后解析封装获得的。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,053评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,527评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,779评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,685评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,699评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,609评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,989评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,654评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,890评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,634评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,716评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,394评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,976评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,950评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,191评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,849评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,458评论 2 342

推荐阅读更多精彩内容

  • •王越:VMware存储API整理,比如核心的存储池与卷两者的CURD。可以参考:VMware in OpenSt...
    笨手笨脚越阅读 5,618评论 0 2
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,591评论 18 139
  • # 一度蜜v3.0协议 --- # 交互协议 [TOC] ## 协议说明 ### 请求参数 下表列出了v3.0版协...
    c5e350bc5b40阅读 640评论 0 0
  • 上一篇学习的UITableView的创建和基础使用,当然这只是单机而已,下面我们来学习联网,额!貌似学习的有点跳,...
    繁华乱世沧桑了谁的容颜阅读 1,015评论 0 2
  • 再过不到十天,科比即将迎来第20个赛季,在这个生涯末年,科比将会如何调整自己,给球队带来最大的帮助,这将是新赛季的...
    篮球故事阅读 2,738评论 12 40