Search in sources :

Example 1 with Gateway

use of com.sequenceiq.cloudbreak.domain.Gateway in project cloudbreak by hortonworks.

the class BlueprintValidatorTest method testKnoxWithKerberosAndNonGwHasKnox.

@Test
public void testKnoxWithKerberosAndNonGwHasKnox() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    instanceGroups.add(createInstanceGroup("gateway1", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("gateway2", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("master", 1, InstanceGroupType.CORE));
    Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
    JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
    ObjectNode rootNode = jsonNodeFactory.objectNode();
    ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
    addHostGroup(hostGroupsNode, "gateway1", SL_MIN0_MAX3, MA_MIN1_MAX3);
    addHostGroup(hostGroupsNode, "gateway2", SL_MIN0_MAX3, MA_MIN1_MAX3);
    addHostGroup(hostGroupsNode, "master", SL_MIN0_MAX3, KNOX);
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(rootNode);
    Cluster cluster = new Cluster();
    cluster.setSecure(true);
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(true);
    cluster.setGateway(gateway);
    thrown.expect(BlueprintValidationException.class);
    thrown.expectMessage("In case of Knox and Kerberos each 'Ambari Server' node must include the 'KNOX_GATEWAY' service. " + "The following host groups are missing the service: gateway1,gateway2");
    // WHEN
    underTest.validateBlueprintForStack(cluster, blueprint, hostGroups, instanceGroups);
// THEN exception thrown
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Gateway(com.sequenceiq.cloudbreak.domain.Gateway) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Test(org.junit.Test)

Example 2 with Gateway

use of com.sequenceiq.cloudbreak.domain.Gateway in project cloudbreak by hortonworks.

the class BlueprintValidatorTest method testKnoxWithKerberosButOneNodeMissingKnox.

@Test
public void testKnoxWithKerberosButOneNodeMissingKnox() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    instanceGroups.add(createInstanceGroup("gateway1", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("gateway2", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("master", 1, InstanceGroupType.CORE));
    Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
    JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
    ObjectNode rootNode = jsonNodeFactory.objectNode();
    ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
    addHostGroup(hostGroupsNode, "gateway1", SL_MIN0_MAX3, KNOX);
    addHostGroup(hostGroupsNode, "gateway2", SL_MIN0_MAX3, MA_MIN1_MAX3);
    addHostGroup(hostGroupsNode, "master", SL_MIN0_MAX3, MA_MIN1_MAX5);
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(rootNode);
    Cluster cluster = new Cluster();
    cluster.setSecure(true);
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(true);
    cluster.setGateway(gateway);
    thrown.expect(BlueprintValidationException.class);
    thrown.expectMessage("In case of Knox and Kerberos each 'Ambari Server' node must include the 'KNOX_GATEWAY' service. " + "The following host groups are missing the service: gateway2");
    // WHEN
    underTest.validateBlueprintForStack(cluster, blueprint, hostGroups, instanceGroups);
// THEN exception thrown
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Gateway(com.sequenceiq.cloudbreak.domain.Gateway) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Test(org.junit.Test)

Example 3 with Gateway

use of com.sequenceiq.cloudbreak.domain.Gateway in project cloudbreak by hortonworks.

the class ClusterRequestToClusterConverter method convertKnox.

private void convertKnox(ClusterRequest source, Cluster cluster) {
    GatewayJson cloudGatewayJson = source.getGateway();
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(Boolean.FALSE);
    gateway.setTopologyName("services");
    gateway.setPath(source.getName());
    gateway.setSsoType(SSOType.NONE);
    if (cloudGatewayJson != null) {
        if (cloudGatewayJson.getPath() != null) {
            gateway.setPath(cloudGatewayJson.getPath());
        }
        if (cloudGatewayJson.getSsoProvider() != null) {
            gateway.setSsoProvider(cloudGatewayJson.getSsoProvider());
        }
        if (cloudGatewayJson.getSsoType() != null) {
            gateway.setSsoType(cloudGatewayJson.getSsoType());
        }
        gateway.setTokenCert(cloudGatewayJson.getTokenCert());
    }
    if (gateway.getSsoProvider() == null) {
        gateway.setSsoProvider('/' + gateway.getPath() + "/sso/api/v1/websso");
    }
    convertExposedServices(cloudGatewayJson, gateway);
    cluster.setGateway(gateway);
    gateway.setCluster(cluster);
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.Gateway) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson)

Example 4 with Gateway

use of com.sequenceiq.cloudbreak.domain.Gateway in project cloudbreak by hortonworks.

the class ClusterToClusterResponseConverter method getAmbariServerUrl.

private String getAmbariServerUrl(Cluster cluster, String ambariIp) {
    String url;
    String orchestrator = cluster.getStack().getOrchestrator().getType();
    if (ambariIp != null) {
        Gateway gateway = cluster.getGateway();
        if (YARN.equals(orchestrator)) {
            url = String.format("http://%s:8080", ambariIp);
        } else {
            if (gateway.getEnableGateway() != null && gateway.getEnableGateway()) {
                url = GatewayType.CENTRAL == gateway.getGatewayType() ? String.format("/%s/%s/ambari/", gateway.getPath(), gateway.getTopologyName()) : String.format("https://%s:8443/%s/%s/ambari/", ambariIp, gateway.getPath(), gateway.getTopologyName());
            } else {
                url = String.format("https://%s/ambari/", ambariIp);
            }
        }
    } else {
        url = null;
    }
    return url;
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.Gateway)

Example 5 with Gateway

use of com.sequenceiq.cloudbreak.domain.Gateway in project cloudbreak by hortonworks.

the class BlueprintValidatorTest method testKnoxWithKerberosAndEachGwHasKnox.

@Test
public void testKnoxWithKerberosAndEachGwHasKnox() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    instanceGroups.add(createInstanceGroup("gateway1", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("gateway2", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("master", 1, InstanceGroupType.CORE));
    Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
    JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
    ObjectNode rootNode = jsonNodeFactory.objectNode();
    ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
    addHostGroup(hostGroupsNode, "gateway1", SL_MIN0_MAX3, KNOX);
    addHostGroup(hostGroupsNode, "gateway2", KNOX, MA_MIN1_MAX3);
    addHostGroup(hostGroupsNode, "master", SL_MIN0_MAX3, MA_MIN1_MAX5);
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(rootNode);
    Cluster cluster = new Cluster();
    cluster.setSecure(true);
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(true);
    cluster.setGateway(gateway);
    // WHEN
    underTest.validateBlueprintForStack(cluster, blueprint, hostGroups, instanceGroups);
// THEN no exception thrown
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Gateway(com.sequenceiq.cloudbreak.domain.Gateway) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Test(org.junit.Test)

Aggregations

Gateway (com.sequenceiq.cloudbreak.domain.Gateway)10 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)5 HashSet (java.util.HashSet)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)4 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)4 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)4 Test (org.junit.Test)4 Json (com.sequenceiq.cloudbreak.domain.json.Json)3 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1 Port (com.sequenceiq.cloudbreak.api.model.Port)1 CloudbreakApiException (com.sequenceiq.cloudbreak.controller.CloudbreakApiException)1 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)1 JsonToString (com.sequenceiq.cloudbreak.domain.json.JsonToString)1 IOException (java.io.IOException)1