Search in sources :

Example 1 with HostMetadataSetupSuccess

use of com.sequenceiq.freeipa.flow.freeipa.provision.event.hostmetadatasetup.HostMetadataSetupSuccess in project cloudbreak by hortonworks.

the class FreeIpaUpscaleActions method recordHostnamesAction.

@Bean(name = "UPSCALE_RECORD_HOSTNAMES_STATE")
public Action<?, ?> recordHostnamesAction() {
    return new AbstractUpscaleAction<>(HostMetadataSetupSuccess.class) {

        @Override
        protected void doExecute(StackContext context, HostMetadataSetupSuccess payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Recording hostnames");
            List<String> instanceIds = getInstanceIds(variables);
            List<String> hosts = stack.getNotDeletedInstanceMetaDataList().stream().filter(instanceMetaData -> instanceIds.contains(instanceMetaData.getInstanceId())).map(InstanceMetaData::getDiscoveryFQDN).collect(Collectors.toList());
            setUpscaleHosts(variables, hosts);
            sendEvent(context, UPSCALE_RECORD_HOSTNAMES_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) HostMetadataSetupSuccess(com.sequenceiq.freeipa.flow.freeipa.provision.event.hostmetadatasetup.HostMetadataSetupSuccess) 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 HostMetadataSetupSuccess

use of com.sequenceiq.freeipa.flow.freeipa.provision.event.hostmetadatasetup.HostMetadataSetupSuccess in project cloudbreak by hortonworks.

the class HostMetadataSetupHandler method accept.

@Override
public void accept(Event<HostMetadataSetupRequest> event) {
    StackEvent request = event.getData();
    LOGGER.debug("Host metadata setup request {}", request);
    Selectable response;
    try {
        hostMetadataSetup.setupHostMetadata(request.getResourceId());
        response = new HostMetadataSetupSuccess(request.getResourceId());
    } catch (Exception e) {
        LOGGER.debug("Host metadata setup failed", e);
        response = new HostMetadataSetupFailed(request.getResourceId(), e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) HostMetadataSetupFailed(com.sequenceiq.freeipa.flow.freeipa.provision.event.hostmetadatasetup.HostMetadataSetupFailed) HostMetadataSetupSuccess(com.sequenceiq.freeipa.flow.freeipa.provision.event.hostmetadatasetup.HostMetadataSetupSuccess)

Aggregations

HostMetadataSetupSuccess (com.sequenceiq.freeipa.flow.freeipa.provision.event.hostmetadatasetup.HostMetadataSetupSuccess)2 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)2 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 HostMetadataSetupFailed (com.sequenceiq.freeipa.flow.freeipa.provision.event.hostmetadatasetup.HostMetadataSetupFailed)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1