use of com.vmware.flowgate.nlyteworker.model.LocationGroup in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testGenerateNewAsset1.
@Test
public void testGenerateNewAsset1() {
List<NlyteAsset> nlyteAssets = getNlyteAsset();
HashMap<Integer, LocationGroup> locationMap = getLocationMap();
HashMap<Integer, Material> materialMap = getMaterialMap();
HashMap<Integer, Manufacturer> manufacturerMap = getManufacturerMap();
List<Asset> assetsFromFlowgate = new ArrayList<Asset>();
Asset preAsset = new Asset();
preAsset.setAssetNumber(197);
preAsset.setAssetSource("l9i8728d55368540fcba1692");
assetsFromFlowgate.add(preAsset);
Mockito.when(this.wormholeAPIClient.getAllAssetsBySourceAndType("l9i8728d55368540fcba1692", AssetCategory.Server)).thenReturn(assetsFromFlowgate);
HashMap<Integer, String> cabinetIdAndNameMap = new HashMap<Integer, String>();
cabinetIdAndNameMap.put(562, "cbName");
nlyteAssets = nlyteDataService.supplementCabinetName(cabinetIdAndNameMap, nlyteAssets);
List<Asset> assets = nlyteDataService.generateAssets("l9i8728d55368540fcba1692", nlyteAssets, locationMap, manufacturerMap, materialMap, AssetCategory.Server, new HashMap<Long, String>());
for (Asset asset : assets) {
if ("sin2-blrqeops-esxstress024".equals(asset.getAssetName())) {
TestCase.assertEquals(197, asset.getAssetNumber());
TestCase.assertEquals("SG-07-04", asset.getRoom());
TestCase.assertEquals("Cisco 1721 Modular Access Router", asset.getModel());
TestCase.assertEquals("Cisco", asset.getManufacturer());
TestCase.assertEquals("cbName", asset.getCabinetName());
}
}
}
use of com.vmware.flowgate.nlyteworker.model.LocationGroup in project flowgate by vmware.
the class SycnRealTimeDataJobTest method getLocationMap.
HashMap<Integer, LocationGroup> getLocationMap() {
HashMap<Integer, LocationGroup> locationMap = new HashMap<Integer, LocationGroup>();
LocationGroup location = new LocationGroup();
location.setLocationGroupID(8);
location.setLocationGroupName("SG-07-04");
location.setLocationGroupType("Room");
location.setParentLocationGroupID(7);
locationMap.put(8, location);
LocationGroup location1 = new LocationGroup();
location1.setLocationGroupID(7);
location1.setLocationGroupName("4th");
location1.setLocationGroupType("Floor");
location1.setParentLocationGroupID(null);
locationMap.put(7, location1);
return locationMap;
}
use of com.vmware.flowgate.nlyteworker.model.LocationGroup in project flowgate by vmware.
the class NlyteAPIClient method getLocationGroups.
public List<LocationGroup> getLocationGroups(boolean isAllData) {
initAuthenticationWebToken();
JsonResultForLocationGroup locationGroupresult = this.restTemplate.exchange(getNlyteServiceEndpoint() + GetLocationGroupsURL, HttpMethod.GET, getDefaultEntity(), JsonResultForLocationGroup.class).getBody();
List<LocationGroup> locationGroups = new LinkedList<LocationGroup>();
locationGroups = locationGroupresult.getValue();
if (!isAllData) {
return locationGroups;
}
List<LocationGroup> nextPageLocationGroup = null;
while (locationGroupresult.getOdatanextLink() != null && !locationGroupresult.getOdatanextLink().equals("")) {
nextPageLocationGroup = new LinkedList<LocationGroup>();
locationGroupresult = this.restTemplate.exchange(locationGroupresult.getOdatanextLink(), HttpMethod.GET, getDefaultEntity(), JsonResultForLocationGroup.class).getBody();
nextPageLocationGroup = locationGroupresult.getValue();
locationGroups.addAll(nextPageLocationGroup);
}
return locationGroups;
}
use of com.vmware.flowgate.nlyteworker.model.LocationGroup 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);
}
Aggregations