def OnlineLunSmartCache(self): smartcache_info = common.GetSmartCacheInfoById(self.lun_info.Extensions[msg_pds.ext_luninfo_smartcache_id]) self.ios_request_body.node_name = g.node_info.node_name self.ios_request_body.lun_id = self.lun_info.lun_id self.ios_request_body.lun_name = self.lun_info.lun_name self.ios_request_body.lun_type = self.lun_info.lun_type self.ios_request_body.keep_res = True self.ios_request_body.Extensions[msg_ios.ext_lunaddrequest_smartcache].CopyFrom(smartcache_info) self.SendRequest(g.ios_service.listen_ip, g.ios_service.listen_port, self.ios_request, self.Entry_OnlineLun) return MS_CONTINUE
def drop_lun(self): # 请求转发给对应的ios节点 self.ios_request = MakeRequest(msg_ios.LUN_DROP_REQUEST, self.request) self.ios_request_body = self.ios_request.body.Extensions[msg_ios.lun_drop_request] self.ios_request_body.node_name = g.node_info.node_name self.ios_request_body.lun_id = self.lun_info.lun_id self.ios_request_body.lun_name = self.lun_info.lun_name self.ios_request_body.lun_type = self.lun_info.lun_type self.ios_request_body.keep_res = False group_uuids = [] for guuid in self.lun_info.group_info: group_uuids.append(guuid.group_uuid) self.ios_request_body.group_name.extend(group_uuids) if self.lun_info.lun_type == msg_pds.LUN_TYPE_SMARTCACHE: smartcache_info = common.GetSmartCacheInfoById(self.lun_info.Extensions[msg_pds.ext_luninfo_smartcache_id]) self.ios_request_body.Extensions[msg_ios.ext_lundroprequest_smartcache].CopyFrom(smartcache_info) elif self.lun_info.lun_type == msg_pds.LUN_TYPE_BASEDISK: basedisk_info = common.GetBaseDiskInfoById(self.lun_info.Extensions[msg_pds.ext_luninfo_basedisk_id]) self.ios_request_body.Extensions[msg_ios.ext_lundroprequest_basedisk].CopyFrom(basedisk_info) elif self.lun_info.lun_type == msg_pds.LUN_TYPE_PALCACHE: palcache_info = common.GetPalCacheInfoById(self.lun_info.Extensions[msg_pds.ext_luninfo_palcache_id]) # palcache类型需要补充pool的名字, 解决palcache不可用时, 设置obsolete的过程 palcache_info.Extensions[msg_ios.ext_palcacheinfo_pool_name] = common.GetPoolInfoById(palcache_info.pool_id).pool_name self.ios_request_body.Extensions[msg_ios.ext_lundroprequest_palcache].CopyFrom(palcache_info) elif self.lun_info.lun_type == msg_pds.LUN_TYPE_PALRAW: palraw_info = common.GetPalRawInfoById(self.lun_info.Extensions[msg_pds.ext_luninfo_palraw_id]) self.ios_request_body.Extensions[msg_ios.ext_lundroprequest_palraw].CopyFrom(palraw_info) elif self.lun_info.lun_type == msg_pds.LUN_TYPE_PALPMT: palpmt_info = common.GetPalPmtInfoById(self.lun_info.Extensions[msg_pds.ext_luninfo_palpmt_id]) self.ios_request_body.Extensions[msg_ios.ext_lundroprequest_palpmt].CopyFrom(palpmt_info) elif self.lun_info.lun_type == msg_pds.LUN_TYPE_BASEDEV: basedev_info = common.GetBaseDevInfoById(self.lun_info.Extensions[msg_pds.ext_luninfo_basedev_id]) self.ios_request_body.Extensions[msg_ios.ext_lundroprequest_basedev].CopyFrom(basedev_info) else: assert(0) self.SendRequest(g.ios_service.listen_ip, g.ios_service.listen_port, self.ios_request, self.Entry_LunDrop) return MS_CONTINUE
def INIT(self, request): self.response = MakeResponse(msg_mds.GET_LUN_LIST_RESPONSE, request) self.request = request self.request_body = request.body.Extensions[ msg_mds.get_lun_list_request] if g.is_ready == False: self.response.rc.retcode = msg_mds.RC_MDS_SERVICE_IS_NOT_READY self.response.rc.message = "MDS service is not ready" self.SendResponse(self.response) return MS_FINISH self.qos_name = "" if self.request_body.HasField("qos_name"): self.qos_name = self.request_body.qos_name self.qos_template_info = common.GetQosTemplateInfoByName( self.qos_name) if not self.qos_template_info: self.response.rc.retcode = msg_mds.RC_MDS_QOS_TEMPLATE_NOT_EXIST self.response.rc.message = "QoS '%s' is not exist" % self.qos_name self.SendResponse(self.response) return MS_FINISH self.group_name = "" if self.request_body.HasField("group_name"): self.group_name = self.request_body.group_name error, self.group_info = common.GetGroupInfoFromName( self.group_name) if error: self.response.rc.retcode = msg_mds.RC_MDS_GROUP_FIND_FAIL self.response.rc.message = "Not found group %s" % self.group_name self.SendResponse(self.response) return MS_FINISH for _lun_info in g.lun_list.lun_infos: # 过滤指定qos下的lun if self.qos_name and _lun_info.qos_template_name != self.qos_name: continue if self.group_name and self.group_name not in _lun_info.group_name: continue lun_info = msg_pds.LunInfo() lun_info.CopyFrom(_lun_info) for group in lun_info.group_info: error, index = common.GetIndexFromUUID(group.group_uuid) if not error: lun_info.node_index.extend([index]) if lun_info.lun_type == msg_pds.LUN_TYPE_BASEDISK: basedisk_info = common.GetBaseDiskInfoById( lun_info.Extensions[msg_pds.ext_luninfo_basedisk_id]) data_disk_info = common.GetDiskInfoByID(basedisk_info.disk_id) data_part_info = common.GetDiskPartByID( basedisk_info.disk_id, basedisk_info.disk_part) lun_info.Extensions[ msg_mds.ext_luninfo_size] = data_part_info.size lun_info.Extensions[msg_mds.ext_luninfo_scsiid] = "xx" lun_info.Extensions[ msg_mds.ext_luninfo_node_name] = g.node_info.node_name lun_info.Extensions[ msg_mds. ext_luninfo_data_dev_name] = data_part_info.dev_name lun_info.Extensions[ msg_mds.ext_luninfo_data_disk_name] = "%sp%s" % ( data_disk_info.disk_name, data_part_info.disk_part) lun_info.Extensions[ msg_mds. ext_luninfo_data_actual_state] = data_part_info.actual_state elif lun_info.lun_type == msg_pds.LUN_TYPE_BASEDEV: basedev_info = common.GetBaseDevInfoById( lun_info.Extensions[msg_pds.ext_luninfo_basedev_id]) lun_info.Extensions[ msg_mds.ext_luninfo_size] = basedev_info.size lun_info.Extensions[msg_mds.ext_luninfo_scsiid] = "xx" lun_info.Extensions[ msg_mds.ext_luninfo_node_name] = g.node_info.node_name lun_info.Extensions[ msg_mds.ext_luninfo_data_dev_name] = basedev_info.dev_name lun_info.Extensions[msg_mds.ext_luninfo_data_disk_name] = "" elif lun_info.lun_type == msg_pds.LUN_TYPE_SMARTCACHE: smartcache_info = common.GetSmartCacheInfoById( lun_info.Extensions[msg_pds.ext_luninfo_smartcache_id]) data_disk_info = common.GetDiskInfoByID( smartcache_info.data_disk_id) data_part_info = common.GetDiskPartByID( smartcache_info.data_disk_id, smartcache_info.data_disk_part) cache_disk_info = common.GetDiskInfoByID( smartcache_info.cache_disk_id) cache_part_info = common.GetDiskPartByID( smartcache_info.cache_disk_id, smartcache_info.cache_disk_part) lun_info.Extensions[ msg_mds.ext_luninfo_size] = data_part_info.size lun_info.Extensions[ msg_mds.ext_luninfo_cache_size] = cache_part_info.size lun_info.Extensions[msg_mds.ext_luninfo_scsiid] = "xx" lun_info.Extensions[ msg_mds.ext_luninfo_node_name] = g.node_info.node_name lun_info.Extensions[ msg_mds. ext_luninfo_data_dev_name] = data_part_info.dev_name lun_info.Extensions[ msg_mds.ext_luninfo_data_disk_name] = "%sp%s" % ( data_disk_info.disk_name, data_part_info.disk_part) lun_info.Extensions[ msg_mds.ext_luninfo_cache_disk_name] = "%sp%s" % ( cache_disk_info.disk_name, cache_part_info.disk_part) lun_info.Extensions[msg_mds.ext_luninfo_cache_dev_name].append( cache_part_info.dev_name) lun_info.Extensions[ msg_mds. ext_luninfo_data_actual_state] = data_part_info.actual_state lun_info.Extensions[ msg_mds.ext_luninfo_cache_actual_state].append( cache_part_info.actual_state) elif lun_info.lun_type == msg_pds.LUN_TYPE_PALCACHE: palcache_info = common.GetPalCacheInfoById( lun_info.Extensions[msg_pds.ext_luninfo_palcache_id]) data_disk_info = common.GetDiskInfoByID(palcache_info.disk_id) data_part_info = common.GetDiskPartByID( palcache_info.disk_id, palcache_info.disk_part) pool_info = common.GetPoolInfoById(palcache_info.pool_id) pool_disk = common.GetDiskInfoByID( pool_info.pool_disk_infos[0].disk_id) pool_part = common.GetDiskPartByID( pool_info.pool_disk_infos[0].disk_id, pool_info.pool_disk_infos[0].disk_part) lun_info.Extensions[ msg_mds.ext_luninfo_size] = data_part_info.size lun_info.Extensions[ msg_mds.ext_luninfo_cache_size] = pool_part.size lun_info.Extensions[msg_mds.ext_luninfo_scsiid] = "xx" lun_info.Extensions[ msg_mds.ext_luninfo_node_name] = g.node_info.node_name lun_info.Extensions[ msg_mds. ext_luninfo_data_dev_name] = data_part_info.dev_name lun_info.Extensions[ msg_mds.ext_luninfo_data_disk_name] = "%sp%s" % ( data_disk_info.disk_name, data_part_info.disk_part) lun_info.Extensions[ msg_mds.ext_luninfo_cache_disk_name] = pool_info.pool_name lun_info.Extensions[msg_mds.ext_luninfo_cache_dev_name].append( pool_part.dev_name) if palcache_info.HasExtension( msg_mds.ext_palcache_export_info): palcache_cache_model = palcache_info.Extensions[ msg_mds.ext_palcache_export_info].palcache_cache_model lun_info.Extensions[ msg_mds. ext_luninfo_palcache_cache_model] = palcache_cache_model lun_info.Extensions[ msg_mds. ext_luninfo_data_actual_state] = data_part_info.actual_state lun_info.Extensions[ msg_mds.ext_luninfo_cache_actual_state].append( pool_part.actual_state) elif lun_info.lun_type == msg_pds.LUN_TYPE_PALRAW: palraw_info = common.GetPalRawInfoById( lun_info.Extensions[msg_pds.ext_luninfo_palraw_id]) data_disk_info = common.GetDiskInfoByID(palraw_info.disk_id) data_part_info = common.GetDiskPartByID( palraw_info.disk_id, palraw_info.disk_part) lun_info.Extensions[ msg_mds.ext_luninfo_size] = data_part_info.size lun_info.Extensions[msg_mds.ext_luninfo_scsiid] = "xx" lun_info.Extensions[ msg_mds.ext_luninfo_node_name] = g.node_info.node_name lun_info.Extensions[ msg_mds. ext_luninfo_data_dev_name] = data_part_info.dev_name lun_info.Extensions[ msg_mds.ext_luninfo_data_disk_name] = "%sp%s" % ( data_disk_info.disk_name, data_part_info.disk_part) lun_info.Extensions[ msg_mds. ext_luninfo_data_actual_state] = data_part_info.actual_state elif lun_info.lun_type == msg_pds.LUN_TYPE_PALPMT: palpmt_info = common.GetPalPmtInfoById( lun_info.Extensions[msg_pds.ext_luninfo_palpmt_id]) pool_info = common.GetPoolInfoById(palpmt_info.pool_id) data_part_info = common.GetDiskPartByID( pool_info.pool_disk_infos[0].disk_id, pool_info.pool_disk_infos[0].disk_part) lun_info.Extensions[ msg_mds.ext_luninfo_size] = palpmt_info.size lun_info.Extensions[ msg_mds.ext_luninfo_node_name] = g.node_info.node_name lun_info.Extensions[ msg_mds.ext_luninfo_data_disk_name] = pool_info.pool_name lun_info.Extensions[ msg_mds. ext_luninfo_data_dev_name] = data_part_info.dev_name lun_info.Extensions[ msg_mds. ext_luninfo_data_actual_state] = data_part_info.actual_state else: assert (0) self.response.body.Extensions[ msg_mds.get_lun_list_response].lun_infos.add().CopyFrom( lun_info) self.response.rc.retcode = msg_pds.RC_SUCCESS self.SendResponse(self.response) return MS_FINISH
def check_lun_state_faulty(self, lun_info): if lun_info.config_state == True and lun_info.actual_state == True: if lun_info.Extensions[ msg_mds.ext_luninfo_lun_export_info].io_error != 0: return True if lun_info.lun_type == msg_pds.LUN_TYPE_BASEDISK: basedisk_info = common.GetBaseDiskInfoById( lun_info.Extensions[msg_pds.ext_luninfo_basedisk_id]) data_part_info = common.GetDiskPartByID( basedisk_info.disk_id, basedisk_info.disk_part) data_actual_state = data_part_info.actual_state elif lun_info.lun_type == msg_pds.LUN_TYPE_BASEDEV: data_actual_state = True elif lun_info.lun_type == msg_pds.LUN_TYPE_SMARTCACHE: smartcache_info = common.GetSmartCacheInfoById( lun_info.Extensions[msg_pds.ext_luninfo_smartcache_id]) data_part_info = common.GetDiskPartByID( smartcache_info.data_disk_id, smartcache_info.data_disk_part) cache_part_info = common.GetDiskPartByID( smartcache_info.cache_disk_id, smartcache_info.cache_disk_part) data_actual_state = data_part_info.actual_state lun_info.Extensions[ msg_mds.ext_luninfo_cache_actual_state].append( cache_part_info.actual_state) elif lun_info.lun_type == msg_pds.LUN_TYPE_PALCACHE: palcache_info = common.GetPalCacheInfoById( lun_info.Extensions[msg_pds.ext_luninfo_palcache_id]) data_part_info = common.GetDiskPartByID( palcache_info.disk_id, palcache_info.disk_part) pool_info = common.GetPoolInfoById(palcache_info.pool_id) pool_part = common.GetDiskPartByID( pool_info.pool_disk_infos[0].disk_id, pool_info.pool_disk_infos[0].disk_part) data_actual_state = data_part_info.actual_state lun_info.Extensions[ msg_mds.ext_luninfo_cache_actual_state].append( pool_part.actual_state) elif lun_info.lun_type == msg_pds.LUN_TYPE_PALRAW: palraw_info = common.GetPalRawInfoById( lun_info.Extensions[msg_pds.ext_luninfo_palraw_id]) data_part_info = common.GetDiskPartByID( palraw_info.disk_id, palraw_info.disk_part) data_actual_state = data_part_info.actual_state elif lun_info.lun_type == msg_pds.LUN_TYPE_PALPMT: palpmt_info = common.GetPalPmtInfoById( lun_info.Extensions[msg_pds.ext_luninfo_palpmt_id]) pool_info = common.GetPoolInfoById(palpmt_info.pool_id) data_part_info = common.GetDiskPartByID( pool_info.pool_disk_infos[0].disk_id, pool_info.pool_disk_infos[0].disk_part) data_actual_state = data_part_info.actual_state else: assert (0) if data_actual_state == False or False in lun_info.Extensions[ msg_mds.ext_luninfo_cache_actual_state]: return True return False
def INIT(self, request): self.response = MakeResponse(msg_mds.GET_DISK_INFO_RESPONSE, request) self.request = request self.request_body = request.body.Extensions[msg_mds.get_disk_info_request] if g.is_ready == False: self.response.rc.retcode = msg_mds.RC_MDS_SERVICE_IS_NOT_READY self.response.rc.message = "MDS service is not ready" self.SendResponse(self.response) return MS_FINISH disk_info = None for _disk_info in g.disk_list.disk_infos: if _disk_info.disk_name == self.request_body.node_disk_name: disk_info = _disk_info break if disk_info == None: self.response.rc.retcode = msg_mds.RC_MDS_DISK_NOT_EXIST self.response.rc.message = "can't find disk %s" % self.request_body.node_disk_name self.SendResponse(self.response) return MS_FINISH # 补充使用该盘的lun列表 lun_infos = common.GetLunInfoByDiskID(disk_info.header.uuid) for lun_info in lun_infos: kv = msg_pds.SimpleKV() kv.value = lun_info.lun_name if lun_info.lun_type == msg_pds.LUN_TYPE_BASEDISK: basedisk_info = common.GetBaseDiskInfoById(lun_info.Extensions[msg_pds.ext_luninfo_basedisk_id]) kv.key = "%s.%s" % (basedisk_info.disk_id, basedisk_info.disk_part) disk_info.Extensions[msg_mds.ext_diskinfo_diskpart_to_lun_name].add().CopyFrom(kv) elif lun_info.lun_type == msg_pds.LUN_TYPE_PALCACHE: palcache_info = common.GetPalCacheInfoById(lun_info.Extensions[msg_pds.ext_luninfo_palcache_id]) kv.key = "%s.%s" % (palcache_info.disk_id, palcache_info.disk_part) disk_info.Extensions[msg_mds.ext_diskinfo_diskpart_to_lun_name].add().CopyFrom(kv) elif lun_info.lun_type == msg_pds.LUN_TYPE_PALRAW: palraw_info = common.GetPalRawInfoById(lun_info.Extensions[msg_pds.ext_luninfo_palraw_id]) kv.key = "%s.%s" % (palraw_info.disk_id, palraw_info.disk_part) disk_info.Extensions[msg_mds.ext_diskinfo_diskpart_to_lun_name].add().CopyFrom(kv) elif lun_info.lun_type == msg_pds.LUN_TYPE_SMARTCACHE: smartcache_info = common.GetSmartCacheInfoById(lun_info.Extensions[msg_pds.ext_luninfo_smartcache_id]) if smartcache_info.data_disk_id == disk_info.header.uuid: kv.key = "%s.%s" % (smartcache_info.data_disk_id, smartcache_info.data_disk_part) disk_info.Extensions[msg_mds.ext_diskinfo_diskpart_to_lun_name].add().CopyFrom(kv) if smartcache_info.cache_disk_id == disk_info.header.uuid: kv.key = "%s.%s" % (smartcache_info.cache_disk_id, smartcache_info.cache_disk_part) disk_info.Extensions[msg_mds.ext_diskinfo_diskpart_to_lun_name_smartcache].add().CopyFrom(kv) elif lun_info.lun_type == msg_pds.LUN_TYPE_BASEDEV: pass elif lun_info.lun_type == msg_pds.LUN_TYPE_PALPMT: pass else: assert(0) # 补充使用该盘的pool列表 pool_infos = common.GetPoolInfoByDiskID(disk_info.header.uuid) for pool_info in pool_infos: for pool_disk_info in pool_info.pool_disk_infos: if pool_disk_info.disk_id == disk_info.header.uuid: kv = msg_pds.SimpleKV() kv.value = pool_info.pool_name kv.key = "%s.%s" % (pool_disk_info.disk_id, pool_disk_info.disk_part) disk_info.Extensions[msg_mds.ext_diskinfo_diskpart_to_pool_name].add().CopyFrom(kv) self.response.body.Extensions[msg_mds.get_disk_info_response].disk_info.CopyFrom(disk_info) self.response.rc.retcode = msg_pds.RC_SUCCESS self.SendResponse(self.response) return MS_FINISH
def INIT(self, request): self.response = MakeResponse(msg_mds.GET_DISK_LIST_RESPONSE, request) self.request = request self.request_body = request.body.Extensions[ msg_mds.get_disk_list_request] if g.is_ready == False: self.response.rc.retcode = msg_mds.RC_MDS_SERVICE_IS_NOT_READY self.response.rc.message = "MDS service is not ready" self.SendResponse(self.response) return MS_FINISH # 初始化过的盘 inited_disk = {'dev_name': [], 'ces_addr': []} for _disk_info in g.disk_list.disk_infos: disk_info = msg_pds.DiskInfo() disk_info.CopyFrom(_disk_info) # 补充磁盘的剩余空间 free_size = disk_info.size for diskpart in disk_info.diskparts: # 减去被lun使用的空间 lun_info = common.GetLunInfoByDiskPart(disk_info.header.uuid, diskpart.disk_part) if lun_info != None: free_size -= diskpart.size # 减去被pool使用的空间 pool_info = common.GetPoolInfoByDiskPart( disk_info.header.uuid, diskpart.disk_part) if pool_info != None: free_size -= diskpart.size disk_info.Extensions[msg_mds.ext_diskinfo_free_size] = free_size # 补充使用该盘的lun列表 lun_infos = common.GetLunInfoByDiskID(disk_info.header.uuid) for lun_info in lun_infos: kv = msg_pds.SimpleKV() kv.value = lun_info.lun_name if lun_info.lun_type == msg_pds.LUN_TYPE_BASEDISK: basedisk_info = common.GetBaseDiskInfoById( lun_info.Extensions[msg_pds.ext_luninfo_basedisk_id]) kv.key = "%s.%s" % (basedisk_info.disk_id, basedisk_info.disk_part) disk_info.Extensions[ msg_mds.ext_diskinfo_diskpart_to_lun_name].add( ).CopyFrom(kv) elif lun_info.lun_type == msg_pds.LUN_TYPE_PALCACHE: palcache_info = common.GetPalCacheInfoById( lun_info.Extensions[msg_pds.ext_luninfo_palcache_id]) kv.key = "%s.%s" % (palcache_info.disk_id, palcache_info.disk_part) disk_info.Extensions[ msg_mds.ext_diskinfo_diskpart_to_lun_name].add( ).CopyFrom(kv) elif lun_info.lun_type == msg_pds.LUN_TYPE_PALRAW: palraw_info = common.GetPalRawInfoById( lun_info.Extensions[msg_pds.ext_luninfo_palraw_id]) kv.key = "%s.%s" % (palraw_info.disk_id, palraw_info.disk_part) disk_info.Extensions[ msg_mds.ext_diskinfo_diskpart_to_lun_name].add( ).CopyFrom(kv) elif lun_info.lun_type == msg_pds.LUN_TYPE_SMARTCACHE: smartcache_info = common.GetSmartCacheInfoById( lun_info.Extensions[msg_pds.ext_luninfo_smartcache_id]) if smartcache_info.data_disk_id == disk_info.header.uuid: kv.key = "%s.%s" % (smartcache_info.data_disk_id, smartcache_info.data_disk_part) disk_info.Extensions[ msg_mds.ext_diskinfo_diskpart_to_lun_name].add( ).CopyFrom(kv) if smartcache_info.cache_disk_id == disk_info.header.uuid: kv.key = "%s.%s" % (smartcache_info.cache_disk_id, smartcache_info.cache_disk_part) disk_info.Extensions[ msg_mds. ext_diskinfo_diskpart_to_lun_name_smartcache].add( ).CopyFrom(kv) elif lun_info.lun_type == msg_pds.LUN_TYPE_BASEDEV: pass else: assert (0) # 补充使用该盘的pool列表 pool_infos = common.GetPoolInfoByDiskID(disk_info.header.uuid) for pool_info in pool_infos: for pool_disk_info in pool_info.pool_disk_infos: if pool_disk_info.disk_id == disk_info.header.uuid: kv = msg_pds.SimpleKV() kv.value = pool_info.pool_name kv.key = "%s.%s" % (pool_disk_info.disk_id, pool_disk_info.disk_part) disk_info.Extensions[ msg_mds.ext_diskinfo_diskpart_to_pool_name].add( ).CopyFrom(kv) self.response.body.Extensions[ msg_mds.get_disk_list_response].disk_infos.add().CopyFrom( disk_info) inited_disk['dev_name'].append(disk_info.dev_name) if disk_info.HasField('raid_disk_info'): ces_addr = "%s:%s:%s" % (disk_info.raid_disk_info.ctl, disk_info.raid_disk_info.eid, disk_info.raid_disk_info.slot) inited_disk['ces_addr'].append(ces_addr) # 补充没有初始化过的盘 for _disk_info in g.disk_list_all.disk_infos: disk_info = msg_pds.DiskInfo() disk_info.CopyFrom(_disk_info) if disk_info.dev_name in inited_disk['dev_name']: continue disk_info.Extensions[ msg_mds.ext_diskinfo_free_size] = disk_info.size self.response.body.Extensions[ msg_mds.get_disk_list_response].disk_infos.add().CopyFrom( disk_info) # 补充没有盘符的raid卡盘 for _raid_disk_info in g.raid_disk_list_all.raid_disk_infos: raid_disk_info = msg_pds.RaidDiskInfo() raid_disk_info.CopyFrom(_raid_disk_info) if raid_disk_info.HasField( 'dev_name') and raid_disk_info.dev_name != "": continue ces_addr = "%s:%s:%s" % (raid_disk_info.ctl, raid_disk_info.eid, raid_disk_info.slot) if ces_addr in inited_disk['ces_addr']: continue self.response.body.Extensions[ msg_mds.get_disk_list_response].raid_disk_infos.add().CopyFrom( raid_disk_info) self.response.rc.retcode = msg_pds.RC_SUCCESS self.SendResponse(self.response) return MS_FINISH