Search in sources :

Example 1 with ClusterProxyRegistrationSuccess

use of com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationSuccess in project cloudbreak by hortonworks.

the class FreeIpaUpscaleActions method bootstrappingMachinesAction.

@Bean(name = "UPSCALE_BOOTSTRAPPING_MACHINES_STATE")
public Action<?, ?> bootstrappingMachinesAction() {
    return new AbstractUpscaleAction<>(ClusterProxyRegistrationSuccess.class) {

        @Override
        protected void doExecute(StackContext context, ClusterProxyRegistrationSuccess payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Bootstrapping machines");
            BootstrapMachinesRequest request = new BootstrapMachinesRequest(stack.getId());
            sendEvent(context, request.selector(), request);
        }
    };
}
Also used : StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) ClusterProxyRegistrationSuccess(com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationSuccess) BootstrapMachinesRequest(com.sequenceiq.freeipa.flow.freeipa.provision.event.bootstrap.BootstrapMachinesRequest) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Bean(org.springframework.context.annotation.Bean)

Example 2 with ClusterProxyRegistrationSuccess

use of com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationSuccess in project cloudbreak by hortonworks.

the class ClusterProxyRegistrationHandler method accept.

@Override
public void accept(Event<ClusterProxyRegistrationRequest> event) {
    ClusterProxyRegistrationRequest request = event.getData();
    try {
        Set<InstanceMetaData> ims = instanceMetaDataService.findNotTerminatedForStack(request.getResourceId());
        if (ims.isEmpty()) {
            LOGGER.error("Cluster Proxy registration has failed. No available instances  found for FreeIPA");
            ClusterProxyRegistrationFailed response = new ClusterProxyRegistrationFailed(request.getResourceId(), new NotFoundException("Cluster Proxy registration has failed. No available instances  found for FreeIPA"));
            sendEvent(response, event);
        } else {
            boolean allInstanceHasFqdn = ims.stream().allMatch(im -> StringUtils.isNotBlank(im.getDiscoveryFQDN()));
            if (allInstanceHasFqdn) {
                LOGGER.info("All instances already have FQDN set, register all to cluster proxy");
                clusterProxyService.registerFreeIpa(request.getResourceId());
            } else {
                LOGGER.info("Instances missing FQDN, fallback to PGW registration");
                clusterProxyService.registerFreeIpaForBootstrap(request.getResourceId());
            }
            sendEvent(new ClusterProxyRegistrationSuccess(request.getResourceId()), event);
        }
    } catch (Exception e) {
        LOGGER.error("Cluster Proxy bootstrap registration has failed", e);
        sendEvent(new ClusterProxyRegistrationFailed(request.getResourceId(), e), event);
    }
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) ClusterProxyRegistrationFailed(com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationFailed) ClusterProxyRegistrationRequest(com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationRequest) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) ClusterProxyRegistrationSuccess(com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationSuccess) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException)

Example 3 with ClusterProxyRegistrationSuccess

use of com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationSuccess in project cloudbreak by hortonworks.

the class ClusterProxyRegistrationHandlerTest method validateResourceId.

private void validateResourceId(ArgumentCaptor<Event> eventCaptor) {
    ClusterProxyRegistrationSuccess event = (ClusterProxyRegistrationSuccess) eventCaptor.getValue().getData();
    assertEquals(1L, event.getResourceId());
}
Also used : ClusterProxyRegistrationSuccess(com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationSuccess)

Example 4 with ClusterProxyRegistrationSuccess

use of com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationSuccess in project cloudbreak by hortonworks.

the class FreeIpaUpscaleActions method updateClusterProxyRegistrationPreBootstrapAction.

@Bean(name = "UPSCALE_UPDATE_CLUSTERPROXY_REGISTRATION_PRE_BOOTSTRAP_STATE")
public Action<?, ?> updateClusterProxyRegistrationPreBootstrapAction() {
    return new AbstractUpscaleAction<>(StackEvent.class) {

        @Override
        protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Update cluster proxy registration before bootstrap");
            List<String> instanceIds = getInstanceIds(variables);
            Set<InstanceMetaData> newInstances = instanceMetaDataService.getByInstanceIds(stack.getId(), instanceIds);
            boolean allNewInstanceHasFqdn = newInstances.stream().allMatch(im -> StringUtils.isNotBlank(im.getDiscoveryFQDN()));
            Selectable event = allNewInstanceHasFqdn ? new ClusterProxyRegistrationRequest(stack.getId()) : new ClusterProxyRegistrationSuccess(stack.getId());
            sendEvent(context, event.selector(), event);
        }
    };
}
Also used : ClusterProxyRegistrationRequest(com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationRequest) Stack(com.sequenceiq.freeipa.entity.Stack) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) ClusterProxyRegistrationSuccess(com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationSuccess) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

ClusterProxyRegistrationSuccess (com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationSuccess)4 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)2 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)2 Stack (com.sequenceiq.freeipa.entity.Stack)2 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)2 ClusterProxyRegistrationRequest (com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationRequest)2 Map (java.util.Map)2 Bean (org.springframework.context.annotation.Bean)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 BootstrapMachinesRequest (com.sequenceiq.freeipa.flow.freeipa.provision.event.bootstrap.BootstrapMachinesRequest)1 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)1 ClusterProxyRegistrationFailed (com.sequenceiq.freeipa.flow.stack.provision.event.clusterproxy.ClusterProxyRegistrationFailed)1