Search in sources :

Example 26 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class GcpInstanceResourceBuilderTest method isSchedulingPreemptibleTest.

@Test
public void isSchedulingPreemptibleTest() throws Exception {
    // GIVEN
    Group group = newGroupWithParams(ImmutableMap.of("preemptible", true));
    List<CloudResource> buildableResources = builder.create(context, privateId, authenticatedContext, group, image);
    context.addComputeResources(0L, buildableResources);
    // WHEN
    when(compute.instances()).thenReturn(instances);
    when(instances.insert(anyString(), anyString(), instanceArg.capture())).thenReturn(insert);
    when(insert.setPrettyPrint(anyBoolean())).thenReturn(insert);
    when(insert.execute()).thenReturn(operation);
    when(defaultCostTaggingService.prepareInstanceTagging()).thenReturn(new HashMap<>());
    builder.build(context, privateId, authenticatedContext, group, image, buildableResources, Collections.emptyMap());
    // THEN
    verify(compute).instances();
    verify(instances).insert(anyString(), anyString(), instanceArg.capture());
    assertTrue(instanceArg.getValue().getScheduling().getPreemptible());
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Test(org.junit.Test)

Example 27 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class GcpInstanceResourceBuilderTest method isSchedulingNotPreemptibleTest.

@Test
public void isSchedulingNotPreemptibleTest() throws Exception {
    // GIVEN
    Group group = newGroupWithParams(ImmutableMap.of("preemptible", false));
    List<CloudResource> buildableResources = builder.create(context, privateId, authenticatedContext, group, image);
    context.addComputeResources(0L, buildableResources);
    // WHEN
    when(compute.instances()).thenReturn(instances);
    when(instances.insert(anyString(), anyString(), instanceArg.capture())).thenReturn(insert);
    when(insert.setPrettyPrint(anyBoolean())).thenReturn(insert);
    when(insert.execute()).thenReturn(operation);
    when(defaultCostTaggingService.prepareInstanceTagging()).thenReturn(new HashMap<>());
    builder.build(context, privateId, authenticatedContext, group, image, buildableResources, Collections.emptyMap());
    // THEN
    verify(compute).instances();
    verify(instances).insert(anyString(), anyString(), instanceArg.capture());
    assertFalse(instanceArg.getValue().getScheduling().getPreemptible());
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Test(org.junit.Test)

Example 28 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class GcpInstanceResourceBuilderTest method preemptibleParameterNotSetTest.

@Test
public void preemptibleParameterNotSetTest() throws Exception {
    // GIVEN
    Group group = newGroupWithParams(ImmutableMap.of());
    List<CloudResource> buildableResources = builder.create(context, privateId, authenticatedContext, group, image);
    context.addComputeResources(0L, buildableResources);
    // WHEN
    when(compute.instances()).thenReturn(instances);
    when(instances.insert(anyString(), anyString(), instanceArg.capture())).thenReturn(insert);
    when(insert.setPrettyPrint(anyBoolean())).thenReturn(insert);
    when(insert.execute()).thenReturn(operation);
    when(defaultCostTaggingService.prepareInstanceTagging()).thenReturn(new HashMap<>());
    builder.build(context, privateId, authenticatedContext, group, image, buildableResources, Collections.emptyMap());
    // THEN
    verify(compute).instances();
    verify(instances).insert(anyString(), anyString(), instanceArg.capture());
    assertFalse(instanceArg.getValue().getScheduling().getPreemptible());
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Test(org.junit.Test)

Example 29 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class OpenStackResourceConnector method removeDeleteRequestedInstances.

private CloudStack removeDeleteRequestedInstances(CloudStack stack) {
    List<Group> groups = new ArrayList<>(stack.getGroups().size());
    for (Group group : stack.getGroups()) {
        List<CloudInstance> instances = new ArrayList<>(group.getInstances());
        for (CloudInstance instance : group.getInstances()) {
            if (InstanceStatus.DELETE_REQUESTED == instance.getTemplate().getStatus()) {
                instances.remove(instance);
            }
        }
        groups.add(new Group(group.getName(), group.getType(), instances, group.getSecurity(), null, stack.getInstanceAuthentication(), stack.getInstanceAuthentication().getLoginUserName(), stack.getInstanceAuthentication().getPublicKey()));
    }
    return new CloudStack(groups, stack.getNetwork(), stack.getImage(), stack.getParameters(), stack.getTags(), stack.getTemplate(), stack.getInstanceAuthentication(), stack.getInstanceAuthentication().getLoginUserName(), stack.getInstanceAuthentication().getPublicKey());
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack)

Example 30 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class OpenStackFlavorVerifierTest method createGroup.

private Group createGroup(String flavor) {
    InstanceTemplate template = new InstanceTemplate(flavor, null, null, new ArrayList<>(), null, null, null);
    CloudInstance skeleton = new CloudInstance("id1", template, null);
    Group group = new Group("name", InstanceGroupType.GATEWAY, new ArrayList<>(), null, skeleton, null, "loginUserName", "publicKey");
    return group;
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)

Aggregations

Group (com.sequenceiq.cloudbreak.cloud.model.Group)62 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)37 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)36 Test (org.junit.Test)36 Network (com.sequenceiq.cloudbreak.cloud.model.Network)35 HashMap (java.util.HashMap)35 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)33 Subnet (com.sequenceiq.cloudbreak.cloud.model.Subnet)33 Matchers.containsString (org.hamcrest.Matchers.containsString)20 AzureCredentialView (com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView)17 AzureStackView (com.sequenceiq.cloudbreak.cloud.azure.view.AzureStackView)17 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)15 DescribeSubnetsResult (com.amazonaws.services.ec2.model.DescribeSubnetsResult)15 Vpc (com.amazonaws.services.ec2.model.Vpc)15 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)15 DescribeVpcsResult (com.amazonaws.services.ec2.model.DescribeVpcsResult)14 Location (com.sequenceiq.cloudbreak.cloud.model.Location)14 ArrayList (java.util.ArrayList)14 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)11 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)9