use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class OpenManageJobTest method getMetricDatasSourceIsDifferent.
@Test
public void getMetricDatasSourceIsDifferent() {
FacilitySoftwareConfig config = new FacilitySoftwareConfig();
config.setId(createAsset().getAssetSource() + "SourceIsDifferent");
List<RealTimeData> metricDatas = openmanageJobService.getMetricDatas(config, openManageAPIClient);
TestCase.assertEquals(true, metricDatas.isEmpty());
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class OpenManageJobTest method executeJobTest.
@Test
public void executeJobTest() {
FacilitySoftwareConfig config = new FacilitySoftwareConfig();
config.setId("executeJob");
IntegrationStatus integrationStatus = new IntegrationStatus();
integrationStatus.setStatus(IntegrationStatus.Status.ACTIVE);
doNothing().when(this.openManageAPIClient).getToken();
doNothing().when(this.wormholeAPIClient).setServiceKey(any(String.class));
Mockito.when(this.openmanageJobService.createClient(config)).thenReturn(this.openManageAPIClient);
Mockito.when(this.wormholeAPIClient.saveAssets(any(Asset.class))).thenReturn(saveAsset());
Mockito.when(this.wormholeAPIClient.saveAssets(ArgumentMatchers.anyList())).thenReturn(null);
Mockito.when(this.wormholeAPIClient.getAllAssetsBySourceAndType(config.getId(), AssetCategory.Server)).thenReturn(getAllAssetsBySourceAndType());
Mockito.when(this.wormholeAPIClient.getAllAssetsBySourceAndType(config.getId(), AssetCategory.Chassis)).thenReturn(new ArrayList<Asset>());
Mockito.when(this.openManageAPIClient.getDevices(any(Integer.class), any(Integer.class), ArgumentMatchers.eq(Server.class))).thenReturn(getCommonResultServer());
Mockito.when(this.openManageAPIClient.getDevices(any(Integer.class), any(Integer.class), ArgumentMatchers.eq(Chassis.class))).thenReturn(new CommonResult<Chassis>());
openmanageJobService.executeJob(EventMessageUtil.OpenManage_SyncAssetsMetaData, config);
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class SyncRealTimeDataJobTest method getFacilitySoftwareByType.
public ResponseEntity<FacilitySoftwareConfig[]> getFacilitySoftwareByType() {
FacilitySoftwareConfig[] configs = new FacilitySoftwareConfig[1];
configs[0] = new FacilitySoftwareConfig();
configs[0].setId("l9i8728d55368540fcba1692");
configs[0].setType(SoftwareType.PowerIQ);
return new ResponseEntity<FacilitySoftwareConfig[]>(configs, HttpStatus.OK);
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class SyncSensorMetaDataJobTest method createFacility.
FacilitySoftwareConfig createFacility() {
FacilitySoftwareConfig config = new FacilitySoftwareConfig();
config.setAdvanceSetting(createAdvanceSettingMap());
return config;
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class PowerIQService method executeAsync.
@Override
@Async("asyncServiceExecutor")
public void executeAsync(EventMessage message) {
// update the value.
if (message.getType() != EventType.PowerIQ) {
logger.warn("Drop none PowerIQ 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.POWERIQ_SyncData:
// it will sync all the data depend on the type in the powerIQJobList.
String messageString = null;
while ((messageString = template.opsForList().rightPop(EventMessageUtil.powerIQJobList)) != 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 powerIQinfo = null;
try {
powerIQinfo = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (null == powerIQinfo) {
continue;
}
if (!powerIQinfo.checkIsActive()) {
continue;
}
for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
executeJob(payloadCommand.getId(), powerIQinfo);
}
}
break;
default:
FacilitySoftwareConfig powerIQ = null;
try {
powerIQ = mapper.readValue(message.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e1) {
// TODO Auto-generated catch block
logger.error("Failed to convert message", e1);
}
if (powerIQ != null) {
executeJob(command.getId(), powerIQ);
}
break;
}
}
}
Aggregations