Search in sources :

Example 1 with StackStatus

use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.

the class AmbariClusterService method updateClusterStatusByStackId.

@Override
@Transactional(TxType.NEVER)
public Cluster updateClusterStatusByStackId(Long stackId, Status status, String statusReason) {
    LOGGER.debug("Updating cluster status. stackId: {}, status: {}, statusReason: {}", stackId, status, statusReason);
    StackStatus stackStatus = stackService.getCurrentStatusByStackId(stackId);
    Cluster cluster = retrieveClusterByStackId(stackId);
    if (cluster != null) {
        cluster.setStatus(status);
        cluster.setStatusReason(statusReason);
        cluster = clusterRepository.save(cluster);
        if (status.isRemovableStatus()) {
            InMemoryStateStore.deleteCluster(cluster.getId());
            if (stackStatus.getStatus().isRemovableStatus()) {
                InMemoryStateStore.deleteStack(stackId);
            }
        } else {
            InMemoryStateStore.putCluster(cluster.getId(), statusToPollGroupConverter.convert(status));
            if (InMemoryStateStore.getStack(stackId) == null) {
                InMemoryStateStore.putStack(stackId, statusToPollGroupConverter.convert(stackStatus.getStatus()));
            }
        }
    }
    return cluster;
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Transactional(javax.transaction.Transactional)

Example 2 with StackStatus

use of com.sequenceiq.cloudbreak.domain.StackStatus 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 3 with StackStatus

use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.

the class StackRequestToStackConverter method convert.

@Override
public Stack convert(StackRequest source) {
    Stack stack = new Stack();
    stack.setName(source.getName());
    stack.setDisplayName(source.getName());
    stack.setRegion(getRegion(source));
    setPlatform(source);
    stack.setCloudPlatform(source.getCloudPlatform());
    Map<String, String> sourceTags = source.getApplicationTags();
    stack.setTags(getTags(mergeTags(sourceTags, source.getUserDefinedTags(), getDefaultTags(source))));
    if (sourceTags != null && sourceTags.get("datalakeId") != null) {
        stack.setDatalakeId(Long.valueOf(String.valueOf(sourceTags.get("datalakeId"))));
    }
    StackAuthentication stackAuthentication = conversionService.convert(source.getStackAuthentication(), StackAuthentication.class);
    stack.setStackAuthentication(stackAuthentication);
    validateStackAuthentication(source);
    stack.setOwner(source.getOwner());
    stack.setAvailabilityZone(source.getAvailabilityZone());
    stack.setOnFailureActionAction(source.getOnFailureAction());
    stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.PROVISION_REQUESTED.getStatus(), "", DetailedStackStatus.PROVISION_REQUESTED));
    stack.setFailurePolicy(getConversionService().convert(source.getFailurePolicy(), FailurePolicy.class));
    stack.setCreated(Calendar.getInstance().getTimeInMillis());
    stack.setPlatformVariant(source.getPlatformVariant());
    stack.setOrchestrator(getConversionService().convert(source.getOrchestrator(), Orchestrator.class));
    if (source.getCredential() != null) {
        stack.setCredential(getConversionService().convert(source.getCredential(), Credential.class));
    }
    Set<InstanceGroup> instanceGroups = convertInstanceGroups(source, stack);
    stack.setInstanceGroups(instanceGroups);
    if (source.getNetwork() != null) {
        stack.setNetwork(getConversionService().convert(source.getNetwork(), Network.class));
    }
    stack.setCustomDomain(source.getCustomDomain());
    stack.setCustomHostname(source.getCustomHostname());
    stack.setClusterNameAsSubdomain(source.isClusterNameAsSubdomain());
    stack.setHostgroupNameAsHostname(source.isHostgroupNameAsHostname());
    stack.setUuid(UUID.randomUUID().toString());
    return stack;
}
Also used : StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) Credential(com.sequenceiq.cloudbreak.domain.Credential) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) Network(com.sequenceiq.cloudbreak.domain.Network) FailurePolicy(com.sequenceiq.cloudbreak.domain.FailurePolicy) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 4 with StackStatus

use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.

the class StackUpdaterTest method updateStackStatusWithoutStatusReasonThenNoNotificationSentOnWebsocket.

@Test
public void updateStackStatusWithoutStatusReasonThenNoNotificationSentOnWebsocket() {
    Stack stack = TestUtil.stack();
    DetailedStackStatus newStatus = DetailedStackStatus.DELETE_COMPLETED;
    StackStatus testStackStatus = new StackStatus(stack, newStatus.getStatus(), "", newStatus);
    when(stackStatusRepository.save(any(StackStatus.class))).thenReturn(testStackStatus);
    when(stackRepository.findOne(anyLong())).thenReturn(stack);
    when(stackRepository.save(any(Stack.class))).thenReturn(stack);
    doNothing().when(cloudbreakEventService).fireCloudbreakEvent(anyLong(), anyString(), anyString());
    when(statusToPollGroupConverter.convert(newStatus.getStatus())).thenReturn(PollGroup.POLLABLE);
    Stack newStack = underTest.updateStackStatus(1L, DetailedStackStatus.DELETE_COMPLETED);
    assertEquals(newStatus.getStatus(), newStack.getStatus());
    assertEquals("", newStack.getStatusReason());
    verify(cloudbreakEventService, times(0)).fireCloudbreakEvent(anyLong(), anyString(), anyString());
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 5 with StackStatus

use of com.sequenceiq.cloudbreak.domain.StackStatus 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;
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) Template(com.sequenceiq.cloudbreak.domain.Template) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

StackStatus (com.sequenceiq.cloudbreak.domain.StackStatus)8 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)7 Stack (com.sequenceiq.cloudbreak.domain.Stack)7 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 Credential (com.sequenceiq.cloudbreak.domain.Credential)2 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)2 Test (org.junit.Test)2 Status (com.sequenceiq.cloudbreak.api.model.Status)1 FailurePolicy (com.sequenceiq.cloudbreak.domain.FailurePolicy)1 Network (com.sequenceiq.cloudbreak.domain.Network)1 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)1 SecurityConfig (com.sequenceiq.cloudbreak.domain.SecurityConfig)1 StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)1 Template (com.sequenceiq.cloudbreak.domain.Template)1 HashSet (java.util.HashSet)1 Transactional (javax.transaction.Transactional)1 Matchers.anyString (org.mockito.Matchers.anyString)1