use of com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse in project cloudbreak by hortonworks.
the class SdxReactorFlowManagerTest method testSdxBackupOnUpgradeAzureSupported.
@Test
void testSdxBackupOnUpgradeAzureSupported() {
sdxCluster = getValidSdxCluster("7.2.2");
sdxCluster.setRangerRazEnabled(false);
DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
detailedEnvironmentResponse.setCloudPlatform("AZURE");
when(environmentClientService.getByName(anyString())).thenReturn(detailedEnvironmentResponse);
when(environmentClientService.getBackupLocation(ENV_CRN)).thenReturn(BACKUP_LOCATION);
when(entitlementService.isDatalakeBackupOnUpgradeEnabled(any())).thenReturn(true);
when(datalakeDrConfig.isConfigured()).thenReturn(true);
sdxCluster.setCloudStorageFileSystemType(FileSystemType.ADLS_GEN_2);
try {
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.triggerDatalakeRuntimeUpgradeFlow(sdxCluster, IMAGE_ID, SdxUpgradeReplaceVms.DISABLED, SKIP_BACKUP));
} catch (Exception ignored) {
}
verify(reactor, times(1)).notify(eq(DatalakeUpgradeFlowChainStartEvent.DATALAKE_UPGRADE_FLOW_CHAIN_EVENT), any(Event.class));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse in project cloudbreak by hortonworks.
the class SdxReactorFlowManagerTest method testSdxBackupOnUpgradeAwsSupported.
@Test
void testSdxBackupOnUpgradeAwsSupported() {
sdxCluster = getValidSdxCluster("7.2.10");
sdxCluster.setRangerRazEnabled(false);
sdxCluster.setCloudStorageFileSystemType(FileSystemType.S3);
DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
detailedEnvironmentResponse.setCloudPlatform("AWS");
when(environmentClientService.getByName(anyString())).thenReturn(detailedEnvironmentResponse);
when(environmentClientService.getBackupLocation(ENV_CRN)).thenReturn(BACKUP_LOCATION);
when(entitlementService.isDatalakeBackupOnUpgradeEnabled(any())).thenReturn(true);
when(datalakeDrConfig.isConfigured()).thenReturn(true);
try {
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.triggerDatalakeRuntimeUpgradeFlow(sdxCluster, IMAGE_ID, SdxUpgradeReplaceVms.DISABLED, SKIP_BACKUP));
} catch (Exception ignored) {
}
verify(reactor, times(1)).notify(eq(DatalakeUpgradeFlowChainStartEvent.DATALAKE_UPGRADE_FLOW_CHAIN_EVENT), any(Event.class));
reset(reactor);
sdxCluster = getValidSdxCluster("7.2.1");
sdxCluster.setCloudStorageFileSystemType(FileSystemType.S3);
try {
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.triggerDatalakeRuntimeUpgradeFlow(sdxCluster, IMAGE_ID, SdxUpgradeReplaceVms.DISABLED, SKIP_BACKUP));
} catch (Exception ignored) {
}
verify(reactor, times(1)).notify(eq(DatalakeUpgradeFlowChainStartEvent.DATALAKE_UPGRADE_FLOW_CHAIN_EVENT), any(Event.class));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse in project cloudbreak by hortonworks.
the class SdxReactorFlowManagerTest method testSdxBackupOnUpgradeForMockPlatformWithEmptyFileSystemType.
@Test
void testSdxBackupOnUpgradeForMockPlatformWithEmptyFileSystemType() {
DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
detailedEnvironmentResponse.setCloudPlatform("MOCK");
sdxCluster = getValidSdxCluster("7.2.9");
sdxCluster.setRangerRazEnabled(false);
sdxCluster.setCloudStorageFileSystemType(null);
when(environmentClientService.getByName(anyString())).thenReturn(detailedEnvironmentResponse);
when(environmentClientService.getBackupLocation(ENV_CRN)).thenReturn(BACKUP_LOCATION);
when(entitlementService.isDatalakeBackupOnUpgradeEnabled(any())).thenReturn(true);
when(datalakeDrConfig.isConfigured()).thenReturn(true);
try {
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.triggerDatalakeRuntimeUpgradeFlow(sdxCluster, IMAGE_ID, SdxUpgradeReplaceVms.DISABLED, SKIP_BACKUP));
} catch (Exception ignored) {
}
verify(reactor, times(1)).notify(eq(DatalakeUpgradeFlowChainStartEvent.DATALAKE_UPGRADE_FLOW_CHAIN_EVENT), any(Event.class));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse in project cloudbreak by hortonworks.
the class StartExternalDatabaseHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<StartExternalDatabaseRequest> event) {
LOGGER.debug("In StartExternalDatabaseHandler.doAccept");
StartExternalDatabaseRequest request = event.getData();
Stack stack = stackService.getById(request.getResourceId());
DatabaseAvailabilityType externalDatabase = ObjectUtils.defaultIfNull(stack.getExternalDatabaseCreationType(), DatabaseAvailabilityType.NONE);
LOGGER.debug("External database: {} for stack {}", externalDatabase.name(), stack.getName());
LOGGER.debug("Getting environment CRN for stack {}", stack.getName());
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(stack.getEnvironmentCrn());
Selectable result;
try {
if (StackType.WORKLOAD != stack.getType()) {
LOGGER.debug("External database start in Cloudbreak service is required for WORKLOAD stacks only.");
result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
} else if (externalDatabase.isEmbedded()) {
LOGGER.info("External database for stack {} is not requested. Start is not possible.", stack.getName());
result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
} else if (!externalDatabaseConfig.isExternalDatabasePauseSupportedFor(CloudPlatform.valueOf(environment.getCloudPlatform()))) {
LOGGER.debug("External database pause is not supported for '{}' cloud platform.", environment.getCloudPlatform());
result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
} else {
LOGGER.debug("Updating stack {} status from {} to {}", stack.getName(), stack.getStatus().name(), DetailedStackStatus.EXTERNAL_DATABASE_START_IN_PROGRESS.name());
stackUpdaterService.updateStatus(stack.getId(), DetailedStackStatus.EXTERNAL_DATABASE_START_IN_PROGRESS, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_START_COMMANCED, "External database start in progress");
startService.startDatabase(stack.getCluster(), externalDatabase, environment);
LOGGER.debug("Updating stack {} status from {} to {}", stack.getName(), stack.getStatus().name(), DetailedStackStatus.EXTERNAL_DATABASE_START_FINISHED.name());
stackUpdaterService.updateStatus(stack.getId(), DetailedStackStatus.EXTERNAL_DATABASE_START_FINISHED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_START_FINISHED, "External database start finished");
result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), stack.getCluster().getDatabaseServerCrn());
}
} catch (UserBreakException e) {
LOGGER.error("Database 'start' polling exited before timeout. Cause: ", e);
result = startFailedEvent(stack, e);
} catch (PollerStoppedException e) {
LOGGER.error(String.format("Database 'start' poller stopped for stack: %s", stack.getName()), e);
result = startFailedEvent(stack, e);
} catch (PollerException e) {
LOGGER.error(String.format("Database 'start' polling failed for stack: %s", stack.getName()), e);
result = startFailedEvent(stack, e);
}
return result;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse in project cloudbreak by hortonworks.
the class StackCreationActions method getTlsInfoAction.
@Bean(name = "GET_TLS_INFO_STATE")
public Action<?, ?> getTlsInfoAction() {
return new AbstractStackCreationAction<>(GetTlsInfoResult.class) {
@Override
protected void doExecute(StackCreationContext context, GetTlsInfoResult payload, Map<Object, Object> variables) {
Stack stack = stackCreationService.saveTlsInfo(context, payload.getTlsInfo());
StackCreationContext newContext = new StackCreationContext(context.getFlowParameters(), stack, context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
sendEvent(newContext);
}
@Override
protected Selectable createRequest(StackCreationContext context) {
Stack stack = context.getStack();
InstanceMetaData gatewayMetaData = stack.getPrimaryGatewayInstance();
DetailedEnvironmentResponse environment = environmentClientService.getByCrnAsInternal(stack.getEnvironmentCrn());
CloudInstance gatewayInstance = metadataConverter.convert(gatewayMetaData, environment, stack.getStackAuthentication());
return new GetSSHFingerprintsRequest<GetSSHFingerprintsResult>(context.getCloudContext(), context.getCloudCredential(), gatewayInstance);
}
};
}
Aggregations