use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class ClusterV4RequestToClusterConverterTest method before.
@BeforeEach
public void before() {
blueprint = new Blueprint();
blueprint.setStackType(StackType.HDP.name());
workspace = new Workspace();
workspace.setId(100L);
workspace.setName("TEST_WS_NAME");
workspace.setDescription("TEST_WS_DESC");
when(workspaceService.getForCurrentUser()).thenReturn(workspace);
when(cloudStorageValidationUtil.isCloudStorageConfigured(nullable(CloudStorageBase.class))).thenReturn(false);
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class DistroXServiceTest method setUp.
@BeforeEach
void setUp() {
MockitoAnnotations.initMocks(this);
Workspace workspace = new Workspace();
workspace.setId(USER_ID);
when(workspaceService.getForCurrentUser()).thenReturn(workspace);
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class CmSyncImageCollectorServiceTest method setupStack.
private void setupStack(boolean setupWorkspace, boolean setupCloudPlatform) {
when(stack.getId()).thenReturn(STACK_ID);
if (setupWorkspace) {
Workspace workspace = mock(Workspace.class);
when(workspace.getId()).thenReturn(WORKSPCE_ID);
when(stack.getWorkspace()).thenReturn(workspace);
}
if (setupCloudPlatform) {
when(stack.getCloudPlatform()).thenReturn(CURRENT_CLOUD_PLATFORM);
when(stack.getPlatformVariant()).thenReturn(CURRENT_CLOUD_PLATFORM);
}
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class ClusterV4RequestToClusterConverter method convert.
public Cluster convert(ClusterV4Request source) {
Workspace workspace = workspaceService.getForCurrentUser();
Cluster cluster = new Cluster();
cluster.setName(source.getName());
cluster.setStatus(REQUESTED);
cluster.setDatabaseServerCrn(source.getDatabaseServerCrn());
cluster.setBlueprint(getBlueprint(source.getBlueprintName(), workspace));
cluster.setCustomConfigurations(getCustomConfigurations(source.getCustomConfigurationsName()));
convertGateway(source, cluster);
if (cloudStorageValidationUtil.isCloudStorageConfigured(source.getCloudStorage())) {
FileSystem fileSystem = cloudStorageConverter.requestToFileSystem(source.getCloudStorage());
cluster.setFileSystem(fileSystem);
String accountId = ThreadBasedUserCrnProvider.getAccountId();
if (entitlementService.dataLakeEfsEnabled(accountId)) {
FileSystem additionalFileSystem = cloudStorageConverter.requestToAdditionalFileSystem(source.getCloudStorage());
cluster.setAdditionalFileSystem(additionalFileSystem);
}
}
convertAttributes(source, cluster);
try {
Json json = new Json(convertContainerConfigs(source.getCustomContainer()));
cluster.setCustomContainerDefinition(json);
} catch (IllegalArgumentException ignored) {
cluster.setCustomContainerDefinition(null);
}
updateDatabases(source, cluster, workspace);
extractClusterManagerAndHdpRepoConfig(cluster, source);
cluster.setProxyConfigCrn(source.getProxyConfigCrn());
cluster.setRangerRazEnabled(source.isRangerRazEnabled());
return cluster;
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverter method convert.
public Stack convert(StackV4Request source) {
Workspace workspace = workspaceService.getForCurrentUser();
Stack stack = new Stack();
stack.setEnvironmentCrn(source.getEnvironmentCrn());
DetailedEnvironmentResponse environment = null;
if (!StringUtils.isEmpty(source.getEnvironmentCrn())) {
environment = measure(() -> environmentClientService.getByCrn(source.getEnvironmentCrn()), LOGGER, "Environment responded in {} ms for stack {}", source.getName());
}
if (isTemplate(source)) {
updateCustomDomainOrKerberos(source, stack);
updateCloudPlatformAndRelatedFields(source, stack, environment);
convertAsStackTemplate(source, stack, environment);
setNetworkAsTemplate(source, stack);
} else {
convertAsStack(source, stack);
updateCloudPlatformAndRelatedFields(source, stack, environment);
setNetworkIfApplicable(source, stack, environment);
setInstanceGroupNetworkIfApplicable(source, stack, environment);
stack.getComponents().add(getTelemetryComponent(stack, source));
}
Map<String, Object> asMap = providerParameterCalculator.get(source).asMap();
if (asMap != null) {
Map<String, String> parameter = new HashMap<>();
asMap.forEach((key, value) -> parameter.put(key, value.toString()));
stack.setParameters(parameter);
}
setTimeToLive(source, stack);
stack.setWorkspace(workspace);
stack.setDisplayName(source.getName());
stack.setDatalakeCrn(datalakeService.getDatalakeCrn(source, workspace));
stack.setStackAuthentication(stackAuthenticationV4RequestToStackAuthenticationConverter.convert(source.getAuthentication()));
stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.PROVISION_REQUESTED));
stack.setCreated(clock.getCurrentTimeMillis());
stack.setInstanceGroups(convertInstanceGroups(source, stack));
Optional<String> parentEnvCloudPlatform = Optional.ofNullable(environment).map(EnvironmentBaseResponse::getParentEnvironmentCloudPlatform);
measure(() -> updateCluster(source, stack, parentEnvCloudPlatform), LOGGER, "Converted cluster and updated the stack in {} ms for stack {}", source.getName());
stack.setGatewayPort(source.getGatewayPort());
stack.setUuid(UUID.randomUUID().toString());
stack.setType(source.getType());
stack.setInputs(Json.silent(new StackInputs(source.getInputs(), new HashMap<>(), new HashMap<>())));
if (source.getImage() != null) {
stack.getComponents().add(getImageComponent(source, stack));
}
if (!isTemplate(source) && environment != null) {
gatewaySecurityGroupDecorator.extendGatewaySecurityGroupWithDefaultGatewayCidrs(stack, environment.getTunnel());
}
stack.setExternalDatabaseCreationType(getIfNotNull(source.getExternalDatabase(), DatabaseRequest::getAvailabilityType));
stack.setExternalDatabaseEngineVersion(getIfNotNull(source.getExternalDatabase(), DatabaseRequest::getDatabaseEngineVersion));
stack.setDomainDnsResolver(targetedUpscaleSupportService.isUnboundEliminationSupported(Crn.safeFromString(source.getEnvironmentCrn()).getAccountId()) ? DnsResolverType.FREEIPA_FOR_ENV : DnsResolverType.LOCAL_UNBOUND);
determineServiceTypeTag(stack, source.getTags());
determineServiceFeatureTag(stack, source.getTags());
Set<LoadBalancer> loadBalancers = loadBalancerConfigService.createLoadBalancers(stack, environment, source);
stack.setLoadBalancers(loadBalancers);
return stack;
}
Aggregations