Search in sources :

Example 66 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class UpgradeServiceTest method mockClouderaManagerRepoDetails.

private void mockClouderaManagerRepoDetails() {
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setBaseUrl("cm-base-url");
    when(clusterComponentConfigProvider.getClouderaManagerRepoDetails(1L)).thenReturn(clouderaManagerRepo);
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)

Example 67 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class UpgradeServiceTest method shouldReturnNewImageName.

@Test
public void shouldReturnNewImageName() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    Stack stack = getStack();
    Image image = getImage("id-1");
    setUpMocks(stack, image, true, "id-1", "id-2");
    Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStartResult = Result.success(new HashMap<>());
    when(clusterRepairService.repairWithDryRun(1L)).thenReturn(repairStartResult);
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setBaseUrl("cm-base-url");
    when(clusterComponentConfigProvider.getClouderaManagerRepoDetails(1L)).thenReturn(clouderaManagerRepo);
    when(stackService.getByNameOrCrnInWorkspace(eq(ofName), eq(WORKSPACE_ID))).thenReturn(stack);
    UpgradeOptionV4Response result = underTest.getOsUpgradeOptionByStackNameOrCrn(WORKSPACE_ID, ofName, user);
    verify(clusterRepairService).repairWithDryRun(eq(stack.getId()));
    verify(distroXV1Endpoint).list(eq(null), eq("env-crn"));
    verify(componentConfigProviderService).getImage(1L);
    verify(imageService).determineImageFromCatalog(eq(WORKSPACE_ID), captor.capture(), eq("aws"), eq("AWS"), eq(stack.getCluster().getBlueprint()), eq(false), eq(false), eq(user), any());
    assertThat(result.getUpgrade().getImageName()).isEqualTo("id-2");
    assertThat(result.getReason()).isEqualTo(null);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) RepairValidation(com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) UpgradeOptionV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Map(java.util.Map) HashMap(java.util.HashMap) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 68 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class ClusterManagerUpgradeService method createSaltConfig.

private SaltConfig createSaltConfig(Stack stack, Long clusterId, GatewayConfig primaryGatewayConfig) {
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    ClouderaManagerRepo clouderaManagerRepo = clusterComponentConfigProvider.getClouderaManagerRepoDetails(clusterId);
    Optional<String> license = clusterHostServiceRunner.decoratePillarWithClouderaManagerLicense(stack.getId(), servicePillar);
    clusterHostServiceRunner.decoratePillarWithClouderaManagerRepo(clouderaManagerRepo, servicePillar, license);
    servicePillar.putAll(clusterHostServiceRunner.createPillarWithClouderaManagerSettings(clouderaManagerRepo, stack, primaryGatewayConfig));
    csdParcelDecorator.decoratePillarWithCsdParcels(stack, servicePillar);
    return new SaltConfig(servicePillar);
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) HashMap(java.util.HashMap) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Example 69 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class ClouderaManagerDeregisterService method deregisterServices.

public void deregisterServices(HttpClientConfig clientConfig, Stack stack, Optional<DatalakeDto> datalakeDto) {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentConfigProvider.getClouderaManagerRepoDetails(cluster.getId());
    try {
        CmTemplateProcessor cmTemplateProcessor = cmTemplateProcessorFactory.get(stack.getCluster().getBlueprint().getBlueprintText());
        if (CMRepositoryVersionUtil.isRangerTearDownSupported(clouderaManagerRepoDetails)) {
            if (datalakeDto.isPresent()) {
                LOGGER.info("The current cluster {} is a Data Hub cluster so teardown REQUIRED.", stack.getName());
                DatalakeDto datalake = datalakeDto.get();
                ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(datalakeClient(datalake));
                clustersResourceApi.tearDownWorkloadCluster(datalake.getName(), stack.getName());
            } else {
                LOGGER.info("The current cluster {} is a Data Lake cluster so teardown NOT_REQUIRED.", stack.getName());
            }
        } else {
            ApiClient client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
            if (cmTemplateProcessor.isCMComponentExistsInBlueprint(COMPONENT_NIFI_REGISTRY_SERVER)) {
                LOGGER.info("The current cluster {} contains NIFI_REGISTRY_SERVER and ranger teardown not supported. " + "CDP will call RemoveRangerRepo command.", stack.getName());
                clouderaManagerApiFactory.getServicesResourceApi(client).serviceCommandByName(stack.getName(), "RemoveRangerRepo", SERVICE_NIFIREGISTRY);
            }
            if (cmTemplateProcessor.isCMComponentExistsInBlueprint(COMPONENT_NIFI_NODE)) {
                LOGGER.info("The current cluster {} contains NIFI_NODE and ranger teardown not supported. " + "CDP will call RemoveRangerRepo command.", stack.getName());
                clouderaManagerApiFactory.getServicesResourceApi(client).serviceCommandByName(stack.getName(), "RemoveRangerRepo", SERVICE_NIFI);
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Couldn't remove services. This has to be done manually." + " It's possible that CM or the instance is not running. Notification is sent to the UI.", e);
        cloudbreakEventService.fireCloudbreakEvent(stack.getId(), stack.getStatus().name(), ResourceEvent.CLUSTER_CM_SECURITY_GROUP_TOO_STRICT, List.of(e.getMessage()));
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) DatalakeDto(com.sequenceiq.cloudbreak.dto.datalake.DatalakeDto) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ApiClient(com.cloudera.api.swagger.client.ApiClient) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)

Example 70 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class ClouderaManagerSetupService method initApiClient.

@PostConstruct
public void initApiClient() throws ClusterClientInitException {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    try {
        ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentProvider.getClouderaManagerRepoDetails(cluster.getId());
        if (isVersionNewerOrEqualThanLimited(clouderaManagerRepoDetails::getVersion, CLOUDERAMANAGER_VERSION_7_1_0)) {
            apiClient = clouderaManagerApiClientProvider.getV40Client(stack.getGatewayPort(), user, password, clientConfig);
        } else {
            apiClient = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
        }
    } catch (ClouderaManagerClientInitException e) {
        throw new ClusterClientInitException(e);
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)96 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)40 Test (org.junit.jupiter.api.Test)38 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)28 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)17 ApiClient (com.cloudera.api.swagger.client.ApiClient)15 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)15 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)15 Test (org.junit.Test)15 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)14 DisplayName (org.junit.jupiter.api.DisplayName)14 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)13 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 Map (java.util.Map)10 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)9 BigDecimal (java.math.BigDecimal)9 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)8