use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method determineCdhRepoConfig.
private Set<ClouderaManagerProduct> determineCdhRepoConfig(Cluster cluster, List<Component> stackCdhRepoConfig, String osType, String blueprintCdhVersion, String imageCatalogName) throws CloudbreakImageCatalogException {
if (Objects.isNull(stackCdhRepoConfig) || stackCdhRepoConfig.isEmpty()) {
DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(cluster, blueprintCdhVersion, osType, imageCatalogName);
Map<String, String> stack = defaultCDHInfo.getRepo().getStack();
Set<ClouderaManagerProduct> cdhProduct = Set.of(new ClouderaManagerProduct().withVersion(defaultCDHInfo.getVersion()).withName(stack.get("repoid").split("-")[0]).withParcel(stack.get(osType)));
LOGGER.debug("Determined CDH product: {}", cdhProduct);
return cdhProduct;
} else {
Set<ClouderaManagerProduct> products = stackCdhRepoConfig.stream().map(Component::getAttributes).map(json -> json.getSilent(ClouderaManagerProduct.class)).collect(Collectors.toSet());
return filterParcelsIfNecessary(cluster, products);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.Stack 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.domain.stack.Stack in project cloudbreak by hortonworks.
the class ClusterCommonService method put.
public FlowIdentifier put(String crn, UpdateClusterV4Request updateJson) {
Stack stack = stackService.getByCrnWithLists(crn);
Long stackId = stack.getId();
MDCBuilder.buildMdcContext(stack);
UserNamePasswordV4Request userNamePasswordJson = updateJson.getUserNamePassword();
FlowIdentifier flowIdentifier;
if (userNamePasswordJson != null) {
flowIdentifier = clusterManagerUserNamePasswordChange(stack, userNamePasswordJson);
} else if (updateJson.getStatus() != null) {
LOGGER.debug("Cluster status update request received. Stack id: {}, status: {} ", stackId, updateJson.getStatus());
flowIdentifier = clusterOperationService.updateStatus(stackId, updateJson.getStatus());
} else if (updateJson.getBlueprintName() != null && updateJson.getHostgroups() != null && stack.getCluster().isCreateFailed()) {
LOGGER.debug("Cluster rebuild request received. Stack id: {}", stackId);
try {
flowIdentifier = recreateCluster(stack, updateJson);
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
} else if (updateJson.getHostGroupAdjustment() != null) {
environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.upscalable());
flowIdentifier = clusterHostgroupAdjustmentChange(stackId, updateJson, stack);
} else {
LOGGER.info("Invalid cluster update request received. Stack id: {}", stackId);
throw new BadRequestException("Invalid update cluster request!");
}
return flowIdentifier;
}
use of com.sequenceiq.cloudbreak.domain.stack.Stack 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")));
}
use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.
the class ClusterCommonService method refreshRecipes.
public UpdateRecipesV4Response refreshRecipes(NameOrCrn nameOrCrn, Long workspaceId, UpdateRecipesV4Request request) {
Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
MDCBuilder.buildMdcContext(stack);
return updateRecipeService.refreshRecipesForCluster(workspaceId, stack, request.getHostGroupRecipes());
}
Aggregations