use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class MessageProcessingTest method testVC.
@Test
public void testVC() throws Exception {
ObjectMapper mapper = new ObjectMapper();
SDDCSoftwareConfig vc = new SDDCSoftwareConfig();
vc.setDescription("good vc");
vc.setName("Test VC");
vc.setServerURL("10.10.10.10");
vc.setPassword("fake password");
vc.setType(SoftwareType.VCENTER);
String payload = mapper.writeValueAsString(vc);
// EventMessage message =
// EventMessageUtil.createEventMessage(EventType.VCenter, EventMessageUtil.VCENTER_SyncCustomerAttrs, payload);
EventMessage message = EventMessageUtil.createEventMessage(EventType.VCenter, EventMessageUtil.VCENTER_SyncData, "");
System.out.println(mapper.writeValueAsString(message));
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareController method updateStatus.
// only modify the status of integration,and not verify information of server.
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/status", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public void updateStatus(@RequestBody SDDCSoftwareConfig server) {
Optional<SDDCSoftwareConfig> oldSddcOptional = sddcRepository.findById(server.getId());
if (!oldSddcOptional.isPresent()) {
throw WormholeRequestException.NotFound("SDDCSoftwareConfig", "id", server.getId());
}
SDDCSoftwareConfig old = oldSddcOptional.get();
old.setIntegrationStatus(server.getIntegrationStatus());
sddcRepository.save(old);
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareController method updateSDDCSoftwareConfig.
// Update
@ResponseStatus(HttpStatus.OK)
@RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public void updateSDDCSoftwareConfig(@RequestBody SDDCSoftwareConfig server) {
Optional<SDDCSoftwareConfig> oldSddcOptional = sddcRepository.findById(server.getId());
if (!oldSddcOptional.isPresent()) {
throw WormholeRequestException.NotFound("SDDCSoftwareConfig", "id", server.getId());
}
SDDCSoftwareConfig old = oldSddcOptional.get();
server.setServerURL(old.getServerURL());
server.setType(old.getType());
server.setUserId(old.getUserId());
if (StringUtils.isBlank(server.getPassword())) {
decryptServerPassword(old);
server.setPassword(old.getPassword());
}
switch(server.getType()) {
case VRO:
serverValidationService.validateVROServer(server);
break;
case VCENTER:
serverValidationService.validVCServer(server);
break;
default:
throw WormholeRequestException.InvalidFiled("type", server.getType().toString());
}
encryptServerPassword(server);
try {
BaseDocumentUtil.applyChanges(old, server);
} catch (Exception e) {
throw new WormholeRequestException("Faild to update the SDDCSoftware", e);
}
sddcRepository.save(old);
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareController method delete.
// Delete
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void delete(@PathVariable String id) {
Optional<SDDCSoftwareConfig> sddcOptional = sddcRepository.findById(id);
SDDCSoftwareConfig server = new SDDCSoftwareConfig();
try {
server = sddcOptional.get();
} catch (NoSuchElementException e) {
throw WormholeRequestException.NotFound("sddc", "id", id);
}
SoftwareType type = server.getType();
switch(type) {
case VCENTER:
List<ServerMapping> vcenterMappings = serverMappingRepository.findAllByVCID(id);
if (vcenterMappings != null && !vcenterMappings.isEmpty()) {
for (ServerMapping mapping : vcenterMappings) {
serverMappingRepository.deleteById(mapping.getId());
}
}
break;
case VRO:
case VROPSMP:
List<ServerMapping> mappings = serverMappingRepository.findAllByVroID(id);
if (mappings != null && !mappings.isEmpty()) {
for (ServerMapping mapping : mappings) {
serverMappingRepository.deleteById(mapping.getId());
}
}
break;
default:
logger.info(String.format("Integration Type: %s No Found.", server.getType()));
break;
}
sddcRepository.deleteById(id);
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareController method getVROServerConfigsByUser.
// get servers by user
// Confuse, if we only filter out vrops why not set the type field?
@RequestMapping(value = "/user/vrops", method = RequestMethod.GET)
public List<SDDCSoftwareConfig> getVROServerConfigsByUser(HttpServletRequest request) {
SDDCSoftwareConfig example = new SDDCSoftwareConfig();
example.setUserId(getCurrentUserID(request));
List<SDDCSoftwareConfig> datas = sddcRepository.findAllByUserId(getCurrentUserID(request));
if (datas.isEmpty()) {
throw new WormholeRequestException("The result is empty");
}
decryptServerListPassword(datas);
return datas;
}
Aggregations