use of com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo 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.DefaultCDHInfo in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method determineCdhRepoConfig.
private Set<ClouderaManagerProduct> determineCdhRepoConfig(Cluster cluster, List<Component> stackCdhRepoConfig, String osType, String blueprintCdhVersion, String imageCatalogName) throws CloudbreakImageCatalogException {
if (Objects.isNull(stackCdhRepoConfig) || stackCdhRepoConfig.isEmpty()) {
DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(cluster, blueprintCdhVersion, osType, imageCatalogName);
Map<String, String> stack = defaultCDHInfo.getRepo().getStack();
Set<ClouderaManagerProduct> cdhProduct = Set.of(new ClouderaManagerProduct().withVersion(defaultCDHInfo.getVersion()).withName(stack.get("repoid").split("-")[0]).withParcel(stack.get(osType)));
LOGGER.debug("Determined CDH product: {}", cdhProduct);
return cdhProduct;
} else {
Set<ClouderaManagerProduct> products = stackCdhRepoConfig.stream().map(Component::getAttributes).map(json -> json.getSilent(ClouderaManagerProduct.class)).collect(Collectors.toSet());
return filterParcelsIfNecessary(cluster, products);
}
}
use of com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo 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.DefaultCDHInfo 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.DefaultCDHInfo 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<>());
}
Aggregations