From 2fc4fd6629551f13bbfa012fadc90ab1c7fd3a5d Mon Sep 17 00:00:00 2001 From: sunyongjie2010 Date: Fri, 5 Dec 2025 09:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96raid=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=B7=B2=E7=9F=A5bug=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/api/bean/raid/RaidConfigXmlBean.java | 179 ++++++++++++++++++ .../base/api/bean/raid/RaidDriveBean.java | 148 +++++++++++++++ 2 files changed, 327 insertions(+) create mode 100644 InManageBoot-iboot/v7.4.0/cosmos-biz-iboot-base/cosmos-biz-iboot-base-api/src/main/java/com/anarchy/cosmos/iboot/base/api/bean/raid/RaidConfigXmlBean.java create mode 100644 InManageBoot-iboot/v7.4.0/cosmos-biz-iboot-base/cosmos-biz-iboot-base-api/src/main/java/com/anarchy/cosmos/iboot/base/api/bean/raid/RaidDriveBean.java diff --git a/InManageBoot-iboot/v7.4.0/cosmos-biz-iboot-base/cosmos-biz-iboot-base-api/src/main/java/com/anarchy/cosmos/iboot/base/api/bean/raid/RaidConfigXmlBean.java b/InManageBoot-iboot/v7.4.0/cosmos-biz-iboot-base/cosmos-biz-iboot-base-api/src/main/java/com/anarchy/cosmos/iboot/base/api/bean/raid/RaidConfigXmlBean.java new file mode 100644 index 0000000..eee7d72 --- /dev/null +++ b/InManageBoot-iboot/v7.4.0/cosmos-biz-iboot-base/cosmos-biz-iboot-base-api/src/main/java/com/anarchy/cosmos/iboot/base/api/bean/raid/RaidConfigXmlBean.java @@ -0,0 +1,179 @@ +package com.anarchy.cosmos.iboot.base.api.bean.raid; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.json.JSONUtil; +import lombok.Data; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @description + * @auther gengzhicheng + * @date 2023/4/14 + */ +@Data +public class RaidConfigXmlBean { + + private RangeBean logical; + private RangeBean global; + private RangeBean dedicated; + private RangeBean jbod; + + private Boolean bootDisk; + + private ValueBean raidLevel; + private ValueBean strip; + private ValueBean readPolicy; + private ValueBean writePolicy; + private ValueBean ioPolicy; + private ValueBean cachePolicy; + private ValueBean accessPolicy; + + private NumberBean RAID0; + private NumberBean RAID1; + private NumberBean RAID5; + private NumberBean RAID6; + private NumberBean RAID10; + private NumberBean RAID1E; + private NumberBean RAID50; + private NumberBean RAID60; + + public static void main(String[] args) { +// String content="[{\"controllerId\":\"0\",\"drives\":[{\"controllerId\":\"0\",\"driveGroup\":\"-\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"5\",\"status\":\"JBOD\"},{\"controllerId\":\"0\",\"driveGroup\":\"-\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"6\",\"status\":\"JBOD\"},{\"controllerId\":\"0\",\"driveGroup\":\"-\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"2\",\"status\":\"HOT_SPARE\"}],\"productName\":\"AVAGO MegaRAID SAS 9460-8i\",\"type\":\"LSI\",\"volumes\":[{\"accessPolicy\":\"\",\"backPlane\":\"\",\"boot\":\"\",\"cachePolicy\":\"Disk's Default\",\"capacity\":\"1.090TB\",\"driveGroup\":\"0\",\"drives\":[{\"controllerId\":\"0\",\"driveGroup\":\"0\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"0\",\"status\":\"ONLINE\"},{\"controllerId\":\"0\",\"driveGroup\":\"0\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"1\",\"status\":\"ONLINE\"},{\"controllerId\":\"0\",\"driveGroup\":\"0\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"4\",\"status\":\"HOT_SPARE\"}],\"ioPolicy\":\"\",\"name\":\"\",\"raidType\":\"RAID1\",\"readPolicy\":\"\",\"slot\":\"133:0,133:1\",\"strip\":\"256 KB\",\"vid\":\"0\",\"writePolicy\":\"\"}]}]"; + String content = "[{\"controllerId\":\"0\",\"drives\":[{\"controllerId\":\"0\",\"driveGroup\":\"-\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"5\",\"status\":\"JBOD\"},{\"controllerId\":\"0\",\"driveGroup\":\"-\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"6\",\"status\":\"JBOD\"},{\"controllerId\":\"0\",\"driveGroup\":\"-\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"2\",\"status\":\"HOT_SPARE\"}],\"productName\":\"AVAGO MegaRAID SAS 9460-8i\",\"type\":\"LSI\",\"volumes\":[{\"accessPolicy\":\"\",\"backPlane\":\"\",\"boot\":\"\",\"cachePolicy\":\"Disk's Default\",\"capacity\":\"1.090TB\",\"driveGroup\":\"0\",\"drives\":[{\"controllerId\":\"0\",\"driveGroup\":\"0\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"0\",\"status\":\"ONLINE\"},{\"controllerId\":\"0\",\"driveGroup\":\"0\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"1\",\"status\":\"ONLINE\"},{\"controllerId\":\"0\",\"driveGroup\":\"0\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"4\",\"status\":\"HOT_SPARE\"}],\"ioPolicy\":\"\",\"name\":\"\",\"raidType\":\"RAID1\",\"readPolicy\":\"\",\"slot\":\"133:0,133:1\",\"strip\":\"256 KB\",\"vid\":\"0\",\"writePolicy\":\"\"}]},{\"controllerId\":\"1\",\"drives\":[{\"controllerId\":\"1\",\"driveGroup\":\"-\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"5\",\"status\":\"JBOD\"},{\"controllerId\":\"1\",\"driveGroup\":\"-\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"6\",\"status\":\"JBOD\"},{\"controllerId\":\"1\",\"driveGroup\":\"-\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"2\",\"status\":\"HOT_SPARE\"}],\"productName\":\"AVAGO MegaRAID SAS 9461-8i\",\"type\":\"LSI\",\"volumes\":[{\"accessPolicy\":\"\",\"backPlane\":\"\",\"boot\":\"\",\"cachePolicy\":\"Disk's Default\",\"capacity\":\"1.090TB\",\"driveGroup\":\"0\",\"drives\":[{\"controllerId\":\"1\",\"driveGroup\":\"0\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"0\",\"status\":\"ONLINE\"},{\"controllerId\":\"1\",\"driveGroup\":\"0\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"1\",\"status\":\"ONLINE\"},{\"controllerId\":\"1\",\"driveGroup\":\"0\",\"enclosureId\":\"133\",\"mediaType\":\"HDD\",\"rawSize\":\"1.090TB\",\"slotNumber\":\"4\",\"status\":\"HOT_SPARE\"}],\"ioPolicy\":\"\",\"name\":\"\",\"raidType\":\"RAID1\",\"readPolicy\":\"\",\"slot\":\"133:0,133:1\",\"strip\":\"256 KB\",\"vid\":\"0\",\"writePolicy\":\"\"}]}]"; +// List raidSingeBeans= JSONUtil.toList(JSONUtil.parseArray(content),RaidSingeBean.class); + List raidTreeList = new ArrayList(); + if (StringUtils.isNotEmpty(content)) { + List raidSingeBeans = JSONUtil.toList(JSONUtil.parseArray(content), RaidSingeBean.class); + for (RaidSingeBean raidSingeBean : raidSingeBeans) {//第一层处理raid + RaidTreeBean raidTreeBean = new RaidTreeBean(); + String firstParantKey = "c" + raidSingeBean.getControllerId(); + raidTreeBean.setKey(firstParantKey); + raidTreeBean.setTitle("/c" + raidSingeBean.getControllerId() + ":" + raidSingeBean.getType().toUpperCase() + ":" + raidSingeBean.getProductName()); + raidTreeBean.setType("card"); + raidTreeBean.setParent(""); + raidTreeBean.setStatus(""); + raidTreeBean.setContent(""); + //处理第二层的逻辑盘 + List raidChildren = new ArrayList(); + List volumes = raidSingeBean.getVolumes(); + if (CollectionUtil.isNotEmpty(volumes)) { + for (RaidVolumeBean raidVolumeBean : volumes) { + RaidTreeBean volumeTree = new RaidTreeBean(); + String twoParantKey = firstParantKey + "v" + raidVolumeBean.getVid(); + volumeTree.setKey(twoParantKey); + volumeTree.setParent(firstParantKey); + volumeTree.setType("logical"); + volumeTree.setStatus(""); + volumeTree.setTitle(raidVolumeBean.getRaidType() + "-" + raidVolumeBean.getCapacity() + "-VID" + raidVolumeBean.getVid() + "-DG" + raidVolumeBean.getDriveGroup()); + volumeTree.setContent(JSONUtil.toJsonStr(raidVolumeBean)); + List volumeDiskTreeList = new ArrayList(); + if (CollectionUtil.isNotEmpty(raidVolumeBean.getDrives())) { + for (RaidDriveBean raidDriveBean : raidVolumeBean.getDrives()) { + RaidTreeBean diskTree = new RaidTreeBean(); + diskTree.setType("disk"); + diskTree.setParent(twoParantKey); + String threeParantKey = twoParantKey + "d" + raidDriveBean.getSlotNumber(); + diskTree.setKey(threeParantKey); + diskTree.setStatus(raidDriveBean.getStatus()); + diskTree.setTitle(raidDriveBean.getEnclosureId() + "-" + raidDriveBean.getSlotNumber() + "-" + raidDriveBean.getRawSize()); + diskTree.setContent(JSONUtil.toJsonStr(raidDriveBean)); + volumeDiskTreeList.add(diskTree); + } + } + volumeTree.setChildren(volumeDiskTreeList); + raidChildren.add(volumeTree); + } + } + //处理第二次的JBOD + List drives = raidSingeBean.getDrives(); + List jobdList = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(drives)) { + for (RaidDriveBean raidDriveBean : drives) { + if (raidDriveBean.getStatus().equals("JBOD")) { + jobdList.add(raidDriveBean); + } + } + } + if (CollectionUtil.isNotEmpty(jobdList)) { + RaidTreeBean jobdTree = new RaidTreeBean(); + jobdTree.setType("jbod"); + jobdTree.setTitle("JBOD"); + String twoParantKey = firstParantKey + "j0"; + jobdTree.setKey(twoParantKey); + jobdTree.setParent(firstParantKey); + List jbodChidredTreeList = new ArrayList(); + for (RaidDriveBean raidDriveBean : jobdList) { + RaidTreeBean diskTree = new RaidTreeBean(); + diskTree.setType("disk"); + diskTree.setParent(twoParantKey); + String threeParantKey = twoParantKey + "d" + raidDriveBean.getSlotNumber(); + diskTree.setKey(threeParantKey); + diskTree.setStatus(raidDriveBean.getStatus()); + diskTree.setTitle(raidDriveBean.getEnclosureId() + "-" + raidDriveBean.getSlotNumber() + "-" + raidDriveBean.getRawSize()); + diskTree.setContent(JSONUtil.toJsonStr(raidDriveBean)); + jbodChidredTreeList.add(diskTree); + } + jobdTree.setChildren(jbodChidredTreeList); + raidChildren.add(jobdTree); + } + //处理单个盘 + if (CollectionUtil.isNotEmpty(drives)) { + for (RaidDriveBean raidDriveBean : drives) { + if (!raidDriveBean.getStatus().equals("JBOD")) { + String twoParantKey = firstParantKey + "d" + raidDriveBean.getSlotNumber(); + RaidTreeBean diskTree = new RaidTreeBean(); + diskTree.setType("disk"); + diskTree.setParent(firstParantKey); + diskTree.setKey(twoParantKey); + if (raidDriveBean.getStatus().equals("HOT_SPARE")) { + diskTree.setStatus("SPARE"); + } else { + diskTree.setStatus(raidDriveBean.getStatus()); + } + diskTree.setTitle(raidDriveBean.getEnclosureId() + "-" + raidDriveBean.getSlotNumber() + "-" + raidDriveBean.getRawSize()); + diskTree.setContent(JSONUtil.toJsonStr(raidDriveBean)); + raidChildren.add(diskTree); + } + } + } + raidTreeBean.setChildren(raidChildren); + raidTreeList.add(raidTreeBean); + } + } + String result = JSONUtil.toJsonStr(raidTreeList); + } + + /** + * 创建的raid或者热备的个数限制 + */ + @Data + public static class RangeBean { + private Object range; + } + + /** + * raid等级、条带、策略的取值 + */ + @Data + public static class ValueBean { + private List value; + } + + /** + * 各raid等级的硬盘取值区间 + */ + @Data + public static class NumberBean { + private int lower; + private int upper; + private int pdperarraylow; + private int pdperarrayup; + private Boolean odd; + private Boolean even; + private Object multiple; + } + +} diff --git a/InManageBoot-iboot/v7.4.0/cosmos-biz-iboot-base/cosmos-biz-iboot-base-api/src/main/java/com/anarchy/cosmos/iboot/base/api/bean/raid/RaidDriveBean.java b/InManageBoot-iboot/v7.4.0/cosmos-biz-iboot-base/cosmos-biz-iboot-base-api/src/main/java/com/anarchy/cosmos/iboot/base/api/bean/raid/RaidDriveBean.java new file mode 100644 index 0000000..eb54eec --- /dev/null +++ b/InManageBoot-iboot/v7.4.0/cosmos-biz-iboot-base/cosmos-biz-iboot-base-api/src/main/java/com/anarchy/cosmos/iboot/base/api/bean/raid/RaidDriveBean.java @@ -0,0 +1,148 @@ +package com.anarchy.cosmos.iboot.base.api.bean.raid; + + +import lombok.Getter; + +public class RaidDriveBean { + + /** + * 磁盘框ID + */ + @Getter + private String enclosureId; + private String eid; + + /** + * 控制器ID, 多控制器情况下,可能需要此字段 + */ + @Getter + private String controllerId; + private String cid; + + /** + * 媒体类型 + */ + @Getter + private String mediaType; + /** + * 原始大小(单位:GB) + */ + @Getter + private String rawSize; + /** + * 槽位号 + */ + @Getter + private String slotNumber; + private String slot; + + /** + * 物理盘状态 + */ + @Getter + private String status; + + + @Getter + private String driveGroup; + /** + * 单位,前端使用 + */ + private String sizeUnit; + /** + * 容量,前端使用 + */ + private String size; + private String globalHot; + + public String getSizeUnit() { + if (this.rawSize != null && !this.rawSize.equals("")) { + if (this.rawSize.contains("T")) { + return "TB"; + } else if (rawSize.contains("G")) { + return "GB"; + } else { + return "MB"; + } + } else { + return "GB"; + } + } + + public void setSizeUnit(String sizeUnit) { + this.sizeUnit = sizeUnit; + } + + public String getSize() { + if (this.rawSize != null && !this.rawSize.equals("")) { + return this.rawSize.replaceAll("T", "").replaceAll("G", "").replaceAll("M", "").replaceAll("B", ""); + } else { + return ""; + } + } + + public void setSize(String size) { + this.size = size; + } + + public void setEnclosureId(String enclosureId) { + this.enclosureId = enclosureId; + } + + public void setControllerId(String controllerId) { + this.controllerId = controllerId; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public void setRawSize(String rawSize) { + this.rawSize = rawSize; + } + + public void setSlotNumber(String slotNumber) { + this.slotNumber = slotNumber; + } + + public void setStatus(String status) { + this.status = status; + } + + public void setDriveGroup(String driveGroup) { + this.driveGroup = driveGroup; + } + + public String getEid() { + return this.enclosureId; + } + + public void setEid(String eid) { + this.eid = this.enclosureId; + } + + public String getCid() { + return this.controllerId; + } + + public void setCid(String cid) { + this.cid = cid; + } + + public String getSlot() { + return this.slotNumber; + } + + public void setSlot(String slot) { + this.slot = slot; + } + + public String getGlobalHot() { + return globalHot; + } + + public void setGlobalHot(String globalHot) { + this.globalHot = globalHot; + } +} + -- Gitee