use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.
the class UpgradeServiceTest method mockClouderaManagerRepoDetails.
private void mockClouderaManagerRepoDetails() {
ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
clouderaManagerRepo.setBaseUrl("cm-base-url");
when(clusterComponentConfigProvider.getClouderaManagerRepoDetails(1L)).thenReturn(clouderaManagerRepo);
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.
the class UpgradeServiceTest method shouldReturnNewImageName.
@Test
public void shouldReturnNewImageName() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
Stack stack = getStack();
Image image = getImage("id-1");
setUpMocks(stack, image, true, "id-1", "id-2");
Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStartResult = Result.success(new HashMap<>());
when(clusterRepairService.repairWithDryRun(1L)).thenReturn(repairStartResult);
ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
clouderaManagerRepo.setBaseUrl("cm-base-url");
when(clusterComponentConfigProvider.getClouderaManagerRepoDetails(1L)).thenReturn(clouderaManagerRepo);
when(stackService.getByNameOrCrnInWorkspace(eq(ofName), eq(WORKSPACE_ID))).thenReturn(stack);
UpgradeOptionV4Response result = underTest.getOsUpgradeOptionByStackNameOrCrn(WORKSPACE_ID, ofName, user);
verify(clusterRepairService).repairWithDryRun(eq(stack.getId()));
verify(distroXV1Endpoint).list(eq(null), eq("env-crn"));
verify(componentConfigProviderService).getImage(1L);
verify(imageService).determineImageFromCatalog(eq(WORKSPACE_ID), captor.capture(), eq("aws"), eq("AWS"), eq(stack.getCluster().getBlueprint()), eq(false), eq(false), eq(user), any());
assertThat(result.getUpgrade().getImageName()).isEqualTo("id-2");
assertThat(result.getReason()).isEqualTo(null);
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.
the class ClusterManagerUpgradeService method createSaltConfig.
private SaltConfig createSaltConfig(Stack stack, Long clusterId, GatewayConfig primaryGatewayConfig) {
Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
ClouderaManagerRepo clouderaManagerRepo = clusterComponentConfigProvider.getClouderaManagerRepoDetails(clusterId);
Optional<String> license = clusterHostServiceRunner.decoratePillarWithClouderaManagerLicense(stack.getId(), servicePillar);
clusterHostServiceRunner.decoratePillarWithClouderaManagerRepo(clouderaManagerRepo, servicePillar, license);
servicePillar.putAll(clusterHostServiceRunner.createPillarWithClouderaManagerSettings(clouderaManagerRepo, stack, primaryGatewayConfig));
csdParcelDecorator.decoratePillarWithCsdParcels(stack, servicePillar);
return new SaltConfig(servicePillar);
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.
the class ClouderaManagerDeregisterService method deregisterServices.
public void deregisterServices(HttpClientConfig clientConfig, Stack stack, Optional<DatalakeDto> datalakeDto) {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentConfigProvider.getClouderaManagerRepoDetails(cluster.getId());
try {
CmTemplateProcessor cmTemplateProcessor = cmTemplateProcessorFactory.get(stack.getCluster().getBlueprint().getBlueprintText());
if (CMRepositoryVersionUtil.isRangerTearDownSupported(clouderaManagerRepoDetails)) {
if (datalakeDto.isPresent()) {
LOGGER.info("The current cluster {} is a Data Hub cluster so teardown REQUIRED.", stack.getName());
DatalakeDto datalake = datalakeDto.get();
ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(datalakeClient(datalake));
clustersResourceApi.tearDownWorkloadCluster(datalake.getName(), stack.getName());
} else {
LOGGER.info("The current cluster {} is a Data Lake cluster so teardown NOT_REQUIRED.", stack.getName());
}
} else {
ApiClient client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
if (cmTemplateProcessor.isCMComponentExistsInBlueprint(COMPONENT_NIFI_REGISTRY_SERVER)) {
LOGGER.info("The current cluster {} contains NIFI_REGISTRY_SERVER and ranger teardown not supported. " + "CDP will call RemoveRangerRepo command.", stack.getName());
clouderaManagerApiFactory.getServicesResourceApi(client).serviceCommandByName(stack.getName(), "RemoveRangerRepo", SERVICE_NIFIREGISTRY);
}
if (cmTemplateProcessor.isCMComponentExistsInBlueprint(COMPONENT_NIFI_NODE)) {
LOGGER.info("The current cluster {} contains NIFI_NODE and ranger teardown not supported. " + "CDP will call RemoveRangerRepo command.", stack.getName());
clouderaManagerApiFactory.getServicesResourceApi(client).serviceCommandByName(stack.getName(), "RemoveRangerRepo", SERVICE_NIFI);
}
}
} catch (Exception e) {
LOGGER.warn("Couldn't remove services. This has to be done manually." + " It's possible that CM or the instance is not running. Notification is sent to the UI.", e);
cloudbreakEventService.fireCloudbreakEvent(stack.getId(), stack.getStatus().name(), ResourceEvent.CLUSTER_CM_SECURITY_GROUP_TOO_STRICT, List.of(e.getMessage()));
}
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.
the class ClouderaManagerSetupService method initApiClient.
@PostConstruct
public void initApiClient() throws ClusterClientInitException {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
try {
ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentProvider.getClouderaManagerRepoDetails(cluster.getId());
if (isVersionNewerOrEqualThanLimited(clouderaManagerRepoDetails::getVersion, CLOUDERAMANAGER_VERSION_7_1_0)) {
apiClient = clouderaManagerApiClientProvider.getV40Client(stack.getGatewayPort(), user, password, clientConfig);
} else {
apiClient = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
}
} catch (ClouderaManagerClientInitException e) {
throw new ClusterClientInitException(e);
}
}
Aggregations