Search in sources :

Example 21 with Stack

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);
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) StopTelemetryRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 22 with Stack

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);
        }
    };
}
Also used : StopTelemetryResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryResponse) DownscaleStackCollectResourcesRequest(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesRequest) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 23 with Stack

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()));
        }
    };
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) DOWNSCALE_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_FINISHED_EVENT) Action(org.springframework.statemachine.action.Action) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_FINISHED_EVENT) LoggerFactory(org.slf4j.LoggerFactory) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) ClientErrorException(javax.ws.rs.ClientErrorException) CollectAdditionalHostnamesRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesRequest) RemoveHostsFromOrchestrationSuccess(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationSuccess) DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FINISHED_EVENT) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) Map(java.util.Map) ClusterProxyUpdateRegistrationFailedToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.ClusterProxyUpdateRegistrationFailedToDownscaleFailureEventConverter) ClusterProxyUpdateRegistrationRequest(com.sequenceiq.freeipa.flow.freeipa.provision.event.clusterproxy.ClusterProxyUpdateRegistrationRequest) DownscaleStackCollectResourcesRequest(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesRequest) EnvironmentEndpoint(com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint) PayloadConverter(com.sequenceiq.flow.core.PayloadConverter) RemoveReplicationAgreementsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest) RevokeCertsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsResponse) UPDATE_METADATA_FOR_DELETION_REQUEST_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.UPDATE_METADATA_FOR_DELETION_REQUEST_FINISHED_EVENT) FailureDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails) Set(java.util.Set) WebApplicationExceptionMessageExtractor(com.sequenceiq.cloudbreak.common.exception.WebApplicationExceptionMessageExtractor) FlowParameters(com.sequenceiq.flow.core.FlowParameters) DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT) Collectors(java.util.stream.Collectors) RevokeCertsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsRequest) STARTING_DOWNSCALE_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.STARTING_DOWNSCALE_FINISHED_EVENT) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) UpdateDnsSoaRecordsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest) RemoveDnsResponseToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.RemoveDnsResponseToDownscaleFailureEventConverter) Objects(java.util.Objects) Configuration(org.springframework.context.annotation.Configuration) DownscaleStackCollectResourcesResultToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.DownscaleStackCollectResourcesResultToDownscaleFailureEventConverter) DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FINISHED_EVENT) List(java.util.List) DownscaleStackCollectResourcesResult(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesResult) StackUpdater(com.sequenceiq.freeipa.service.stack.StackUpdater) Flow(com.sequenceiq.flow.core.Flow) CollectAdditionalHostnamesResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesResponse) KerberosConfigUpdateService(com.sequenceiq.freeipa.service.config.KerberosConfigUpdateService) InstanceGroupService(com.sequenceiq.freeipa.service.stack.instance.InstanceGroupService) RevokeCertsResponseToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.RevokeCertsResponseToDownscaleFailureEventConverter) DownscaleStackResultToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.DownscaleStackResultToDownscaleFailureEventConverter) RemoveServersResponseToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.RemoveServersResponseToDownscaleFailureEventConverter) StopTelemetryRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest) DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FAILED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FAILED_EVENT) FAIL_HANDLED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.FAIL_HANDLED_EVENT) UPDATE_METADATA_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.UPDATE_METADATA_FINISHED_EVENT) StopTelemetryResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryResponse) DownscaleStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackResult) RemoveServersResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse) UpdateDnsSoaRecordsResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) StateContext(org.springframework.statemachine.StateContext) DownscaleFlowEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) LinkedList(java.util.LinkedList) RemoveServersRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersRequest) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) RemoveHostsFromOrchestrationRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationRequest) Logger(org.slf4j.Logger) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ClusterProxyUpdateRegistrationSuccess(com.sequenceiq.freeipa.flow.freeipa.provision.event.clusterproxy.ClusterProxyUpdateRegistrationSuccess) DownscaleState(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleState) RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) OperationService(com.sequenceiq.freeipa.service.operation.OperationService) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) TerminationService(com.sequenceiq.freeipa.flow.stack.termination.action.TerminationService) DownscaleEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent) SuccessDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails) RemoveHostsResponseToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.RemoveHostsResponseToDownscaleFailureEventConverter) Bean(org.springframework.context.annotation.Bean) RemoveDnsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest) Collections(java.util.Collections) DownscaleStackRequest(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackRequest) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) CollectAdditionalHostnamesResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesResponse) Map(java.util.Map) LinkedList(java.util.LinkedList) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 24 with Stack

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;
}
Also used : ValidateCloudStorageRequest(com.sequenceiq.freeipa.flow.freeipa.provision.event.cloudstorage.ValidateCloudStorageRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ValidateCloudStorageFailed(com.sequenceiq.freeipa.flow.freeipa.provision.event.cloudstorage.ValidateCloudStorageFailed) ValidateCloudStorageSuccess(com.sequenceiq.freeipa.flow.freeipa.provision.event.cloudstorage.ValidateCloudStorageSuccess) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 25 with Stack

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);
}
Also used : ChangePrimaryGatewayContext(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayContext) Stack(com.sequenceiq.freeipa.entity.Stack)

Aggregations

Stack (com.sequenceiq.freeipa.entity.Stack)468 Test (org.junit.jupiter.api.Test)237 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)107 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)63 Map (java.util.Map)63 Bean (org.springframework.context.annotation.Bean)50 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)45 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)41 List (java.util.List)37 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)34 Inject (javax.inject.Inject)30 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)29 Collectors (java.util.stream.Collectors)29 Logger (org.slf4j.Logger)29 LoggerFactory (org.slf4j.LoggerFactory)29 Set (java.util.Set)28 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)25 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)25 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)24 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)23