Search in sources :

Example 1 with StackV2Request

use of com.sequenceiq.cloudbreak.api.model.v2.StackV2Request in project cloudbreak by hortonworks.

the class MockStackCreationV2Test method testStackCreation.

@Test
public void testStackCreation() throws Exception {
    // GIVEN
    // WHEN
    super.testStackCreation();
    // THEN
    StackCreationMock stackCreationMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, StackCreationMock.class);
    String stackName = getItContext().getContextParam(CloudbreakV2Constants.STACK_NAME);
    stackCreationMock.verifyCalls(stackName);
    StackV2Request stackV2Request = getItContext().getContextParam(CloudbreakV2Constants.STACK_CREATION_REQUEST, StackV2Request.class);
    AmbariV2Request ambariV2Request = stackV2Request.getCluster().getAmbari();
    if (ambariV2Request.getEnableSecurity()) {
        KerberosRequest kerberosRequest = ambariV2Request.getKerberos();
        stackCreationMock.verifyKerberosCalls(stackName, kerberosRequest.getAdmin(), kerberosRequest.getPassword());
    }
}
Also used : StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) AmbariV2Request(com.sequenceiq.cloudbreak.api.model.v2.AmbariV2Request) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) Test(org.testng.annotations.Test) AbstractStackCreationV2Test(com.sequenceiq.it.cloudbreak.v2.AbstractStackCreationV2Test)

Example 2 with StackV2Request

use of com.sequenceiq.cloudbreak.api.model.v2.StackV2Request in project cloudbreak by hortonworks.

the class StackV2RequestToStackRequestConverter method convert.

@Override
public StackRequest convert(StackV2Request source) {
    StackRequest stackRequest = new StackRequest();
    stackRequest.setName(source.getGeneral().getName());
    if (source.getPlacement() != null) {
        stackRequest.setAvailabilityZone(source.getPlacement().getAvailabilityZone());
        stackRequest.setRegion(source.getPlacement().getRegion());
    }
    stackRequest.setPlatformVariant(source.getPlatformVariant());
    stackRequest.setAmbariVersion(source.getAmbariVersion());
    stackRequest.setHdpVersion(source.getHdpVersion());
    stackRequest.setParameters(convertParameters(source.getParameters()));
    if (source.getCustomDomain() != null) {
        stackRequest.setCustomDomain(source.getCustomDomain().getCustomDomain());
        stackRequest.setCustomHostname(source.getCustomDomain().getCustomHostname());
        stackRequest.setClusterNameAsSubdomain(source.getCustomDomain().isClusterNameAsSubdomain());
        stackRequest.setHostgroupNameAsHostname(source.getCustomDomain().isHostgroupNameAsHostname());
    }
    if (source.getTags() != null) {
        stackRequest.setApplicationTags(source.getTags().getApplicationTags());
        stackRequest.setDefaultTags(source.getTags().getDefaultTags());
        stackRequest.setUserDefinedTags(source.getTags().getUserDefinedTags());
    }
    stackRequest.setInstanceGroups(new ArrayList<>());
    for (InstanceGroupV2Request instanceGroupV2Request : source.getInstanceGroups()) {
        InstanceGroupRequest convert = conversionService.convert(instanceGroupV2Request, InstanceGroupRequest.class);
        stackRequest.getInstanceGroups().add(convert);
    }
    stackRequest.setFailurePolicy(source.getFailurePolicy());
    stackRequest.setStackAuthentication(source.getStackAuthentication());
    stackRequest.setNetwork(conversionService.convert(source.getNetwork(), NetworkRequest.class));
    OrchestratorRequest orchestrator = new OrchestratorRequest();
    orchestrator.setType("SALT");
    stackRequest.setOrchestrator(orchestrator);
    if (source.getImageSettings() != null) {
        stackRequest.setImageCatalog(source.getImageSettings().getImageCatalog());
        stackRequest.setImageId(source.getImageSettings().getImageId());
    }
    stackRequest.setFlexId(source.getFlexId());
    stackRequest.setCredentialName(source.getGeneral().getCredentialName());
    stackRequest.setOwner(Strings.isNullOrEmpty(source.getOwner()) ? authenticatedUserService.getCbUser().getUserId() : source.getOwner());
    stackRequest.setAccount(Strings.isNullOrEmpty(source.getAccount()) ? authenticatedUserService.getCbUser().getAccount() : source.getAccount());
    stackRequest.setOwnerEmail(Strings.isNullOrEmpty(source.getOwnerEmail()) ? authenticatedUserService.getCbUser().getUsername() : source.getOwnerEmail());
    convertClusterRequest(source, stackRequest);
    stackRequest.setCloudPlatform(credentialService.get(stackRequest.getCredentialName(), stackRequest.getAccount()).cloudPlatform());
    return stackRequest;
}
Also used : InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) OrchestratorRequest(com.sequenceiq.cloudbreak.api.model.OrchestratorRequest) NetworkRequest(com.sequenceiq.cloudbreak.api.model.NetworkRequest) StackRequest(com.sequenceiq.cloudbreak.api.model.StackRequest)

Example 3 with StackV2Request

use of com.sequenceiq.cloudbreak.api.model.v2.StackV2Request in project cloudbreak by hortonworks.

the class StackToStackV2RequestConverter method prepareImage.

private void prepareImage(Stack source, StackV2Request stackV2Request) {
    try {
        Image image = componentConfigProvider.getImage(source.getId());
        ImageSettings is = new ImageSettings();
        is.setImageId(Strings.isNullOrEmpty(image.getImageId()) ? "" : image.getImageId());
        is.setImageCatalog(Strings.isNullOrEmpty(image.getImageCatalogName()) ? "" : image.getImageCatalogName());
        stackV2Request.setImageSettings(is);
    } catch (CloudbreakImageNotFoundException e) {
        LOGGER.error(e.toString());
    }
}
Also used : CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ImageSettings(com.sequenceiq.cloudbreak.api.model.v2.ImageSettings)

Example 4 with StackV2Request

use of com.sequenceiq.cloudbreak.api.model.v2.StackV2Request in project cloudbreak by hortonworks.

the class StackToStackV2RequestConverter method prepareTags.

private void prepareTags(Stack source, StackV2Request stackV2Request) {
    try {
        StackTags stackTags = source.getTags().get(StackTags.class);
        if (stackTags.getUserDefinedTags() != null) {
            Tags tags = new Tags();
            tags.setApplicationTags(null);
            tags.setDefaultTags(null);
            tags.setUserDefinedTags(stackTags.getUserDefinedTags());
            stackV2Request.setTags(tags);
        }
    } catch (IOException e) {
        stackV2Request.setTags(null);
    }
}
Also used : StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) IOException(java.io.IOException) Tags(com.sequenceiq.cloudbreak.api.model.v2.Tags) StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags)

Example 5 with StackV2Request

use of com.sequenceiq.cloudbreak.api.model.v2.StackV2Request in project cloudbreak by hortonworks.

the class StackToStackV2RequestConverter method convert.

@Override
public StackV2Request convert(Stack source) {
    StackV2Request stackV2Request = new StackV2Request();
    stackV2Request.setGeneral(getGeneralSettings("", source.getCredential().getName()));
    stackV2Request.setPlacement(getPlacementSettings(source.getRegion(), source.getAvailabilityZone()));
    stackV2Request.setCustomDomain(getCustomDomainSettings(source.getCustomDomain(), source.getCustomHostname(), source.isHostgroupNameAsHostname(), source.isClusterNameAsSubdomain()));
    stackV2Request.setFlexId(source.getFlexSubscription() == null ? null : source.getFlexSubscription().getId());
    stackV2Request.setParameters(source.getParameters());
    stackV2Request.setInstanceGroups(new ArrayList<>());
    stackV2Request.setStackAuthentication(getConversionService().convert(source.getStackAuthentication(), StackAuthenticationRequest.class));
    stackV2Request.setNetwork(getConversionService().convert(source.getNetwork(), NetworkV2Request.class));
    stackV2Request.setCluster(getConversionService().convert(source.getCluster(), ClusterV2Request.class));
    for (InstanceGroup instanceGroup : source.getInstanceGroups()) {
        InstanceGroupV2Request instanceGroupV2Request = getConversionService().convert(instanceGroup, InstanceGroupV2Request.class);
        instanceGroupV2Request = collectInformationsFromActualHostgroup(source, instanceGroup, instanceGroupV2Request);
        stackV2Request.getInstanceGroups().add(instanceGroupV2Request);
    }
    prepareImage(source, stackV2Request);
    prepareTags(source, stackV2Request);
    return stackV2Request;
}
Also used : StackAuthenticationRequest(com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest) StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) ClusterV2Request(com.sequenceiq.cloudbreak.api.model.v2.ClusterV2Request) NetworkV2Request(com.sequenceiq.cloudbreak.api.model.v2.NetworkV2Request) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Aggregations

StackV2Request (com.sequenceiq.cloudbreak.api.model.v2.StackV2Request)8 InstanceGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request)5 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)4 Parameters (org.testng.annotations.Parameters)4 BeforeMethod (org.testng.annotations.BeforeMethod)3 Test (org.testng.annotations.Test)3 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)2 StackAuthenticationRequest (com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest)2 AmbariV2Request (com.sequenceiq.cloudbreak.api.model.v2.AmbariV2Request)2 ClusterV2Request (com.sequenceiq.cloudbreak.api.model.v2.ClusterV2Request)2 ImageSettings (com.sequenceiq.cloudbreak.api.model.v2.ImageSettings)2 NetworkV2Request (com.sequenceiq.cloudbreak.api.model.v2.NetworkV2Request)2 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)1 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)1 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)1 InstanceGroupRequest (com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest)1 NetworkRequest (com.sequenceiq.cloudbreak.api.model.NetworkRequest)1 OrchestratorRequest (com.sequenceiq.cloudbreak.api.model.OrchestratorRequest)1 StackRequest (com.sequenceiq.cloudbreak.api.model.StackRequest)1 GeneralSettings (com.sequenceiq.cloudbreak.api.model.v2.GeneralSettings)1