use of com.sequenceiq.cloudbreak.common.user.CloudbreakUser in project cloudbreak by hortonworks.
the class StackUpgradeOperationsTest method testCheckForOsUpgradeShouldShouldCallUpgradeServiceWhenTheClusterNameIsAvailable.
@Test
void testCheckForOsUpgradeShouldShouldCallUpgradeServiceWhenTheClusterNameIsAvailable() {
User user = new User();
when(userService.getOrCreate(cloudbreakUser)).thenReturn(user);
underTest.checkForOsUpgrade(nameOrCrn, cloudbreakUser, WORKSPACE_ID);
verify(userService).getOrCreate(cloudbreakUser);
verify(upgradeService).getOsUpgradeOptionByStackNameOrCrn(WORKSPACE_ID, nameOrCrn, user);
}
use of com.sequenceiq.cloudbreak.common.user.CloudbreakUser in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverter method convert.
public TemplatePreparationObject convert(StackV4Request source) {
try {
CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
User user = userService.getOrCreate(cloudbreakUser);
Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
Credential credential = getCredential(source, environment);
LdapView ldapConfig = getLdapConfig(source, environment);
BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(source, credential.getAttributes());
Set<RDSConfig> rdsConfigs = getRdsConfigs(source, workspace);
Blueprint blueprint = getBlueprint(source, workspace);
Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
Gateway gateway = source.getCluster().getGateway() == null ? null : stackV4RequestToGatewayConverter.convert(source);
BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(blueprint);
Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, cloudbreakUser.getEmail(), blueprintService.getBlueprintVariant(blueprint));
String gatewaySignKey = null;
if (gateway != null) {
gatewaySignKey = gateway.getSignKey();
}
String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapConfig != null ? ldapConfig.getAdminGroup() : "");
Builder builder = Builder.builder().withCloudPlatform(source.getCloudPlatform()).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withLdapConfig(ldapConfig).withCustomInputs(source.getInputs()).withKerberosConfig(getKerberosConfig(source, environment)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
decorateBuilderWithPlacement(source, builder);
decorateBuilderWithAccountMapping(source, environment, credential, builder);
decorateBuilderWithProductDetails(source, builder);
decorateDatalakeView(source, builder);
return builder.build();
} catch (BlueprintProcessingException | IOException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.common.user.CloudbreakUser in project cloudbreak by hortonworks.
the class GatewayV4RequestToGatewayConverter method convert.
public Gateway convert(GatewayV4Request source) {
ValidationResult validationResult = gatewayJsonValidator.validate(source);
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
if (CollectionUtils.isEmpty(source.getTopologies())) {
return null;
}
Gateway gateway = new Gateway();
gatewayConvertUtil.setBasicProperties(source, gateway);
gatewayConvertUtil.setTopologies(source, gateway);
gatewayConvertUtil.setGatewayPathAndSsoProvider(source, gateway);
CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
User user = userService.getOrCreate(cloudbreakUser);
Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
gateway.setWorkspace(workspace);
return gateway;
}
use of com.sequenceiq.cloudbreak.common.user.CloudbreakUser in project cloudbreak by hortonworks.
the class ImageToStackImageV4ResponseConverter method decorateWithImageCatalogUrl.
private void decorateWithImageCatalogUrl(Image source, StackImageV4Response image) {
if (Strings.isNullOrEmpty(source.getImageCatalogUrl())) {
LOGGER.debug(String.format("Persisted image catalog url is null for image catalog '%s'", source.getImageCatalogName()));
ImageCatalog imageCatalog = getImageCatalog(source);
if (shouldLookupImageCatalogUrlByCloudbreakUser(imageCatalog)) {
CloudbreakUser cloudbreakUser = legacyRestRequestThreadLocalService.getCloudbreakUser();
LOGGER.debug(String.format("Lookup the url of '%s' user's image catalog.", cloudbreakUser == null ? null : cloudbreakUser.getUserCrn()));
User user = userService.getOrCreate(cloudbreakUser);
image.setCatalogUrl(imageCatalogService.getImageDefaultCatalogUrl(user));
}
} else {
image.setCatalogUrl(source.getImageCatalogUrl());
}
}
use of com.sequenceiq.cloudbreak.common.user.CloudbreakUser in project cloudbreak by hortonworks.
the class ImageCatalogToImageCatalogV4ShortResponseConverter method isDefault.
private boolean isDefault(String imageCatalogName) {
CloudbreakUser cloudbreakUser = legacyRestRequestThreadLocalService.getCloudbreakUser();
User user = userService.getOrCreate(cloudbreakUser);
String defaultImageCatalogName = imageCatalogService.getDefaultImageCatalogName(user);
return imageCatalogName.equals(defaultImageCatalogName) || (defaultImageCatalogName == null && imageCatalogService.isEnvDefault(imageCatalogName));
}
Aggregations