Search in sources :

Example 51 with Workspace

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);
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) CloudStorageBase(com.sequenceiq.common.api.cloudstorage.CloudStorageBase) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 52 with Workspace

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);
}
Also used : Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 53 with 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);
    }
}
Also used : Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 54 with Workspace

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;
}
Also used : FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Json(com.sequenceiq.cloudbreak.common.json.Json) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 55 with Workspace

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;
}
Also used : HashMap(java.util.HashMap) StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) EnvironmentBaseResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentBaseResponse) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) StackInputs(com.sequenceiq.cloudbreak.cloud.model.StackInputs) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Aggregations

Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)75 User (com.sequenceiq.cloudbreak.workspace.model.User)26 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)24 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Tenant (com.sequenceiq.cloudbreak.workspace.model.Tenant)12 CloudbreakUser (com.sequenceiq.cloudbreak.common.user.CloudbreakUser)9 Test (org.junit.jupiter.api.Test)9 HashMap (java.util.HashMap)8 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)7 Before (org.junit.Before)7 Test (org.junit.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)4 Json (com.sequenceiq.cloudbreak.common.json.Json)4 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)4 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)4 ClusterTemplate (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate)4 HashSet (java.util.HashSet)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4