Search in sources :

Example 26 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class GeneralClusterConfigsProvider method generalClusterConfigs.

public GeneralClusterConfigs generalClusterConfigs(Stack stack, Cluster cluster) {
    boolean gatewayInstanceMetadataPresented = false;
    boolean instanceMetadataPresented = false;
    if (stack.getInstanceGroups() != null && !stack.getInstanceGroups().isEmpty()) {
        List<InstanceMetaData> gatewayInstanceMetadata = stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata();
        gatewayInstanceMetadataPresented = !gatewayInstanceMetadata.isEmpty() && stack.getCluster().getGateway() != null;
        instanceMetadataPresented = true;
    }
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setClusterManagerIp(cluster.getClusterManagerIp());
    generalClusterConfigs.setInstanceGroupsPresented(instanceMetadataPresented);
    generalClusterConfigs.setGatewayInstanceMetadataPresented(gatewayInstanceMetadataPresented);
    generalClusterConfigs.setClusterName(cluster.getName());
    generalClusterConfigs.setStackName(stack.getName());
    generalClusterConfigs.setUuid(stack.getUuid());
    generalClusterConfigs.setUserName(cluster.getUserName());
    generalClusterConfigs.setPassword(cluster.getPassword());
    generalClusterConfigs.setCloudbreakAmbariUser(cluster.getCloudbreakAmbariUser());
    generalClusterConfigs.setCloudbreakAmbariPassword(cluster.getCloudbreakAmbariPassword());
    generalClusterConfigs.setNodeCount(stack.getFullNodeCount());
    generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.ofNullable(stack.getPrimaryGatewayInstance().getDiscoveryFQDN()));
    generalClusterConfigs.setVariant(cluster.getVariant());
    generalClusterConfigs.setAutoTlsEnabled(cluster.getAutoTlsEnabled());
    boolean userFacingCertHasBeenGenerated = StringUtils.isNotEmpty(stack.getSecurityConfig().getUserFacingKey()) && StringUtils.isNotEmpty(stack.getSecurityConfig().getUserFacingCert());
    generalClusterConfigs.setKnoxUserFacingCertConfigured(userFacingCertHasBeenGenerated);
    generalClusterConfigs.setExternalFQDN(cluster.getFqdn());
    generalClusterConfigs.setEnableRangerRaz(cluster.isRangerRazEnabled());
    return generalClusterConfigs;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)

Example 27 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testConfigureManagementServicesWhenThePrimaryGatewayInstanceDiscoveryFQDNIsPresentedOnCMSideShoudCallSetupMgmtServices.

@Test
public void testConfigureManagementServicesWhenThePrimaryGatewayInstanceDiscoveryFQDNIsPresentedOnCMSideShoudCallSetupMgmtServices() throws Exception {
    HostsResourceApi mockHostsResourceApi = mock(HostsResourceApi.class);
    TemplatePreparationObject mockTemplatePreparationObject = mock(TemplatePreparationObject.class);
    String mockSdxContext = JsonUtil.writeValueAsString(new ApiRemoteDataContext());
    String mockSdxStackCrn = "mockSdxStackCrn";
    Telemetry telemetry = mock(Telemetry.class);
    ProxyConfig proxyConfig = mock(ProxyConfig.class);
    ApiClient apiClient = mock(ApiClient.class);
    ApiHostList apiHostList = mock(ApiHostList.class);
    GeneralClusterConfigs generalClusterConfigs = mock(GeneralClusterConfigs.class);
    CdpResourceApi cdpResourceApi = mock(CdpResourceApi.class);
    ApiRemoteDataContext mockApiRemoteDataContext = mock(ApiRemoteDataContext.class);
    when(mockHostsResourceApi.readHosts(null, null, DataView.SUMMARY.name())).thenReturn(apiHostList);
    when(mockTemplatePreparationObject.getGeneralClusterConfigs()).thenReturn(generalClusterConfigs);
    when(generalClusterConfigs.getPrimaryGatewayInstanceDiscoveryFQDN()).thenReturn(Optional.of("fqdn"));
    when(apiHostList.getItems()).thenReturn(List.of(apiHost("fqdn")));
    when(clouderaManagerApiClientProvider.getRootClient(any(Integer.class), anyString(), anyString(), any(HttpClientConfig.class))).thenReturn(apiClient);
    when(clouderaManagerApiFactory.getHostsResourceApi(any(ApiClient.class))).thenReturn(mockHostsResourceApi);
    when(clouderaManagerApiFactory.getCdpResourceApi(any(ApiClient.class))).thenReturn(cdpResourceApi);
    when(cdpResourceApi.postRemoteContext(any(ApiRemoteDataContext.class))).thenReturn(mockApiRemoteDataContext);
    when(mockApiRemoteDataContext.getEndPointId()).thenReturn("endpoint");
    doNothing().when(mgmtSetupService).setupMgmtServices(any(Stack.class), any(ApiClient.class), any(ApiHostRef.class), any(Telemetry.class), anyString(), anyString(), any(ProxyConfig.class));
    underTest.configureManagementServices(mockTemplatePreparationObject, mockSdxContext, mockSdxStackCrn, telemetry, proxyConfig);
    verify(mgmtSetupService, times(1)).setupMgmtServices(any(Stack.class), any(ApiClient.class), any(ApiHostRef.class), any(Telemetry.class), anyString(), anyString(), any(ProxyConfig.class));
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) ApiClient(com.cloudera.api.swagger.client.ApiClient) CdpResourceApi(com.cloudera.api.swagger.CdpResourceApi) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ApiRemoteDataContext(com.cloudera.api.swagger.model.ApiRemoteDataContext) HostsResourceApi(com.cloudera.api.swagger.HostsResourceApi) ApiHostRef(com.cloudera.api.swagger.model.ApiHostRef) Test(org.junit.jupiter.api.Test)

Example 28 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testConfigureManagementServicesWhenApiExceptionHappensThenShouldThrowClouderaManagerOperationFailedException.

@Test
public void testConfigureManagementServicesWhenApiExceptionHappensThenShouldThrowClouderaManagerOperationFailedException() throws Exception {
    ApiException error = mock(ApiException.class);
    HostsResourceApi mockHostsResourceApi = mock(HostsResourceApi.class);
    TemplatePreparationObject mockTemplatePreparationObject = mock(TemplatePreparationObject.class);
    String mockSdxContext = JsonUtil.writeValueAsString(new ApiRemoteDataContext());
    String mockSdxStackCrn = "mockSdxStackCrn";
    Telemetry telemetry = mock(Telemetry.class);
    ProxyConfig proxyConfig = mock(ProxyConfig.class);
    ApiClient apiClient = mock(ApiClient.class);
    ApiHostList apiHostList = mock(ApiHostList.class);
    GeneralClusterConfigs generalClusterConfigs = mock(GeneralClusterConfigs.class);
    CdpResourceApi cdpResourceApi = mock(CdpResourceApi.class);
    ApiRemoteDataContext mockApiRemoteDataContext = mock(ApiRemoteDataContext.class);
    when(error.getResponseBody()).thenReturn(null);
    when(error.getMessage()).thenReturn("error");
    when(mockHostsResourceApi.readHosts(null, null, DataView.SUMMARY.name())).thenReturn(apiHostList);
    when(mockTemplatePreparationObject.getGeneralClusterConfigs()).thenReturn(generalClusterConfigs);
    when(generalClusterConfigs.getPrimaryGatewayInstanceDiscoveryFQDN()).thenReturn(Optional.of("fqdn"));
    when(apiHostList.getItems()).thenReturn(List.of(apiHost("fqdn")));
    when(clouderaManagerApiClientProvider.getRootClient(any(Integer.class), anyString(), anyString(), any(HttpClientConfig.class))).thenReturn(apiClient);
    when(clouderaManagerApiFactory.getHostsResourceApi(any(ApiClient.class))).thenReturn(mockHostsResourceApi);
    when(clouderaManagerApiFactory.getCdpResourceApi(any(ApiClient.class))).thenReturn(cdpResourceApi);
    when(cdpResourceApi.postRemoteContext(any(ApiRemoteDataContext.class))).thenReturn(mockApiRemoteDataContext);
    when(mockApiRemoteDataContext.getEndPointId()).thenReturn("endpoint");
    doThrow(error).when(mgmtSetupService).setupMgmtServices(any(Stack.class), any(ApiClient.class), any(ApiHostRef.class), any(Telemetry.class), anyString(), anyString(), any(ProxyConfig.class));
    ClouderaManagerOperationFailedException actual = assertThrows(ClouderaManagerOperationFailedException.class, () -> underTest.configureManagementServices(mockTemplatePreparationObject, mockSdxContext, mockSdxStackCrn, telemetry, proxyConfig));
    assertEquals(ClouderaManagerOperationFailedException.class, actual.getClass());
    verify(mgmtSetupService, times(1)).setupMgmtServices(any(Stack.class), any(ApiClient.class), any(ApiHostRef.class), any(Telemetry.class), anyString(), anyString(), any(ProxyConfig.class));
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) ApiClient(com.cloudera.api.swagger.client.ApiClient) CdpResourceApi(com.cloudera.api.swagger.CdpResourceApi) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ApiRemoteDataContext(com.cloudera.api.swagger.model.ApiRemoteDataContext) HostsResourceApi(com.cloudera.api.swagger.HostsResourceApi) ApiHostRef(com.cloudera.api.swagger.model.ApiHostRef) ApiException(com.cloudera.api.swagger.client.ApiException) Test(org.junit.jupiter.api.Test)

Example 29 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testConfigureSupportTagsWhenCmHostPresentedShouldEverythingWorks.

@Test
public void testConfigureSupportTagsWhenCmHostPresentedShouldEverythingWorks() throws ApiException {
    HostsResourceApi mockHostsResourceApi = mock(HostsResourceApi.class);
    ApiHostList apiHostList = mock(ApiHostList.class);
    TemplatePreparationObject mockTemplatePreparationObject = mock(TemplatePreparationObject.class);
    GeneralClusterConfigs generalClusterConfigs = mock(GeneralClusterConfigs.class);
    when(mockTemplatePreparationObject.getGeneralClusterConfigs()).thenReturn(generalClusterConfigs);
    when(generalClusterConfigs.getPrimaryGatewayInstanceDiscoveryFQDN()).thenReturn(Optional.of("fqdn"));
    when(apiHostList.getItems()).thenReturn(List.of(apiHost("fqdn")));
    when(mockHostsResourceApi.readHosts(null, null, DataView.SUMMARY.name())).thenReturn(apiHostList);
    when(clouderaManagerApiFactory.getHostsResourceApi(any(ApiClient.class))).thenReturn(mockHostsResourceApi);
    doNothing().when(clouderaManagerSupportSetupService).prepareSupportRole(any(ApiClient.class), any(StackType.class));
    underTest.configureSupportTags(mockTemplatePreparationObject);
    verify(clouderaManagerSupportSetupService, times(1)).prepareSupportRole(any(ApiClient.class), any(StackType.class));
}
Also used : ApiHostList(com.cloudera.api.swagger.model.ApiHostList) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) HostsResourceApi(com.cloudera.api.swagger.HostsResourceApi) ApiClient(com.cloudera.api.swagger.client.ApiClient) Test(org.junit.jupiter.api.Test)

Example 30 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testConfigureSupportTagsWhenThrowCManagerOperationFailedExceptionShouldThrowCManagerOperationFailedException.

@Test
public void testConfigureSupportTagsWhenThrowCManagerOperationFailedExceptionShouldThrowCManagerOperationFailedException() throws ApiException {
    HostsResourceApi mockHostsResourceApi = mock(HostsResourceApi.class);
    ApiHostList apiHostList = mock(ApiHostList.class);
    TemplatePreparationObject mockTemplatePreparationObject = mock(TemplatePreparationObject.class);
    GeneralClusterConfigs generalClusterConfigs = mock(GeneralClusterConfigs.class);
    when(mockTemplatePreparationObject.getGeneralClusterConfigs()).thenReturn(generalClusterConfigs);
    when(generalClusterConfigs.getPrimaryGatewayInstanceDiscoveryFQDN()).thenReturn(Optional.of("fqdn"));
    when(apiHostList.getItems()).thenReturn(List.of(apiHost("fqdn")));
    when(mockHostsResourceApi.readHosts(null, null, DataView.SUMMARY.name())).thenReturn(apiHostList);
    when(clouderaManagerApiFactory.getHostsResourceApi(any(ApiClient.class))).thenReturn(mockHostsResourceApi);
    doThrow(new ClouderaManagerOperationFailedException("error")).when(clouderaManagerSupportSetupService).prepareSupportRole(any(ApiClient.class), any(StackType.class));
    ClouderaManagerOperationFailedException actual = assertThrows(ClouderaManagerOperationFailedException.class, () -> underTest.configureSupportTags(mockTemplatePreparationObject));
    verify(clouderaManagerSupportSetupService, times(1)).prepareSupportRole(any(ApiClient.class), any(StackType.class));
    assertEquals(ClouderaManagerOperationFailedException.class, actual.getClass());
}
Also used : ApiHostList(com.cloudera.api.swagger.model.ApiHostList) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) HostsResourceApi(com.cloudera.api.swagger.HostsResourceApi) ApiClient(com.cloudera.api.swagger.client.ApiClient) Test(org.junit.jupiter.api.Test)

Aggregations

GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)67 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)52 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)28 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)21 Test (org.junit.jupiter.api.Test)20 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)19 Test (org.junit.Test)18 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)16 DisplayName (org.junit.jupiter.api.DisplayName)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)15 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 DatalakeView (com.sequenceiq.cloudbreak.template.views.DatalakeView)12 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)11 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 HashSet (java.util.HashSet)8 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)7 ArrayList (java.util.ArrayList)7 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)6