use of com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateFailed in project cloudbreak by hortonworks.
the class UpdateUserDataOnProviderHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<UserDataUpdateOnProviderRequest> event) {
UserDataUpdateOnProviderRequest request = event.getData();
try {
LOGGER.info("Updating userData on cloud provider side...");
CloudConnector<?> connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
AuthenticatedContext auth = connector.authentication().authenticate(request.getCloudContext(), request.getCloudCredential());
CloudStack stack = request.getCloudStack();
connector.resources().updateUserData(auth, stack, request.getCloudResources(), request.getUserData());
return new UserDataUpdateOnProviderResult(request.getResourceId());
} catch (Exception e) {
LOGGER.error("Updating user data on provider side has failed", e);
return new UserDataUpdateFailed(UPDATE_USERDATA_FAILED_EVENT.event(), request.getResourceId(), e);
}
}
use of com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateFailed 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);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateFailed in project cloudbreak by hortonworks.
the class UserDataUpdateActions method updateUserDataOnProviderSide.
@Bean(name = "UPDATE_USERDATA_ON_PROVIDER_STATE")
public AbstractUserDataUpdateAction<?> updateUserDataOnProviderSide() {
return new AbstractUserDataUpdateAction<>(UserDataUpdateSuccess.class) {
@Override
protected void doExecute(StackContext context, UserDataUpdateSuccess payload, Map<Object, Object> variables) {
sendEvent(context);
}
@Override
protected Selectable createRequest(StackContext context) {
Stack stack = context.getStack();
String userData = stack.getImage().getUserdata();
List<CloudResource> cloudResources = getCloudResources(stack.getId());
return new UserDataUpdateOnProviderRequest(context.getCloudContext(), context.getCloudCredential(), context.getCloudStack(), cloudResources, userData);
}
@Override
protected Object getFailurePayload(UserDataUpdateSuccess payload, Optional<StackContext> flowContext, Exception ex) {
return new UserDataUpdateFailed(UPDATE_USERDATA_FAILED_EVENT.event(), payload.getResourceId(), ex);
}
private List<CloudResource> getCloudResources(Long stackId) {
List<Resource> resources = resourceService.findAllByStackId(stackId);
return resources.stream().map(r -> resourceToCloudResourceConverter.convert(r)).collect(Collectors.toList());
}
};
}
use of com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateFailed 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);
}
}
Aggregations