use of com.vmware.flowgate.nlyteworker.model.NlyteAsset in project flowgate by vmware.
the class NlyteDataService method syncMappedData.
private void syncMappedData(FacilitySoftwareConfig nlyte) {
NlyteAPIClient nlyteAPIclient = new NlyteAPIClient(nlyte);
HandleAssetUtil assetUtil = new HandleAssetUtil();
List<NlyteAsset> nlyteAssets = null;
try {
nlyteAssets = nlyteAPIclient.getAssets(true, AssetCategory.Server);
} catch (HttpClientErrorException e) {
logger.error("Failed to query data from Nlyte", e);
IntegrationStatus integrationStatus = nlyte.getIntegrationStatus();
if (integrationStatus == null) {
integrationStatus = new IntegrationStatus();
}
integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
integrationStatus.setDetail(e.getMessage());
integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
updateIntegrationStatus(nlyte);
return;
} catch (ResourceAccessException e1) {
if (e1.getCause().getCause() instanceof ConnectException) {
checkAndUpdateIntegrationStatus(nlyte, e1.getMessage());
return;
}
}
HashMap<Integer, LocationGroup> locationMap = assetUtil.initLocationGroupMap(nlyteAPIclient);
HashMap<Integer, Material> materialMap = assetUtil.initServerMaterialsMap(nlyteAPIclient);
HashMap<Integer, Manufacturer> manufacturerMap = assetUtil.initManufacturersMap(nlyteAPIclient);
saveAssetForMappedData(nlyte.getId(), nlyteAssets, locationMap, materialMap, manufacturerMap, AssetCategory.Server);
HashMap<Integer, Material> pduMaterialMap = new HashMap<Integer, Material>();
nlyteAssets = nlyteAPIclient.getAssets(true, AssetCategory.PDU);
List<Material> powerStripMaterials = nlyteAPIclient.getMaterials(true, HandleAssetUtil.powerStripMaterial);
for (Material material : powerStripMaterials) {
material.setMaterialType(AssetCategory.PDU);
pduMaterialMap.put(material.getMaterialID(), material);
}
saveAssetForMappedData(nlyte.getId(), nlyteAssets, locationMap, pduMaterialMap, manufacturerMap, AssetCategory.PDU);
HashMap<Integer, Material> networksMaterialMap = new HashMap<Integer, Material>();
nlyteAssets = nlyteAPIclient.getAssets(true, AssetCategory.Networks);
List<Material> networkMaterials = nlyteAPIclient.getMaterials(true, HandleAssetUtil.networkMaterials);
for (Material material : networkMaterials) {
material.setMaterialType(AssetCategory.Networks);
networksMaterialMap.put(material.getMaterialID(), material);
}
saveAssetForMappedData(nlyte.getId(), nlyteAssets, locationMap, networksMaterialMap, manufacturerMap, AssetCategory.Networks);
}
use of com.vmware.flowgate.nlyteworker.model.NlyteAsset in project flowgate by vmware.
the class NlyteDataService method generateAssets.
public List<Asset> generateAssets(String nlyteSource, List<NlyteAsset> nlyteAssets, HashMap<Integer, LocationGroup> locationMap, HashMap<Integer, Manufacturer> manufacturerMap, HashMap<Integer, Material> materialMap, AssetCategory category, HashMap<Long, String> chassisMountedAssetNumberAndChassisIdMap) {
HandleAssetUtil assetUtil = new HandleAssetUtil();
List<Asset> oldAssetsFromWormhole = restClient.getAllAssetsBySourceAndType(nlyteSource, category);
Map<Long, Asset> assetsFromWormholeMap = assetUtil.generateAssetsMap(oldAssetsFromWormhole);
List<Asset> allAssetsFromNlyte = assetUtil.getAssetsFromNlyte(nlyteSource, nlyteAssets, locationMap, materialMap, manufacturerMap, chassisMountedAssetNumberAndChassisIdMap);
return assetUtil.handleAssets(allAssetsFromNlyte, assetsFromWormholeMap);
}
Aggregations