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
}
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
}
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);
}
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;
}
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
}
Aggregations