Search in sources :

Example 6 with Gateway

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

the class BlueprintValidatorTest method testKnoxWithKerberosButNoKnoxInTheBlueprintForAllNodes.

@Test
public void testKnoxWithKerberosButNoKnoxInTheBlueprintForAllNodes() 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_MAX1);
    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: 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 7 with Gateway

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

the class ClusterToClusterResponseConverter method collectServicePorts.

private void collectServicePorts(Map<String, String> result, Iterable<Port> ports, String ambariIp, String serviceAddress, StackServiceComponentDescriptor componentDescriptor, Cluster cluster) throws IOException {
    if (componentDescriptor != null && componentDescriptor.isMaster()) {
        List<String> exposedServices = new ArrayList<>();
        Gateway gateway = cluster.getGateway();
        if (gateway.getExposedServices() != null && gateway.getExposedServices().getValue() != null) {
            exposedServices = gateway.getExposedServices().get(ExposedServices.class).getServices();
        }
        for (Port port : ports) {
            collectServicePort(result, port, serviceAddress, ambariIp, componentDescriptor, exposedServices, gateway);
        }
    }
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.Gateway) Port(com.sequenceiq.cloudbreak.api.model.Port) ArrayList(java.util.ArrayList)

Example 8 with Gateway

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

the class ClusterToClusterResponseConverter method convertKnox.

private void convertKnox(Cluster source, ClusterResponse clusterResponse) {
    Gateway gateway = source.getGateway();
    GatewayJson cloudGatewayJson = new GatewayJson();
    cloudGatewayJson.setEnableGateway(gateway.getEnableGateway());
    cloudGatewayJson.setTopologyName(gateway.getTopologyName());
    Json exposedJson = gateway.getExposedServices();
    if (exposedJson != null && StringUtils.isNoneEmpty(exposedJson.getValue())) {
        try {
            cloudGatewayJson.setExposedServices(exposedJson.get(ExposedServices.class).getServices());
        } catch (IOException e) {
            LOGGER.error("Failed to add exposedServices to response", e);
            throw new CloudbreakApiException("Failed to add exposedServices to response", e);
        }
    }
    cloudGatewayJson.setPath(gateway.getPath());
    cloudGatewayJson.setTokenCert(gateway.getTokenCert());
    cloudGatewayJson.setSsoProvider(gateway.getSsoProvider());
    cloudGatewayJson.setSsoType(gateway.getSsoType());
    cloudGatewayJson.setGatewayType(gateway.getGatewayType());
    clusterResponse.setGateway(cloudGatewayJson);
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.Gateway) AmbariRepoDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson) Json(com.sequenceiq.cloudbreak.domain.json.Json) BlueprintInputJson(com.sequenceiq.cloudbreak.api.model.BlueprintInputJson) IOException(java.io.IOException) CloudbreakApiException(com.sequenceiq.cloudbreak.controller.CloudbreakApiException) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson)

Example 9 with Gateway

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

the class TestUtil method cluster.

public static Cluster cluster(Blueprint blueprint, Stack stack, Long id, KerberosConfig kerberosConfig) {
    Cluster cluster = new Cluster();
    cluster.setAmbariIp("50.51.52.100");
    cluster.setStack(stack);
    cluster.setId(id);
    cluster.setName("dummyCluster");
    cluster.setAmbariIp("10.0.0.1");
    cluster.setBlueprint(blueprint);
    cluster.setUpSince(new Date().getTime());
    cluster.setStatus(AVAILABLE);
    cluster.setStatusReason("statusReason");
    cluster.setUserName("admin");
    cluster.setPassword("admin");
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(true);
    gateway.setTopologyName("cb");
    cluster.setGateway(gateway);
    cluster.setExecutorType(ExecutorType.DEFAULT);
    RDSConfig rdsConfig = new RDSConfig();
    Set<RDSConfig> rdsConfigs = new HashSet<>();
    rdsConfigs.add(rdsConfig);
    cluster.setRdsConfigs(rdsConfigs);
    cluster.setLdapConfig(ldapConfig());
    cluster.setHostGroups(hostGroups(cluster));
    Map<String, String> inputs = new HashMap<>();
    inputs.put("S3_BUCKET", "testbucket");
    try {
        cluster.setBlueprintInputs(new Json(inputs));
    } catch (JsonProcessingException ignored) {
        cluster.setBlueprintInputs(null);
    }
    Map<String, String> map = new HashMap<>();
    try {
        cluster.setAttributes(new Json(map));
    } catch (JsonProcessingException ignored) {
        cluster.setAttributes(null);
    }
    if (kerberosConfig != null) {
        cluster.setSecure(true);
        cluster.setKerberosConfig(kerberosConfig);
    }
    return cluster;
}
Also used : HashMap(java.util.HashMap) Gateway(com.sequenceiq.cloudbreak.domain.Gateway) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) JsonToString(com.sequenceiq.cloudbreak.domain.json.JsonToString) Json(com.sequenceiq.cloudbreak.domain.json.Json) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Date(java.util.Date) HashSet(java.util.HashSet)

Example 10 with Gateway

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

the class TestUtil method gateway.

public static Gateway gateway() throws JsonProcessingException {
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(true);
    gateway.setTopologyName("topology");
    gateway.setPath("/path");
    gateway.setSsoProvider("simple");
    gateway.setGatewayType(GatewayType.CENTRAL);
    gateway.setSignCert("signcert");
    gateway.setSignKey("signkey");
    gateway.setTokenCert("tokencert");
    gateway.setSignPub("signpub");
    gateway.setExposedServices(new Json("{}"));
    return gateway;
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.Gateway) Json(com.sequenceiq.cloudbreak.domain.json.Json)

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