use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class CmTemplateValidatorTest method testValidationIfNifi728PresentedAndDownScaleThenValidationShouldThrowException.
@Test
public void testValidationIfNifi728PresentedAndDownScaleThenValidationShouldThrowException() {
Blueprint blueprint = readBlueprint("input/nifi_7_2_8.bp");
String hostGroup = "master";
ClouderaManagerProduct clouderaManagerRepo = new ClouderaManagerProduct();
clouderaManagerRepo.setVersion("7.2.8");
when(entitlementService.isEntitledFor(anyString(), any())).thenReturn(true);
assertDoesNotThrow(() -> subject.validateHostGroupScalingRequest(ACCOUNT_ID, blueprint, Optional.of(clouderaManagerRepo), hostGroup, -2, List.of()));
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class KnoxGatewayConfigProvider method getDefaultsIfRequired.
private Set<ApiClusterTemplateConfig> getDefaultsIfRequired(TemplatePreparationObject source) {
Set<ApiClusterTemplateConfig> apiClusterTemplateConfigs = new HashSet<>();
Optional<ClouderaManagerProduct> cdhProduct = getCdhProduct(source);
if (cdhProduct.isPresent() && source.getProductDetailsView() != null) {
String cdhVersion = cdhProduct.get().getVersion().split("-")[0];
ClouderaManagerRepo clouderaManagerRepoDetails = source.getProductDetailsView().getCm();
if (tokenServiceSupported(cdhVersion, clouderaManagerRepoDetails)) {
Optional<String> accountId = source.getGeneralClusterConfigs().getAccountId();
if (accountId.isPresent() && !entitlementService.isOjdbcTokenDhOneHour(accountId.get())) {
apiClusterTemplateConfigs.add(config(GATEWAY_TOKEN_GENERATION_KNOX_TOKEN_TTL, GATEWAY_TOKEN_GENERATION_KNOX_TOKEN_TTL_ONE_DAY));
apiClusterTemplateConfigs.add(config(GATEWAY_TOKEN_GENERATION_ENABLE_LIFESPAN_INPUT, GATEWAY_TOKEN_GENERATION_ENABLE_LIFESPAN_INPUT_TRUE));
}
}
}
return apiClusterTemplateConfigs;
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class ImageFilterParamsFactory method getStackRelatedParcels.
public Map<String, String> getStackRelatedParcels(Stack stack) {
Set<ClusterComponent> componentsByBlueprint = parcelService.getParcelComponentsByBlueprint(stack);
if (stack.isDatalake()) {
ClouderaManagerProduct stackProduct = getCdhProduct(componentsByBlueprint);
LOGGER.debug("For datalake clusters only the CDH parcel is related in CM: {}", stackProduct);
return Map.of(stackProduct.getName(), stackProduct.getVersion());
} else {
Set<ClouderaManagerProduct> products = clouderaManagerProductsProvider.getProducts(componentsByBlueprint);
LOGGER.debug("The following parcels are related for this datahub cluster: {}", products);
return products.stream().collect(Collectors.toMap(ClouderaManagerProduct::getName, ClouderaManagerProduct::getVersion));
}
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class ClouderaManagerParcelDecommissionServiceTest method testRemoveUnusedParcelVersions.
@Test
public void testRemoveUnusedParcelVersions() throws ApiException {
Stack stack = mock(Stack.class);
when(stack.getName()).thenReturn(STACK_NAME);
ClouderaManagerProduct currentProductWithVersionToKeep = new ClouderaManagerProduct().withName("CDH").withVersion("current");
doReturn(List.of(new ApiParcel().product("ignored").version("current"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old2"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version(currentProductWithVersionToKeep.getVersion()))).when(parcelManagementService).getClouderaManagerParcelsByStatus(parcelsResourceApi, STACK_NAME, ParcelStatus.DISTRIBUTED);
ArgumentCaptor<Multimap<String, String>> parcelVersionsCaptorForDownloaded = ArgumentCaptor.forClass(Multimap.class);
when(clouderaManagerPollingServiceProvider.startPollingCmParcelStatus(eq(stack), eq(apiClient), parcelVersionsCaptorForDownloaded.capture(), eq(ParcelStatus.DOWNLOADED))).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
doReturn(List.of(new ApiParcel().product("ignored").version("current"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old2"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version(currentProductWithVersionToKeep.getVersion()))).when(parcelManagementService).getClouderaManagerParcelsByStatus(parcelsResourceApi, STACK_NAME, ParcelStatus.DOWNLOADED);
ArgumentCaptor<Multimap<String, String>> parcelVersionsCaptorForDelete = ArgumentCaptor.forClass(Multimap.class);
when(clouderaManagerPollingServiceProvider.startPollingCmParcelDelete(eq(stack), eq(apiClient), parcelVersionsCaptorForDelete.capture())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
underTest.removeUnusedParcelVersions(apiClient, parcelsResourceApi, parcelResourceApi, stack, currentProductWithVersionToKeep);
verify(parcelResourceApi).startRemovalOfDistributionCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old");
verify(parcelResourceApi).startRemovalOfDistributionCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old2");
assertEquals(2, parcelVersionsCaptorForDownloaded.getValue().size());
assertTrue(parcelVersionsCaptorForDownloaded.getValue().containsEntry("CDH", "old"));
assertTrue(parcelVersionsCaptorForDownloaded.getValue().containsEntry("CDH", "old2"));
verify(parcelResourceApi).removeDownloadCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old");
verify(parcelResourceApi).removeDownloadCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old2");
assertEquals(2, parcelVersionsCaptorForDelete.getValue().size());
assertTrue(parcelVersionsCaptorForDelete.getValue().containsEntry("CDH", "old"));
assertTrue(parcelVersionsCaptorForDelete.getValue().containsEntry("CDH", "old2"));
verifyNoMoreInteractions(parcelResourceApi);
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class ImageService method createProductRepo.
private ClouderaManagerProduct createProductRepo(ImageStackDetails stack, String osType) {
ClouderaManagerProduct cmProduct = new ClouderaManagerProduct();
Map<String, String> stackInfo = stack.getRepo().getStack();
cmProduct.withVersion(stackInfo.get(StackRepoDetails.REPOSITORY_VERSION)).withName(stackInfo.get(StackRepoDetails.REPO_ID_TAG).split("-")[0]).withParcel(stackInfo.get(osType));
return cmProduct;
}
Aggregations