Search in sources :

Example 6 with Tenant

use of com.sequenceiq.cloudbreak.workspace.model.Tenant in project cloudbreak by hortonworks.

the class TestUtil method stack.

public static Stack stack(Status stackStatus, Credential credential) {
    User user = new User();
    user.setUserId("horton@hortonworks.com");
    user.setUserCrn("testCrn");
    user.setUserName("Alma ur");
    Workspace workspace = new Workspace();
    workspace.setId(1L);
    Tenant tenant = new Tenant();
    tenant.setName("testtenant");
    workspace.setTenant(tenant);
    Stack stack = new Stack();
    stack.setCreator(user);
    stack.setWorkspace(workspace);
    stack.setStackStatus(new StackStatus(stack, stackStatus, "statusReason", DetailedStackStatus.UNKNOWN));
    stack.setName("simplestack");
    stack.setId(1L);
    stack.setInstanceGroups(generateGcpInstanceGroups(3));
    stack.setRegion("region");
    stack.setCreated(123L);
    stack.setCloudPlatform(credential.cloudPlatform());
    stack.setOrchestrator(orchestrator());
    stack.setEnvironmentCrn("envCrn");
    stack.setResourceCrn("crn:cdp:cloudbreak:us-west-1:someone:stack:12345");
    switch(credential.cloudPlatform()) {
        case AWS:
            stack.setInstanceGroups(generateAwsInstanceGroups(3));
            break;
        case GCP:
            stack.setInstanceGroups(generateGcpInstanceGroups(3));
            break;
        default:
            break;
    }
    stack.setSecurityConfig(new SecurityConfig());
    return stack;
}
Also used : CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) User(com.sequenceiq.cloudbreak.workspace.model.User) Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 7 with Tenant

use of com.sequenceiq.cloudbreak.workspace.model.Tenant in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testStack.

private Stack testStack() {
    Stack stack = new Stack();
    User user = new User();
    user.setUserId("1");
    user.setId(1L);
    user.setUserName("testJoska");
    user.setUserCrn("joska::crn");
    user.setTenant(new Tenant());
    stack.setCreator(user);
    stack.setGatewayPort(1);
    stack.setCluster(testCluster());
    stack.setType(StackType.DATALAKE);
    stack.setResourceCrn("crn:cdp:datahub:us-west-1:accountId:cluster:name");
    return stack;
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 8 with Tenant

use of com.sequenceiq.cloudbreak.workspace.model.Tenant in project cloudbreak by hortonworks.

the class UserService method createUser.

private User createUser(CloudbreakUser cloudbreakUser) {
    try {
        return transactionService.requiresNew(() -> {
            User user = new User();
            user.setUserId(cloudbreakUser.getUserId());
            user.setUserName(cloudbreakUser.getUsername());
            user.setUserCrn(cloudbreakUser.getUserCrn());
            Tenant tenant = tenantService.findByName(cloudbreakUser.getTenant()).orElse(null);
            if (tenant == null) {
                tenant = new Tenant();
                tenant.setName(cloudbreakUser.getTenant());
                tenant = tenantService.save(tenant);
                createTenantDefaultWorkspace(tenant);
            }
            user.setTenant(tenant);
            return userRepository.save(user);
        });
    } catch (TransactionExecutionException e) {
        throw new TransactionRuntimeExecutionException(e);
    }
}
Also used : CrnUser(com.sequenceiq.cloudbreak.auth.CrnUser) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) User(com.sequenceiq.cloudbreak.workspace.model.User) Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)

Example 9 with Tenant

use of com.sequenceiq.cloudbreak.workspace.model.Tenant in project cloudbreak by hortonworks.

the class OpdbServiceEndpointCollectorTest method createClusterWithComponents.

private Cluster createClusterWithComponents(GatewayType gatewayType) {
    Cluster cluster = clusterWithOrchestrator("ANY");
    GatewayTopology topology1 = gatewayTopology("proxy");
    topology1.setGateway(cluster.getGateway());
    cluster.getGateway().setTopologies(Collections.singleton(topology1));
    cluster.getGateway().setGatewayType(gatewayType);
    Workspace workspace = new Workspace();
    Tenant tenant = new Tenant();
    tenant.setName("tenant");
    workspace.setTenant(tenant);
    cluster.setWorkspace(workspace);
    return cluster;
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 10 with Tenant

use of com.sequenceiq.cloudbreak.workspace.model.Tenant in project cloudbreak by hortonworks.

the class ServiceEndpointCollectorTest method mockBlueprintTextProcessor.

private void mockBlueprintTextProcessor() {
    Blueprint blueprint = new Blueprint();
    blueprint.setBlueprintText("{\"Blueprints\":{}}");
    Workspace workspace = new Workspace();
    Tenant tenant = new Tenant();
    tenant.setName("tenant");
    workspace.setTenant(tenant);
    blueprint.setWorkspace(workspace);
    when(blueprintService.getByNameForWorkspaceId(any(), anyLong())).thenReturn(blueprint);
    CmTemplateProcessor cmTemplateProcessor = mock(CmTemplateProcessor.class);
    when(cmTemplateProcessorFactory.get(any())).thenReturn(cmTemplateProcessor);
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Aggregations

Tenant (com.sequenceiq.cloudbreak.workspace.model.Tenant)18 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)12 User (com.sequenceiq.cloudbreak.workspace.model.User)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)5 CloudbreakUser (com.sequenceiq.cloudbreak.common.user.CloudbreakUser)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)3 Before (org.junit.Before)3 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)2 Test (org.junit.Test)2 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 CrnUser (com.sequenceiq.cloudbreak.auth.CrnUser)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)1 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)1 StackImageUpdateTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent)1