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;
}
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);
}
}
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);
}
}
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);
}
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;
}
Aggregations