Search in sources :

Example 16 with StackEvent

use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.

the class HostMetadataSetupHandler method accept.

@Override
public void accept(Event<HostMetadataSetupRequest> event) {
    StackEvent request = event.getData();
    LOGGER.debug("Host metadata setup request {}", request);
    Selectable response;
    try {
        hostMetadataSetup.setupHostMetadata(request.getResourceId());
        response = new HostMetadataSetupSuccess(request.getResourceId());
    } catch (Exception e) {
        LOGGER.debug("Host metadata setup failed", e);
        response = new HostMetadataSetupFailed(request.getResourceId(), e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) HostMetadataSetupFailed(com.sequenceiq.freeipa.flow.freeipa.provision.event.hostmetadatasetup.HostMetadataSetupFailed) HostMetadataSetupSuccess(com.sequenceiq.freeipa.flow.freeipa.provision.event.hostmetadatasetup.HostMetadataSetupSuccess)

Example 17 with StackEvent

use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.

the class InstallFreeIpaServicesHandler method accept.

@Override
public void accept(Event<InstallFreeIpaServicesRequest> event) {
    StackEvent request = event.getData();
    Selectable response;
    try {
        freeIpaInstallService.installFreeIpa(request.getResourceId());
        response = new InstallFreeIpaServicesSuccess(request.getResourceId());
    } catch (Exception e) {
        LOGGER.error("FreeIPA service install failed", e);
        response = new InstallFreeIpaServicesFailed(request.getResourceId(), e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) InstallFreeIpaServicesSuccess(com.sequenceiq.freeipa.flow.freeipa.provision.event.services.InstallFreeIpaServicesSuccess) InstallFreeIpaServicesFailed(com.sequenceiq.freeipa.flow.freeipa.provision.event.services.InstallFreeIpaServicesFailed)

Example 18 with StackEvent

use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.

the class ChangePrimaryGatewayActions method startingAction.

@Bean(name = "CHANGE_PRIMARY_GATEWAY_STATE_STARTING")
public Action<?, ?> startingAction() {
    return new AbstractChangePrimaryGatewayAction<>(ChangePrimaryGatewayEvent.class) {

        @Override
        protected void doExecute(ChangePrimaryGatewayContext context, ChangePrimaryGatewayEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            String operationId = payload.getOperationId();
            setOperationId(variables, operationId);
            setInstanceIds(variables, payload.getRepairInstaceIds());
            setFinalChain(variables, payload.isFinalChain());
            LOGGER.info("Starting to change the primary gateway {}", payload);
            stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Starting to change the primary gateway");
            sendEvent(context, CHANGE_PRIMARY_GATEWAY_STARTING_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) ChangePrimaryGatewayContext(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayContext) Map(java.util.Map) ChangePrimaryGatewayEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayEvent) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 19 with StackEvent

use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.

the class UpgradeCcmActions method finished.

@Bean(name = UPGRADE_CCM_FINISHED_STATE_NAME)
public Action<?, ?> finished() {
    return new AbstractUpgradeCcmEventAction() {

        @Override
        protected void doExecute(UpgradeCcmContext context, UpgradeCcmEvent payload, Map<Object, Object> variables) {
            LOGGER.info("FreeIPA CCM upgrade finished {}", payload);
            upgradeCcmService.finishedState(context.getStack().getId());
            completeOperation(context.getStack().getAccountId(), context.getStack().getEnvironmentCrn(), variables);
            sendEvent(context, UPGRADE_CCM_FINISHED_EVENT.event(), new StackEvent(context.getStack().getId()));
        }
    };
}
Also used : UpgradeCcmEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmEvent) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 20 with StackEvent

use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.

the class ProvisionFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(StackEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new StackEvent(StackProvisionEvent.START_CREATION_EVENT.event(), event.getResourceId(), event.accepted()));
    flowEventChain.add(new StackEvent(FreeIpaProvisionEvent.FREEIPA_PROVISION_EVENT.event(), event.getResourceId()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Aggregations

StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)54 Map (java.util.Map)40 Bean (org.springframework.context.annotation.Bean)40 Stack (com.sequenceiq.freeipa.entity.Stack)38 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)28 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)17 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)12 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)11 OperationService (com.sequenceiq.freeipa.service.operation.OperationService)11 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)10 ClientErrorException (javax.ws.rs.ClientErrorException)10 EnvironmentEndpoint (com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint)9 Flow (com.sequenceiq.flow.core.Flow)9 FlowParameters (com.sequenceiq.flow.core.FlowParameters)8 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 Inject (javax.inject.Inject)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 Configuration (org.springframework.context.annotation.Configuration)8