Search in sources :

Example 1 with PageModelImp

use of com.vmware.flowgate.common.model.PageModelImp in project flowgate by vmware.

the class PowerIQService method syncAllSensorMetricFormula.

public void syncAllSensorMetricFormula() {
    restClient.setServiceKey(serviceKeyConfig.getServiceKey());
    FacilitySoftwareConfig[] powerIQs = restClient.getFacilitySoftwareInternalByType(SoftwareType.PowerIQ).getBody();
    for (FacilitySoftwareConfig powerIQ : powerIQs) {
        logger.info("Start sync sensor metrics formula for " + powerIQ.getName());
        List<Asset> pdusFromFlowgate = restClient.getAllAssetsBySourceAndType(powerIQ.getId(), AssetCategory.PDU);
        Map<String, Asset> pduIDAndAssetMap = getPDUIDAndAssetMap(pdusFromFlowgate);
        int pageSize = 200;
        int pageNumber = 0;
        List<Asset> sensors = null;
        ResponseEntity<PageModelImp<Asset>> res = restClient.getAssetsBySourceAndType(powerIQ.getId(), AssetCategory.Sensors, pageNumber, pageSize);
        while (!res.getBody().getContent().isEmpty()) {
            sensors = res.getBody().getContent();
            Set<Asset> pduAssetNeedToUpdate = updatePduMetricformular(sensors, pduIDAndAssetMap);
            restClient.saveAssets(new ArrayList<Asset>(pduAssetNeedToUpdate));
            pageNumber++;
            res = restClient.getAssetsBySourceAndType(powerIQ.getId(), AssetCategory.Sensors, pageNumber, pageSize);
        }
        logger.info("Finished sync sensor metrics formula for " + powerIQ.getName());
    }
}
Also used : FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) Asset(com.vmware.flowgate.common.model.Asset) PageModelImp(com.vmware.flowgate.common.model.PageModelImp)

Aggregations

Asset (com.vmware.flowgate.common.model.Asset)1 FacilitySoftwareConfig (com.vmware.flowgate.common.model.FacilitySoftwareConfig)1 PageModelImp (com.vmware.flowgate.common.model.PageModelImp)1