use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class InfobloxClientTest method getInfobloxFacilitySoftware.
private 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 facilitySoftwareConfigs;
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class LabsdbService method executeAsync.
@Override
public void executeAsync(EventMessage message) {
// TODO Auto-generated method stub
if (message.getType() != EventType.Labsdb) {
logger.warn("Drop none Labsdb 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.Labsdb_SyncData:
// it will sync all the data depend on the type in the labsdbJobList.
String messageString = null;
while ((messageString = template.opsForList().rightPop(EventMessageUtil.labsdbJobList)) != 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 labsdb = null;
try {
labsdb = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (null == labsdb) {
continue;
}
if (!labsdb.checkIsActive()) {
continue;
}
for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
excuteJob(payloadCommand.getId(), labsdb);
}
}
break;
default:
FacilitySoftwareConfig labsdb = null;
try {
labsdb = mapper.readValue(message.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e1) {
// TODO Auto-generated catch block
logger.error("Failed to convert message", e1);
}
if (labsdb != null) {
excuteJob(command.getId(), labsdb);
}
break;
}
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class AssetController method searchAssetsByAssetNameAndTagLike.
// searchAssetsByAssetNameAndTagLike
@RequestMapping(value = { "/page/{pageNumber}/pagesize/{pageSize}/keywords/{keyWords}", "/page/{pageNumber}/pagesize/{pageSize}" }, method = RequestMethod.GET)
public Page<Asset> searchAssetsByAssetNameAndTagLike(@PathVariable("pageNumber") int pageNumber, @PathVariable("pageSize") int pageSize, @PathVariable(required = false) String keyWords, @RequestParam(required = false) AssetCategory category) {
if (keyWords == null) {
keyWords = "%%";
} else {
keyWords = "%" + keyWords + "%";
}
if (category == null) {
category = AssetCategory.Server;
}
if (pageNumber < FlowgateConstant.defaultPageNumber) {
pageNumber = FlowgateConstant.defaultPageNumber;
} else if (pageSize <= 0) {
pageSize = FlowgateConstant.defaultPageSize;
} else if (pageSize > FlowgateConstant.maxPageSize) {
pageSize = FlowgateConstant.maxPageSize;
}
PageRequest pageable = PageRequest.of(pageNumber - 1, pageSize);
List<Asset> assets = assetRepository.findByAssetNameLikeAndCategory(keyWords, category.name(), pageSize, pageSize * (pageNumber - 1));
PageImpl<Asset> assetPage = new PageImpl<Asset>(assets, pageable, 0);
HashMap<String, String> assetSourceIDAndAssetSourceNameMap = new HashMap<String, String>();
assetSourceIDAndAssetSourceNameMap.put(FLOWGATE_SOURCE, FLOWGATE_SOURCE);
for (Asset asset : assetPage.getContent()) {
String assetSourceID = asset.getAssetSource();
if (assetSourceID == null) {
continue;
}
String[] assetSource = assetSourceID.split(FlowgateConstant.SPILIT_FLAG);
List<String> assetSourceNames = new ArrayList<String>();
for (String sourceId : assetSource) {
String assetSourceName = assetSourceIDAndAssetSourceNameMap.get(sourceId);
if (assetSourceName == null) {
Optional<FacilitySoftwareConfig> facilityOptional = facilityRepository.findById(sourceId);
if (facilityOptional.isPresent()) {
assetSourceName = facilityOptional.get().getName();
assetSourceIDAndAssetSourceNameMap.put(sourceId, assetSourceName);
}
}
assetSourceNames.add(assetSourceName);
}
String sourceNames = String.join(FlowgateConstant.SPILIT_FLAG, assetSourceNames);
asset.setAssetSource(sourceNames);
}
return assetPage;
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareController method updateFacilitySoftwareConfig.
// Update
@ResponseStatus(HttpStatus.OK)
@RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public void updateFacilitySoftwareConfig(@RequestBody FacilitySoftwareConfig config) {
Optional<FacilitySoftwareConfig> oldServerOptional = repository.findById(config.getId());
if (!oldServerOptional.isPresent()) {
throw WormholeRequestException.NotFound("FacilitySoftwareConfig", "id", config.getId());
}
FacilitySoftwareConfig old = oldServerOptional.get();
old.setName(config.getName());
old.setDescription(config.getDescription());
old.setUserName(config.getUserName());
old.setVerifyCert(config.isVerifyCert());
old.setAdvanceSetting(config.getAdvanceSetting());
old.setIntegrationStatus(config.getIntegrationStatus());
if (StringUtils.isNotBlank(config.getPassword())) {
old.setPassword(config.getPassword());
} else {
decryptServerPassword(old);
}
serverValidationService.validateFacilityServer(old);
encryptServerPassword(old);
repository.save(old);
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareController method syncFacilityServerData.
@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(value = "/syncdatabyserverid/{id}", method = RequestMethod.POST)
public void syncFacilityServerData(@PathVariable("id") String id, HttpServletRequest request) {
Optional<FacilitySoftwareConfig> serverOptional = repository.findById(id);
if (!serverOptional.isPresent()) {
throw WormholeRequestException.NotFound("FacilitySoftwareConfig", "id", id);
}
FacilitySoftwareConfig server = serverOptional.get();
decryptServerPassword(server);
notifyFacilityWorker(server);
}
Aggregations