use of com.sequenceiq.freeipa.flow.stack.StackContext 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.StackContext in project cloudbreak by hortonworks.
the class AbstractImageChangeAction method createFlowContext.
@Override
protected StackContext createFlowContext(FlowParameters flowParameters, StateContext<ImageChangeState, ImageChangeEvents> stateContext, P payload) {
Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
CloudContext cloudContext = CloudContext.Builder.builder().withId(stack.getId()).withName(stack.getName()).withCrn(stack.getResourceCrn()).withPlatform(stack.getCloudPlatform()).withVariant(stack.getPlatformvariant()).withLocation(location).withUserName(stack.getOwner()).withAccountId(stack.getAccountId()).build();
CloudCredential cloudCredential = credentialConverter.convert(credentialService.getCredentialByEnvCrn(stack.getEnvironmentCrn()));
CloudStack cloudStack = cloudStackConverter.convert(stack);
return new StackContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack);
}
Aggregations