use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class SdxServiceTest method testGetDefaultTemplate.
@Test
void testGetDefaultTemplate() {
StackV4Request defaultTemplate = new StackV4Request();
when(cdpConfigService.getConfigForKey(any())).thenReturn(defaultTemplate);
SdxDefaultTemplateResponse response = underTest.getDefaultTemplate(LIGHT_DUTY, "7.2.14", "AWS");
assertEquals(defaultTemplate, response.getTemplate());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class StackToStackV4RequestConverter method prepareImage.
private void prepareImage(Stack source, StackV4Request stackV2Request) {
try {
Image image = componentConfigProviderService.getImage(source.getId());
ImageSettingsV4Request is = new ImageSettingsV4Request();
is.setId(Strings.isNullOrEmpty(image.getImageId()) ? "" : image.getImageId());
is.setCatalog(Strings.isNullOrEmpty(image.getImageCatalogName()) ? "" : image.getImageCatalogName());
stackV2Request.setImage(is);
} catch (CloudbreakImageNotFoundException e) {
LOGGER.info(e.toString());
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class StackToStackV4RequestConverter method convert.
public StackV4Request convert(Stack source) {
StackV4Request stackV4Request = new StackV4Request();
stackV4Request.setCloudPlatform(getIfNotNull(source.getCloudPlatform(), cp -> Enum.valueOf(CloudPlatform.class, cp)));
stackV4Request.setEnvironmentCrn(source.getEnvironmentCrn());
stackV4Request.setCustomDomain(getCustomDomainSettings(source));
providerParameterCalculator.parse(new HashMap<>(source.getParameters()), stackV4Request);
stackV4Request.setAuthentication(stackAuthenticationToStackAuthenticationV4RequestConverter.convert(source.getStackAuthentication()));
stackV4Request.setNetwork(networkToNetworkV4RequestConverter.convert(source.getNetwork()));
stackV4Request.setCluster(clusterToClusterV4RequestConverter.convert(source.getCluster()));
stackV4Request.setExternalDatabase(getIfNotNull(source, stackToExternalDatabaseRequestConverter::convert));
if (!source.getLoadBalancers().isEmpty()) {
stackV4Request.setEnableLoadBalancer(true);
}
stackV4Request.setInstanceGroups(getInstanceGroups(source));
prepareImage(source, stackV4Request);
prepareTags(source, stackV4Request);
prepareTelemetryRequest(source, stackV4Request);
datalakeService.prepareDatalakeRequest(source, stackV4Request);
stackV4Request.setPlacement(getPlacementSettings(source.getRegion(), source.getAvailabilityZone()));
prepareInputs(source, stackV4Request);
stackV4Request.setTimeToLive(getStackTimeToLive(source));
return stackV4Request;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverter method decorateBuilderWithPlacement.
private void decorateBuilderWithPlacement(StackV4Request source, Builder builder) {
PlacementSettingsV4Request placementSettings = source.getPlacement();
if (placementSettings != null) {
String region = placementSettings.getRegion();
builder.withPlacementView(new PlacementView(region, region));
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class StackDecorator method prepareInstanceGroups.
private void prepareInstanceGroups(Stack subject, StackV4Request request, Credential credential, User user, DetailedEnvironmentResponse environment) {
Map<String, InstanceGroupParameterResponse> instanceGroupParameterResponse = cloudParameterService.getInstanceGroupParameters(extendedCloudCredentialConverter.convert(credential), getInstanceGroupParameterRequests(subject));
CloudbreakUser cloudbreakUser = legacyRestRequestThreadLocalService.getCloudbreakUser();
subject.getInstanceGroups().parallelStream().forEach(instanceGroup -> {
subject.getCluster().getHostGroups().stream().filter(hostGroup -> hostGroup.getName().equals(instanceGroup.getGroupName())).forEach(hostGroup -> hostGroup.setInstanceGroup(instanceGroup));
legacyRestRequestThreadLocalService.setCloudbreakUser(cloudbreakUser);
updateInstanceGroupParameters(instanceGroupParameterResponse, instanceGroup);
if (instanceGroup.getTemplate() != null) {
Template template = instanceGroup.getTemplate();
if (template.getId() == null) {
template.setCloudPlatform(credential.cloudPlatform());
PlacementSettingsV4Request placement = request.getPlacement();
String availabilityZone = placement != null ? placement.getAvailabilityZone() : subject.getAvailabilityZone();
String region = placement != null ? placement.getRegion() : subject.getRegion();
CdpResourceType cdpResourceType = cdpResourceTypeProvider.fromStackType(request.getType());
template = templateDecorator.decorate(credential, template, region, availabilityZone, subject.getPlatformVariant(), cdpResourceType);
template.setWorkspace(subject.getWorkspace());
setupDatabaseAttachedVolume(subject, instanceGroup, template);
template = templateService.create(user, template);
instanceGroup.setTemplate(template);
}
}
if (instanceGroup.getSecurityGroup() != null) {
SecurityGroup securityGroup = instanceGroup.getSecurityGroup();
if (securityGroup.getId() == null) {
securityGroup.setCloudPlatform(credential.cloudPlatform());
securityGroup.setWorkspace(subject.getWorkspace());
securityGroup = securityGroupService.create(user, securityGroup);
instanceGroup.setSecurityGroup(securityGroup);
}
}
if (instanceGroup.getInstanceGroupNetwork() != null) {
InstanceGroupNetwork ign = instanceGroup.getInstanceGroupNetwork();
instanceGroup.setAvailabilityZones(getAvailabilityZoneFromEnv(instanceGroup, environment));
if (ign.getId() == null) {
ign.setCloudPlatform(credential.cloudPlatform());
ign = instanceGroupNetworkService.create(ign);
instanceGroup.setInstanceGroupNetwork(ign);
}
}
});
}
Aggregations