Search in sources :

Example 51 with ClouderaManagerProduct

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;
}
Also used : ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)

Example 52 with 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;
}
Also used : ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)

Example 53 with ClouderaManagerProduct

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());
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 54 with ClouderaManagerProduct

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"));
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 55 with ClouderaManagerProduct

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);
    }
}
Also used : HashMap(java.util.HashMap) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) AccountTagValidationFailed(com.sequenceiq.cloudbreak.tag.AccountTagValidationFailed) StackInputs(com.sequenceiq.cloudbreak.cloud.model.StackInputs) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) BlueprintProcessingException(com.sequenceiq.cloudbreak.template.BlueprintProcessingException) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Credential(com.sequenceiq.cloudbreak.dto.credential.Credential) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) IOException(java.io.IOException) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Collection(java.util.Collection) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject)

Aggregations

ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)91 Test (org.junit.Test)34 Test (org.junit.jupiter.api.Test)23 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)20 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)14 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)10 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)9 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)9 ParcelInfo (com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo)9 HashSet (java.util.HashSet)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)7 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)6 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)6 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)6 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)6 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)6 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)5