Search in sources :

Example 26 with Stack

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());
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 27 with Stack

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;
}
Also used : SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 28 with 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);
            }
        }
    }
}
Also used : CloudbreakUsage(com.sequenceiq.cloudbreak.domain.CloudbreakUsage) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 29 with Stack

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;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ProxyConfig(com.sequenceiq.cloudbreak.domain.ProxyConfig) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 30 with Stack

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);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) CloudbreakSecuritySetupException(com.sequenceiq.cloudbreak.core.CloudbreakSecuritySetupException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) Logger(org.slf4j.Logger) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) InstanceMetaDataRepository(com.sequenceiq.cloudbreak.repository.InstanceMetaDataRepository) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) List(java.util.List) OrchestratorTypeResolver(com.sequenceiq.cloudbreak.core.bootstrap.service.OrchestratorTypeResolver) HostOrchestratorResolver(com.sequenceiq.cloudbreak.core.bootstrap.service.host.HostOrchestratorResolver) Service(org.springframework.stereotype.Service) Map(java.util.Map) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Stack(com.sequenceiq.cloudbreak.domain.Stack) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.Stack)207 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)74 Test (org.junit.Test)70 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)32 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)30 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)26 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)23 ArrayList (java.util.ArrayList)20 List (java.util.List)20 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)18 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)18 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)18 HashMap (java.util.HashMap)18 HashSet (java.util.HashSet)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Map (java.util.Map)17 Matchers.anyString (org.mockito.Matchers.anyString)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)15 Set (java.util.Set)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14