use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.
the class AggregatorServiceTest method getFacilitySoftware.
private ResponseEntity<FacilitySoftwareConfig[]> getFacilitySoftware() {
FacilitySoftwareConfig[] facilitySoftwareConfigs = new FacilitySoftwareConfig[1];
FacilitySoftwareConfig facilitySoftwareConfig = new FacilitySoftwareConfig();
facilitySoftwareConfig.setId("QWENBADJWRTUIJWJAYQY");
facilitySoftwareConfig.setPassword("O75xginpkAD748w=Lc20CrTzd1lEpvDTdJqH5IXBZTb5gYp7P8awDAs19F0=");
facilitySoftwareConfig.setServerURL("https://10.161.71.133");
facilitySoftwareConfig.setName("powerIQ-1");
facilitySoftwareConfig.setVerifyCert(false);
IntegrationStatus integrationStatus = new IntegrationStatus();
integrationStatus.setRetryCounter(0);
integrationStatus.setDetail("");
integrationStatus.setStatus(IntegrationStatus.Status.ACTIVE);
facilitySoftwareConfig.setIntegrationStatus(integrationStatus);
facilitySoftwareConfig.setUserName("admin");
facilitySoftwareConfig.setType(FacilitySoftwareConfig.SoftwareType.PowerIQ);
facilitySoftwareConfig.setUserId("e1edfv8953002379827896a1aaiqoose");
facilitySoftwareConfigs[0] = facilitySoftwareConfig;
return new ResponseEntity<>(facilitySoftwareConfigs, HttpStatus.OK);
}
use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.
the class MessageProcessingTest method createFacilitySoftware.
FacilitySoftwareConfig createFacilitySoftware() {
FacilitySoftwareConfig example = new FacilitySoftwareConfig();
example.setId(UUID.randomUUID().toString());
example.setName("OtherDcimSample");
example.setUserName("administrator@vsphere.local");
example.setPassword("Admin!23");
example.setServerURL("https://10.160.30.134");
example.setType(FacilitySoftwareConfig.SoftwareType.OtherDCIM);
example.setUserId("1");
example.setVerifyCert(false);
example.setDescription("description");
HashMap<AdvanceSettingType, String> advanceSetting = new HashMap<AdvanceSettingType, String>();
example.setAdvanceSetting(advanceSetting);
IntegrationStatus integrationStatus = new IntegrationStatus();
integrationStatus.setDetail("");
integrationStatus.setRetryCounter(0);
integrationStatus.setStatus(Status.ACTIVE);
example.setIntegrationStatus(integrationStatus);
return example;
}
use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.
the class NlyteDataService method SyncAlldata.
private void SyncAlldata(FacilitySoftwareConfig nlyte) {
NlyteAPIClient nlyteAPIclient = createClient(nlyte);
restClient.setServiceKey(serviceKeyConfig.getServiceKey());
HandleAssetUtil assetUtil = new HandleAssetUtil();
List<NlyteAsset> nlyteAssets = null;
try {
nlyteAssets = nlyteAPIclient.getAssets(true, AssetCategory.Cabinet);
} 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<Long, String> chassisMountedAssetNumberAndChassisIdMap = null;
HashMap<Integer, LocationGroup> locationMap = assetUtil.initLocationGroupMap(nlyteAPIclient);
HashMap<Integer, Manufacturer> manufacturerMap = assetUtil.initManufacturersMap(nlyteAPIclient);
HashMap<Integer, Material> cabinetMaterialMap = new HashMap<Integer, Material>();
List<Material> cabinetMaterials = nlyteAPIclient.getMaterials(true, HandleAssetUtil.cabinetMaterials);
for (Material material : cabinetMaterials) {
material.setMaterialType(AssetCategory.Cabinet);
cabinetMaterialMap.put(material.getMaterialID(), material);
}
List<Asset> cabinetsNeedToSaveOrUpdate = generateAssets(nlyte.getId(), nlyteAssets, locationMap, manufacturerMap, cabinetMaterialMap, AssetCategory.Cabinet, chassisMountedAssetNumberAndChassisIdMap);
if (cabinetsNeedToSaveOrUpdate.isEmpty()) {
logger.info("No cabinet asset need to save");
} else {
restClient.saveAssets(cabinetsNeedToSaveOrUpdate);
logger.info("Finish sync the cabinets data for: " + nlyte.getName() + ", size: " + cabinetsNeedToSaveOrUpdate.size());
}
// init cabinetIdAndNameMap
HashMap<Integer, String> cabinetIdAndNameMap = getCabinetIdAndNameMap(nlyteAssets);
nlyteAssets = nlyteAPIclient.getAssets(true, AssetCategory.Chassis);
nlyteAssets = supplementCabinetName(cabinetIdAndNameMap, nlyteAssets);
List<Material> chassisMaterials = nlyteAPIclient.getMaterials(true, HandleAssetUtil.chassisMaterials);
HashMap<Integer, Material> chassisMaterialMap = new HashMap<Integer, Material>();
for (Material material : chassisMaterials) {
material.setMaterialType(AssetCategory.Chassis);
chassisMaterialMap.put(material.getMaterialID(), material);
}
List<Asset> chassisNeedToSaveOrUpdate = generateAssets(nlyte.getId(), nlyteAssets, locationMap, manufacturerMap, chassisMaterialMap, AssetCategory.Chassis, chassisMountedAssetNumberAndChassisIdMap);
if (chassisNeedToSaveOrUpdate.isEmpty()) {
logger.info("No chassis asset need to save");
} else {
restClient.saveAssets(chassisNeedToSaveOrUpdate);
logger.info("Finish sync the chassis data for: " + nlyte.getName() + ", size: " + chassisNeedToSaveOrUpdate.size());
}
List<Asset> chassisFromFlowgate = restClient.getAllAssetsBySourceAndType(nlyte.getId(), AssetCategory.Chassis);
chassisMountedAssetNumberAndChassisIdMap = generateMountedAssetNumberAndChassisAssetIdMap(chassisFromFlowgate);
nlyteAssets = nlyteAPIclient.getAssets(true, AssetCategory.Server);
nlyteAssets = supplementCabinetName(cabinetIdAndNameMap, nlyteAssets);
HashMap<Integer, Material> materialMap = assetUtil.initServerMaterialsMap(nlyteAPIclient);
List<Asset> serversNeedToSaveOrUpdate = generateAssets(nlyte.getId(), nlyteAssets, locationMap, manufacturerMap, materialMap, AssetCategory.Server, chassisMountedAssetNumberAndChassisIdMap);
if (serversNeedToSaveOrUpdate.isEmpty()) {
logger.info("No server asset need to save");
} else {
restClient.saveAssets(serversNeedToSaveOrUpdate);
logger.info("Finish sync the servers data for: " + nlyte.getName() + ", size: " + serversNeedToSaveOrUpdate.size());
}
HashMap<Integer, Material> pduMaterialMap = new HashMap<Integer, Material>();
nlyteAssets = nlyteAPIclient.getAssets(true, AssetCategory.PDU);
nlyteAssets = supplementCabinetName(cabinetIdAndNameMap, nlyteAssets);
List<Material> powerStripMaterials = nlyteAPIclient.getMaterials(true, HandleAssetUtil.powerStripMaterial);
for (Material material : powerStripMaterials) {
material.setMaterialType(AssetCategory.PDU);
pduMaterialMap.put(material.getMaterialID(), material);
}
List<Asset> pDUsNeedToSaveOrUpdate = generateAssets(nlyte.getId(), nlyteAssets, locationMap, manufacturerMap, pduMaterialMap, AssetCategory.PDU, chassisMountedAssetNumberAndChassisIdMap);
if (pDUsNeedToSaveOrUpdate.isEmpty()) {
logger.info("No pdu asset need to save");
} else {
savePduAssetAndUpdatePduUsageFormula(pDUsNeedToSaveOrUpdate);
logger.info("Finish sync the pdus data for: " + nlyte.getName() + ", size: " + pDUsNeedToSaveOrUpdate.size());
}
HashMap<Integer, Material> networkMaterialMap = new HashMap<Integer, Material>();
nlyteAssets = nlyteAPIclient.getAssets(true, AssetCategory.Networks);
nlyteAssets = supplementCabinetName(cabinetIdAndNameMap, nlyteAssets);
List<Material> networkMaterials = nlyteAPIclient.getMaterials(true, HandleAssetUtil.networkMaterials);
for (Material material : networkMaterials) {
material.setMaterialType(AssetCategory.Networks);
networkMaterialMap.put(material.getMaterialID(), material);
}
List<Asset> networkersNeedToSaveOrUpdate = generateAssets(nlyte.getId(), nlyteAssets, locationMap, manufacturerMap, networkMaterialMap, AssetCategory.Networks, chassisMountedAssetNumberAndChassisIdMap);
if (networkersNeedToSaveOrUpdate.isEmpty()) {
logger.info("No network asset need to save");
} else {
restClient.saveAssets(networkersNeedToSaveOrUpdate);
logger.info("Finish sync the networks data for: " + nlyte.getName() + ", size: " + networkersNeedToSaveOrUpdate.size());
}
}
use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.
the class PowerIQService method syncPowerIQAssetsMetaData.
public void syncPowerIQAssetsMetaData(FacilitySoftwareConfig powerIQ) {
PowerIQAPIClient client = createClient(powerIQ);
restClient.setServiceKey(serviceKeyConfig.getServiceKey());
try {
client.testConnection();
} catch (ResourceAccessException e1) {
if (e1.getCause().getCause() instanceof ConnectException) {
checkAndUpdateIntegrationStatus(powerIQ, e1.getMessage());
return;
}
} catch (HttpClientErrorException e) {
logger.error("Failed to query data from PowerIQ", e);
IntegrationStatus integrationStatus = powerIQ.getIntegrationStatus();
if (integrationStatus == null) {
integrationStatus = new IntegrationStatus();
}
integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
integrationStatus.setDetail(e.getMessage());
integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
updateIntegrationStatus(powerIQ);
return;
}
LocationInfo location = getLocationInfo(client);
List<Asset> pdusFromFlowgate = restClient.getAllAssetsBySourceAndType(powerIQ.getId(), AssetCategory.PDU);
Map<String, Asset> pduIDAndAssetMap = getPDUIDAndAssetMap(pdusFromFlowgate);
boolean hasNewPduToSave = savePduAssetsToFlowgate(pduIDAndAssetMap, powerIQ.getId(), client, location);
logger.info("Finish sync PDU metadata for " + powerIQ.getName());
Map<String, Asset> exsitingSensorAssets = getAssetsFromWormhole(powerIQ.getId());
saveSensorAssetsToFlowgate(exsitingSensorAssets, client, powerIQ.getId(), location);
logger.info("Finish sync Sensor metadata for: " + powerIQ.getName());
if (hasNewPduToSave) {
try {
EventMessage eventMessage = EventMessageUtil.createEventMessage(EventType.Aggregator, EventMessageUtil.AggregateAndCleanPowerIQPDU, "");
String jobmessage = EventMessageUtil.convertEventMessageAsString(eventMessage);
publisher.publish(EventMessageUtil.AggregatorTopic, jobmessage);
logger.info("Send aggregate Pdu data command");
} catch (IOException e) {
logger.error("Failed to Send aggregate pdu data command", e);
}
}
}
use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.
the class PowerIQService method checkAndUpdateIntegrationStatus.
public void checkAndUpdateIntegrationStatus(FacilitySoftwareConfig powerIQ, String message) {
IntegrationStatus integrationStatus = powerIQ.getIntegrationStatus();
if (integrationStatus == null) {
integrationStatus = new IntegrationStatus();
}
int timesOftry = integrationStatus.getRetryCounter();
timesOftry++;
if (timesOftry < FlowgateConstant.MAXNUMBEROFRETRIES) {
integrationStatus.setRetryCounter(timesOftry);
} else {
integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
integrationStatus.setDetail(message);
integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
logger.error("Failed to query data from PowerIQ,error message is " + message);
}
powerIQ.setIntegrationStatus(integrationStatus);
updateIntegrationStatus(powerIQ);
}
Aggregations