Search in sources :

Example 61 with Workspace

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

the class BlueprintService method getBlueprintAndText.

public Pair<Blueprint, String> getBlueprintAndText(String blueprintName, Long workspaceId) {
    User user = getLoggedInUser();
    Workspace workspace = getWorkspaceService().get(workspaceId, user);
    Blueprint blueprint = getByNameForWorkspaceAndLoadDefaultsIfNecessary(blueprintName, workspace);
    String blueprintText = getBlueprintText(blueprintName, workspaceId);
    return Pair.of(blueprint, blueprintText);
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 62 with Workspace

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

the class BlueprintService method getBlueprintText.

public String getBlueprintText(String blueprintName, Long workspaceId) {
    User user = getLoggedInUser();
    Workspace workspace = getWorkspaceService().get(workspaceId, user);
    return getByNameForWorkspaceAndLoadDefaultsIfNecessary(blueprintName, workspace).getBlueprintText();
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 63 with Workspace

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

the class StackCreatorServiceTest method shouldThrowBadRequestWhenStackNameAlreadyExists.

@Test
public void shouldThrowBadRequestWhenStackNameAlreadyExists() {
    User user = new User();
    Workspace workspace = new Workspace();
    workspace.setId(WORKSPACE_ID);
    StackV4Request stackRequest = new StackV4Request();
    stackRequest.setName(STACK_NAME);
    InstanceGroupV4Request instanceGroupV4Request = new InstanceGroupV4Request();
    instanceGroupV4Request.setName(INSTANCE_GROUP);
    instanceGroupV4Request.setRecipeNames(Set.of(RECIPE_NAME));
    stackRequest.setInstanceGroups(List.of(instanceGroupV4Request));
    doNothing().when(nodeCountLimitValidator).validateProvision(any());
    when(stackViewService.findByName(anyString(), anyLong())).thenReturn(Optional.of(new StackView()));
    BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.createStack(user, workspace, stackRequest, false));
    assertThat(badRequestException).hasMessage("Cluster already exists: STACK_NAME");
    verify(recipeService).get(NameOrCrn.ofName(RECIPE_NAME), WORKSPACE_ID);
    verify(stackViewService).findByName(STACK_NAME, WORKSPACE_ID);
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 64 with Workspace

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

the class ClusterCreationEnvironmentValidatorTest method getStack.

private Stack getStack() {
    Stack stack = new Stack();
    stack.setRegion("region1");
    stack.setCloudPlatform("aws");
    Workspace workspace = new Workspace();
    workspace.setId(1L);
    Tenant tenant = new Tenant();
    tenant.setName("test-tenant-name");
    workspace.setTenant(tenant);
    stack.setWorkspace(workspace);
    stack.setEnvironmentCrn("");
    return stack;
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 65 with Workspace

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

the class RecipeServiceTest method testCreateWithInternalUser.

@Test
public void testCreateWithInternalUser() {
    Recipe recipe = getRecipe();
    recipe.setCreator(null);
    Workspace workspace = new Workspace();
    workspace.setId(1L);
    when(workspaceService.getByIdWithoutAuth(any())).thenReturn(workspace);
    when(recipeRepository.save(any())).thenReturn(recipe);
    Recipe savedRecipe = underTest.createWithInternalUser(recipe, 1L, "account_id");
    assertThat(recipe.getCreator(), nullValue());
    assertTrue(recipe.getResourceCrn().matches("crn:cdp:datahub:us-west-1:account_id:recipe:.*"));
    assertEquals(workspace, savedRecipe.getWorkspace());
    assertEquals(CreationType.SERVICE, savedRecipe.getCreationType());
}
Also used : Recipe(com.sequenceiq.cloudbreak.domain.Recipe) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Test(org.junit.jupiter.api.Test)

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