use of com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method getDefaultCDHInfo.
private DefaultCDHInfo getDefaultCDHInfo(Long workspaceId, String blueprintCdhVersion, String osType, String cloudPlatform, String imageCatalogName) throws CloudbreakImageCatalogException {
DefaultCDHInfo defaultCDHInfo = null;
Map<String, ImageBasedDefaultCDHInfo> entries = imageBasedDefaultCDHEntries.getEntries(workspaceId, cloudPlatform, imageCatalogName);
if (blueprintCdhVersion != null && entries.containsKey(blueprintCdhVersion)) {
defaultCDHInfo = entries.get(blueprintCdhVersion).getDefaultCDHInfo();
}
if (defaultCDHInfo == null) {
defaultCDHInfo = entries.entrySet().stream().filter(e -> Objects.nonNull(e.getValue().getDefaultCDHInfo().getRepo().getStack().get(osType))).max(ImageBasedDefaultCDHEntries.IMAGE_BASED_CDH_ENTRY_COMPARATOR).orElseThrow(notFound("Default Product Info with OS type:", osType)).getValue().getDefaultCDHInfo();
}
return defaultCDHInfo;
}
use of com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method getDefaultCDHInfo.
private DefaultCDHInfo getDefaultCDHInfo(Cluster cluster, String blueprintCdhVersion, String osType, String imageCatalogName) throws CloudbreakImageCatalogException {
DefaultCDHInfo defaultCDHInfo = null;
Stack stack = cluster.getStack();
ImageCatalogPlatform platformString = platformStringTransformer.getPlatformStringForImageCatalog(stack.getCloudPlatform(), stack.getPlatformVariant());
Map<String, ImageBasedDefaultCDHInfo> entries = imageBasedDefaultCDHEntries.getEntries(cluster.getWorkspace().getId(), platformString, imageCatalogName);
if (blueprintCdhVersion != null && entries.containsKey(blueprintCdhVersion)) {
defaultCDHInfo = entries.get(blueprintCdhVersion).getDefaultCDHInfo();
}
if (defaultCDHInfo == null) {
defaultCDHInfo = entries.entrySet().stream().filter(e -> Objects.nonNull(e.getValue().getDefaultCDHInfo().getRepo().getStack().get(osType))).max(ImageBasedDefaultCDHEntries.IMAGE_BASED_CDH_ENTRY_COMPARATOR).orElseThrow(notFound("Default Product Info with OS type:", osType)).getValue().getDefaultCDHInfo();
}
return defaultCDHInfo;
}
use of com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo in project cloudbreak by hortonworks.
the class ImagesToImagesV4ResponseConverterTest method setupStackEntries.
private void setupStackEntries() {
Map<String, ImageBasedDefaultCDHInfo> cdhEntries = new HashMap<>();
DefaultCDHInfo cdhInfo = getDefaultCDHInfo("6.1.0-1.cdh6.1.0.p0.770702");
Image image = mock(Image.class);
cdhEntries.put("6.1.0", new ImageBasedDefaultCDHInfo(cdhInfo, image));
when(imageBasedDefaultCDHEntries.getEntries(Mockito.any(Images.class))).thenReturn(cdhEntries);
}
use of com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo in project cloudbreak by hortonworks.
the class ClusterCreationSetupServiceTest method init.
@Before
public void init() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException, IOException {
MockitoAnnotations.initMocks(this);
workspace = new Workspace();
clusterRequest = new ClusterV4Request();
stack = new Stack();
stack.setId(1L);
stack.setWorkspace(workspace);
stack.setEnvironmentCrn("env");
stack.setName("name");
blueprint = new Blueprint();
blueprint.setBlueprintText("{}");
user = new User();
Map<InstanceGroupType, String> userData = new HashMap<>();
userData.put(InstanceGroupType.CORE, "userdata");
Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", "imgcatname", "id", Collections.emptyMap());
Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
cluster = new Cluster();
stack.setCluster(cluster);
when(clusterDecorator.decorate(any(), any(), any(), any(), any(), any())).thenReturn(cluster);
when(componentConfigProviderService.getAllComponentsByStackIdAndType(any(), any())).thenReturn(Sets.newHashSet(imageComponent));
when(blueprintUtils.getBlueprintStackVersion(any())).thenReturn(HDP_VERSION);
when(blueprintUtils.getBlueprintStackName(any())).thenReturn("HDP");
DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(CDH_VERSION);
when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(Collections.singletonMap(CDH_VERSION, new ImageBasedDefaultCDHInfo(defaultCDHInfo, Mockito.mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class))));
when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
stackMatrixV4Response.setCdh(Collections.singletonMap(CDH_VERSION, null));
when(stackMatrixService.getStackMatrix(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(stackMatrixV4Response);
when(clouderaManagerClusterCreationSetupService.prepareClouderaManagerCluster(any(), any(), any(), any(), any())).thenReturn(new ArrayList<>());
}
use of com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo in project cloudbreak by hortonworks.
the class ImagesToImagesV4ResponseConverter method getBaseImageResponses.
private List<BaseImageV4Response> getBaseImageResponses(Images source) {
Map<String, ImageBasedDefaultCDHInfo> imageBasedDefaultCDHInfoMap = imageBasedDefaultCDHEntries.getEntries(source);
List<ClouderaManagerStackDetailsV4Response> defaultCdhStacks = getDefaultCdhStackInfo(imageBasedDefaultCDHInfoMap);
List<BaseImageV4Response> baseImages = source.getBaseImages().stream().map(image -> {
BaseImageV4Response imgJson = new BaseImageV4Response();
copyImageFieldsToJson(image, imgJson);
imgJson.setCdhStacks(defaultCdhStacks);
imgJson.setRepository(new HashMap<>());
return imgJson;
}).collect(Collectors.toList());
return baseImages;
}
Aggregations