Search in sources :

Example 81 with InstanceGroup

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

the class EmailSenderService method getInstanceTypes.

private String getInstanceTypes(Stack stack) {
    StringBuilder instanceTypesStringBuilder = new StringBuilder();
    for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
        String instanceType = instanceGroup.getTemplate().getInstanceType();
        instanceTypesStringBuilder.append("<br />").append(" - ");
        instanceTypesStringBuilder.append(instanceGroup.getGroupName()).append(" (").append(instanceGroup.getNodeCount()).append(") : ");
        instanceTypesStringBuilder.append(instanceType);
    }
    return instanceTypesStringBuilder.toString();
}
Also used : FreeMarkerTemplateUtils.processTemplateIntoString(org.springframework.ui.freemarker.FreeMarkerTemplateUtils.processTemplateIntoString) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 82 with InstanceGroup

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

the class TestUtil method generateOpenStackInstanceGroups.

public static Set<InstanceGroup> generateOpenStackInstanceGroups(int count) {
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    instanceGroups.add(instanceGroup(1L, InstanceGroupType.GATEWAY, gcpTemplate(1L)));
    for (int i = 0; i < count - 1; i++) {
        instanceGroups.add(instanceGroup(1L, InstanceGroupType.CORE, gcpTemplate(1L)));
    }
    return instanceGroups;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Constraint(com.sequenceiq.cloudbreak.domain.Constraint) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet)

Example 83 with InstanceGroup

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

the class TestUtil method hostGroup.

public static HostGroup hostGroup(String name, int count) {
    HostGroup hostGroup = new HostGroup();
    hostGroup.setId(1L);
    hostGroup.setName(name);
    hostGroup.setRecipes(recipes(1));
    hostGroup.setHostMetadata(hostMetadata(hostGroup, count));
    InstanceGroup instanceGroup = instanceGroup(1L, name, InstanceGroupType.CORE, gcpTemplate(1L), count);
    Constraint constraint = new Constraint();
    constraint.setInstanceGroup(instanceGroup);
    constraint.setHostCount(instanceGroup.getNodeCount());
    hostGroup.setConstraint(constraint);
    hostGroup.setCluster(cluster(blueprint(), stack(), 1L));
    hostGroup.setRecoveryMode(RecoveryMode.MANUAL);
    return hostGroup;
}
Also used : Constraint(com.sequenceiq.cloudbreak.domain.Constraint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 84 with InstanceGroup

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

the class TestUtil method generateAwsInstanceGroups.

public static Set<InstanceGroup> generateAwsInstanceGroups(int count) {
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    instanceGroups.add(instanceGroup(1L, InstanceGroupType.GATEWAY, awsTemplate(1L)));
    for (int i = 0; i < count - 1; i++) {
        instanceGroups.add(instanceGroup(1L, InstanceGroupType.CORE, awsTemplate(1L)));
    }
    return instanceGroups;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Constraint(com.sequenceiq.cloudbreak.domain.Constraint) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet)

Example 85 with InstanceGroup

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

the class StackRequestToStackConverterTest method testConvertWithNoGateway.

@SuppressFBWarnings(value = "DLS_DEAD_LOCAL_STORE")
@Test
public void testConvertWithNoGateway() throws CloudbreakException {
    InstanceGroup instanceGroup = mock(InstanceGroup.class);
    when(instanceGroup.getInstanceGroupType()).thenReturn(InstanceGroupType.CORE);
    // GIVEN
    ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
    given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
    given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
    given(conversionService.convert(any(StackAuthenticationRequest.class), eq(StackAuthentication.class))).willReturn(new StackAuthentication());
    given(conversionService.convert(any(FailurePolicyRequest.class), eq(FailurePolicy.class))).willReturn(new FailurePolicy());
    given(conversionService.convert(any(InstanceGroupRequest.class), eq(InstanceGroup.class))).willReturn(instanceGroup);
    given(conversionService.convert(any(OrchestratorRequest.class), eq(Orchestrator.class))).willReturn(new Orchestrator());
    given(orchestratorTypeResolver.resolveType(any(String.class))).willReturn(OrchestratorType.HOST);
    // WHEN
    try {
        Stack stack = underTest.convert(getRequest("stack/stack.json"));
    } catch (BadRequestException e) {
        // THEN
        Assert.assertEquals("Ambari server must be specified", e.getMessage());
    }
}
Also used : StackAuthenticationRequest(com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest) StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) Matchers.anyString(org.mockito.Matchers.anyString) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Stack(com.sequenceiq.cloudbreak.domain.Stack) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) OrchestratorRequest(com.sequenceiq.cloudbreak.api.model.OrchestratorRequest) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) FailurePolicyRequest(com.sequenceiq.cloudbreak.api.model.FailurePolicyRequest) FailurePolicy(com.sequenceiq.cloudbreak.domain.FailurePolicy) Test(org.junit.Test) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)89 Test (org.junit.Test)32 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)27 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)27 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)24 HashSet (java.util.HashSet)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Stack (com.sequenceiq.cloudbreak.domain.Stack)14 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)9 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)8 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)8 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)8 Matchers.anyString (org.mockito.Matchers.anyString)8 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)6 StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)6 Template (com.sequenceiq.cloudbreak.domain.Template)6 ArrayList (java.util.ArrayList)6 InstanceGroupRequest (com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest)5 StackAuthenticationRequest (com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest)5 FailurePolicy (com.sequenceiq.cloudbreak.domain.FailurePolicy)5