Search in sources :

Example 41 with Workspace

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

the class RecipeEngineTest method stack.

private Stack stack() {
    Stack stack = new Stack();
    stack.setId(DUMMY_STACK_ID);
    stack.setName("dummy");
    Cluster cluster = new Cluster();
    cluster.setId(DUMMY_STACK_ID);
    stack.setCluster(cluster);
    Workspace workspace = new Workspace();
    workspace.setId(DUMMY_STACK_ID);
    stack.setWorkspace(workspace);
    return stack;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 42 with Workspace

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

the class ClouderaManagerClusterCreationSetupServiceTest method init.

@Before
public void init() throws CloudbreakImageCatalogException {
    MockitoAnnotations.initMocks(this);
    Workspace workspace = new Workspace();
    clusterRequest = new ClusterV4Request();
    stack = new Stack();
    stack.setId(STACK_ID);
    stack.setName("test-stack");
    stack.setWorkspace(workspace);
    Blueprint blueprint = new Blueprint();
    blueprint.setBlueprintText("{}");
    Map<InstanceGroupType, String> userData = new HashMap<>();
    userData.put(InstanceGroupType.CORE, "userdata");
    Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", IMAGE_CATALOG_NAME, "id", Collections.emptyMap());
    imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
    cluster = new Cluster();
    stack.setCluster(cluster);
    cluster.setStack(stack);
    cluster.setBlueprint(blueprint);
    cluster.setWorkspace(workspace);
    setupDefaultClouderaManagerEntries();
    Map<String, ImageBasedDefaultCDHInfo> defaultCDHInfoMap = Map.of(OLDER_CDH_VERSION, new ImageBasedDefaultCDHInfo(getDefaultCDHInfo(OLDER_CDH_VERSION), mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class)), SOME_CDH_VERSION, new ImageBasedDefaultCDHInfo(getDefaultCDHInfo(SOME_CDH_VERSION), mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class)), NEWER_CDH_VERSION, new ImageBasedDefaultCDHInfo(getDefaultCDHInfo(NEWER_CDH_VERSION), mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class)));
    when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), null, IMAGE_CATALOG_NAME)).thenReturn(defaultCDHInfoMap);
    StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
    stackMatrixV4Response.setCdh(Collections.singletonMap(OLDER_CDH_VERSION, null));
    when(stackMatrixService.getStackMatrix(Mockito.eq(workspace.getId()), Mockito.eq(null), Mockito.anyString())).thenReturn(stackMatrixV4Response);
    when(platformStringTransformer.getPlatformStringForImageCatalog(anyString(), anyString())).thenReturn(imageCatalogPlatform("AWS"));
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Component(com.sequenceiq.cloudbreak.domain.stack.Component) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Before(org.junit.Before)

Example 43 with Workspace

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

the class ClusterTemplateLoaderServiceTest method clusterTemplate.

private ClusterTemplate clusterTemplate(String templateName, String cloudPlatform, String hostgroupName, String instanceGroupName) {
    Workspace workspace = new Workspace();
    ClusterTemplate clusterTemplate = new ClusterTemplate();
    clusterTemplate.setStatus(ResourceStatus.DEFAULT);
    clusterTemplate.setName(templateName);
    Stack stack = new Stack();
    stack.setWorkspace(workspace);
    stack.setCloudPlatform(cloudPlatform);
    Cluster cluster = new Cluster();
    cluster.setWorkspace(workspace);
    HostGroup hostGroup = new HostGroup();
    hostGroup.setName(hostgroupName);
    cluster.setHostGroups(singleton(hostGroup));
    stack.setCluster(cluster);
    stack.setPlatformVariant("VARIANT");
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setGroupName(instanceGroupName);
    stack.setInstanceGroups(singleton(instanceGroup));
    clusterTemplate.setStackTemplate(stack);
    clusterTemplate.setWorkspace(workspace);
    clusterTemplate.setResourceCrn("crn");
    return clusterTemplate;
}
Also used : ClusterTemplate(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 44 with Workspace

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

the class StackStatusCheckerJobTest method init.

@Before
public void init() {
    Tracer tracer = Mockito.mock(Tracer.class);
    underTest = new StackStatusCheckerJob(tracer);
    MockitoAnnotations.openMocks(this);
    when(flowLogService.isOtherFlowRunning(anyLong())).thenReturn(Boolean.FALSE);
    underTest.setLocalId("1");
    underTest.setRemoteResourceCrn("remote:crn");
    stack = new Stack();
    stack.setId(1L);
    stack.setResourceCrn("crn:cdp:datahub:us-west-1:acc1:stack:cluster1");
    workspace = new Workspace();
    workspace.setId(1L);
    stack.setWorkspace(workspace);
    stack.setCluster(cluster);
    user = new User();
    user.setUserId("1");
    stack.setCreator(user);
    stack.setCloudPlatform("AWS");
    when(stackService.get(anyLong())).thenReturn(stack);
    when(jobExecutionContext.getMergedJobDataMap()).thenReturn(new JobDataMap());
    when(cluster.getBlueprint()).thenReturn(blueprint);
    when(blueprint.getBlueprintText()).thenReturn(BLUEPRINT_TEXT);
    when(cmTemplateProcessorFactory.get(anyString())).thenReturn(cmTemplateProcessor);
}
Also used : JobDataMap(org.quartz.JobDataMap) User(com.sequenceiq.cloudbreak.workspace.model.User) Tracer(io.opentracing.Tracer) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Before(org.junit.Before)

Example 45 with Workspace

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

the class ClusterTemplateV4RequestToClusterTemplateConverter method convert.

public ClusterTemplate convert(ClusterTemplateV4Request source) {
    if (source.getDistroXTemplate() == null) {
        throw new BadRequestException("The Datahub template cannot be null.");
    }
    if (StringUtils.isEmpty(source.getDistroXTemplate().getEnvironmentName())) {
        throw new BadRequestException("The environmentName cannot be null.");
    }
    ClusterTemplate clusterTemplate = new ClusterTemplate();
    CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
    User user = userService.getOrCreate(cloudbreakUser);
    Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
    clusterTemplate.setWorkspace(workspace);
    StackV4Request stackV4Request = stackV4RequestConverter.convert(source.getDistroXTemplate());
    stackV4Request.setType(StackType.TEMPLATE);
    Stack stack = stackV4RequestToStackConverter.convert(stackV4Request);
    prepareEmptyInstanceMetadata(stack);
    clusterTemplate.setStackTemplate(stack);
    clusterTemplate.setCloudPlatform(getCloudPlatform(source, stack));
    clusterTemplate.setName(source.getName());
    clusterTemplate.setDescription(source.getDescription());
    clusterTemplate.setDatalakeRequired(DatalakeRequired.OPTIONAL);
    clusterTemplate.setFeatureState(FeatureState.RELEASED);
    clusterTemplate.setStatus(ResourceStatus.USER_MANAGED);
    checkStackWhetherItsCapableOfProvidingCldrRuntimeVersion(stack);
    clusterTemplate.setClouderaRuntimeVersion(stack.getCluster().getBlueprint().getStackVersion());
    if (source.getType() == null) {
        clusterTemplate.setType(ClusterTemplateV4Type.OTHER);
    } else {
        clusterTemplate.setType(source.getType());
    }
    return clusterTemplate;
}
Also used : ClusterTemplate(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate) User(com.sequenceiq.cloudbreak.workspace.model.User) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

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