use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method getDefaultCDHInfo.
private DefaultCDHInfo getDefaultCDHInfo(Long workspaceId, String blueprintCdhVersion, String osType, String cloudPlatform, String imageCatalogName) throws CloudbreakImageCatalogException {
DefaultCDHInfo defaultCDHInfo = null;
Map<String, ImageBasedDefaultCDHInfo> entries = imageBasedDefaultCDHEntries.getEntries(workspaceId, cloudPlatform, imageCatalogName);
if (blueprintCdhVersion != null && entries.containsKey(blueprintCdhVersion)) {
defaultCDHInfo = entries.get(blueprintCdhVersion).getDefaultCDHInfo();
}
if (defaultCDHInfo == null) {
defaultCDHInfo = entries.entrySet().stream().filter(e -> Objects.nonNull(e.getValue().getDefaultCDHInfo().getRepo().getStack().get(osType))).max(ImageBasedDefaultCDHEntries.IMAGE_BASED_CDH_ENTRY_COMPARATOR).orElseThrow(notFound("Default Product Info with OS type:", osType)).getValue().getDefaultCDHInfo();
}
return defaultCDHInfo;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class BlueprintLoaderService method collectDeviationOfExistingAndCachedBlueprints.
private Set<Blueprint> collectDeviationOfExistingAndCachedBlueprints(Collection<Blueprint> blueprintsInDatabase) {
LOGGER.debug("Collecting blueprints which are missing from the cache.");
Set<Blueprint> diff = new HashSet<>();
for (Blueprint blueprint : blueprintsInDatabase) {
if (blueprint.getStatus().equals(DEFAULT) && defaultBlueprintCache.defaultBlueprints().entrySet().stream().noneMatch(bp -> bp.getKey().equals(blueprint.getName()))) {
diff.add(blueprint);
}
}
LOGGER.debug("Finished to collect the default blueprints which are missing: {}.", diff);
return diff;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class BlueprintLoaderService method deleteOldDefaults.
public void deleteOldDefaults(Set<Blueprint> blueprintsInDatabase) {
List<Blueprint> deletableDefaults = blueprintsInDatabase.stream().filter(blueprint -> blueprint.getStatus().equals(DEFAULT)).filter(blueprint -> !defaultBlueprintCache.defaultBlueprints().containsKey(blueprint.getName())).filter(blueprint -> clusterTemplateService.getTemplatesByBlueprint(blueprint).isEmpty()).collect(Collectors.toList());
LOGGER.info("Put old default blueprints to DEFAULT_DELETED: " + deletableDefaults);
for (Blueprint blueprint : deletableDefaults) {
blueprint.setStatus(DEFAULT_DELETED);
}
blueprintService.pureSaveAll(deletableDefaults);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method getDefaultCDHInfo.
private DefaultCDHInfo getDefaultCDHInfo(Cluster cluster, String blueprintCdhVersion, String osType, String imageCatalogName) throws CloudbreakImageCatalogException {
DefaultCDHInfo defaultCDHInfo = null;
Stack stack = cluster.getStack();
ImageCatalogPlatform platformString = platformStringTransformer.getPlatformStringForImageCatalog(stack.getCloudPlatform(), stack.getPlatformVariant());
Map<String, ImageBasedDefaultCDHInfo> entries = imageBasedDefaultCDHEntries.getEntries(cluster.getWorkspace().getId(), platformString, imageCatalogName);
if (blueprintCdhVersion != null && entries.containsKey(blueprintCdhVersion)) {
defaultCDHInfo = entries.get(blueprintCdhVersion).getDefaultCDHInfo();
}
if (defaultCDHInfo == null) {
defaultCDHInfo = entries.entrySet().stream().filter(e -> Objects.nonNull(e.getValue().getDefaultCDHInfo().getRepo().getStack().get(osType))).max(ImageBasedDefaultCDHEntries.IMAGE_BASED_CDH_ENTRY_COMPARATOR).orElseThrow(notFound("Default Product Info with OS type:", osType)).getValue().getDefaultCDHInfo();
}
return defaultCDHInfo;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class ClusterCommonService method getHostNamesAsIniString.
/**
* Get cluster host details (ips + cluster name) - ini format
*
* @param stack stack object that is used to fill the cluster details ini
* @param loginUser ssh username that will be used as a default user in the inventory
* @return Ini file content in string
*/
public String getHostNamesAsIniString(Stack stack, String loginUser) {
Cluster cluster = stack.getCluster();
String clusterName = cluster.getName();
String serverHost = cluster.getClusterManagerIp();
List<InstanceMetaData> agentHostsSet = instanceMetaDataService.getAllInstanceMetadataByStackId(stack.getId()).stream().filter(i -> i.getInstanceStatus() != InstanceStatus.TERMINATED).collect(Collectors.toList());
if (agentHostsSet.isEmpty()) {
throw new NotFoundException(String.format("Not found any agent hosts (yet) for cluster '%s'", cluster.getId()));
}
String agentHosts = agentHostsSet.stream().map(InstanceMetaData::getPublicIpWrapper).collect(Collectors.joining("\n"));
List<String> hostGroupHostsStrings = agentHostsSet.stream().collect(Collectors.groupingBy(InstanceMetaData::getInstanceGroupName)).entrySet().stream().map(s -> addSectionWithBody(s.getKey(), s.getValue().stream().map(InstanceMetaData::getPublicIpWrapper).collect(Collectors.joining("\n")))).collect(Collectors.toList());
return String.join("\n", addSectionWithBody("cluster", "name=" + clusterName), addSectionWithBody("server", serverHost), String.join("\n", hostGroupHostsStrings), addSectionWithBody("agent", agentHosts), addSectionWithBody("all:vars", String.join("\n", String.format("ansible_ssh_user=%s", loginUser), "ansible_ssh_common_args='-o StrictHostKeyChecking=no'", "ansible_become=yes")));
}
Aggregations