use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class StackToCreateFreeIpaRequestConverter method getImageSettingsRequest.
private ImageSettingsRequest getImageSettingsRequest(ImageEntity image) {
ImageSettingsRequest request = null;
if (image != null) {
request = new ImageSettingsRequest();
request.setCatalog(image.getImageCatalogUrl());
request.setId(image.getImageId());
request.setOs(image.getOs());
}
LOGGER.debug("Created image settings request {} from image entity {}", request, image);
return request;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class FreeIpaCreationService method launchFreeIpa.
public DescribeFreeIpaResponse launchFreeIpa(CreateFreeIpaRequest request, String accountId) {
String userCrn = crnService.getUserCrn();
Future<String> ownerFuture = initiateOwnerFetching(userCrn);
Credential credential = credentialService.getCredentialByEnvCrn(request.getEnvironmentCrn());
DetailedEnvironmentResponse environment = measure(() -> cachedEnvironmentClientService.getByCrn(request.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn());
Stack stack = stackConverter.convert(request, environment, accountId, ownerFuture, userCrn, credential.getCloudPlatform());
stack.setAppVersion(appVersion);
GetPlatformTemplateRequest getPlatformTemplateRequest = templateService.triggerGetTemplate(stack, credential);
Telemetry telemetry = stack.getTelemetry();
if (telemetry != null) {
telemetry.setRules(accountTelemetryService.getAnonymizationRules(accountId));
}
cloudStorageFolderResolverService.updateStorageLocation(telemetry, FluentClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
stack.setTelemetry(telemetry);
Backup backup = stack.getBackup();
backup = cloudBackupFolderResolverService.updateStorageLocation(backup, BackupClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
stack.setBackup(backup);
fillInstanceMetadata(stack, environment);
String template = templateService.waitGetTemplate(getPlatformTemplateRequest);
stack.setTemplate(template);
SecurityConfig securityConfig = tlsSecurityService.generateSecurityKeys(accountId);
multiAzValidator.validateMultiAzForStack(stack.getPlatformvariant(), stack.getInstanceGroups());
freeIpaRecommendationService.validateCustomInstanceType(stack, credential);
try {
Triple<Stack, ImageEntity, FreeIpa> stackImageFreeIpaTuple = transactionService.required(() -> {
SecurityConfig savedSecurityConfig = securityConfigService.save(securityConfig);
stack.setSecurityConfig(savedSecurityConfig);
Stack savedStack = stackService.save(stack);
ImageSettingsRequest imageSettingsRequest = request.getImage();
ImageEntity image = imageService.create(savedStack, Objects.nonNull(imageSettingsRequest) ? imageSettingsRequest : new ImageSettingsRequest());
FreeIpa freeIpa = freeIpaService.create(savedStack, request.getFreeIpa());
return Triple.of(savedStack, image, freeIpa);
});
flowManager.notify(FlowChainTriggers.PROVISION_TRIGGER_EVENT, new StackEvent(FlowChainTriggers.PROVISION_TRIGGER_EVENT, stackImageFreeIpaTuple.getLeft().getId()));
InMemoryStateStore.putStack(stack.getId(), PollGroup.POLLABLE);
return stackToDescribeFreeIpaResponseConverter.convert(stackImageFreeIpaTuple.getLeft(), stackImageFreeIpaTuple.getMiddle(), stackImageFreeIpaTuple.getRight(), Optional.empty(), false);
} catch (TransactionService.TransactionExecutionException e) {
LOGGER.error("Creation of FreeIPA failed", e);
throw new BadRequestException("Creation of FreeIPA failed: " + e.getCause().getMessage(), e);
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeImageService method getCurrentImageDateFromCatalog.
private Optional<String> getCurrentImageDateFromCatalog(Stack stack, ImageInfoResponse currentImage) {
try {
String catalog = Optional.ofNullable(currentImage.getCatalog()).orElse(currentImage.getCatalogName());
LOGGER.debug("Current image date field is empty. Using catalog [{}] to get image date", catalog);
ImageSettingsRequest imageSettings = new ImageSettingsRequest();
imageSettings.setCatalog(catalog);
imageSettings.setId(currentImage.getId());
imageSettings.setOs(currentImage.getOs());
ImageWrapper image = imageService.getImage(imageSettings, stack.getRegion(), stack.getCloudPlatform().toLowerCase());
LOGGER.debug("Image date from catalog: {}", image.getImage().getDate());
return Optional.ofNullable(image.getImage().getDate());
} catch (ImageNotFoundException e) {
LOGGER.warn("Image not found, returning empty date", e);
return Optional.empty();
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeService method triggerUpgrade.
@SuppressWarnings("IllegalType")
private FreeIpaUpgradeResponse triggerUpgrade(FreeIpaUpgradeRequest request, Stack stack, String pgwInstanceId, HashSet<String> nonPgwInstanceIds, ImageSettingsRequest imageSettingsRequest, ImageInfoResponse selectedImage, ImageInfoResponse currentImage) {
Operation operation = startUpgradeOperation(stack.getAccountId(), request);
UpgradeEvent upgradeEvent = new UpgradeEvent(FlowChainTriggers.UPGRADE_TRIGGER_EVENT, stack.getId(), nonPgwInstanceIds, pgwInstanceId, operation.getOperationId(), imageSettingsRequest, Objects.nonNull(stack.getBackup()));
LOGGER.info("Trigger upgrade flow with event: {}", upgradeEvent);
FlowIdentifier flowIdentifier = flowManager.notify(FlowChainTriggers.UPGRADE_TRIGGER_EVENT, upgradeEvent);
return new FreeIpaUpgradeResponse(flowIdentifier, selectedImage, currentImage, operation.getOperationId());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class ImageService method getImageForStack.
private Image getImageForStack(Stack stack) {
final ImageEntity imageEntity = getByStack(stack);
final ImageSettingsRequest imageSettings = imageEntityToImageSettingsRequest(imageEntity);
final ImageWrapper imageWrapper = getImage(imageSettings, stack.getRegion(), getPlatformString(stack));
return imageWrapper.getImage();
}
Aggregations