Search in sources :

Example 51 with DBStack

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);
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 52 with DBStack

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);
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Credential(com.sequenceiq.redbeams.dto.Credential) DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) DatabaseStack(com.sequenceiq.cloudbreak.cloud.model.DatabaseStack) RedbeamsStopContext(com.sequenceiq.redbeams.flow.redbeams.stop.RedbeamsStopContext) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 53 with DBStack

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);
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) Payload(com.sequenceiq.cloudbreak.common.event.Payload)

Example 54 with DBStack

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.");
}
Also used : UpdateDatabaseServerRegistrationRequest(com.sequenceiq.redbeams.flow.redbeams.provision.event.register.UpdateDatabaseServerRegistrationRequest) DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Test(org.junit.jupiter.api.Test)

Example 55 with DBStack

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;
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack)

Aggregations

DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)83 Test (org.junit.jupiter.api.Test)28 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)17 Test (org.junit.Test)13 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)8 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)7 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)7 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)7 DatabaseStack (com.sequenceiq.cloudbreak.cloud.model.DatabaseStack)7 DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)7 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)6 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)6 Credential (com.sequenceiq.redbeams.dto.Credential)6 RedbeamsFailureEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent)6 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)5 CloudDatabaseServerSslCertificate (com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate)5 RedbeamsEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Location (com.sequenceiq.cloudbreak.cloud.model.Location)4