use of com.vmware.flowgate.common.model.SDDCSoftwareConfig 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);
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class EventMessageUtil method generateSDDCMessageListByType.
public static List<String> generateSDDCMessageListByType(EventType type, String targetCommand, SDDCSoftwareConfig[] sddcs) throws JsonProcessingException {
List<String> result = new ArrayList<String>();
for (SDDCSoftwareConfig sddc : sddcs) {
String payload = mapper.writeValueAsString(sddc);
EventMessage message = EventMessageUtil.createEventMessage(type, targetCommand, payload);
result.add(mapper.writeValueAsString(message));
}
return result;
}
Aggregations