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;
}
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"));
}
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;
}
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);
}
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;
}
Aggregations