Search in sources :

Example 1 with UserDataUpdateRequest

use of com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateRequest in project cloudbreak by hortonworks.

the class UserDataUpdateActions method updateUserData.

@Bean(name = "UPDATE_USERDATA_STATE")
public AbstractUserDataUpdateAction<?> updateUserData() {
    return new AbstractUserDataUpdateAction<>(UserDataUpdateRequest.class) {

        @Override
        protected void doExecute(StackContext context, UserDataUpdateRequest payload, Map<Object, Object> variables) throws Exception {
            LOGGER.info("Recreate userdata for new freeipa instances");
            setOperationId(variables, payload.getOperationId());
            setChainedAction(variables, payload.isChained());
            setFinalChain(variables, payload.isFinal());
            sendEvent(context, new UserDataUpdateRequest(context.getStack().getId(), payload.getOldTunnel()));
        }

        @Override
        protected Object getFailurePayload(UserDataUpdateRequest payload, Optional<StackContext> flowContext, Exception ex) {
            return new UserDataUpdateFailed(payload.getResourceId(), ex);
        }
    };
}
Also used : Optional(java.util.Optional) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) UserDataUpdateRequest(com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateRequest) UserDataUpdateFailed(com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateFailed) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with UserDataUpdateRequest

use of com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateRequest in project cloudbreak by hortonworks.

the class UpgradeCcmFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(UpgradeCcmFlowChainTriggerEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new UpgradeCcmTriggerEvent(UpgradeCcmStateSelector.UPGRADE_CCM_TRIGGER_EVENT.event(), event.getOperationId(), event.getResourceId(), event.getOldTunnel(), event.accepted()).withIsChained(true).withIsFinal(false));
    flowEventChain.add(new UserDataUpdateRequest(UpdateUserDataEvents.UPDATE_USERDATA_TRIGGER_EVENT.event(), event.getResourceId(), event.getOldTunnel()).withOperationId(event.getOperationId()).withIsChained(true).withIsFinal(true));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UserDataUpdateRequest(com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateRequest) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) UpgradeCcmTriggerEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmTriggerEvent)

Example 3 with UserDataUpdateRequest

use of com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateRequest in project cloudbreak by hortonworks.

the class UpdateUserDataHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UserDataUpdateRequest> event) {
    UserDataUpdateRequest request = event.getData();
    try {
        LOGGER.info("Updating userData in the stack's current used image entity...");
        switch(request.getOldTunnel()) {
            case CCM:
                LOGGER.debug("Regenerating user data from request payload.");
                userDataService.regenerateUserData(request.getResourceId());
                break;
            case CCMV2:
                LOGGER.debug("Updating Jumpgate flag only.");
                userDataService.updateJumpgateFlagOnly(request.getResourceId());
                break;
            default:
                throw new IllegalStateException(String.format("Upgrade from %s is not implemented", request.getOldTunnel()));
        }
        return new UserDataUpdateSuccess(request.getResourceId());
    } catch (Exception e) {
        LOGGER.error("Updating user data in the stack's image entity has failed", e);
        return new UserDataUpdateFailed(UPDATE_USERDATA_FAILED_EVENT.event(), request.getResourceId(), e);
    }
}
Also used : UserDataUpdateRequest(com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateRequest) UserDataUpdateSuccess(com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateSuccess) UserDataUpdateFailed(com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateFailed)

Aggregations

UserDataUpdateRequest (com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateRequest)3 UserDataUpdateFailed (com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateFailed)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 UserDataUpdateSuccess (com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateSuccess)1 UpgradeCcmTriggerEvent (com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmTriggerEvent)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 Bean (org.springframework.context.annotation.Bean)1