use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.
the class StackCreationActions method getTlsInfoAction.
@Bean(name = "GET_TLS_INFO_STATE")
public Action<?, ?> getTlsInfoAction() {
return new AbstractStackCreationAction<>(GetTlsInfoResult.class) {
@Override
protected void doExecute(StackCreationContext context, GetTlsInfoResult payload, Map<Object, Object> variables) {
Stack stack = stackCreationService.saveTlsInfo(context, payload.getTlsInfo());
StackCreationContext newContext = new StackCreationContext(context.getFlowParameters(), stack, context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
sendEvent(newContext);
}
@Override
protected Selectable createRequest(StackCreationContext context) {
Stack stack = context.getStack();
InstanceMetaData gatewayMetaData = stack.getPrimaryGatewayInstance();
DetailedEnvironmentResponse environment = environmentClientService.getByCrnAsInternal(stack.getEnvironmentCrn());
CloudInstance gatewayInstance = metadataConverter.convert(gatewayMetaData, environment, stack.getStackAuthentication());
return new GetSSHFingerprintsRequest<GetSSHFingerprintsResult>(context.getCloudContext(), context.getCloudCredential(), gatewayInstance);
}
};
}
use of com.sequenceiq.cloudbreak.domain.stack.Stack 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);
}
};
}
use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.
the class StackStopRestartAction method restart.
@Override
public void restart(FlowParameters flowParameters, String flowChainId, String event, Object payload) {
Payload stackPayload = (Payload) payload;
Stack stack = stackService.getById(stackPayload.getResourceId());
MDCBuilder.buildMdcContext(stack);
super.restart(flowParameters, flowChainId, event, payload);
}
use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.
the class InstanceTerminationService method finishInstanceTermination.
public void finishInstanceTermination(InstanceTerminationContext context, RemoveInstanceResult payload) throws TransactionService.TransactionExecutionException {
Stack stack = context.getStack();
List<InstanceMetaData> instanceMetaDataList = context.getInstanceMetaDataList();
Set<Long> privateIds = instanceMetaDataList.stream().map(InstanceMetaData::getPrivateId).collect(Collectors.toSet());
stackScalingService.updateInstancesToTerminated(privateIds, stack.getId());
LOGGER.debug("Terminate instance result: {}", payload);
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.AVAILABLE, "Instance removed");
flowMessageService.fireEventAndLog(stack.getId(), AVAILABLE.name(), STACK_REMOVING_INSTANCE_FINISHED);
}
use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.
the class AbstractAwsVariantMigrationAction method createFlowContext.
@Override
protected AwsVariantMigrationFlowContext createFlowContext(FlowParameters flowParameters, StateContext<AwsVariantMigrationFlowState, AwsVariantMigrationEvent> stateContext, P payload) {
Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
stack.setResources(new HashSet<>(resourceService.getAllByStackId(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).withWorkspaceId(stack.getWorkspace().getId()).withAccountId(Crn.safeFromString(stack.getResourceCrn()).getAccountId()).withTenantId(stack.getTenant().getId()).build();
CloudCredential cloudCredential = stackUtil.getCloudCredential(stack);
CloudStack cloudStack = cloudStackConverter.convert(stack);
return new AwsVariantMigrationFlowContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack);
}
Aggregations