Search in sources :

Example 6 with RedbeamsContext

use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsContext in project cloudbreak by hortonworks.

the class RedbeamsProvisionActions method updateDatabaseServerRegistration.

@Bean(name = "UPDATE_DATABASE_SERVER_REGISTRATION_STATE")
public Action<?, ?> updateDatabaseServerRegistration() {
    return new AbstractRedbeamsProvisionAction<>(AllocateDatabaseServerSuccess.class) {

        @Override
        protected void doExecute(RedbeamsContext context, AllocateDatabaseServerSuccess payload, Map<Object, Object> variables) {
            dbStackStatusUpdater.updateStatus(payload.getResourceId(), DetailedDBStackStatus.PROVISIONED);
            List<CloudResourceStatus> dbResourcesList = dbResourceService.getAllAsCloudResourceStatus(payload.getResourceId());
            sendEvent(context, new UpdateDatabaseServerRegistrationRequest(context.getCloudContext(), context.getCloudCredential(), context.getDatabaseStack(), ResourceLists.transform(dbResourcesList)));
        }
    };
}
Also used : UpdateDatabaseServerRegistrationRequest(com.sequenceiq.redbeams.flow.redbeams.provision.event.register.UpdateDatabaseServerRegistrationRequest) AllocateDatabaseServerSuccess(com.sequenceiq.redbeams.flow.redbeams.provision.event.allocate.AllocateDatabaseServerSuccess) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) AbstractRedbeamsProvisionAction(com.sequenceiq.redbeams.flow.redbeams.provision.AbstractRedbeamsProvisionAction) RedbeamsContext(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsContext) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 7 with RedbeamsContext

use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsContext in project cloudbreak by hortonworks.

the class AbstractRedbeamsTerminationActionTest method testCreateFlowContext.

@Test
public void testCreateFlowContext() {
    when(dbStackService.findById(Long.valueOf(1L))).thenReturn(Optional.of(dbStack));
    when(credentialService.getCredentialByEnvCrn("myenv")).thenReturn(credential);
    when(credentialConverter.convert(credential)).thenReturn(cloudCredential);
    when(databaseStackConverter.convert(dbStack)).thenReturn(databaseStack);
    RedbeamsContext ctx = underTest.createFlowContext(flowParameters, stateContext, new RedbeamsEvent(1L));
    assertEquals(dbStack.getId(), ctx.getCloudContext().getId());
    assertEquals(dbStack.getName(), ctx.getCloudContext().getName());
    assertEquals(Platform.platform(dbStack.getCloudPlatform()), ctx.getCloudContext().getPlatform());
    assertEquals(Variant.variant(dbStack.getPlatformVariant()), ctx.getCloudContext().getVariant());
    assertEquals(Location.location(Region.region(dbStack.getRegion()), AvailabilityZone.availabilityZone(dbStack.getAvailabilityZone())), ctx.getCloudContext().getLocation());
    assertEquals(dbStack.getOwnerCrn().getAccountId(), ctx.getCloudContext().getAccountId());
    assertEquals(cloudCredential, ctx.getCloudCredential());
    assertEquals(databaseStack, ctx.getDatabaseStack());
}
Also used : RedbeamsEvent(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent) RedbeamsContext(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsContext) Test(org.junit.Test)

Aggregations

RedbeamsContext (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsContext)7 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)4 Map (java.util.Map)3 Bean (org.springframework.context.annotation.Bean)3 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)2 DatabaseStack (com.sequenceiq.cloudbreak.cloud.model.DatabaseStack)2 Location (com.sequenceiq.cloudbreak.cloud.model.Location)2 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)2 Flow (com.sequenceiq.flow.core.Flow)2 FlowParameters (com.sequenceiq.flow.core.FlowParameters)2 Credential (com.sequenceiq.redbeams.dto.Credential)2 RedbeamsEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent)2 RedbeamsFailureEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent)2 AbstractRedbeamsProvisionAction (com.sequenceiq.redbeams.flow.redbeams.provision.AbstractRedbeamsProvisionAction)2 StateContext (org.springframework.statemachine.StateContext)2 CloudResourceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus)1 RedbeamsException (com.sequenceiq.redbeams.exception.RedbeamsException)1 AllocateDatabaseServerSuccess (com.sequenceiq.redbeams.flow.redbeams.provision.event.allocate.AllocateDatabaseServerSuccess)1 UpdateDatabaseServerRegistrationRequest (com.sequenceiq.redbeams.flow.redbeams.provision.event.register.UpdateDatabaseServerRegistrationRequest)1