Search in sources :

Example 1 with ServerDeviceDetailBean

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

the class ESightServiceImplTest method testGetServerDetail.

/**
 * 测试获取服务器信息方法
 */
@Test
public void testGetServerDetail() {
    ESightService service = new ESightServiceImpl();
    service.setLogger(Logger.getLogger(ESightServiceImpl.class));
    InputStream inputStream = null;
    try {
        Properties configProperties = new Properties();
        inputStream = this.getClass().getClassLoader().getResourceAsStream("unit-test.properties");
        configProperties.load(inputStream);
        String host = configProperties.getProperty("test.esight.ip");
        int port = Integer.parseInt(configProperties.getProperty("test.esight.port"));
        String account = configProperties.getProperty("test.esight.account");
        String eSightCode = configProperties.getProperty("test.esight.code");
        String openid = service.login(host, port, account, eSightCode);
        Assert.assertNotNull(openid);
        if (openid == null || openid.isEmpty()) {
            logger.error("Login FAIL!");
            fail("Login FAIL!");
        }
        String[] serverTypes = new String[] { "rack", "blade", "highdensity", "kunlun" };
        for (String serverType : serverTypes) {
            List<ServerDeviceBean> serverList = service.getServerDeviceList(serverType);
            Assert.assertNotNull(serverList);
            for (ServerDeviceBean bean : serverList) {
                ServerDeviceDetailBean detailBean = service.getServerDetail(bean.getDn());
                if (detailBean == null) {
                    logger.error("faile to fetch detail for device with dn ='" + bean.getDn() + "'");
                }
                Assert.assertNotNull(detailBean);
            }
        }
        service.logout(openid);
        logger.info("All Junit test PASSED!");
    } catch (IOException e) {
        logger.error("Call API ERROR", e);
        fail("Excetion throw found!");
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException e) {
                logger.error("close stream fail", e);
            }
        }
    }
}
Also used : ServerDeviceBean(com.huawei.esight.service.bean.ServerDeviceBean) InputStream(java.io.InputStream) ServerDeviceDetailBean(com.huawei.esight.service.bean.ServerDeviceDetailBean) IOException(java.io.IOException) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with ServerDeviceDetailBean

use of com.huawei.esight.service.bean.ServerDeviceDetailBean 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)

Aggregations

ServerDeviceDetailBean (com.huawei.esight.service.bean.ServerDeviceDetailBean)2 ChildBladeBean (com.huawei.esight.service.bean.ChildBladeBean)1 ServerDeviceBean (com.huawei.esight.service.bean.ServerDeviceBean)1 ResourceKey (com.integrien.alive.common.adapter3.ResourceKey)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Test (org.junit.Test)1