use of com.sequenceiq.cloudbreak.domain.Template in project cloudbreak by hortonworks.
the class TemplateController method getPublic.
@Override
public TemplateResponse getPublic(@PathVariable String name) {
IdentityUser user = authenticatedUserService.getCbUser();
Template template = templateService.getPublicTemplate(name, user);
return convert(template);
}
use of com.sequenceiq.cloudbreak.domain.Template in project cloudbreak by hortonworks.
the class TemplateController method getPublics.
@Override
public Set<TemplateResponse> getPublics() {
IdentityUser user = authenticatedUserService.getCbUser();
Set<Template> templates = templateService.retrieveAccountTemplates(user);
return convert(templates);
}
use of com.sequenceiq.cloudbreak.domain.Template in project cloudbreak by hortonworks.
the class StackToCloudStackConverter method buildInstanceGroups.
public List<Group> buildInstanceGroups(List<InstanceGroup> instanceGroups, StackAuthentication stackAuthentication, Collection<String> deleteRequests) {
// sort by name to avoid shuffling the different instance groups
Collections.sort(instanceGroups);
List<Group> groups = new ArrayList<>();
long privateId = getFirstValidPrivateId(instanceGroups);
for (InstanceGroup instanceGroup : instanceGroups) {
if (instanceGroup.getTemplate() != null) {
CloudInstance skeleton = null;
List<CloudInstance> instances = new ArrayList<>();
Template template = instanceGroup.getTemplate();
int desiredNodeCount = instanceGroup.getNodeCount();
// existing instances
for (InstanceMetaData metaData : instanceGroup.getInstanceMetaData()) {
InstanceStatus status = getInstanceStatus(metaData, deleteRequests);
instances.add(buildInstance(metaData, template, stackAuthentication, instanceGroup.getGroupName(), metaData.getPrivateId(), status));
}
// new instances
int existingNodesSize = instances.size();
if (existingNodesSize < desiredNodeCount) {
for (long i = 0; i < desiredNodeCount - existingNodesSize; i++) {
instances.add(buildInstance(null, template, stackAuthentication, instanceGroup.getGroupName(), privateId++, InstanceStatus.CREATE_REQUESTED));
}
}
if (existingNodesSize == desiredNodeCount && desiredNodeCount == 0) {
skeleton = buildInstance(null, template, stackAuthentication, instanceGroup.getGroupName(), 0L, InstanceStatus.CREATE_REQUESTED);
}
Json attributes = instanceGroup.getAttributes();
InstanceAuthentication instanceAuthentication = buildInstanceAuthentication(stackAuthentication);
Map<String, Object> fields = attributes == null ? Collections.emptyMap() : attributes.getMap();
groups.add(new Group(instanceGroup.getGroupName(), instanceGroup.getInstanceGroupType(), instances, buildSecurity(instanceGroup), skeleton, fields, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
}
}
return groups;
}
use of com.sequenceiq.cloudbreak.domain.Template in project cloudbreak by hortonworks.
the class ServiceTestUtils method createTemplate.
public static Template createTemplate(String owner, String account, String platform) {
switch(platform) {
case AWS:
Template awsTemplate = new Template();
awsTemplate.setId(1L);
awsTemplate.setOwner(owner);
awsTemplate.setAccount(account);
awsTemplate.setInstanceType(C3LARGE_INSTANCE);
awsTemplate.setVolumeType("gp2");
awsTemplate.setVolumeCount(1);
awsTemplate.setVolumeSize(100);
awsTemplate.setDescription("aws test template");
awsTemplate.setPublicInAccount(true);
awsTemplate.setCloudPlatform(AWS);
return awsTemplate;
case GCP:
Template gcpTemplate = new Template();
gcpTemplate.setId(1L);
gcpTemplate.setInstanceType(N1_STANDARD_1);
gcpTemplate.setVolumeType("pd-standard");
gcpTemplate.setDescription("gcp test template");
gcpTemplate.setOwner(owner);
gcpTemplate.setAccount(account);
gcpTemplate.setVolumeCount(1);
gcpTemplate.setVolumeSize(100);
gcpTemplate.setPublicInAccount(true);
gcpTemplate.setCloudPlatform(GCP);
return gcpTemplate;
default:
return null;
}
}
use of com.sequenceiq.cloudbreak.domain.Template in project cloudbreak by hortonworks.
the class ServiceTestUtils method createStack.
public static Stack createStack(String owner, String account, Template template, Credential credential, Cluster cluster, Set<Resource> resources) {
Template template1 = createTemplate(AWS);
Template template2 = createTemplate(AWS);
Set<InstanceGroup> instanceGroups = new HashSet<>();
InstanceGroup instanceGroup1 = new InstanceGroup();
instanceGroup1.setNodeCount(2);
instanceGroup1.setGroupName("master");
instanceGroup1.setTemplate(template1);
instanceGroups.add(instanceGroup1);
InstanceGroup instanceGroup2 = new InstanceGroup();
instanceGroup2.setNodeCount(2);
instanceGroup2.setGroupName("slave_1");
instanceGroup2.setTemplate(template2);
instanceGroups.add(instanceGroup2);
Stack stack = new Stack();
stack.setCredential(credential);
stack.setRegion("EU_WEST_1");
stack.setOwner(owner);
stack.setAccount(account);
stack.setStackStatus(new StackStatus(stack, Status.REQUESTED, "", DetailedStackStatus.PROVISION_REQUESTED));
stack.setInstanceGroups(instanceGroups);
stack.setCluster(cluster);
stack.setPublicInAccount(true);
stack.setResources(resources);
return stack;
}
Aggregations