Search in sources :

Example 6 with FlexSubscription

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

the class FlexUsageGenerator method getFlexUsageCbdInstance.

private FlexUsageCbdInstanceJson getFlexUsageCbdInstance(Long fromDate) {
    FlexUsageCbdInstanceJson cbdComponentInstance = new FlexUsageCbdInstanceJson();
    cbdComponentInstance.setGuid(cloudbreakNodeConfig.getInstanceUUID());
    cbdComponentInstance.setPeakUsage(1);
    cbdComponentInstance.setProvider(cbInstanceProvider);
    cbdComponentInstance.setRegion(cbInstanceRegion);
    String creationTime = "";
    if (controllerCreated != null) {
        creationTime = formatInstant(Instant.ofEpochMilli(bumpToMillis(controllerCreated)), FLEX_TIME_ZONE_FORMAT_PATTERN);
    }
    cbdComponentInstance.setCreationTime(creationTime);
    FlexSubscription usedForController = Optional.ofNullable(flexSubscriptionRepository.findFirstByUsedForController(true)).orElse(flexSubscriptionRepository.findFirstByIsDefault(true));
    cbdComponentInstance.setFlexSubscriptionId(usedForController == null ? "" : usedForController.getSubscriptionId());
    cbdComponentInstance.setUsageDate(formatInstant(Instant.ofEpochMilli(fromDate), FLEX_USAGE_DAY_FORMAT_PATTERN));
    return cbdComponentInstance;
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) FlexUsageCbdInstanceJson(com.sequenceiq.cloudbreak.api.model.flex.FlexUsageCbdInstanceJson)

Example 7 with FlexSubscription

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

the class StackRequestToBlueprintPreparationObjectConverter method convert.

@Override
public BlueprintPreparationObject convert(StackV2Request source) {
    try {
        IdentityUser identityUser = userDetailsService.getDetails(source.getOwner(), UserFilterField.USERID);
        FlexSubscription flexSubscription = getFlexSubscription(source);
        String smartsenseSubscriptionId = getSmartsenseSubscriptionId(source, flexSubscription);
        KerberosConfig kerberosConfig = getKerberosConfig(source);
        LdapConfig ldapConfig = getLdapConfig(source, identityUser);
        FileSystemConfigurationView fileSystemConfigurationView = getFileSystemConfigurationView(source);
        Set<RDSConfig> rdsConfigs = getRdsConfigs(source, identityUser);
        Blueprint blueprint = getBlueprint(source, identityUser);
        BlueprintStackInfo blueprintStackInfo = stackInfoService.blueprintStackInfo(blueprint.getBlueprintText());
        Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
        BlueprintView blueprintView = new BlueprintView(blueprint.getBlueprintText(), blueprintStackInfo.getVersion(), blueprintStackInfo.getType());
        GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, identityUser);
        return BlueprintPreparationObject.Builder.builder().withFlexSubscription(flexSubscription).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withBlueprintView(blueprintView).withStackRepoDetailsHdpVersion(blueprintStackInfo.getVersion()).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withSmartSenseSubscriptionId(smartsenseSubscriptionId).withLdapConfig(ldapConfig).withKerberosConfig(kerberosConfig).build();
    } catch (BlueprintProcessingException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    } catch (IOException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    }
}
Also used : BlueprintProcessingException(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException) GeneralClusterConfigs(com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BlueprintView(com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) IOException(java.io.IOException) IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) BlueprintStackInfo(com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) FileSystemConfigurationView(com.sequenceiq.cloudbreak.blueprint.template.views.FileSystemConfigurationView) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView)

Example 8 with FlexSubscription

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

the class StackDecorator method prepareFlexSubscription.

private void prepareFlexSubscription(Stack subject, Long flexId) {
    if (flexId != null) {
        FlexSubscription flexSubscription = flexSubscriptionService.findOneById(flexId);
        subject.setFlexSubscription(flexSubscription);
    }
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Example 9 with FlexSubscription

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

the class FlexSubscriptionService method delete.

public void delete(Long id) {
    FlexSubscription subscription = flexRepo.findById(id);
    delete(subscription);
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Example 10 with FlexSubscription

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

the class FlexSubscriptionService method create.

public FlexSubscription create(FlexSubscription subscription) {
    if (!flexRepo.countByNameAndAccount(subscription.getName(), subscription.getAccount()).equals(0L)) {
        throw new BadRequestException(String.format("The name: '%s' has already taken by an other FlexSubscription.", subscription.getName()));
    } else if (!flexRepo.countBySubscriptionId(subscription.getSubscriptionId()).equals(0L)) {
        throw new BadRequestException(String.format("The subscriptionId: '%s' has already taken by an other FlexSubscription.", subscription.getSubscriptionId()));
    }
    subscription = flexRepo.save(subscription);
    List<FlexSubscription> allInAccount = flexRepo.findAllByAccount(subscription.getAccount());
    setSubscriptionAsDefaultIfNeeded(subscription, allInAccount);
    updateSubscriptionsDefaultFlagsIfNeeded(subscription, allInAccount);
    LOGGER.info("Flex subscription has been created: {}", subscription);
    return subscription;
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException)

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