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