Search in sources :

Example 1 with ChildBladeBean

use of com.huawei.esight.service.bean.ChildBladeBean in project Server_Management_Plugin_vRealize by Huawei.

the class ESightServiceImpl method getServerDeviceList.

@Override
public List<ServerDeviceBean> getServerDeviceList(String servertype) {
    GetServerDeviceApi<String> api = new GetServerDeviceApi<>(esightServer, openIdProvider);
    int pageNo = 1;
    List<ServerDeviceBean> result = new ArrayList<>();
    // 分页读取所有数据
    while (true) {
        String response = api.doCall(servertype, pageNo + "", Constant.PAGE_SIZE, String.class);
        if (logger.isInfoEnabled()) {
            logger.info("Json string for server type = '" + servertype + "', pageNo='" + pageNo + "' is :  " + response);
        }
        ResponseServerDeviceListBean bean = ConvertUtils.json2Object(response, ResponseServerDeviceListBean.class);
        if (bean == null) {
            break;
        }
        // 分页数据保存到result
        result.addAll(bean.getData());
        if (bean.getTotalPage() <= pageNo) {
            break;
        }
        pageNo++;
    }
    // 将子服务器数据保存到result
    List<ServerDeviceBean> childList = new ArrayList<>();
    for (ServerDeviceBean bean : result) {
        for (ChildBladeBean child : bean.getChildBlades()) {
            ServerDeviceBean deviceBean = new ServerDeviceBean();
            deviceBean.setDn(child.getDn());
            deviceBean.setIpAddress(child.getIpAddress());
            deviceBean.setVersion(child.getVersion());
            deviceBean.setLocation(child.getLocation());
            deviceBean.setChildBlade(true);
            childList.add(deviceBean);
        }
    }
    result.addAll(0, childList);
    // 结果排序
    Collections.sort(result, new ServerDeviceBean());
    return result;
}
Also used : ResponseServerDeviceListBean(com.huawei.esight.service.bean.ResponseServerDeviceListBean) ServerDeviceBean(com.huawei.esight.service.bean.ServerDeviceBean) GetServerDeviceApi(com.huawei.esight.api.rest.server.GetServerDeviceApi) ArrayList(java.util.ArrayList) ChildBladeBean(com.huawei.esight.service.bean.ChildBladeBean)

Example 2 with ChildBladeBean

use of com.huawei.esight.service.bean.ChildBladeBean in project Server_Management_Plugin_vRealize by Huawei.

the class ESightAdapter method setConfig.

private void setConfig(String host, List<ResourceKey> allResourceList, List<ResourceKey> serverDeviceKeyList, List<String> serverTypeChildHealthList, ServerDeviceBean deviceBean) {
    ServerDeviceDetailBean device = service.getServerDetail(deviceBean.getDn());
    if (device == null) {
        logger.error("Failed to get detail of device with dn = " + deviceBean.getDn());
        return;
    }
    ResourceKey deviceResourceKey = device.convert2Resource(deviceBean.getDn(), getAdapterKind(), metricsByResource);
    // dn --> device key map
    deviceResourceKeyMap.put(deviceBean.getDn(), deviceResourceKey);
    deviceHealthMap.put(deviceBean.getDn(), ConvertUtils.convertHealthState(device.getStatus()));
    serverTypeChildHealthList.add(ConvertUtils.convertHealthState(device.getStatus()));
    allResourceList.add(deviceResourceKey);
    List<ResourceKey> deviceChildKeys = new ArrayList<>();
    List<ResourceKey> childBladeDeviceKeyList = new ArrayList<>();
    // child Blades
    List<ChildBladeBean> childBladeBeans = deviceBean.getChildBlades();
    for (ChildBladeBean bean : childBladeBeans) {
        childBladeDeviceKeyList.add(deviceResourceKeyMap.get(bean.getDn()));
    }
    // 处理childBlade显示重复的问题
    if (!deviceBean.isChildBlade()) {
        serverDeviceKeyList.add(deviceResourceKey);
    }
    // board
    deviceChildKeys.addAll(setBoard(host, allResourceList, deviceBean, device));
    // CPU
    deviceChildKeys.addAll(setCpu(host, allResourceList, deviceBean, device));
    // disk
    deviceChildKeys.addAll(setDisk(host, allResourceList, deviceBean, device));
    // fan
    deviceChildKeys.addAll(setFan(host, allResourceList, deviceBean, device, childBladeBeans));
    // memory
    deviceChildKeys.addAll(setMemory(host, allResourceList, deviceBean, device));
    // PSU
    deviceChildKeys.addAll(setPsu(host, allResourceList, deviceBean, device, childBladeBeans));
    // device Group
    deviceChildKeys.addAll(setDeviceGroup(device, childBladeDeviceKeyList, childBladeBeans));
    // PCIE
    deviceChildKeys.addAll(setPcie(host, allResourceList, deviceBean, device));
    // RAID
    deviceChildKeys.addAll(setRaid(host, allResourceList, deviceBean, device));
    // network card
    deviceChildKeys.addAll(setNetworkCard(host, allResourceList, deviceBean, device));
    // Mezz
    deviceChildKeys.addAll(setMezz(host, allResourceList, deviceBean, device));
    // 设置server device和group object(如cpuGroup, diskGroup, fanGroup等)的关联关系
    relationshipsByResource.put(deviceResourceKey, deviceChildKeys);
    allResourceList.addAll(deviceChildKeys);
}
Also used : ServerDeviceDetailBean(com.huawei.esight.service.bean.ServerDeviceDetailBean) ArrayList(java.util.ArrayList) ChildBladeBean(com.huawei.esight.service.bean.ChildBladeBean) ResourceKey(com.integrien.alive.common.adapter3.ResourceKey)

Example 3 with ChildBladeBean

use of com.huawei.esight.service.bean.ChildBladeBean in project Server_Management_Plugin_vRealize by Huawei.

the class ESightAdapter method setDeviceGroup.

private List<ResourceKey> setDeviceGroup(ServerDeviceDetailBean device, List<ResourceKey> childBladeDeviceKeyList, List<ChildBladeBean> childBladeBeans) {
    List<ResourceKey> deviceChildKeys = new ArrayList<>();
    if (!childBladeDeviceKeyList.isEmpty()) {
        List<String> childHealthList = new ArrayList<>();
        for (ChildBladeBean childBean : childBladeBeans) {
            childHealthList.add(deviceHealthMap.get(childBean.getDn()));
        }
        ResourceKey devicesGroup = device.createGroupKey(Constant.TREE_DEVICES_GROUP, Constant.KIND_DEVICES_GROUP, childBladeDeviceKeyList, relationshipsByResource, getAdapterKind());
        deviceChildKeys.add(devicesGroup);
        setHealStatus4GroupObject(devicesGroup, Constant.ATTR_STATUS, childHealthList);
    }
    return deviceChildKeys;
}
Also used : ArrayList(java.util.ArrayList) ChildBladeBean(com.huawei.esight.service.bean.ChildBladeBean) ResourceKey(com.integrien.alive.common.adapter3.ResourceKey)

Aggregations

ChildBladeBean (com.huawei.esight.service.bean.ChildBladeBean)3 ArrayList (java.util.ArrayList)3 ResourceKey (com.integrien.alive.common.adapter3.ResourceKey)2 GetServerDeviceApi (com.huawei.esight.api.rest.server.GetServerDeviceApi)1 ResponseServerDeviceListBean (com.huawei.esight.service.bean.ResponseServerDeviceListBean)1 ServerDeviceBean (com.huawei.esight.service.bean.ServerDeviceBean)1 ServerDeviceDetailBean (com.huawei.esight.service.bean.ServerDeviceDetailBean)1