use of com.vmware.flowgate.common.model.FacilitySoftwareConfig 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());
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class NlyteDataService method executeAsync.
@Override
public void executeAsync(EventMessage message) {
if (message.getType() != EventType.Nlyte) {
logger.warn("Drop none Nlyte message " + message.getType());
return;
}
logger.info("message received");
Set<EventUser> users = message.getTarget().getUsers();
for (EventUser command : users) {
logger.info(command.getId());
switch(command.getId()) {
case EventMessageUtil.NLYTE_SyncData:
// it will sync all the data depend on the type in the nlyteJobList.
String messageString = null;
while ((messageString = template.opsForList().rightPop(EventMessageUtil.nlyteJobList)) != null) {
EventMessage payloadMessage = null;
try {
payloadMessage = mapper.readValue(messageString, EventMessageImpl.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (payloadMessage == null) {
continue;
}
FacilitySoftwareConfig nlyte = null;
try {
nlyte = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (null == nlyte) {
continue;
}
if (!nlyte.checkIsActive()) {
continue;
}
for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
executeJob(payloadCommand.getId(), nlyte);
}
}
break;
default:
FacilitySoftwareConfig nlyteInfo = null;
try {
nlyteInfo = mapper.readValue(message.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e) {
// TODO Auto-generated catch block
logger.info("Failed to convert message", e);
}
if (nlyteInfo != null) {
executeJob(EventMessageUtil.NLYTE_SyncMappedAssetData, nlyteInfo);
}
break;
}
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class OpenManageJobService method executeAsync.
@Override
public void executeAsync(EventMessage message) {
if (message.getType() != EventType.OpenManage) {
logger.warn("Drop non-OpenManage message " + message.getType());
return;
}
logger.info("message received");
String messageString = null;
while ((messageString = template.opsForList().rightPop(EventMessageUtil.OpenManageJobList)) != null) {
EventMessage payloadMessage = null;
try {
payloadMessage = mapper.readValue(messageString, EventMessageImpl.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (payloadMessage == null) {
continue;
}
FacilitySoftwareConfig integration = null;
try {
integration = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (null == integration) {
continue;
}
if (!integration.checkIsActive()) {
continue;
}
for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
executeJob(payloadCommand.getId(), integration);
}
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class OpenManageJobTest method getMetricDatas.
@Test
public void getMetricDatas() {
Mockito.when(this.openManageAPIClient.getCommonResult(Plugin.class)).thenReturn(getCommonResult());
Mockito.when(this.openManageAPIClient.getDevicePowerMetrics("10074")).thenReturn(getPowerMetricsData());
Mockito.when(this.openManageAPIClient.getDeviceTemperatureMetrics("10074")).thenReturn(getDeviceTemperature());
Mockito.when(this.openManageAPIClient.getMetricsFromPowerManage(any(PowerManageMetricsRequestBody.class))).thenReturn(getDeviceMetricsResult());
Mockito.when(this.openManageAPIClient.getCommonResult(PowerSetting.class)).thenReturn(getPowerSettings());
FacilitySoftwareConfig config = new FacilitySoftwareConfig();
config.setId(createAsset().getAssetSource());
List<RealTimeData> metricDatas = openmanageJobService.getMetricDatas(config, openManageAPIClient);
for (RealTimeData data : metricDatas) {
if ("assetid1611766210404".equals(data.getId())) {
// power metrics
List<ValueUnit> values = data.getValues();
for (ValueUnit value : values) {
switch(value.getKey()) {
case MetricName.SERVER_AVERAGE_USED_POWER:
TestCase.assertEquals(0.074, value.getValueNum());
break;
// use powerManager value to override it
case MetricName.SERVER_POWER:
TestCase.assertEquals(0.072, value.getValueNum());
break;
case MetricName.SERVER_MINIMUM_USED_POWER:
TestCase.assertEquals(0.07, value.getValueNum());
break;
case MetricName.SERVER_PEAK_USED_POWER:
TestCase.assertEquals(0.08, value.getValueNum());
break;
case MetricName.SERVER_ENERGY_CONSUMPTION:
TestCase.assertEquals(800.0, value.getValueNum());
break;
case MetricName.SERVER_AVERAGE_TEMPERATURE:
TestCase.assertEquals(22.0, value.getValueNum());
break;
case MetricName.SERVER_TEMPERATURE:
TestCase.assertEquals(24.0, value.getValueNum());
break;
case MetricName.SERVER_PEAK_TEMPERATURE:
TestCase.assertEquals(30.0, value.getValueNum());
break;
case MetricName.SERVER_FRONT_TEMPERATURE:
TestCase.assertEquals(24.0, value.getValueNum());
break;
default:
TestCase.fail();
break;
}
}
} else {
TestCase.fail();
}
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class OpenManageJobTest method getMetricDatasTestNA.
@Test
public void getMetricDatasTestNA() {
Mockito.when(this.openManageAPIClient.getCommonResult(Plugin.class)).thenReturn(getCommonResult());
DevicePower powerMetrics = getPowerMetricsData();
powerMetrics.setMinimumPower("N/A");
Mockito.when(this.openManageAPIClient.getDevicePowerMetrics("10074")).thenReturn(powerMetrics);
Mockito.when(this.openManageAPIClient.getDeviceTemperatureMetrics("10074")).thenReturn(getDeviceTemperature());
Mockito.when(this.openManageAPIClient.getMetricsFromPowerManage(any(PowerManageMetricsRequestBody.class))).thenReturn(getDeviceMetricsResult());
Mockito.when(this.openManageAPIClient.getCommonResult(PowerSetting.class)).thenReturn(getPowerSettings());
FacilitySoftwareConfig config = new FacilitySoftwareConfig();
config.setId(createAsset().getAssetSource());
List<RealTimeData> metricDatas = openmanageJobService.getMetricDatas(config, openManageAPIClient);
for (RealTimeData data : metricDatas) {
if ("assetid1611766210404".equals(data.getId())) {
// power metrics
List<ValueUnit> values = data.getValues();
for (ValueUnit value : values) {
switch(value.getKey()) {
case MetricName.SERVER_AVERAGE_USED_POWER:
TestCase.assertEquals(0.074, value.getValueNum());
break;
// use powerManager value to override it
case MetricName.SERVER_POWER:
TestCase.assertEquals(0.072, value.getValueNum());
break;
case MetricName.SERVER_MINIMUM_USED_POWER:
TestCase.fail("Should not contain the " + MetricName.SERVER_MINIMUM_USED_POWER);
break;
case MetricName.SERVER_PEAK_USED_POWER:
TestCase.assertEquals(0.08, value.getValueNum());
break;
case MetricName.SERVER_ENERGY_CONSUMPTION:
TestCase.assertEquals(800.0, value.getValueNum());
break;
case MetricName.SERVER_AVERAGE_TEMPERATURE:
TestCase.assertEquals(22.0, value.getValueNum());
break;
case MetricName.SERVER_TEMPERATURE:
TestCase.assertEquals(24.0, value.getValueNum());
break;
case MetricName.SERVER_PEAK_TEMPERATURE:
TestCase.assertEquals(30.0, value.getValueNum());
break;
case MetricName.SERVER_FRONT_TEMPERATURE:
TestCase.assertEquals(24.0, value.getValueNum());
break;
default:
TestCase.fail();
break;
}
}
} else {
TestCase.fail();
}
}
}
Aggregations