Search in sources :

Example 31 with IntegrationStatus

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

the class SDDCSoftwareController method createServer.

@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(method = RequestMethod.POST)
public void createServer(@RequestBody SDDCSoftwareConfig server, HttpServletRequest request) {
    String ip = server.getServerURL();
    SDDCSoftwareConfig example = sddcRepository.findOneByServerURL(ip);
    if (example != null) {
        String message = String.format("The server %s is already exsit.", ip);
        throw new WormholeRequestException(message);
    }
    switch(server.getType()) {
        case VRO:
            serverValidationService.validateVROServer(server);
            break;
        case VCENTER:
            serverValidationService.validVCServer(server);
            break;
        case VROPSMP:
            break;
        default:
            throw WormholeRequestException.InvalidFiled("type", server.getType().toString());
    }
    WormholeUserDetails user = accessTokenService.getCurrentUser(request);
    server.setUserId(user.getUserId());
    IntegrationStatus integrationStatus = new IntegrationStatus();
    integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
    integrationStatus.setStatus(IntegrationStatus.Status.ACTIVE);
    server.setIntegrationStatus(integrationStatus);
    // encrypt the password
    encryptServerPassword(server);
    BaseDocumentUtil.generateID(server);
    sddcRepository.save(server);
    // notify worker for the start jobs
    decryptServerPassword(server);
    notifySDDCWorker(server);
}
Also used : SDDCSoftwareConfig(com.vmware.flowgate.common.model.SDDCSoftwareConfig) WormholeRequestException(com.vmware.flowgate.exception.WormholeRequestException) WormholeUserDetails(com.vmware.flowgate.util.WormholeUserDetails) IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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