use of com.cloudera.api.swagger.model.ApiClusterTemplate in project cloudbreak by hortonworks.
the class ClouderaManagerSetupService method installCluster.
@Override
public void installCluster(String template) {
Cluster cluster = stack.getCluster();
try {
Optional<ApiCluster> cmCluster = getCmClusterByName(cluster.getName());
boolean prewarmed = isPrewarmed(cluster.getId());
Optional<ClusterCommand> importCommand = clusterCommandRepository.findTopByClusterIdAndClusterCommandType(cluster.getId(), ClusterCommandType.IMPORT_CLUSTER);
if (cmCluster.isEmpty() || importCommand.isEmpty()) {
ApiClusterTemplate apiClusterTemplate = JsonUtil.readValue(template, ApiClusterTemplate.class);
cluster.setExtendedBlueprintText(getExtendedBlueprintText(apiClusterTemplate));
ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient);
LOGGER.info("Generated Cloudera cluster template: {}", AnonymizerUtil.anonymize(template));
// addRepositories - if true the parcels repositories in the cluster template
// will be added.
ApiCommand apiCommand = clouderaManagerResourceApi.importClusterTemplate(calculateAddRepositories(apiClusterTemplate, prewarmed), apiClusterTemplate);
ClusterCommand clusterCommand = new ClusterCommand();
clusterCommand.setClusterId(cluster.getId());
clusterCommand.setCommandId(apiCommand.getId());
clusterCommand.setClusterCommandType(ClusterCommandType.IMPORT_CLUSTER);
importCommand = Optional.of(clusterCommandRepository.save(clusterCommand));
LOGGER.debug("Cloudera cluster template has been submitted, cluster install is in progress");
}
importCommand.ifPresent(cmd -> clouderaManagerPollingServiceProvider.startPollingCmTemplateInstallation(stack, apiClient, cmd.getCommandId()));
} catch (ApiException e) {
String msg = "Installation of CDP with Cloudera Manager has failed: " + extractMessage(e);
throw new ClouderaManagerOperationFailedException(msg, e);
} catch (CloudStorageConfigurationFailedException e) {
LOGGER.info("Error while configuring cloud storage. Message: {}", e.getMessage(), e);
throw new ClouderaManagerOperationFailedException(mapStorageError(e, stack.getResourceCrn(), stack.cloudPlatform(), cluster), e);
} catch (Exception e) {
throw mapException(e);
}
}
use of com.cloudera.api.swagger.model.ApiClusterTemplate in project cloudbreak by hortonworks.
the class ClouderaManagerSetupService method prepareTemplate.
@Override
public String prepareTemplate(Map<HostGroup, List<InstanceMetaData>> instanceMetaDataByHostGroup, TemplatePreparationObject templatePreparationObject, String sdxContext, String sdxCrn, KerberosConfig kerberosConfig) {
Long clusterId = stack.getCluster().getId();
try {
Set<InstanceMetaData> instances = instanceMetaDataByHostGroup.values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
waitForHosts(instances);
String sdxContextName = Optional.ofNullable(sdxContext).map(this::setupRemoteDataContext).orElse(null);
ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentProvider.getClouderaManagerRepoDetails(clusterId);
ApiClusterTemplate apiClusterTemplate = getCmTemplate(templatePreparationObject, sdxContextName, instanceMetaDataByHostGroup, clouderaManagerRepoDetails, clusterId);
return getExtendedBlueprintText(apiClusterTemplate);
} catch (CancellationException cancellationException) {
throw cancellationException;
} catch (Exception e) {
throw mapException(e);
}
}
use of com.cloudera.api.swagger.model.ApiClusterTemplate in project cloudbreak by hortonworks.
the class ClouderaManagerShowBlueprintTest method checkValidClouderaManagerTemplate.
private StackTestDto checkValidClouderaManagerTemplate(TestContext testContext, StackTestDto stackTestDto, CloudbreakClient cloudbreakClient) {
String extendedBlueprintText = stackTestDto.getResponse().getCluster().getExtendedBlueprintText();
ApiClusterTemplate cmTemplate = parseCmTemplate(extendedBlueprintText);
checkHostNumberGreaterThanZero(cmTemplate);
return stackTestDto;
}
use of com.cloudera.api.swagger.model.ApiClusterTemplate in project cloudbreak by hortonworks.
the class CentralCmTemplateUpdaterTest method configsAreInjected.
@Test
public void configsAreInjected() {
List<ApiClusterTemplateConfig> serviceConfigs = List.of(config("service_config_name", "service_config_value"));
List<ApiClusterTemplateConfig> roleConfigs = List.of(config("role_config_name", "role_config_value"));
ReflectionTestUtils.setField(cmTemplateConfigInjectorProcessor, "injectors", List.of(new CmTemplateConfigInjector() {
@Override
public List<ApiClusterTemplateConfig> getServiceConfigs(ApiClusterTemplateService service, TemplatePreparationObject source) {
return serviceConfigs;
}
@Override
public List<ApiClusterTemplateConfig> getRoleConfigs(ApiClusterTemplateRoleConfigGroup roleConfigGroup, ApiClusterTemplateService service, TemplatePreparationObject source) {
return roleConfigs;
}
}));
when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/namenode-ha.bp"));
ApiClusterTemplate generated = testGetCmTemplate();
assertMatchesBlueprintAtPath("output/namenode-ha-injected.bp", generated);
}
use of com.cloudera.api.swagger.model.ApiClusterTemplate in project cloudbreak by hortonworks.
the class CentralCmTemplateUpdaterTest method getCmTemplateNoMetastoreWithTemplateParams.
@Test
public void getCmTemplateNoMetastoreWithTemplateParams() {
when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-fixparam.bp"));
ApiClusterTemplate generated = testGetCmTemplate();
assertMatchesBlueprintAtPath("output/clouderamanager-fixparam.bp", generated);
}
Aggregations