use of com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse in project cloudbreak by hortonworks.
the class AzurePlatformParameters method collectInstanceGroupParameters.
@Override
public Map<String, InstanceGroupParameterResponse> collectInstanceGroupParameters(Set<InstanceGroupParameterRequest> instanceGroupParameterRequests) {
Map<String, InstanceGroupParameterResponse> result = new HashMap<>();
for (InstanceGroupParameterRequest groupParameterRequest : instanceGroupParameterRequests) {
InstanceGroupParameterResponse instanceGroupParameterResponse = new InstanceGroupParameterResponse();
if (groupParameterRequest.getParameters().keySet().contains("availabilitySet")) {
instanceGroupParameterResponse.setGroupName(groupParameterRequest.getGroupName());
instanceGroupParameterResponse.setParameters(groupParameterRequest.getParameters());
} else if (groupParameterRequest.getNodeCount() > 1) {
Map<String, Object> parameters = groupParameterRequest.getParameters();
Map<String, Object> availabilitySet = new HashMap<>();
availabilitySet.put("name", String.format("%s-%s-as", groupParameterRequest.getGroupName(), groupParameterRequest.getStackName()));
availabilitySet.put("faultDomainCount", DEFAULT_FAULT_DOMAIN_COUNTER);
availabilitySet.put("updateDomainCount", DEFAULT_UPDATE_DOMAIN_COUNTER);
parameters.put("availabilitySet", availabilitySet);
instanceGroupParameterResponse.setGroupName(groupParameterRequest.getGroupName());
instanceGroupParameterResponse.setParameters(parameters);
}
result.put(instanceGroupParameterResponse.getGroupName(), instanceGroupParameterResponse);
}
return result;
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse in project cloudbreak by hortonworks.
the class GetPlatformInstanceGroupParametersHandler method accept.
@Override
public void accept(Event<GetPlatformInstanceGroupParameterRequest> getPlatformInstanceGroupParameterRequestEvent) {
LOGGER.info("Received event: {}", getPlatformInstanceGroupParameterRequestEvent);
GetPlatformInstanceGroupParameterRequest request = getPlatformInstanceGroupParameterRequestEvent.getData();
try {
CloudPlatformVariant variant = new CloudPlatformVariant(platform(request.getExtendedCloudCredential().getCloudPlatform()), variant(request.getVariant()));
Map<String, InstanceGroupParameterResponse> instanceGroupParameterResponses = cloudPlatformConnectors.get(variant).parameters().collectInstanceGroupParameters(request.getInstanceGroupParameterRequest());
GetPlatformInstanceGroupParameterResult getPlatformInstanceGroupParameterResult = new GetPlatformInstanceGroupParameterResult(request, instanceGroupParameterResponses);
request.getResult().onNext(getPlatformInstanceGroupParameterResult);
LOGGER.info("Query platform instance group parameters finished.");
} catch (Exception e) {
request.getResult().onNext(new GetPlatformInstanceGroupParameterResult(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse in project cloudbreak by hortonworks.
the class StackDecorator method updateInstanceGroupParameters.
private void updateInstanceGroupParameters(Map<String, InstanceGroupParameterResponse> instanceGroupParameterResponses, InstanceGroup instanceGroup) {
InstanceGroupParameterResponse instanceGroupParameterResponse = instanceGroupParameterResponses.get(instanceGroup.getGroupName());
if (instanceGroupParameterResponse != null) {
try {
Json jsonProperties = new Json(instanceGroupParameterResponse.getParameters());
instanceGroup.setAttributes(jsonProperties);
} catch (JsonProcessingException e) {
LOGGER.error("Could not update '{}' instancegroup parameters with defaults.", instanceGroupParameterResponse.getGroupName());
}
}
}
use of com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse in project cloudbreak by hortonworks.
the class StackDecorator method prepareInstanceGroups.
private void prepareInstanceGroups(Stack subject, StackRequest request, Credential credential, IdentityUser user) {
Map<String, InstanceGroupParameterResponse> instanceGroupParameterResponse = cloudParameterService.getInstanceGroupParameters(credential, getInstanceGroupParameterRequests(subject));
for (InstanceGroup instanceGroup : subject.getInstanceGroups()) {
updateInstanceGroupParameters(instanceGroupParameterResponse, instanceGroup);
if (instanceGroup.getTemplate() != null) {
Template template = instanceGroup.getTemplate();
if (template.getId() == null) {
template.setPublicInAccount(subject.isPublicInAccount());
template.setCloudPlatform(getCloudPlatform(subject, request, template.cloudPlatform()));
templateValidator.validateTemplateRequest(credential, instanceGroup.getTemplate(), request.getRegion(), request.getAvailabilityZone(), request.getPlatformVariant());
template = templateDecorator.decorate(credential, template, request.getRegion(), request.getAvailabilityZone(), request.getPlatformVariant());
template = templateService.create(user, template);
}
instanceGroup.setTemplate(template);
}
if (instanceGroup.getSecurityGroup() != null) {
SecurityGroup securityGroup = instanceGroup.getSecurityGroup();
if (securityGroup.getId() == null) {
securityGroup.setPublicInAccount(subject.isPublicInAccount());
securityGroup.setCloudPlatform(getCloudPlatform(subject, request, securityGroup.getCloudPlatform()));
securityGroup = securityGroupService.create(user, securityGroup);
instanceGroup.setSecurityGroup(securityGroup);
}
}
}
}
Aggregations