use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method stopTelemetryAction.
@Bean(name = "DOWNSCALE_STOP_TELEMETRY_STATE")
public Action<?, ?> stopTelemetryAction() {
return new AbstractDownscaleAction<>(StackEvent.class) {
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Stopping telemetry");
List<String> repairInstanceIds = getInstanceIds(variables);
StopTelemetryRequest stopTelemetryRequest = new StopTelemetryRequest(stack.getId(), repairInstanceIds);
sendEvent(context, stopTelemetryRequest.selector(), stopTelemetryRequest);
}
};
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method collectResourcesAction.
@Bean(name = "DOWNSCALE_COLLECT_RESOURCES_STATE")
public Action<?, ?> collectResourcesAction() {
return new AbstractDownscaleAction<>(StopTelemetryResponse.class) {
@Override
protected void doExecute(StackContext context, StopTelemetryResponse payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Collecting resources");
List<String> repairInstanceIds = getInstanceIds(variables);
List<CloudResource> cloudResources = getCloudResources(stack);
List<CloudInstance> cloudInstances = getCloudInstances(stack, repairInstanceIds);
DownscaleStackCollectResourcesRequest request = new DownscaleStackCollectResourcesRequest(context.getCloudContext(), context.getCloudCredential(), context.getCloudStack(), cloudResources, cloudInstances);
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method downscaleAddAdditionalHostnamesAction.
@Bean(name = "DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_STATE")
public Action<?, ?> downscaleAddAdditionalHostnamesAction() {
return new AbstractDownscaleAction<>(CollectAdditionalHostnamesResponse.class) {
@Override
protected void doExecute(StackContext context, CollectAdditionalHostnamesResponse payload, Map<Object, Object> variables) throws Exception {
Stack stack = context.getStack();
Set<String> knownHostnamesFromStack = stack.getNotDeletedInstanceMetaDataList().stream().map(InstanceMetaData::getDiscoveryFQDN).filter(Objects::nonNull).collect(Collectors.toSet());
List<String> currentHostsToRemove = getDownscaleHosts(variables);
Set<String> newHostsToRemove = payload.getHostnames().stream().filter(hostname -> !currentHostsToRemove.contains(hostname)).filter(hostname -> !knownHostnamesFromStack.contains(hostname)).collect(Collectors.toSet());
if (isRepair(variables) && !newHostsToRemove.isEmpty()) {
LOGGER.info("Adding hostnames [{}] to the list of hostnames to remove", newHostsToRemove);
List<String> allHostnamesToRemove = new LinkedList<>(currentHostsToRemove);
allHostnamesToRemove.addAll(newHostsToRemove);
setDownscaleHosts(variables, allHostnamesToRemove);
}
sendEvent(context, DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class ValidateCloudStorageHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ValidateCloudStorageRequest> event) {
ValidateCloudStorageRequest request = event.getData();
Selectable response;
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
freeIpaCloudStorageValidationService.validate(stack);
response = new ValidateCloudStorageSuccess(request.getResourceId());
} catch (Exception e) {
LOGGER.error("FreeIPA cloud storage validation failed", e);
response = new ValidateCloudStorageFailed(request.getResourceId(), e);
}
return response;
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class AbstractChangePrimaryGatewayAction method createFlowContext.
@Override
protected ChangePrimaryGatewayContext createFlowContext(FlowParameters flowParameters, StateContext<ChangePrimaryGatewayState, ChangePrimaryGatewayFlowEvent> stateContext, P payload) {
Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
addMdcOperationIdIfPresent(stateContext.getExtendedState().getVariables());
return new ChangePrimaryGatewayContext(flowParameters, stack);
}
Aggregations