use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class InstanceGroupToInstanceGroupResponseConverter method convert.
public InstanceGroupResponse convert(InstanceGroup source, Boolean includeAllInstances) {
InstanceGroupResponse instanceGroupResponse = new InstanceGroupResponse();
instanceGroupResponse.setName(source.getGroupName());
if (source.getTemplate() != null) {
instanceGroupResponse.setInstanceTemplate(templateResponseConverter.convert(source.getTemplate()));
}
Set<InstanceMetaData> metaDataSet = includeAllInstances ? source.getInstanceMetaDataSet() : source.getNotTerminatedInstanceMetaDataSet();
instanceGroupResponse.setMetaData(metaDataConverter.convert(metaDataSet));
if (source.getSecurityGroup() != null) {
instanceGroupResponse.setSecurityGroup(securityGroupConverter.convert(source.getSecurityGroup()));
}
if (source.getInstanceGroupNetwork() != null) {
instanceGroupResponse.setNetwork(instanceGroupNetworkConverter.convert(source.getInstanceGroupNetwork()));
}
instanceGroupResponse.setNodeCount(source.getNodeCount());
instanceGroupResponse.setName(source.getGroupName());
return instanceGroupResponse;
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData 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.InstanceMetaData in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayActions method clusterProxyRegistrationAction.
@Bean(name = "CHANGE_PRIMARY_GATEWAY_CLUSTERPROXY_REGISTRATION_STATE")
public Action<?, ?> clusterProxyRegistrationAction() {
return new AbstractChangePrimaryGatewayAction<>(StackEvent.class) {
@Override
protected void doExecute(ChangePrimaryGatewayContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Changing the primary gateway cluster proxy registration");
List<String> repairInstanceIds = getInstanceIds(variables);
ClusterProxyUpdateRegistrationRequest request;
if (Objects.nonNull(repairInstanceIds)) {
List<String> instanceIdsToRegister = stack.getNotDeletedInstanceMetaDataList().stream().map(InstanceMetaData::getInstanceId).filter(instanceId -> !repairInstanceIds.contains(instanceId)).collect(Collectors.toList());
LOGGER.debug("When changing the primary gateway cluster proxy in stack {}, [{}] will be reregistered", stack.getId(), instanceIdsToRegister);
request = new ClusterProxyUpdateRegistrationRequest(stack.getId(), instanceIdsToRegister);
} else {
LOGGER.debug("When changing the primary gateway cluster proxy in stack {}, the whole stack will be reregistered", stack.getId());
request = new ClusterProxyUpdateRegistrationRequest(stack.getId());
}
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class DiagnosticsPreFlightCheckHandler method executeOperation.
@Override
public Selectable executeOperation(HandlerEvent<DiagnosticsCollectionEvent> event) throws Exception {
DiagnosticsCollectionEvent data = event.getData();
Long resourceId = data.getResourceId();
String resourceCrn = data.getResourceCrn();
DiagnosticParameters parameters = data.getParameters();
Stack stack = stackService.getByIdWithListsInTransaction(resourceId);
Set<InstanceMetaData> instanceMetaDataSet = instanceMetaDataService.findNotTerminatedForStack(resourceId);
instanceMetaDataSet.stream().filter(im -> im.getInstanceMetadataType() == InstanceMetadataType.GATEWAY_PRIMARY).forEach(instance -> executeNetworkReport(stack, instance));
return DiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_DIAGNOSTICS_INIT_EVENT.selector()).withParameters(parameters).build();
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class StackStatusTest method setUp.
void setUp(int instanceCount) throws Exception {
underTest.setLocalId(STACK_ID.toString());
stack = new Stack();
stack.setId(STACK_ID);
StackStatus stackStatus = new StackStatus();
stackStatus.setDetailedStackStatus(DetailedStackStatus.PROVISIONED);
stack.setStackStatus(stackStatus);
when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
when(flowLogService.isOtherFlowRunning(STACK_ID)).thenReturn(false);
InstanceGroup instanceGroup1 = new InstanceGroup();
Set<InstanceMetaData> instances = new HashSet<>();
if (instanceCount >= 1) {
instances.add(createInstance(INSTANCE_1));
}
if (instanceCount >= 2) {
instances.add(createInstance(INSTANCE_2));
}
if (instanceCount >= 3) {
instances.add(createInstance(INSTANCE_3));
}
instanceGroup1.setInstanceMetaData(instances);
stack.setInstanceGroups(Set.of(instanceGroup1));
notTerminatedInstances = instances;
when(instanceMetaDataService.findNotTerminatedForStack(STACK_ID)).thenReturn(notTerminatedInstances);
rpcResponse = new RPCResponse<>();
when(freeIpaInstanceHealthDetailsService.checkFreeIpaHealth(eq(stack), any())).thenReturn(rpcResponse);
}
Aggregations