use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.
the class AmbariRepositoryVersionService method setBaseRepoURL.
public void setBaseRepoURL(String stackName, long clusterId, Orchestrator orchestrator, StackService ambariClient) throws CloudbreakException {
StackRepoDetails stackRepoDetails = getStackRepoDetails(clusterId, orchestrator);
if (stackRepoDetails != null) {
try {
LOGGER.info("Use specific Ambari repository: {}", stackRepoDetails);
AmbariRepo ambariRepoDetails = clusterComponentConfigProvider.getAmbariRepo(clusterId);
if (isVersionNewerOrEqualThanLimited(ambariRepoDetails::getVersion, AMBARI_VERSION_2_6_0_0)) {
addVersionDefinitionFileToAmbari(stackName, ambariClient, stackRepoDetails);
} else {
setRepositoryVersionOnApi(ambariClient, stackRepoDetails);
}
} catch (HttpResponseException e) {
String exceptionErrorMsg = AmbariClientExceptionUtil.getErrorMessage(e);
String msg = String.format("Cannot use the specified Ambari stack: %s. Error: %s", stackRepoDetails.toString(), exceptionErrorMsg);
throw new AmbariServiceException(msg, e);
}
} else {
LOGGER.info("Using latest HDP repository");
}
}
use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.
the class AmbariStackDetailsJsonToStackRepoDetailsConverter method convert.
@Override
public StackRepoDetails convert(AmbariStackDetailsJson source) {
StackRepoDetails repo = new StackRepoDetails();
Map<String, String> stack = new HashMap<>();
Map<String, String> util = new HashMap<>();
boolean baseRepoRequiredFieldsExists = Stream.of(source.getStackRepoId(), source.getStackBaseURL(), source.getUtilsRepoId(), source.getUtilsBaseURL()).noneMatch(StringUtils::isEmpty);
if (!isVdfRequiredFieldsExists(source) && !baseRepoRequiredFieldsExists) {
String msg = "The 'repositoryVersion', 'versionDefinitionFileUrl' or " + "'stackBaseURL', 'stackRepoId', 'utilsBaseUrl', 'utilsRepoId' fields must be specified!";
throw new BadRequestException(msg);
}
stack.put("repoid", source.getStackRepoId());
util.put("repoid", source.getUtilsRepoId());
if (baseRepoRequiredFieldsExists) {
String stackBaseURL = source.getStackBaseURL();
String utilsBaseURL = source.getUtilsBaseURL();
if (source.getOs() == null) {
stack.put(REDHAT_6, stackBaseURL);
stack.put(REDHAT_7, stackBaseURL);
stack.put(DEBIAN_9, stackBaseURL);
stack.put(UBUNTU_16, stackBaseURL);
util.put(REDHAT_6, utilsBaseURL);
util.put(REDHAT_7, utilsBaseURL);
util.put(DEBIAN_9, utilsBaseURL);
util.put(UBUNTU_16, utilsBaseURL);
} else {
stack.put(source.getOs(), stackBaseURL);
util.put(source.getOs(), utilsBaseURL);
}
}
if (!StringUtils.isEmpty(source.getRepositoryVersion())) {
stack.put(StackRepoDetails.REPOSITORY_VERSION, source.getRepositoryVersion());
stack.put("repoid", source.getStack());
}
if (!StringUtils.isEmpty(source.getVersionDefinitionFileUrl())) {
stack.put(StackRepoDetails.CUSTOM_VDF_REPO_KEY, source.getVersionDefinitionFileUrl());
}
if (!StringUtils.isEmpty(source.getMpackUrl())) {
stack.put(StackRepoDetails.MPACK_TAG, source.getMpackUrl());
}
repo.setStack(stack);
repo.setUtil(util);
repo.setEnableGplRepo(source.isEnableGplRepo());
repo.setVerify(source.getVerify());
repo.setHdpVersion(source.getVersion());
return repo;
}
use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.
the class AmbariStackDetailsJsonToStackRepoDetailsConverterTest method testConvertWhenBaseImage.
@Test
public void testConvertWhenBaseImage() {
StackRepoDetails result = underTest.convert(getRequest("stack/ambari-stack-details-base-image.json"));
assertAllFieldsNotNull(result, Collections.singletonList("knox"));
Assert.assertFalse(result.getStack().containsKey(StackRepoDetails.CUSTOM_VDF_REPO_KEY));
}
use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.
the class AmbariStackDetailsJsonToStackRepoDetailsConverterTest method testConvertWhenVDFProvided.
@Test
public void testConvertWhenVDFProvided() {
AmbariStackDetailsJson request = getRequest("stack/ambari-stack-details-vdf.json");
StackRepoDetails result = underTest.convert(request);
Assert.assertFalse(result.getStack().containsKey(request.getOs()));
}
use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.
the class ClusterToClusterDetailsConverter method convertComponents.
private void convertComponents(ClusterDetails clusterDetails, Cluster cluster) {
AmbariRepo ambariRepo = clusterComponentConfigProvider.getAmbariRepo(cluster.getId());
if (ambariRepo != null) {
clusterDetails.setAmbariVersion(ambariRepo.getVersion());
}
StackRepoDetails stackRepoDetails = clusterComponentConfigProvider.getHDPRepo(cluster.getId());
if (stackRepoDetails != null) {
clusterDetails.setClusterType(stackRepoDetails.getStack().get(StackRepoDetails.REPO_ID_TAG));
clusterDetails.setClusterVersion(stackRepoDetails.getHdpVersion());
}
}
Aggregations