Search in sources :

Example 61 with GeneralClusterConfigs

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

the class RangerUserSyncRoleConfigProviderTest method testAzureWhenCmVersionIs728ShouldReturnWithRangerAsSysAdmin.

@Test
public void testAzureWhenCmVersionIs728ShouldReturnWithRangerAsSysAdmin() {
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setEnableRangerRaz(false);
    TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder().withCloudPlatform(CloudPlatform.AZURE).withProductDetails(new ClouderaManagerRepo().withVersion("7.2.8"), new ArrayList<>()).withServicePrincipals(null).withGeneralClusterConfigs(generalClusterConfigs).build();
    List<ApiClusterTemplateConfig> serviceConfigs = underTest.getRoleConfigs(RANGER_USERSYNC, preparationObject);
    assertEquals(2, serviceConfigs.size());
    assertEquals("conf/ranger-ugsync-site.xml_role_safety_valve", serviceConfigs.get(0).getName());
    assertEquals("<property><name>ranger.usersync.unix.backend</name><value>nss</value></property>", serviceConfigs.get(0).getValue());
    assertEquals("ranger.usersync.group.based.role.assignment.rules", serviceConfigs.get(1).getName());
    assertEquals("&ROLE_SYS_ADMIN:g:mockAdmin&ROLE_SYS_ADMIN:u:ranger", serviceConfigs.get(1).getValue());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.Test)

Example 62 with GeneralClusterConfigs

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

the class RangerUserSyncRoleConfigProviderTest method testAwsWhenCmVersionIs728ShouldReturnWithRangerAsSysAdmin.

@Test
public void testAwsWhenCmVersionIs728ShouldReturnWithRangerAsSysAdmin() {
    TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder().withCloudPlatform(CloudPlatform.AWS).withServicePrincipals(null).withProductDetails(new ClouderaManagerRepo().withVersion("7.2.8"), new ArrayList<>()).withGeneralClusterConfigs(new GeneralClusterConfigs()).build();
    List<ApiClusterTemplateConfig> serviceConfigs = underTest.getRoleConfigs(RANGER_USERSYNC, preparationObject);
    assertEquals(2, serviceConfigs.size());
    assertEquals("conf/ranger-ugsync-site.xml_role_safety_valve", serviceConfigs.get(0).getName());
    assertEquals("<property><name>ranger.usersync.unix.backend</name><value>nss</value></property>", serviceConfigs.get(0).getValue());
    assertEquals("ranger.usersync.group.based.role.assignment.rules", serviceConfigs.get(1).getName());
    assertEquals("&ROLE_SYS_ADMIN:g:mockAdmin&ROLE_SYS_ADMIN:u:ranger", serviceConfigs.get(1).getValue());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.Test)

Example 63 with GeneralClusterConfigs

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

the class RangerRazBaseConfigProviderTest method getServiceTypesConfigWheAGCPAnd7210ShouldNOTAddProperty.

@Test
public void getServiceTypesConfigWheAGCPAnd7210ShouldNOTAddProperty() {
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    when(blueprintTextProcessor.getVersion()).thenReturn(Optional.of("7.2.10"));
    TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder().withStackType(StackType.WORKLOAD).withBlueprintView(new BlueprintView("", "7.2.10", "CDH", blueprintTextProcessor)).withCloudPlatform(CloudPlatform.GCP).withGeneralClusterConfigs(new GeneralClusterConfigs()).withDataLakeView(new DatalakeView(false)).build();
    List<ApiClusterTemplateConfig> roleConfigs = underTest.getRoleConfigs("", preparationObject);
    assertEquals(0, roleConfigs.size());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) DatalakeView(com.sequenceiq.cloudbreak.template.views.DatalakeView) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 64 with GeneralClusterConfigs

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

the class GeneralClusterConfigsProvider method generalClusterConfigs.

public GeneralClusterConfigs generalClusterConfigs(StackV4Request stack, String email, String clusterVariant) {
    boolean gatewayInstanceMetadataPresented = false;
    int nodeCount = 0;
    for (InstanceGroupV4Request instanceGroup : stack.getInstanceGroups()) {
        nodeCount += instanceGroup.getNodeCount();
    }
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setIdentityUserEmail(email);
    generalClusterConfigs.setClusterManagerIp(PENDING_DEFAULT_VALUE);
    generalClusterConfigs.setInstanceGroupsPresented(false);
    generalClusterConfigs.setPassword(stack.getCluster().getPassword());
    if (stack.getCluster().getGateway() != null) {
        gatewayInstanceMetadataPresented = true;
    }
    generalClusterConfigs.setGatewayInstanceMetadataPresented(gatewayInstanceMetadataPresented);
    generalClusterConfigs.setClusterName(stack.getName());
    generalClusterConfigs.setStackName(stack.getName());
    generalClusterConfigs.setUuid(PENDING_DEFAULT_VALUE);
    generalClusterConfigs.setUserName(stack.getCluster().getUserName());
    generalClusterConfigs.setNodeCount(nodeCount);
    generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.of(PENDING_DEFAULT_VALUE));
    generalClusterConfigs.setVariant(clusterVariant);
    Boolean autoTlsEnabled = Optional.ofNullable(stack.getCluster().getCm()).map(ClouderaManagerV4Request::getEnableAutoTls).orElse(Boolean.FALSE);
    generalClusterConfigs.setAutoTlsEnabled(autoTlsEnabled);
    return generalClusterConfigs;
}
Also used : GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)

Example 65 with GeneralClusterConfigs

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

the class KnoxGatewayConfigProvider method getRoleConfigs.

@Override
protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) {
    GatewayView gateway = source.getGatewayView();
    GeneralClusterConfigs generalClusterConfigs = source.getGeneralClusterConfigs();
    String masterSecret = gateway != null ? gateway.getMasterSecret() : generalClusterConfigs.getPassword();
    String topologyName = gateway != null && gateway.getExposedServices() != null ? gateway.getTopologyName() : DEFAULT_TOPOLOGY;
    VirtualGroupRequest virtualGroupRequest = source.getVirtualGroupRequest();
    String adminGroup = virtualGroupService.createOrGetVirtualGroup(virtualGroupRequest, UmsVirtualGroupRight.KNOX_ADMIN);
    switch(roleType) {
        case KnoxRoles.KNOX_GATEWAY:
            List<ApiClusterTemplateConfig> config = new ArrayList<>();
            config.add(config(KNOX_MASTER_SECRET, masterSecret));
            config.add(config(GATEWAY_DEFAULT_TOPOLOGY_NAME, topologyName));
            config.add(config(GATEWAY_ADMIN_GROUPS, adminGroup));
            config.add(config(GATEWAY_CM_AUTO_DISCOVERY_ENABLED, "false"));
            if (gateway != null) {
                config.add(config(GATEWAY_PATH, gateway.getPath()));
                config.add(config(GATEWAY_SIGNING_KEYSTORE_NAME, SIGNING_JKS));
                config.add(config(GATEWAY_SIGNING_KEYSTORE_TYPE, JKS));
                config.add(config(GATEWAY_SIGNING_KEY_ALIAS, SIGNING_IDENTITY));
                config.add(getGatewayWhitelistConfig(source));
                config.addAll(getDefaultsIfRequired(source));
            }
            if (source.getProductDetailsView() != null && isKnoxDatabaseSupported(source.getProductDetailsView().getCm(), getCdhProduct(source), getCdhPatchVersion(source))) {
                config.add(config(GATEWAY_SERVICE_TOKENSTATE_IMPL, "org.apache.knox.gateway.services.token.impl.JDBCTokenStateService"));
            }
            return config;
        case KnoxRoles.IDBROKER:
            return List.of(config(IDBROKER_MASTER_SECRET, source.getIdBroker().getMasterSecret()), config(IDBROKER_GATEWAY_ADMIN_GROUPS, adminGroup), config(IDBROKER_SIGNING_KEYSTORE_NAME, SIGNING_JKS), config(IDBROKER_SIGNING_KEYSTORE_TYPE, JKS), config(IDBROKER_SIGNING_KEY_ALIAS, SIGNING_IDENTITY));
        default:
            return List.of();
    }
}
Also used : GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) GatewayView(com.sequenceiq.cloudbreak.template.views.GatewayView)

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