use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class AccountPreferencesValidator method validate.
public void validate(Long stackId, Integer scalingAdjustment) throws AccountPreferencesValidationException {
Stack stack = stackService.getByIdWithLists(stackId);
Integer newNodeCount = stack.getFullNodeCount() + scalingAdjustment;
validate(stack.getInstanceGroups(), newNodeCount, stack.getAccount(), stack.getOwner());
}
use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class TestUtil method stack.
public static Stack stack(Status stackStatus, Credential credential) {
Stack stack = new Stack();
stack.setStackStatus(new StackStatus(stack, stackStatus, "statusReason", DetailedStackStatus.UNKNOWN));
stack.setCredential(credential);
stack.setName("simplestack");
stack.setOwner("userid");
stack.setAccount("account");
stack.setId(1L);
stack.setInstanceGroups(generateGcpInstanceGroups(3));
stack.setRegion("region");
stack.setCreated(123L);
stack.setCloudPlatform(credential.cloudPlatform());
stack.setOrchestrator(orchestrator());
switch(credential.cloudPlatform()) {
case AWS:
stack.setInstanceGroups(generateAwsInstanceGroups(3));
break;
case GCP:
stack.setInstanceGroups(generateGcpInstanceGroups(3));
break;
case OPENSTACK:
stack.setInstanceGroups(generateOpenStackInstanceGroups(3));
break;
default:
break;
}
stack.setSecurityConfig(new SecurityConfig());
return stack;
}
use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class UsageService method openNewIfNotFound.
private void openNewIfNotFound() {
List<CloudbreakUsage> usages = usageRepository.findAllOpenAndStopped(Date.from(ZonedDateTime.now().toInstant()));
Set<Long> stackIdsForOpenUsages = usages.stream().map(CloudbreakUsage::getStackId).collect(Collectors.toSet());
List<Stack> stacks = stackRepository.findAllAliveAndProvisioned();
for (Stack stack : stacks) {
if (!stackIdsForOpenUsages.contains(stack.getId())) {
Stack fullStack = stackRepository.findOneWithLists(stack.getId());
openUsagesForStack(fullStack);
if (fullStack.getStatus() == Status.STOPPED) {
stopUsagesForStack(fullStack);
}
}
}
}
use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class ClusterToClusterResponseConverterTest method createSource.
@Override
public Cluster createSource() {
Stack stack = TestUtil.stack();
Blueprint blueprint = TestUtil.blueprint();
Cluster cluster = TestUtil.cluster(blueprint, stack, 1L);
ProxyConfig proxyConfig = new ProxyConfig();
proxyConfig.setName("test");
cluster.setProxyConfig(proxyConfig);
stack.setCluster(cluster);
return cluster;
}
use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class HostMetadataSetup method setupNewHostMetadata.
public void setupNewHostMetadata(Long stackId, Collection<String> newAddresses) throws CloudbreakException {
LOGGER.info("Extending host metadata.");
Stack stack = stackService.getByIdWithLists(stackId);
if (!orchestratorTypeResolver.resolveType(stack.getOrchestrator()).containerOrchestrator()) {
Set<InstanceMetaData> newInstanceMetadata = stack.getRunningInstanceMetaData().stream().filter(instanceMetaData -> newAddresses.contains(instanceMetaData.getPrivateIp())).collect(Collectors.toSet());
updateWithHostData(stack, newInstanceMetadata);
instanceMetaDataRepository.save(newInstanceMetadata);
}
}
Aggregations