use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupServiceTest method clouderaManagerProduct.
private ClouderaManagerProduct clouderaManagerProduct(String name, String version) {
ClouderaManagerProduct clouderaManagerProduct = new ClouderaManagerProduct();
clouderaManagerProduct.setCsd(new ArrayList<>());
clouderaManagerProduct.setVersion(version);
clouderaManagerProduct.setParcel(String.format("http://public-repo-1.hortonworks.com/cm/centos7/%s/updates/%s", version, version));
clouderaManagerProduct.setName(name);
clouderaManagerProduct.setDisplayName(name);
return clouderaManagerProduct;
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class ClouderaManagerModificationServiceTest method createClouderaManagerProduct.
private ClouderaManagerProduct createClouderaManagerProduct(String name, String version) {
ClouderaManagerProduct product = new ClouderaManagerProduct();
product.setName(name);
product.setVersion(version);
return product;
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class ClouderaManagerModificationServiceTest method removeUnusedParcels.
@Test
void removeUnusedParcels() {
// GIVEN
Set<String> parcelNamesFromImage = new HashSet<>();
ClouderaManagerProduct cmProduct1 = createClouderaManagerProduct("product1", "version1");
ClouderaManagerProduct cmProduct2 = createClouderaManagerProduct("product2", "version2");
Set<ClusterComponent> usedComponents = Set.of(createClusterComponent(cmProduct1), createClusterComponent(cmProduct2));
Set<String> usedParcelComponentNames = Set.of(cmProduct1.getName(), cmProduct2.getName());
when(clouderaManagerApiFactory.getParcelsResourceApi(apiClientMock)).thenReturn(parcelsResourceApi);
when(clouderaManagerApiFactory.getParcelResourceApi(apiClientMock)).thenReturn(parcelResourceApi);
when(clouderaManagerParcelDecommissionService.deactivateUnusedParcels(parcelsResourceApi, parcelResourceApi, STACK_NAME, usedParcelComponentNames, parcelNamesFromImage)).thenReturn(new ParcelOperationStatus(Map.of("product3", "version3"), Map.of()));
when(clouderaManagerParcelDecommissionService.undistributeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage)).thenReturn(new ParcelOperationStatus(Map.of("product3", "version3"), Map.of()));
when(clouderaManagerParcelDecommissionService.removeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage)).thenReturn(new ParcelOperationStatus(Map.of("product3", "version3"), Map.of()));
// WHEN
ParcelOperationStatus operationStatus = underTest.removeUnusedParcels(usedComponents, parcelNamesFromImage);
// THEN
verify(clouderaManagerParcelDecommissionService).deactivateUnusedParcels(parcelsResourceApi, parcelResourceApi, stack.getName(), usedParcelComponentNames, parcelNamesFromImage);
verify(clouderaManagerParcelDecommissionService).undistributeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage);
verify(clouderaManagerParcelDecommissionService).removeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage);
assertEquals(1, operationStatus.getSuccessful().size());
assertEquals(0, operationStatus.getFailed().size());
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class ClouderaManagerModificationServiceTest method removeUnusedParcelsWhenSomeParcelOperationsFail.
@Test
void removeUnusedParcelsWhenSomeParcelOperationsFail() {
// GIVEN
Set<String> parcelNamesFromImage = new HashSet<>();
ClouderaManagerProduct cmProduct1 = createClouderaManagerProduct("product1", "version1");
ClouderaManagerProduct cmProduct2 = createClouderaManagerProduct("product2", "version2");
Set<ClusterComponent> usedComponents = Set.of(createClusterComponent(cmProduct1), createClusterComponent(cmProduct2));
Set<String> usedParcelComponentNames = Set.of(cmProduct1.getName(), cmProduct2.getName());
when(clouderaManagerApiFactory.getParcelsResourceApi(apiClientMock)).thenReturn(parcelsResourceApi);
when(clouderaManagerApiFactory.getParcelResourceApi(apiClientMock)).thenReturn(parcelResourceApi);
when(clouderaManagerParcelDecommissionService.deactivateUnusedParcels(parcelsResourceApi, parcelResourceApi, STACK_NAME, usedParcelComponentNames, parcelNamesFromImage)).thenReturn(new ParcelOperationStatus(Map.of("spark3", "version3", "product5", "version5"), Map.of("product4", "version4")));
when(clouderaManagerParcelDecommissionService.undistributeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage)).thenReturn(new ParcelOperationStatus(Map.of("product5", "version5"), Map.of("spark3", "version3")));
when(clouderaManagerParcelDecommissionService.removeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage)).thenReturn(new ParcelOperationStatus(Map.of("product5", "version5"), Map.of()));
// WHEN
ParcelOperationStatus operationStatus = underTest.removeUnusedParcels(usedComponents, parcelNamesFromImage);
// THEN
verify(clouderaManagerParcelDecommissionService, times(1)).deactivateUnusedParcels(parcelsResourceApi, parcelResourceApi, stack.getName(), usedParcelComponentNames, parcelNamesFromImage);
verify(clouderaManagerParcelDecommissionService, times(1)).undistributeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage);
verify(clouderaManagerParcelDecommissionService, times(1)).removeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage);
assertEquals(1, operationStatus.getSuccessful().size());
assertTrue(operationStatus.getSuccessful().containsEntry("product5", "version5"));
assertEquals(2, operationStatus.getFailed().size());
assertTrue(operationStatus.getFailed().containsEntry("spark3", "version3"));
assertTrue(operationStatus.getFailed().containsEntry("product4", "version4"));
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.
the class StackToTemplatePreparationObjectConverter method convert.
public TemplatePreparationObject convert(Stack source) {
try {
Map<String, Collection<ClusterExposedServiceView>> views = serviceEndpointCollector.prepareClusterExposedServicesViews(source.getCluster(), stackUtil.extractClusterManagerAddress(source));
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
Credential credential = credentialConverter.convert(environment.getCredential());
Cluster cluster = clusterService.getById(source.getCluster().getId());
FileSystem fileSystem = cluster.getFileSystem();
Optional<LdapView> ldapView = ldapConfigService.get(source.getEnvironmentCrn(), source.getName());
ClouderaManagerRepo cm = clusterComponentConfigProvider.getClouderaManagerRepoDetails(cluster.getId());
List<ClouderaManagerProduct> products = clusterComponentConfigProvider.getClouderaManagerProductDetails(cluster.getId());
BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(credential, source, fileSystem);
updateFileSystemViewWithBackupLocation(environment, fileSystemConfigurationView);
StackInputs stackInputs = getStackInputs(source);
Map<String, Object> fixInputs = stackInputs.getFixInputs() == null ? new HashMap<>() : stackInputs.getFixInputs();
fixInputs.putAll(stackInputs.getDatalakeInputs() == null ? new HashMap<>() : stackInputs.getDatalakeInputs());
Gateway gateway = cluster.getGateway();
String gatewaySignKey = null;
if (gateway != null) {
gatewaySignKey = gateway.getSignKey();
}
IdBroker idbroker = idBrokerService.getByCluster(cluster);
if (idbroker == null) {
idbroker = idBrokerConverterUtil.generateIdBrokerSignKeys(cluster);
idBrokerService.save(idbroker);
}
String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapView.map(LdapView::getAdminGroup).orElse(""));
String accountId = Crn.safeFromString(source.getResourceCrn()).getAccountId();
List<UserManagementProto.ServicePrincipalCloudIdentities> servicePrincipalCloudIdentities = grpcUmsClient.listServicePrincipalCloudIdentities(accountId, source.getEnvironmentCrn(), MDCUtils.getRequestId());
BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(cluster.getBlueprint());
Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
Builder builder = Builder.builder().withCloudPlatform(CloudPlatform.valueOf(source.getCloudPlatform())).withRdsConfigs(postgresConfigService.createRdsConfigIfNeeded(source, cluster)).withRdsSslCertificateFilePath(dbCertificateProvider.getSslCertsFilePath()).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withIdBroker(idbroker).withCustomConfigurationsView(getCustomConfigurationsView(source, cluster)).withCustomInputs(stackInputs.getCustomInputs() == null ? new HashMap<>() : stackInputs.getCustomInputs()).withFixInputs(fixInputs).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(calculateGeneralClusterConfigs(source, cluster)).withLdapConfig(ldapView.orElse(null)).withKerberosConfig(kerberosConfigService.get(source.getEnvironmentCrn(), source.getName()).orElse(null)).withProductDetails(cm, products).withExposedServices(views).withDefaultTags(getStackTags(source)).withSharedServiceConfigs(datalakeService.createSharedServiceConfigsView(source)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
transactionService.required(() -> {
builder.withHostgroups(hostGroupService.getByCluster(cluster.getId()));
});
decorateBuilderWithPlacement(source, builder);
decorateBuilderWithAccountMapping(source, environment, credential, builder, virtualGroupRequest);
decorateBuilderWithServicePrincipals(source, builder, servicePrincipalCloudIdentities);
decorateDatalakeView(source, builder);
return builder.build();
} catch (AccountTagValidationFailed aTVF) {
throw new CloudbreakServiceException(aTVF);
} catch (BlueprintProcessingException | IOException | TransactionService.TransactionExecutionException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
Aggregations