use of com.sequenceiq.common.api.type.CdpResourceType 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