use of com.sequenceiq.freeipa.flow.stack.update.event.UserDataUpdateSuccess 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.UserDataUpdateSuccess 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