use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response in project cloudbreak by hortonworks.
the class StackMatrixServiceTest method getStackMatrixWithoutAmbari.
@Test
public void getStackMatrixWithoutAmbari() throws Exception {
setupStackEntries();
when(repositoryInfoToClouderaManagerInfoV4ResponseConverter.convert(any(RepositoryInfo.class))).thenReturn(new ClouderaManagerInfoV4Response());
StackMatrixV4Response stackMatrixV4Response = stackMatrixService.getStackMatrix(WORKSPACE_ID, IMAGECATALOGPLATFORM, IMAGE_CATALOG_NAME);
assertEquals(1L, stackMatrixV4Response.getCdh().size());
assertEquals("6.1.0-1.cdh6.1.0.p0.770702", stackMatrixV4Response.getCdh().get("6.1.0").getVersion());
assertNull(stackMatrixV4Response.getCdh().get("6.1.0").getClouderaManager().getRepository());
assertNull(stackMatrixV4Response.getCdh().get("6.1.0").getClouderaManager().getVersion());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response 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.api.endpoint.v4.util.responses.StackMatrixV4Response in project cloudbreak by hortonworks.
the class StackMatrixService method getImageBasedStackMatrix.
private StackMatrixV4Response getImageBasedStackMatrix(Long workspaceId, ImageCatalogPlatform platform, String imageCatalogName) throws CloudbreakImageCatalogException {
Map<String, ImageBasedDefaultCDHInfo> cdhEntries = imageBasedDefaultCDHEntries.getEntries(workspaceId, platform, imageCatalogName);
StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
Map<String, ClouderaManagerStackDescriptorV4Response> cdhStackDescriptors = new HashMap<>();
for (Entry<String, ImageBasedDefaultCDHInfo> defaultCDHInfoEntry : cdhEntries.entrySet()) {
DefaultCDHInfo defaultCDHInfo = defaultCDHInfoEntry.getValue().getDefaultCDHInfo();
Image image = defaultCDHInfoEntry.getValue().getImage();
ClouderaManagerStackDescriptorV4Response stackDescriptorV4 = getImageBasedCMStackDescriptor(defaultCDHInfo, image);
cdhStackDescriptors.put(defaultCDHInfoEntry.getKey(), stackDescriptorV4);
}
stackMatrixV4Response.setCdh(cdhStackDescriptors);
return stackMatrixV4Response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method checkCmStackRepositories.
private void checkCmStackRepositories(ClusterComponent cmRepoConfig, Component imageComponent) throws IOException, CloudbreakImageCatalogException {
if (Objects.nonNull(cmRepoConfig)) {
ClouderaManagerRepo clouderaManagerRepo = cmRepoConfig.getAttributes().get(ClouderaManagerRepo.class);
Image image = imageComponent.getAttributes().get(Image.class);
StackMatrixV4Response stackMatrixV4Response = stackMatrixService.getStackMatrix(cmRepoConfig.getCluster().getWorkspace().getId(), platformStringTransformer.getPlatformStringForImageCatalog(cmRepoConfig.getCluster().getStack().getCloudPlatform(), cmRepoConfig.getCluster().getStack().getPlatformVariant()), image.getImageCatalogName());
Map<String, ClouderaManagerStackDescriptorV4Response> stackDescriptorMap = stackMatrixV4Response.getCdh();
ClouderaManagerStackDescriptorV4Response clouderaManagerStackDescriptor = stackDescriptorMap.get(clouderaManagerRepo.getVersion());
if (clouderaManagerStackDescriptor != null) {
boolean hasDefaultStackRepoUrlForOsType = clouderaManagerStackDescriptor.getRepository().getStack().containsKey(image.getOsType());
boolean hasDefaultCmRepoUrlForOsType = clouderaManagerStackDescriptor.getClouderaManager().getRepository().containsKey(image.getOsType());
if (!hasDefaultCmRepoUrlForOsType || !hasDefaultStackRepoUrlForOsType) {
String message = String.format("The given repository information seems to be incompatible." + " CM version: %s, Image Id: %s, Os type: %s.", clouderaManagerRepo.getVersion(), image.getImageId(), image.getOsType());
LOGGER.warn(message);
}
}
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response in project cloudbreak by hortonworks.
the class StackMatrixService method getImageBasedStackMatrix.
private StackMatrixV4Response getImageBasedStackMatrix(Long workspaceId, String platform, String imageCatalogName) throws CloudbreakImageCatalogException {
Map<String, ImageBasedDefaultCDHInfo> cdhEntries = imageBasedDefaultCDHEntries.getEntries(workspaceId, platform, imageCatalogName);
StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
Map<String, ClouderaManagerStackDescriptorV4Response> cdhStackDescriptors = new HashMap<>();
for (Entry<String, ImageBasedDefaultCDHInfo> defaultCDHInfoEntry : cdhEntries.entrySet()) {
DefaultCDHInfo defaultCDHInfo = defaultCDHInfoEntry.getValue().getDefaultCDHInfo();
Image image = defaultCDHInfoEntry.getValue().getImage();
ClouderaManagerStackDescriptorV4Response stackDescriptorV4 = getImageBasedCMStackDescriptor(defaultCDHInfo, image);
cdhStackDescriptors.put(defaultCDHInfoEntry.getKey(), stackDescriptorV4);
}
stackMatrixV4Response.setCdh(cdhStackDescriptors);
return stackMatrixV4Response;
}
Aggregations