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