Search in sources :

Example 1 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class FacilitySoftwareControllerTest method createFacilitySoftware.

FacilitySoftwareConfig createFacilitySoftware() throws Exception {
    FacilitySoftwareConfig example = new FacilitySoftwareConfig();
    example.setId(UUID.randomUUID().toString());
    example.setName("Nlyte");
    example.setUserName("administrator@vsphere.local");
    example.setPassword("Admin!23");
    example.setServerURL("https://10.160.30.134");
    example.setType(FacilitySoftwareConfig.SoftwareType.Nlyte);
    example.setUserId("1");
    example.setVerifyCert(false);
    example.setDescription("description");
    HashMap 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;
}
Also used : HashMap(java.util.HashMap) IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig)

Example 2 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class InfobloxServiceTest method getInfobloxFacilitySoftware.

private ResponseEntity<FacilitySoftwareConfig[]> getInfobloxFacilitySoftware() {
    FacilitySoftwareConfig[] facilitySoftwareConfigs = new FacilitySoftwareConfig[1];
    FacilitySoftwareConfig facilitySoftwareConfig = new FacilitySoftwareConfig();
    facilitySoftwareConfig.setPassword("O75xginpkAD748w=Lc20CrTzd1lEpvDTdJqH5IXBZTb5gYp7P8awDAs19F0=");
    facilitySoftwareConfig.setServerURL("https://10.161.71.133");
    facilitySoftwareConfig.setName("infoblox-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.InfoBlox);
    facilitySoftwareConfig.setUserId("e1edfv8953002379827896a1aaiqoose");
    facilitySoftwareConfigs[0] = facilitySoftwareConfig;
    return new ResponseEntity<>(facilitySoftwareConfigs, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig)

Example 3 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class LabsdbService method checkAndUpdateIntegrationStatus.

public void checkAndUpdateIntegrationStatus(FacilitySoftwareConfig labsdb, String message) {
    IntegrationStatus integrationStatus = labsdb.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 Labsdb");
    }
    labsdb.setIntegrationStatus(integrationStatus);
    updateIntegrationStatus(labsdb);
}
Also used : IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus)

Example 4 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class NlyteDataService method getRealTimeDatas.

public List<RealTimeData> getRealTimeDatas(NlyteAPIClient nlyteAPIclient, FacilitySoftwareConfig facilitySoftwareConfig, Set<String> assetIds) {
    List<RealTimeData> realTimeDatas = new ArrayList<RealTimeData>();
    for (String assetId : assetIds) {
        Asset asset = restClient.getAssetByID(assetId).getBody();
        if (asset == null || !facilitySoftwareConfig.getId().equals(asset.getAssetSource())) {
            continue;
        }
        RealTimeData realTimeData = null;
        try {
            realTimeData = generateRealTimeData(asset, nlyteAPIclient, getAdvanceSetting(facilitySoftwareConfig));
        } catch (HttpClientErrorException e) {
            logger.error("Failed to query data from Nlyte", e);
            IntegrationStatus integrationStatus = facilitySoftwareConfig.getIntegrationStatus();
            if (integrationStatus == null) {
                integrationStatus = new IntegrationStatus();
            }
            integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
            integrationStatus.setDetail(e.getMessage());
            integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
            updateIntegrationStatus(facilitySoftwareConfig);
            break;
        } catch (ResourceAccessException e1) {
            if (e1.getCause().getCause() instanceof ConnectException) {
                checkAndUpdateIntegrationStatus(facilitySoftwareConfig, e1.getMessage());
                break;
            }
        }
        if (realTimeData == null) {
            continue;
        }
        realTimeDatas.add(realTimeData);
    }
    return realTimeDatas;
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) ArrayList(java.util.ArrayList) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Asset(com.vmware.flowgate.common.model.Asset) ResourceAccessException(org.springframework.web.client.ResourceAccessException) ConnectException(java.net.ConnectException)

Example 5 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class InfoBloxService method checkAndUpdateIntegrationStatus.

private void checkAndUpdateIntegrationStatus(FacilitySoftwareConfig infoblox, String message) {
    IntegrationStatus integrationStatus = infoblox.getIntegrationStatus();
    if (integrationStatus == null) {
        integrationStatus = new IntegrationStatus();
    }
    int timesOftry = integrationStatus.getRetryCounter();
    timesOftry++;
    if (timesOftry < FlowgateConstant.MAXNUMBEROFRETRIES) {
        integrationStatus.setRetryCounter(timesOftry);
    } else {
        logger.error("Failed to query data from Infoblox");
        integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
        integrationStatus.setDetail(message);
        integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
    }
    infoblox.setIntegrationStatus(integrationStatus);
    updateIntegrationStatus(infoblox);
}
Also used : IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus)

Aggregations

IntegrationStatus (com.vmware.flowgate.common.model.IntegrationStatus)31 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)12 Asset (com.vmware.flowgate.common.model.Asset)10 ConnectException (java.net.ConnectException)10 IOException (java.io.IOException)8 FacilitySoftwareConfig (com.vmware.flowgate.common.model.FacilitySoftwareConfig)7 HashMap (java.util.HashMap)7 ResourceAccessException (org.springframework.web.client.ResourceAccessException)7 ArrayList (java.util.ArrayList)5 AssetIPMapping (com.vmware.flowgate.common.model.AssetIPMapping)3 RealTimeData (com.vmware.flowgate.common.model.RealTimeData)3 SDDCSoftwareConfig (com.vmware.flowgate.common.model.SDDCSoftwareConfig)3 NlyteAsset (com.vmware.flowgate.nlyteworker.model.NlyteAsset)3 PowerIQAPIClient (com.vmware.flowgate.poweriqworker.client.PowerIQAPIClient)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 AdvanceSettingType (com.vmware.flowgate.common.model.FacilitySoftwareConfig.AdvanceSettingType)2 ServerMapping (com.vmware.flowgate.common.model.ServerMapping)2 WormholeRequestException (com.vmware.flowgate.exception.WormholeRequestException)2 LocationGroup (com.vmware.flowgate.nlyteworker.model.LocationGroup)2 Manufacturer (com.vmware.flowgate.nlyteworker.model.Manufacturer)2