Search in sources :

Example 16 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class HostAttributeDecorator method createHostAttributePillars.

public Map<String, SaltPillarProperties> createHostAttributePillars(Stack stack) {
    Set<Node> allNodes = stackUtil.collectNodes(stack);
    stack.getCluster().getBlueprint().getBlueprintText();
    BlueprintTextProcessor blueprintTextProcessor = cmTemplateProcessorFactory.get(stack.getCluster().getBlueprint().getBlueprintText());
    Versioned blueprintVersion = () -> blueprintTextProcessor.getVersion().get();
    Map<String, Map<String, ServiceAttributes>> serviceAttributes = blueprintTextProcessor.getHostGroupBasedServiceAttributes(blueprintVersion);
    Map<String, Map<String, Object>> attributes = new HashMap<>();
    for (Node node : allNodes) {
        Map<String, Map<String, String>> hgAttributes = getAttributesForHostGroup(node.getHostGroup(), serviceAttributes);
        Map<String, Object> hostAttributes = new HashMap<>();
        hostAttributes.put("attributes", hgAttributes);
        if (node.getHostGroup() != null) {
            hostAttributes.put("hostGroup", node.getHostGroup());
        }
        attributes.put(node.getHostname(), hostAttributes);
    }
    return Map.of("hostattrs", new SaltPillarProperties("/nodes/hostattrs.sls", singletonMap("hostattrs", attributes)));
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) HashMap(java.util.HashMap) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap)

Example 17 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class CloudResourceAdvisor method createForBlueprint.

public ScaleRecommendation createForBlueprint(Long workspaceId, Blueprint blueprint) {
    LOGGER.debug("Scale advice for blueprintName: {}.", blueprint.getName());
    BlueprintTextProcessor blueprintTextProcessor = getBlueprintTextProcessor(blueprint);
    AutoscaleRecommendation autoscale = recommendAutoscale(blueprintTextProcessor);
    List<String> entitlements = entitlementService.getEntitlements(blueprint.getWorkspace().getTenant().getName());
    ResizeRecommendation resize = recommendResize(blueprintTextProcessor, entitlements);
    return new ScaleRecommendation(autoscale, resize);
}
Also used : AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) ResizeRecommendation(com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation) ScaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.ScaleRecommendation) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)

Example 18 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method roleConfigsWithoutGateway.

@Test
public void roleConfigsWithoutGateway() {
    GeneralClusterConfigs gcc = new GeneralClusterConfigs();
    gcc.setPassword("secret");
    gcc.setAccountId(Optional.of("1234"));
    IdBroker idBroker = new IdBroker();
    idBroker.setMasterSecret("supersecret");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    BlueprintView blueprintView = new BlueprintView("text", "7.2.11", "CDH", blueprintTextProcessor);
    TemplatePreparationObject source = Builder.builder().withGeneralClusterConfigs(gcc).withVirtualGroupView(new VirtualGroupRequest(TestConstants.CRN, "")).withIdBroker(idBroker).withBlueprintView(blueprintView).withProductDetails(new ClouderaManagerRepo().withVersion("7.4.2"), List.of(new ClouderaManagerProduct().withVersion("7.2.10").withName("CDH"))).build();
    when(virtualGroupService.createOrGetVirtualGroup(source.getVirtualGroupRequest(), UmsVirtualGroupRight.KNOX_ADMIN)).thenReturn("");
    assertEquals(List.of(config("idbroker_master_secret", "supersecret"), config("idbroker_gateway_knox_admin_groups", ""), config("idbroker_gateway_signing_keystore_name", "signing.jks"), config("idbroker_gateway_signing_keystore_type", "JKS"), config("idbroker_gateway_signing_key_alias", "signing-identity")), underTest.getRoleConfigs(KnoxRoles.IDBROKER, source));
    assertEquals(List.of(config("gateway_master_secret", gcc.getPassword()), config("gateway_default_topology_name", "cdp-proxy"), config("gateway_knox_admin_groups", ""), config("gateway_auto_discovery_enabled", "false"), config("gateway_service_tokenstate_impl", "org.apache.knox.gateway.services.token.impl.JDBCTokenStateService")), underTest.getRoleConfigs(KnoxRoles.KNOX_GATEWAY, source));
    assertEquals(List.of(), underTest.getRoleConfigs("NAMENODE", source));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) Test(org.junit.Test)

Example 19 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method roleConfigsWithGatewayWhenOdbcEntitlementFalse.

@Test
public void roleConfigsWithGatewayWhenOdbcEntitlementFalse() {
    GatewayTopology topology = new GatewayTopology();
    topology.setTopologyName("my-topology");
    topology.setExposedServices(Json.silent(new ExposedServices()));
    Gateway gateway = new Gateway();
    gateway.setKnoxMasterSecret("admin");
    gateway.setPath("/a/b/c");
    gateway.setTopologies(Set.of(topology));
    IdBroker idBroker = new IdBroker();
    idBroker.setMasterSecret("supersecret");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    BlueprintView blueprintView = new BlueprintView("text", "7.2.11", "CDH", blueprintTextProcessor);
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setAccountId(Optional.of("1234"));
    TemplatePreparationObject source = Builder.builder().withGateway(gateway, "key", new HashSet<>()).withGeneralClusterConfigs(generalClusterConfigs).withBlueprintView(blueprintView).withVirtualGroupView(new VirtualGroupRequest(TestConstants.CRN, "")).withProductDetails(new ClouderaManagerRepo().withVersion("7.4.2"), List.of(new ClouderaManagerProduct().withVersion("7.2.10").withName("CDH"))).withIdBroker(idBroker).build();
    when(virtualGroupService.createOrGetVirtualGroup(source.getVirtualGroupRequest(), UmsVirtualGroupRight.KNOX_ADMIN)).thenReturn("");
    when(entitlementService.isOjdbcTokenDhOneHour(anyString())).thenReturn(false);
    assertEquals(List.of(config("idbroker_master_secret", "supersecret"), config("idbroker_gateway_knox_admin_groups", ""), config("idbroker_gateway_signing_keystore_name", "signing.jks"), config("idbroker_gateway_signing_keystore_type", "JKS"), config("idbroker_gateway_signing_key_alias", "signing-identity")), underTest.getRoleConfigs(KnoxRoles.IDBROKER, source));
    assertEquals(List.of(config("gateway_master_secret", gateway.getKnoxMasterSecret()), config("gateway_default_topology_name", gateway.getTopologies().iterator().next().getTopologyName()), config("gateway_knox_admin_groups", ""), config("gateway_auto_discovery_enabled", "false"), config("gateway_path", gateway.getPath()), config("gateway_signing_keystore_name", "signing.jks"), config("gateway_signing_keystore_type", "JKS"), config("gateway_signing_key_alias", "signing-identity"), config("gateway_dispatch_whitelist", "^*.*$"), config("gateway_token_generation_enable_lifespan_input", "true"), config("gateway_token_generation_knox_token_ttl", "86400000"), config("gateway_service_tokenstate_impl", "org.apache.knox.gateway.services.token.impl.JDBCTokenStateService")), ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.getRoleConfigs(KnoxRoles.KNOX_GATEWAY, source)));
    assertEquals(List.of(), underTest.getRoleConfigs("NAMENODE", source));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) Test(org.junit.Test)

Example 20 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method roleConfigsWithGatewayWithLdapConfigWhenOdbcEntitlementFalse.

@Test
public void roleConfigsWithGatewayWithLdapConfigWhenOdbcEntitlementFalse() {
    Gateway gateway = new Gateway();
    gateway.setKnoxMasterSecret("admin");
    gateway.setPath("/a/b/c");
    IdBroker idBroker = new IdBroker();
    idBroker.setMasterSecret("supersecret");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    LdapView ldapConfig = LdapViewBuilder.aLdapView().build();
    BlueprintView blueprintView = new BlueprintView("text", "7.2.11", "CDH", blueprintTextProcessor);
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setAccountId(Optional.of("1234"));
    TemplatePreparationObject source = Builder.builder().withGateway(gateway, "key", new HashSet<>()).withLdapConfig(ldapConfig).withGeneralClusterConfigs(generalClusterConfigs).withBlueprintView(blueprintView).withVirtualGroupView(new VirtualGroupRequest(TestConstants.CRN, "")).withProductDetails(new ClouderaManagerRepo().withVersion("7.4.2"), List.of(new ClouderaManagerProduct().withVersion("7.2.10").withName("CDH"))).withIdBroker(idBroker).build();
    when(virtualGroupService.createOrGetVirtualGroup(source.getVirtualGroupRequest(), UmsVirtualGroupRight.KNOX_ADMIN)).thenReturn("knox_admins");
    when(entitlementService.isOjdbcTokenDhOneHour(anyString())).thenReturn(false);
    assertEquals(List.of(config("idbroker_master_secret", "supersecret"), config("idbroker_gateway_knox_admin_groups", "knox_admins"), config("idbroker_gateway_signing_keystore_name", "signing.jks"), config("idbroker_gateway_signing_keystore_type", "JKS"), config("idbroker_gateway_signing_key_alias", "signing-identity")), underTest.getRoleConfigs(KnoxRoles.IDBROKER, source));
    assertEquals(List.of(config("gateway_master_secret", gateway.getKnoxMasterSecret()), config("gateway_default_topology_name", "cdp-proxy"), config("gateway_knox_admin_groups", "knox_admins"), config("gateway_auto_discovery_enabled", "false"), config("gateway_path", gateway.getPath()), config("gateway_signing_keystore_name", "signing.jks"), config("gateway_signing_keystore_type", "JKS"), config("gateway_signing_key_alias", "signing-identity"), config("gateway_dispatch_whitelist", "^*.*$"), config("gateway_token_generation_enable_lifespan_input", "true"), config("gateway_token_generation_knox_token_ttl", "86400000"), config("gateway_service_tokenstate_impl", "org.apache.knox.gateway.services.token.impl.JDBCTokenStateService")), ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.getRoleConfigs(KnoxRoles.KNOX_GATEWAY, source)));
    assertEquals(List.of(), underTest.getRoleConfigs("NAMENODE", source));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)22 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)13 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)12 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)11 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)7 Test (org.junit.jupiter.api.Test)7 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)6 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)6 DatalakeView (com.sequenceiq.cloudbreak.template.views.DatalakeView)6 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)5 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)5 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)5 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 HashSet (java.util.HashSet)4 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)3 AutoscaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation)2 ResizeRecommendation (com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation)2 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)2 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)2