use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackStartStopContext in project cloudbreak by hortonworks.
the class StackStartActions method stackStartAction.
@Bean(name = "START_STATE")
public Action<?, ?> stackStartAction() {
return new AbstractStackStartAction<>(StackEvent.class) {
@Override
protected void doExecute(StackStartStopContext context, StackEvent payload, Map<Object, Object> variables) {
stackStartStopService.startStackStart(context);
sendEvent(context);
}
@Override
protected Selectable createRequest(StackStartStopContext context) {
Stack stack = context.getStack();
LOGGER.debug("Assembling start request for stack: {}", stack);
List<CloudInstance> cloudInstances = instanceMetaDataToCloudInstanceConverter.convert(stack.getNotDeletedAndNotZombieInstanceMetaDataList(), stack.getEnvironmentCrn(), stack.getStackAuthentication());
List<CloudResource> resources = stack.getResources().stream().map(s -> resourceToCloudResourceConverter.convert(s)).collect(Collectors.toList());
cloudInstances.forEach(instance -> context.getStack().getParameters().forEach(instance::putParameter));
return new StartInstancesRequest(context.getCloudContext(), context.getCloudCredential(), resources, cloudInstances);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackStartStopContext in project cloudbreak by hortonworks.
the class StackStopActions method stackStopAction.
@Bean(name = "STOP_STATE")
public Action<?, ?> stackStopAction() {
return new AbstractStackStopAction<>(StackEvent.class) {
@Override
protected void doExecute(StackStartStopContext context, StackEvent payload, Map<Object, Object> variables) {
stackStartStopService.startStackStop(context);
sendEvent(context);
}
@Override
protected Selectable createRequest(StackStartStopContext context) {
Stack stack = context.getStack();
List<CloudInstance> cloudInstances = instanceMetaDataToCloudInstanceConverter.convert(context.getInstanceMetaData(), stack.getEnvironmentCrn(), stack.getStackAuthentication());
List<CloudResource> cloudResources = stack.getResources().stream().map(s -> resourceToCloudResourceConverter.convert(s)).collect(Collectors.toList());
cloudInstances.forEach(instance -> stack.getParameters().forEach(instance::putParameter));
return new StopInstancesRequest(context.getCloudContext(), context.getCloudCredential(), cloudResources, cloudInstances);
}
};
}
Aggregations