use of com.sequenceiq.cloudbreak.api.model.GatewayJson 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.api.model.GatewayJson in project cloudbreak by hortonworks.
the class MockClusterCreationWithSaltSuccessTest method testClusterCreation.
@Test
@Parameters({ "clusterName", "ambariPort", "ambariUser", "ambariPassword", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "mockPort" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("8080") String ambariPort, @Optional("admin") String ambariUser, @Optional("admin123!@#") String ambariPassword, @Optional("false") boolean emailNeeded, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("9443") int mockPort) throws Exception {
// GIVEN
IntegrationTestContext itContext = getItContext();
String stackIdStr = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
Integer stackId = Integer.valueOf(stackIdStr);
Integer blueprintId = Integer.valueOf(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID));
List<HostGroup> hostgroups = itContext.getContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, List.class);
Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts);
itContext.putContextParam(CloudbreakITContextConstants.AMBARI_USER_ID, ambariUser);
itContext.putContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID, ambariPassword);
// WHEN
ClusterRequest clusterRequest = new ClusterRequest();
clusterRequest.setName(clusterName);
clusterRequest.setDescription("Cluster for integration test");
clusterRequest.setEmailNeeded(emailNeeded);
clusterRequest.setEnableSecurity(enableSecurity);
clusterRequest.setPassword(ambariPassword);
clusterRequest.setUserName(ambariUser);
clusterRequest.setBlueprintId(Long.valueOf(blueprintId));
clusterRequest.setHostGroups(hostGroupJsons1);
if (enableSecurity) {
KerberosRequest kerberosRequest = new KerberosRequest();
kerberosRequest.setAdmin(kerberosAdmin);
kerberosRequest.setPassword(kerberosPassword);
kerberosRequest.setMasterKey(kerberosMasterKey);
clusterRequest.setKerberos(kerberosRequest);
}
GatewayJson gatewayJson = new GatewayJson();
gatewayJson.setEnableGateway(Boolean.TRUE);
gatewayJson.setExposedServices(ImmutableList.of("ALL"));
clusterRequest.setGateway(gatewayJson);
ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
// THEN
Assert.assertNotNull(clusterId);
CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackIdStr, "AVAILABLE");
CloudbreakUtil.checkClusterAvailability(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackIdStr, ambariUser, ambariPassword, checkAmbari);
StackCreationMock stackCreationMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, StackCreationMock.class);
stackCreationMock.verifyCalls(clusterName);
}
use of com.sequenceiq.cloudbreak.api.model.GatewayJson in project cloudbreak by hortonworks.
the class GatewayToGatewayRequestConverter method convert.
@Override
public GatewayJson convert(Gateway source) {
GatewayJson gatewayJson = new GatewayJson();
gatewayJson.setEnableGateway(source.getEnableGateway());
try {
gatewayJson.setExposedServices(source.getExposedServices().get(List.class));
} catch (IOException e) {
gatewayJson.setExposedServices(new ArrayList<>());
}
gatewayJson.setGatewayType(source.getGatewayType());
gatewayJson.setPath(source.getPath());
gatewayJson.setSsoProvider(source.getSsoProvider());
gatewayJson.setSsoType(source.getSsoType());
gatewayJson.setTokenCert(source.getTokenCert());
gatewayJson.setTopologyName(source.getTopologyName());
return gatewayJson;
}
use of com.sequenceiq.cloudbreak.api.model.GatewayJson 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.api.model.GatewayJson in project cloudbreak by hortonworks.
the class AbstractStackCreationV2Test method ambariParameters.
@BeforeMethod(dependsOnGroups = "V2StackCreationInit")
@Parameters({ "blueprintName", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword" })
public void ambariParameters(@Optional("") String blueprintName, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword) {
IntegrationTestContext itContext = getItContext();
blueprintName = StringUtils.hasText(blueprintName) ? blueprintName : itContext.getContextParam(CloudbreakV2Constants.SSH_PUBLICKEY_ID);
Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID), "Ambari user is mandatory.");
Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID), "Ambari password is mandatory.");
Assert.assertNotNull(blueprintName, "blueprint name is mandatory.");
StackV2Request stackV2Request = itContext.getContextParam(CloudbreakV2Constants.STACK_CREATION_REQUEST, StackV2Request.class);
ClusterV2Request clusterV2Request = new ClusterV2Request();
stackV2Request.setCluster(clusterV2Request);
AmbariV2Request ambariV2Request = new AmbariV2Request();
clusterV2Request.setAmbari(ambariV2Request);
ambariV2Request.setBlueprintName(blueprintName);
ambariV2Request.setUserName(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID));
ambariV2Request.setPassword(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID));
GatewayJson gatewayJson = new GatewayJson();
gatewayJson.setEnableGateway(Boolean.FALSE);
gatewayJson.setExposedServices(ImmutableList.of("ALL"));
ambariV2Request.setGateway(gatewayJson);
if (enableSecurity) {
ambariV2Request.setEnableSecurity(enableSecurity);
KerberosRequest kerberosRequest = new KerberosRequest();
kerberosRequest.setMasterKey(kerberosMasterKey);
kerberosRequest.setAdmin(kerberosAdmin);
kerberosRequest.setPassword(kerberosPassword);
ambariV2Request.setKerberos(kerberosRequest);
}
}
Aggregations