Search in sources :

Example 21 with FlexSubscription

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

the class FlexSubscriptionServiceTest method testCreateShouldThrowBadRequestWhenSubscriptionExistsWithTheSameName.

@Test(expected = BadRequestException.class)
public void testCreateShouldThrowBadRequestWhenSubscriptionExistsWithTheSameName() {
    when(flexRepo.countByNameAndAccount(anyString(), anyString())).thenReturn(1L);
    FlexSubscription subscription = getFlexSubscription("testFlexSubscription", "FLEX-000000000");
    underTest.create(subscription);
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) Test(org.junit.Test)

Example 22 with FlexSubscription

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

the class UsageGeneratorService method openNewUsage.

public CloudbreakUsage openNewUsage(Stack stack, String instanceType, Integer instanceNum, String groupName, TemporalAccessor started) {
    CloudbreakUsage usage = new CloudbreakUsage();
    usage.setStackUuid(stack.getUuid());
    usage.setParentUuid(cloudbreakNodeConfig.getInstanceUUID());
    usage.setOwner(stack.getOwner());
    usage.setAccount(stack.getAccount());
    usage.setProvider(stack.cloudPlatform());
    usage.setRegion(stack.getRegion());
    usage.setAvailabilityZone(stack.getAvailabilityZone());
    usage.setInstanceHours(0L);
    usage.setCosts(0.0);
    Date day = Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant());
    usage.setDay(day);
    usage.setStackId(stack.getId());
    usage.setStackName(stack.getName());
    usage.setInstanceType(instanceType);
    usage.setInstanceNum(instanceNum);
    usage.setPeak(instanceNum);
    usage.setInstanceGroup(groupName);
    if (stack.getCluster() != null && stack.getCluster().getBlueprint() != null) {
        Blueprint bp = stack.getCluster().getBlueprint();
        usage.setBlueprintId(bp.getId());
        usage.setBlueprintName(bp.getAmbariName());
    }
    usage.setPeriodStarted(Date.from(LocalDateTime.from(started).atZone(ZoneId.systemDefault()).toInstant()));
    usage.setStatus(UsageStatus.OPEN);
    FlexSubscription flexSubscription = stack.getFlexSubscription();
    if (flexSubscription != null && flexSubscription.getSmartSenseSubscription() != null) {
        usage.setFlexId(flexSubscription.getSubscriptionId());
        usage.setSmartSenseId(flexSubscription.getSmartSenseSubscription().getSubscriptionId());
    }
    return usage;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) Date(java.util.Date) LocalDate(java.time.LocalDate) CloudbreakUsage(com.sequenceiq.cloudbreak.domain.CloudbreakUsage)

Aggregations

FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)22 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)8 Test (org.junit.Test)6 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 SmartSenseSubscription (com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)2 FlexUsageCbdInstanceJson (com.sequenceiq.cloudbreak.api.model.flex.FlexUsageCbdInstanceJson)1 BlueprintProcessingException (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException)1 BlueprintView (com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView)1 FileSystemConfigurationView (com.sequenceiq.cloudbreak.blueprint.template.views.FileSystemConfigurationView)1 HostgroupView (com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView)1 BlueprintStackInfo (com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo)1 GeneralClusterConfigs (com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 CloudbreakUsage (com.sequenceiq.cloudbreak.domain.CloudbreakUsage)1 KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)1 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)1 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)1 IOException (java.io.IOException)1