use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class DatabaseServerV4Controller method create.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATABASE_SERVER)
public DatabaseServerStatusV4Response create(AllocateDatabaseServerV4Request request) {
MDCBuilder.addEnvironmentCrn(request.getEnvironmentCrn());
DBStack dbStack = dbStackConverter.convert(request, ThreadBasedUserCrnProvider.getUserCrn());
DBStack savedDBStack = redbeamsCreationService.launchDatabaseServer(dbStack, request.getClusterCrn());
return dbStackToDatabaseServerStatusV4ResponseConverter.convert(savedDBStack);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class AbstractRedbeamsStopAction method createFlowContext.
@Override
protected RedbeamsStopContext createFlowContext(FlowParameters flowParameters, StateContext<RedbeamsStopState, RedbeamsStopEvent> stateContext, P payload) {
DBStack dbStack = dbStackService.getById(payload.getResourceId());
MDCBuilder.buildMdcContext(dbStack);
Location location = location(region(dbStack.getRegion()), availabilityZone(dbStack.getAvailabilityZone()));
String userName = dbStack.getOwnerCrn().getUserId();
String accountId = dbStack.getOwnerCrn().getAccountId();
CloudContext cloudContext = CloudContext.Builder.builder().withId(dbStack.getId()).withName(dbStack.getName()).withCrn(dbStack.getResourceCrn()).withPlatform(dbStack.getCloudPlatform()).withVariant(dbStack.getPlatformVariant()).withLocation(location).withUserName(userName).withAccountId(accountId).build();
Credential credential = credentialService.getCredentialByEnvCrn(dbStack.getEnvironmentId());
CloudCredential cloudCredential = credentialConverter.convert(credential);
DatabaseStack databaseStack = databaseStackConverter.convert(dbStack);
return new RedbeamsStopContext(flowParameters, cloudContext, cloudCredential, databaseStack);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class FillInMemoryStateStoreRestartAction method restart.
@Override
public void restart(FlowParameters flowParameters, String flowChainId, String event, Object payload) {
Payload redbeamsPayload = (Payload) payload;
DBStack dbStack = dbStackService.getById(redbeamsPayload.getResourceId());
if (dbStack != null) {
redbeamsInMemoryStateStoreUpdaterService.update(dbStack.getId(), dbStack.getStatus());
MDCBuilder.buildMdcContext(dbStack);
MDCBuilder.addEnvironmentCrn(dbStack.getEnvironmentId());
MDCBuilder.addAccountId(getAccountId(dbStack));
}
super.restart(flowParameters, flowChainId, event, payload);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class UpdateDatabaseServerRegistrationHandlerTest method doAcceptTestWhenFailureCloudResourceHostnameNotFound.
@Test
void doAcceptTestWhenFailureCloudResourceHostnameNotFound() throws Exception {
DBStack dbStack = getDBStack();
when(dbStackService.getById(anyLong())).thenReturn(dbStack);
UpdateDatabaseServerRegistrationRequest request = getRequest();
when(event.getData()).thenReturn(request);
when(cloudResourceHelper.getResourceTypeFromList(eq(ResourceType.RDS_HOSTNAME), any())).thenReturn(Optional.empty());
when(databaseServerConfigService.getByCrn(CRN)).thenReturn(Optional.of(getOriginalDatabaseServerConfig()));
Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
verifyFailureEvent(selectable);
Exception e = extractException(selectable);
assertThat(e).isInstanceOf(IllegalStateException.class);
assertThat(e).hasMessage("DB hostname not found for allocated database.");
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class UpdateDatabaseServerRegistrationHandlerTest method getDBStack.
private DBStack getDBStack() {
DBStack dbStack = new DBStack();
dbStack.setName(DB_STACK_NAME);
dbStack.setEnvironmentId(ENVIRONMENT_CRN);
dbStack.setResourceCrn(CRN.toString());
return dbStack;
}
Aggregations