Search in sources :

Example 1 with GatewayJson

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);
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.Gateway) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson)

Example 2 with GatewayJson

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);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.it.cloudbreak.HostGroup) ClusterV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) StackCreationMock(com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 3 with GatewayJson

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;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson)

Example 4 with 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);
}
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 5 with GatewayJson

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);
    }
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) AmbariV2Request(com.sequenceiq.cloudbreak.api.model.v2.AmbariV2Request) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) ClusterV2Request(com.sequenceiq.cloudbreak.api.model.v2.ClusterV2Request) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson) Parameters(org.testng.annotations.Parameters) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)5 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)2 Gateway (com.sequenceiq.cloudbreak.domain.Gateway)2 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)2 IOException (java.io.IOException)2 Parameters (org.testng.annotations.Parameters)2 ClusterV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint)1 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)1 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)1 AmbariV2Request (com.sequenceiq.cloudbreak.api.model.v2.AmbariV2Request)1 ClusterV2Request (com.sequenceiq.cloudbreak.api.model.v2.ClusterV2Request)1 StackV2Request (com.sequenceiq.cloudbreak.api.model.v2.StackV2Request)1 CloudbreakApiException (com.sequenceiq.cloudbreak.controller.CloudbreakApiException)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)1 HostGroup (com.sequenceiq.it.cloudbreak.HostGroup)1 StackCreationMock (com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock)1 ArrayList (java.util.ArrayList)1