Search in sources :

Example 11 with FacilitySoftwareConfig

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());
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 12 with FacilitySoftwareConfig

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);
}
Also used : Chassis(com.vmware.flowgate.openmanage.datamodel.Chassis) Server(com.vmware.flowgate.openmanage.datamodel.Server) IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) Asset(com.vmware.flowgate.common.model.Asset) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 13 with FacilitySoftwareConfig

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig)

Example 14 with FacilitySoftwareConfig

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;
}
Also used : FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig)

Example 15 with FacilitySoftwareConfig

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;
        }
    }
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) EventUser(com.vmware.flowgate.common.model.redis.message.EventUser) EventMessageImpl(com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) IOException(java.io.IOException) Async(org.springframework.scheduling.annotation.Async)

Aggregations

FacilitySoftwareConfig (com.vmware.flowgate.common.model.FacilitySoftwareConfig)60 Test (org.junit.Test)29 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)29 ArrayList (java.util.ArrayList)13 Asset (com.vmware.flowgate.common.model.Asset)8 IntegrationStatus (com.vmware.flowgate.common.model.IntegrationStatus)8 MvcResult (org.springframework.test.web.servlet.MvcResult)8 EventMessage (com.vmware.flowgate.common.model.redis.message.EventMessage)7 IOException (java.io.IOException)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 FacilityAdapter (com.vmware.flowgate.common.model.FacilityAdapter)6 AdapterJobCommand (com.vmware.flowgate.common.model.AdapterJobCommand)5 EventUser (com.vmware.flowgate.common.model.redis.message.EventUser)5 EventMessageImpl (com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl)5 HashMap (java.util.HashMap)5 ResponseEntity (org.springframework.http.ResponseEntity)5 RealTimeData (com.vmware.flowgate.common.model.RealTimeData)4 WormholeUser (com.vmware.flowgate.common.model.WormholeUser)4 WormholeUserDetails (com.vmware.flowgate.util.WormholeUserDetails)4