use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method removeInstancesAction.
@Bean(name = "DOWNSCALE_REMOVE_INSTANCES_STATE")
public Action<?, ?> removeInstancesAction() {
return new AbstractDownscaleAction<>(DownscaleStackCollectResourcesResult.class) {
@Override
protected void doExecute(StackContext context, DownscaleStackCollectResourcesResult payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Decommissioning instances");
List<String> repairInstanceIds = getInstanceIds(variables);
List<CloudResource> cloudResources = getCloudResources(stack);
List<CloudInstance> cloudInstances = getNonTerminatedCloudInstances(stack, repairInstanceIds);
DownscaleStackRequest request = new DownscaleStackRequest(context.getCloudContext(), context.getCloudCredential(), context.getCloudStack(), cloudResources, cloudInstances, payload.getResourcesToScale());
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method removeServersAction.
@Bean(name = "DOWNSCALE_REMOVE_SERVERS_STATE")
public Action<?, ?> removeServersAction() {
return new AbstractDownscaleAction<>(DownscaleStackResult.class) {
@Override
protected void doExecute(StackContext context, DownscaleStackResult payload, Map<Object, Object> variables) {
CleanupEvent cleanupEvent = buildCleanupEvent(context, getDownscaleHosts(variables));
stackUpdater.updateStackStatus(context.getStack().getId(), getInProgressStatus(variables), "Removing servers");
RemoveServersRequest request = new RemoveServersRequest(cleanupEvent);
sendEvent(context, request);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method removeHostsFromOrchestrationAction.
@Bean(name = "DOWNSCALE_REMOVE_HOSTS_FROM_ORCHESTRATION_STATE")
public Action<?, ?> removeHostsFromOrchestrationAction() {
return new AbstractDownscaleAction<>(UpdateDnsSoaRecordsResponse.class) {
@Override
protected void doExecute(StackContext context, UpdateDnsSoaRecordsResponse payload, Map<Object, Object> variables) {
stackUpdater.updateStackStatus(context.getStack().getId(), getInProgressStatus(variables), "Removing hosts from orchestration");
CleanupEvent cleanupEvent = buildCleanupEvent(context, getDownscaleHosts(variables));
RemoveHostsFromOrchestrationRequest request = new RemoveHostsFromOrchestrationRequest(cleanupEvent);
sendEvent(context, request);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method updateKerberosNameserversConfigAction.
@Bean(name = "DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_STATE")
public Action<?, ?> updateKerberosNameserversConfigAction() {
return new AbstractDownscaleAction<>(StackEvent.class) {
@Inject
private KerberosConfigUpdateService kerberosConfigUpdateService;
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Updating kerberos nameserver config");
try {
kerberosConfigUpdateService.updateNameservers(stack.getId());
sendEvent(context, DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
} catch (Exception e) {
LOGGER.error("Failed to update the kerberos nameserver config", e);
sendEvent(context, DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FAILED_EVENT.selector(), new DownscaleFailureEvent(stack.getId(), "Updating kerberos nameserver config", Set.of(), Map.of(), e));
}
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method startingDownscaleAction.
@Bean(name = "STARTING_DOWNSCALE_STATE")
public Action<?, ?> startingDownscaleAction() {
return new AbstractDownscaleAction<>(DownscaleEvent.class) {
@Override
protected void doExecute(StackContext context, DownscaleEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
List<String> instanceIds = payload.getInstanceIds();
setInstanceIds(variables, instanceIds);
String operationId = payload.getOperationId();
setOperationId(variables, operationId);
List<String> fqdns = getInstanceMetadataFromStack(stack, instanceIds).stream().map(InstanceMetaData::getDiscoveryFQDN).filter(Objects::nonNull).collect(Collectors.toList());
setDownscaleHosts(variables, fqdns);
setRepair(variables, payload.isRepair());
setChainedAction(variables, payload.isChained());
setFinalChain(variables, payload.isFinalChain());
setInstanceCountByGroup(variables, payload.getInstanceCountByGroup());
LOGGER.info("Starting downscale {}", payload);
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Starting downscale");
sendEvent(context, STARTING_DOWNSCALE_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
Aggregations