Search in sources :

Example 1 with Host

use of org.jboss.hal.core.runtime.host.Host in project console by hal.

the class EnableSSLWizard method show.

public void show() {
    Constants constants = resources.constants();
    AddressTemplate template = undertowHttps ? UNDERTOW_HTTPS_LISTENER_TEMPLATE : HTTP_INTERFACE_TEMPLATE;
    Wizard.Builder<EnableSSLContext, EnableSSLState> wb = new Wizard.Builder<>(constants.enableSSLManagementTitle(), new EnableSSLContext());
    wb.addStep(EnableSSLState.DEFINE_STRATEGY, new DefineStrategyStep(resources, environment.isStandalone(), undertowHttps)).addStep(EnableSSLState.CONFIGURATION, new ConfigurationStep(existingResources, resources, environment, undertowHttps, template)).addStep(EnableSSLState.REVIEW, new ReviewStep(dispatcher, statementContext, resources, environment, undertowHttps, template)).onBack((context, currentState) -> {
        EnableSSLState previous = null;
        switch(currentState) {
            case DEFINE_STRATEGY:
                break;
            case CONFIGURATION:
                previous = EnableSSLState.DEFINE_STRATEGY;
                break;
            case REVIEW:
                previous = EnableSSLState.CONFIGURATION;
                break;
            default:
                break;
        }
        return previous;
    }).onNext((context, currentState) -> {
        EnableSSLState next = null;
        switch(currentState) {
            case DEFINE_STRATEGY:
                next = EnableSSLState.CONFIGURATION;
                break;
            case CONFIGURATION:
                next = EnableSSLState.REVIEW;
                break;
            case REVIEW:
                break;
            default:
                break;
        }
        return next;
    }).stayOpenAfterFinish().onFinish((wizard, context) -> {
        ModelNode model = context.model;
        ModelNode credRef = new ModelNode();
        credRef.get(CLEAR_TEXT).set(asString(model, AbstractConfiguration.KEY_STORE_PASSWORD));
        // use Flow tasks to run DMR operations as there are resources that must exists before next
        // operations are called, as in the example of a generate-key-pair and import-certificate
        // the key-store must exists. For this case, the Composite doesn't work.
        List<Task<FlowContext>> tasks = new ArrayList<>();
        // key-store is only created when user chooses to create all resources or create a key-store based on
        // an existing JKS file
        boolean createKeyStore = !context.strategy.equals(EnableSSLContext.Strategy.KEYSTORE_RESOURCE_EXISTS);
        String keyStoreName = createKeyStore ? asString(model, AbstractConfiguration.KEY_STORE_NAME) : asString(model, KEY_STORE);
        if (createKeyStore) {
            if (context.strategy.equals(EnableSSLContext.Strategy.KEYSTORE_CREATE)) {
                ResourceAddress ksAddress = keyStoreTemplate().resolve(statementContext, keyStoreName);
                tasks.add(flowContext -> {
                    Operation.Builder builder = new Operation.Builder(ksAddress, ADD).param(PATH, asString(model, KEY_STORE_PATH)).param(CREDENTIAL_REFERENCE, credRef).param(TYPE, asString(model, AbstractConfiguration.KEY_STORE_TYPE));
                    if (model.hasDefined(AbstractConfiguration.KEY_STORE_RELATIVE_TO)) {
                        builder.param(RELATIVE_TO, asString(model, AbstractConfiguration.KEY_STORE_RELATIVE_TO));
                    }
                    Operation keyStoreOp = builder.build();
                    return dispatcher.execute(keyStoreOp).doOnError(exception -> wizard.showError(constants.failed(), resources.messages().addKeyStoreError(keyStoreName), exception.getMessage(), false)).toCompletable();
                });
                tasks.add(flowContext -> {
                    Composite composite = new Composite();
                    // the generate-key=pair can only be called on an existing key-store
                    String dn = "CN=" + asString(model, AbstractConfiguration.PRIVATE_KEY_DN_CN) + ", OU=" + asString(model, AbstractConfiguration.PRIVATE_KEY_DN_OU) + ", O=" + asString(model, AbstractConfiguration.PRIVATE_KEY_DN_O) + ", L=" + asString(model, AbstractConfiguration.PRIVATE_KEY_DN_L) + ", ST=" + asString(model, AbstractConfiguration.PRIVATE_KEY_DN_ST) + ", C=" + asString(model, AbstractConfiguration.PRIVATE_KEY_DN_C);
                    Operation genKeyOp = new Operation.Builder(ksAddress, GENERATE_KEY_PAIR).param(ALIAS, asString(model, AbstractConfiguration.PRIVATE_KEY_ALIAS)).param(DISTINGUISHED_NAME, dn).param(VALIDITY, asString(model, AbstractConfiguration.PRIVATE_KEY_VALIDITY)).param(ModelDescriptionConstants.ALGORITHM, asString(model, AbstractConfiguration.PRIVATE_KEY_ALGORITHM)).build();
                    composite.add(genKeyOp);
                    Operation storeOp = new Operation.Builder(ksAddress, STORE).build();
                    composite.add(storeOp);
                    return dispatcher.execute(composite).toCompletable();
                });
            } else if (context.strategy.equals(EnableSSLContext.Strategy.KEYSTORE_FILE_EXISTS)) {
                tasks.add(flowContext -> {
                    ResourceAddress ksAddress = keyStoreTemplate().resolve(statementContext, keyStoreName);
                    Operation.Builder builder = new Operation.Builder(ksAddress, ADD).param(PATH, asString(model, KEY_STORE_PATH)).param(CREDENTIAL_REFERENCE, credRef).param(TYPE, asString(model, AbstractConfiguration.KEY_STORE_TYPE)).param(REQUIRED, true);
                    if (model.hasDefined(AbstractConfiguration.KEY_STORE_RELATIVE_TO)) {
                        builder.param(RELATIVE_TO, asString(model, AbstractConfiguration.KEY_STORE_RELATIVE_TO));
                    }
                    Operation keyStoreOp = builder.build();
                    return dispatcher.execute(keyStoreOp).doOnError(exception -> wizard.showError(constants.failed(), resources.messages().addKeyStoreError(keyStoreName), exception.getMessage(), false)).toCompletable();
                });
            } else if (context.strategy.equals(EnableSSLContext.Strategy.KEYSTORE_OBTAIN_LETSENCRYPT)) {
                ResourceAddress ksAddress = keyStoreTemplate().resolve(statementContext, keyStoreName);
                tasks.add(flowContext -> {
                    Operation.Builder builder = new Operation.Builder(ksAddress, ADD).param(PATH, asString(model, KEY_STORE_PATH)).param(CREDENTIAL_REFERENCE, credRef).param(TYPE, asString(model, AbstractConfiguration.KEY_STORE_TYPE));
                    if (model.hasDefined(AbstractConfiguration.KEY_STORE_RELATIVE_TO)) {
                        builder.param(RELATIVE_TO, asString(model, AbstractConfiguration.KEY_STORE_RELATIVE_TO));
                    }
                    Operation keyStoreOp = builder.build();
                    return dispatcher.execute(keyStoreOp).doOnError(exception -> wizard.showError(constants.failed(), resources.messages().addKeyStoreError(keyStoreName), exception.getMessage(), false)).toCompletable();
                });
                String caaName = asString(model, CAA_NAME);
                ResourceAddress caaAddress = certificateAuthorityAccountTemplate().resolve(statementContext, caaName);
                tasks.add(flowContext -> {
                    Operation caaOp = new Operation.Builder(caaAddress, ADD).param(KEY_STORE, keyStoreName).param(ALIAS, asString(model, CAA_ALIAS)).build();
                    return dispatcher.execute(caaOp).doOnError(exception -> wizard.showError(constants.failed(), resources.messages().addResourceError(caaName, exception.getMessage()), false)).toCompletable();
                });
                tasks.add(flowContext -> {
                    Composite composite = new Composite();
                    String obtainAlias = asString(model, PRIVATE_KEY_ALIAS);
                    Operation obtainOp = new Operation.Builder(ksAddress, OBTAIN_CERTIFICATE).param(ALIAS, obtainAlias).param(CERTIFICATE_AUTHORITY_ACCOUNT, caaName).param("domain-names", model.get(CAA_DOMAIN_NAMES)).param("agree-to-terms-of-service", true).param("staging", asString(model, CAA_STAGING)).build();
                    composite.add(obtainOp);
                    Operation storeOp = new Operation.Builder(ksAddress, STORE).build();
                    composite.add(storeOp);
                    return dispatcher.execute(composite).doOnError(ex -> wizard.showError(constants.failed(), resources.messages().obtainCertificateError(obtainAlias, keyStoreName, ex.getMessage()), false)).toCompletable();
                });
            }
        }
        String trustManagerName = model.hasDefined(TRUST_MANAGER) ? asString(model, TRUST_MANAGER) : null;
        if (context.mutualAuthentication) {
            ModelNode tsCredRef = new ModelNode();
            tsCredRef.get(CLEAR_TEXT).set(asString(model, AbstractConfiguration.TRUST_STORE_PASSWORD));
            String trustStoreName = asString(model, AbstractConfiguration.TRUST_STORE_NAME);
            ResourceAddress tsAddress = keyStoreTemplate().resolve(statementContext, trustStoreName);
            tasks.add(flowContext -> {
                Operation.Builder builder = new Operation.Builder(tsAddress, ADD).param(PATH, asString(model, AbstractConfiguration.TRUST_STORE_PATH)).param(CREDENTIAL_REFERENCE, tsCredRef).param(TYPE, asString(model, AbstractConfiguration.TRUST_STORE_TYPE));
                if (model.hasDefined(AbstractConfiguration.TRUST_STORE_RELATIVE_TO)) {
                    builder.param(RELATIVE_TO, asString(model, AbstractConfiguration.TRUST_STORE_RELATIVE_TO));
                }
                Operation trustStoreOp = builder.build();
                return dispatcher.execute(trustStoreOp).toCompletable();
            });
            tasks.add(flowContext -> {
                Composite composite = new Composite();
                Operation importCertOp = new Operation.Builder(tsAddress, IMPORT_CERTIFICATE).param(ALIAS, asString(model, AbstractConfiguration.CLIENT_CERTIFICATE_ALIAS)).param(PATH, asString(model, AbstractConfiguration.CLIENT_CERTIFICATE_PATH)).param(CREDENTIAL_REFERENCE, tsCredRef).param(VALIDATE, model.get(AbstractConfiguration.CLIENT_CERTIFICATE_VALIDATE).asBoolean(false)).param(TRUST_CACERTS, model.get(AbstractConfiguration.CLIENT_CERTIFICATE_TRUST).asBoolean(false)).build();
                composite.add(importCertOp);
                Operation storeOp = new Operation.Builder(tsAddress, STORE).build();
                composite.add(storeOp);
                ResourceAddress etmAddress = trustManagerTemplate().resolve(statementContext, trustManagerName);
                Operation trustManagerOp = new Operation.Builder(etmAddress, ADD).param(KEY_STORE, trustStoreName).param(ModelDescriptionConstants.ALGORITHM, KEY_MANAGER_ALGORITHM).build();
                composite.add(trustManagerOp);
                return dispatcher.execute(composite).toCompletable();
            });
        }
        Composite composite = new Composite();
        String keyManager = asString(model, KEY_MANAGER);
        ResourceAddress ekmAddress = keyManagerTemplate().resolve(statementContext, keyManager);
        Operation keyManagerOp = new Operation.Builder(ekmAddress, ADD).param(KEY_STORE, keyStoreName).param(ModelDescriptionConstants.ALGORITHM, KEY_MANAGER_ALGORITHM).param(CREDENTIAL_REFERENCE, credRef).build();
        composite.add(keyManagerOp);
        ModelNode protocols = new ModelNode();
        protocols.add(KEY_MANAGER_TLSV1_2);
        String serverSslContext = asString(model, SERVER_SSL_CONTEXT);
        ResourceAddress sslCtxAddress = sslContextTemplate().resolve(statementContext, serverSslContext);
        Operation.Builder sslCtxBuilder = new Operation.Builder(sslCtxAddress, ADD).param(KEY_MANAGER, keyManager).param(PROTOCOLS, protocols);
        if (context.mutualAuthentication) {
            sslCtxBuilder.param(TRUST_MANAGER, trustManagerName);
            sslCtxBuilder.param(WANT_CLIENT_AUTH, true);
        }
        Operation sslCtxOp = sslCtxBuilder.build();
        composite.add(sslCtxOp);
        if (undertowHttps) {
            ResourceAddress httpsAddress = UNDERTOW_HTTPS_LISTENER_TEMPLATE.resolve(statementContext, undertowServer, httpsListener);
            Operation writeSslCtxOp = new Operation.Builder(httpsAddress, WRITE_ATTRIBUTE_OPERATION).param(NAME, SSL_CONTEXT).param(VALUE, serverSslContext).build();
            composite.add(writeSslCtxOp);
            // undefine the "alternatives" attributes
            composite.add(undefineAttribute(httpsAddress, SECURITY_REALM));
            composite.add(undefineAttribute(httpsAddress, "verify-client"));
            composite.add(undefineAttribute(httpsAddress, "enabled-cipher-suites"));
            composite.add(undefineAttribute(httpsAddress, "enabled-protocols"));
            composite.add(undefineAttribute(httpsAddress, "ssl-session-cache-size"));
            composite.add(undefineAttribute(httpsAddress, "ssl-session-timeout"));
        } else {
            ResourceAddress httpInterfaceAddress = HTTP_INTERFACE_TEMPLATE.resolve(statementContext);
            Operation writeSslCtxOp = new Operation.Builder(httpInterfaceAddress, WRITE_ATTRIBUTE_OPERATION).param(NAME, SSL_CONTEXT).param(VALUE, serverSslContext).build();
            composite.add(writeSslCtxOp);
            if (environment.isStandalone()) {
                Operation writeSecureSocketBinding = new Operation.Builder(httpInterfaceAddress, WRITE_ATTRIBUTE_OPERATION).param(NAME, SECURE_SOCKET_BINDING).param(VALUE, asString(model, SECURE_SOCKET_BINDING)).build();
                composite.add(writeSecureSocketBinding);
            } else {
                Operation writeSecurePortOp = new Operation.Builder(httpInterfaceAddress, WRITE_ATTRIBUTE_OPERATION).param(NAME, SECURE_PORT).param(VALUE, asString(model, SECURE_PORT)).build();
                composite.add(writeSecurePortOp);
            }
        }
        tasks.add(flowContext -> dispatcher.execute(composite).toCompletable());
        series(new FlowContext(progress.get()), tasks).subscribe(new SuccessfulOutcome<FlowContext>(eventBus, resources) {

            @Override
            public void onSuccess(FlowContext flowContext) {
                if (undertowHttps) {
                    wizard.showSuccess(resources.constants().success(), resources.messages().enableSSLResultsSuccessUndertow(httpsListener, serverSslContext), context1 -> presenter.reloadView(), true);
                } else {
                    // constructs the http management console url
                    String serverName = environment.isStandalone() ? Names.STANDALONE_SERVER : Names.DOMAIN_CONTROLLER;
                    String label = resources.constants().reload() + " " + serverName;
                    SafeHtml description;
                    StringBuilder location = new StringBuilder("https://" + window.location.getHostname() + ":");
                    if (environment.isStandalone()) {
                        location.append(context.securePort);
                        description = resources.messages().enableSSLResultsSuccessStandalone(location.toString());
                    } else {
                        location.append(asString(model, SECURE_PORT));
                        description = resources.messages().enableSSLResultsSuccessDomain(location.toString());
                    }
                    // extracts the url search path, so the url shows the view the user is located
                    String urlSuffix = window.location.getHref();
                    urlSuffix = urlSuffix.substring(urlSuffix.indexOf("//") + 2);
                    urlSuffix = urlSuffix.substring(urlSuffix.indexOf("/"));
                    location.append(urlSuffix);
                    wizard.showSuccess(resources.constants().success(), description, label, // reloads the server/host if user clicks on the success action
                    context1 -> presenter.reloadServer(host, location.toString()), // reload only the view and displays a success message
                    context2 -> {
                        presenter.reloadView();
                        MessageEvent.fire(eventBus, Message.success(resources.messages().enableSSLSuccess()));
                    }, true);
                }
            }

            @Override
            public void onError(FlowContext context, Throwable exception) {
                wizard.showError(resources.constants().failed(), resources.messages().enableSSLResultsError(), exception.getMessage(), false);
            }
        });
    });
    Wizard<EnableSSLContext, EnableSSLState> wizard = wb.build();
    wizard.show();
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) ModelNode(org.jboss.hal.dmr.ModelNode) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) StatementContext(org.jboss.hal.meta.StatementContext) MessageEvent(org.jboss.hal.spi.MessageEvent) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) AbstractConfiguration(org.jboss.hal.client.shared.sslwizard.AbstractConfiguration) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) Task(org.jboss.hal.flow.Task) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) Constants(org.jboss.hal.resources.Constants) Map(java.util.Map) Message(org.jboss.hal.spi.Message) Names(org.jboss.hal.resources.Names) Operation(org.jboss.hal.dmr.Operation) Wizard(org.jboss.hal.ballroom.wizard.Wizard) EventBus(com.google.web.bindery.event.shared.EventBus) DomGlobal.window(elemental2.dom.DomGlobal.window) Composite(org.jboss.hal.dmr.Composite) List(java.util.List) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Resources(org.jboss.hal.resources.Resources) Flow.series(org.jboss.hal.flow.Flow.series) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Host(org.jboss.hal.core.runtime.host.Host) Task(org.jboss.hal.flow.Task) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ArrayList(java.util.ArrayList) Operation(org.jboss.hal.dmr.Operation) FlowContext(org.jboss.hal.flow.FlowContext) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Constants(org.jboss.hal.resources.Constants) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) ModelNode(org.jboss.hal.dmr.ModelNode) Wizard(org.jboss.hal.ballroom.wizard.Wizard)

Example 2 with Host

use of org.jboss.hal.core.runtime.host.Host in project console by hal.

the class TopologyPreview method update.

// ------------------------------------------------------ dmr functions
@Override
public void update(StaticItem item) {
    // remember selection
    HTMLElement element = (HTMLElement) document.querySelector(DOT + topology + " ." + selected);
    String hostName = element != null ? String.valueOf(element.dataset.get("host")) : null;
    String serverGroupName = element != null ? String.valueOf(element.dataset.get("serverGroup")) : null;
    String serverName = element != null ? String.valueOf(element.dataset.get("server")) : null;
    clearSelected();
    setVisible(loadingSection, false);
    setVisible(topologySection, false);
    hideDetails();
    // show the loading indicator if the operations take too long
    double timeoutHandle = setTimeout((o) -> setVisible(loadingSection, true), MEDIUM_TIMEOUT);
    series(new FlowContext(progress.get()), topology(environment, dispatcher)).subscribe(new Outcome<FlowContext>() {

        @Override
        public void onError(FlowContext context, Throwable error) {
            clearTimeout(timeoutHandle);
            setVisible(loadingSection, false);
            MessageEvent.fire(eventBus, Message.error(resources.messages().topologyError(), error.getMessage()));
        }

        @Override
        public void onSuccess(FlowContext context) {
            clearTimeout(timeoutHandle);
            setVisible(loadingSection, false);
            Elements.removeChildrenFrom(topologySection);
            List<Host> hosts = context.get(TopologyTasks.HOSTS);
            List<ServerGroup> serverGroups = context.get(TopologyTasks.SERVER_GROUPS);
            List<Server> servers = context.get(TopologyTasks.SERVERS);
            topologySection.appendChild(buildTable(hosts, serverGroups, servers));
            setVisible(topologySection, true);
            adjustTdHeight();
            // restore selection
            if (hostName != null) {
                hosts.stream().filter(host -> hostName.equals(host.getName())).findAny().ifPresent(host -> hostDetails(host));
            }
            if (serverGroupName != null) {
                serverGroups.stream().filter(serverGroup -> serverGroupName.equals(serverGroup.getName())).findAny().ifPresent(serverGroup -> serverGroupDetails(serverGroup));
            }
            if (serverName != null) {
                servers.stream().filter(server -> serverName.equals(server.getName())).findAny().ifPresent(server -> serverDetails(server));
            }
        }
    });
}
Also used : PreviewContent(org.jboss.hal.core.finder.PreviewContent) HostActions(org.jboss.hal.core.runtime.host.HostActions) ServerGroupActionEvent(org.jboss.hal.core.runtime.group.ServerGroupActionEvent) Constraint(org.jboss.hal.meta.security.Constraint) HostResultEvent(org.jboss.hal.core.runtime.host.HostResultEvent) TopologyTasks(org.jboss.hal.core.runtime.TopologyTasks) AuthorisationDecision(org.jboss.hal.meta.security.AuthorisationDecision) PreviewAttribute(org.jboss.hal.core.finder.PreviewAttributes.PreviewAttribute) Server(org.jboss.hal.core.runtime.server.Server) CSS.hostContainer(org.jboss.hal.resources.CSS.hostContainer) Places(org.jboss.hal.core.mvp.Places) Names(org.jboss.hal.resources.Names) HostActionEvent(org.jboss.hal.core.runtime.host.HostActionEvent) ServerActions(org.jboss.hal.core.runtime.server.ServerActions) ServerGroupResultEvent(org.jboss.hal.core.runtime.group.ServerGroupResultEvent) CSS.inactive(org.jboss.hal.resources.CSS.inactive) HTMLTableElement(elemental2.dom.HTMLTableElement) Set(java.util.Set) CSS(org.jboss.hal.resources.CSS) ServerGroup(org.jboss.hal.core.runtime.group.ServerGroup) ServerActionHandler(org.jboss.hal.core.runtime.server.ServerActionEvent.ServerActionHandler) Flow.series(org.jboss.hal.flow.Flow.series) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) CSS.spinnerLg(org.jboss.hal.resources.CSS.spinnerLg) CSS.withProgress(org.jboss.hal.resources.CSS.withProgress) Constraints(org.jboss.hal.meta.security.Constraints) Supplier(java.util.function.Supplier) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) ServerGroupResultHandler(org.jboss.hal.core.runtime.group.ServerGroupResultEvent.ServerGroupResultHandler) Strings(com.google.common.base.Strings) EventCallbackFn(org.jboss.gwt.elemento.core.EventCallbackFn) Progress(org.jboss.hal.flow.Progress) CSS.marginRight5(org.jboss.hal.resources.CSS.marginRight5) CSS.name(org.jboss.hal.resources.CSS.name) EventBus(com.google.web.bindery.event.shared.EventBus) MouseEvent(elemental2.dom.MouseEvent) ServerStatusSwitch(org.jboss.hal.client.runtime.server.ServerStatusSwitch) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) NameTokens(org.jboss.hal.meta.token.NameTokens) HTMLDivElement(elemental2.dom.HTMLDivElement) NamedNode(org.jboss.hal.dmr.NamedNode) Elements(org.jboss.gwt.elemento.core.Elements) CSS.rowHeader(org.jboss.hal.resources.CSS.rowHeader) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) HTMLTableCellElement(elemental2.dom.HTMLTableCellElement) HtmlContentBuilder(org.jboss.gwt.elemento.core.builder.HtmlContentBuilder) HostPreviewAttributes(org.jboss.hal.core.runtime.host.HostPreviewAttributes) CSS.divider(org.jboss.hal.resources.CSS.divider) HostActionHandler(org.jboss.hal.core.runtime.host.HostActionEvent.HostActionHandler) CSS.serverGroupContainer(org.jboss.hal.resources.CSS.serverGroupContainer) HTMLElement(elemental2.dom.HTMLElement) Message(org.jboss.hal.spi.Message) NodeList(elemental2.dom.NodeList) PreviewAttributes(org.jboss.hal.core.finder.PreviewAttributes) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Lists.asList(com.google.common.collect.Lists.asList) HTMLTableSectionElement(elemental2.dom.HTMLTableSectionElement) CSS.marginLeft5(org.jboss.hal.resources.CSS.marginLeft5) Predicate(java.util.function.Predicate) CSS.dropdownMenu(org.jboss.hal.resources.CSS.dropdownMenu) CSS.px(org.jboss.hal.resources.CSS.px) EventType.click(org.jboss.gwt.elemento.core.EventType.click) FinderPath(org.jboss.hal.core.finder.FinderPath) ServerGroupActions(org.jboss.hal.core.runtime.group.ServerGroupActions) ServerPreviewAttributes(org.jboss.hal.core.runtime.server.ServerPreviewAttributes) CSS.error(org.jboss.hal.resources.CSS.error) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) UIConstants(org.jboss.hal.resources.UIConstants) CSS.dropdownToggle(org.jboss.hal.resources.CSS.dropdownToggle) ServerResultEvent(org.jboss.hal.core.runtime.server.ServerResultEvent) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) SecurityContextRegistry(org.jboss.hal.meta.security.SecurityContextRegistry) HostResultHandler(org.jboss.hal.core.runtime.host.HostResultEvent.HostResultHandler) CSS.centerBlock(org.jboss.hal.resources.CSS.centerBlock) DomGlobal.setTimeout(elemental2.dom.DomGlobal.setTimeout) ModelNode(org.jboss.hal.dmr.ModelNode) Element(elemental2.dom.Element) CSS.selected(org.jboss.hal.resources.CSS.selected) MessageEvent(org.jboss.hal.spi.MessageEvent) ServerActionEvent(org.jboss.hal.core.runtime.server.ServerActionEvent) ServerResultHandler(org.jboss.hal.core.runtime.server.ServerResultEvent.ServerResultHandler) CSS.server(org.jboss.hal.resources.CSS.server) CSS.clickable(org.jboss.hal.resources.CSS.clickable) Function(java.util.function.Function) HashSet(java.util.HashSet) CSS.topology(org.jboss.hal.resources.CSS.topology) ServerGroupActionHandler(org.jboss.hal.core.runtime.group.ServerGroupActionEvent.ServerGroupActionHandler) AddressTemplate(org.jboss.hal.meta.AddressTemplate) Comparator.comparing(java.util.Comparator.comparing) CSS.spinner(org.jboss.hal.resources.CSS.spinner) CSS.ok(org.jboss.hal.resources.CSS.ok) CSS.warning(org.jboss.hal.resources.CSS.warning) DomGlobal.document(elemental2.dom.DomGlobal.document) CSS.suspended(org.jboss.hal.resources.CSS.suspended) Ids(org.jboss.hal.resources.Ids) HTMLTableColElement(elemental2.dom.HTMLTableColElement) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) CSS.disconnected(org.jboss.hal.resources.CSS.disconnected) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) Consumer(java.util.function.Consumer) DomGlobal.clearTimeout(elemental2.dom.DomGlobal.clearTimeout) Collectors.toList(java.util.stream.Collectors.toList) CSS.pullRight(org.jboss.hal.resources.CSS.pullRight) Resources(org.jboss.hal.resources.Resources) Format(org.jboss.hal.ballroom.Format) TopologyTasks.topology(org.jboss.hal.core.runtime.TopologyTasks.topology) CSS.height(org.jboss.hal.resources.CSS.height) CSS.empty(org.jboss.hal.resources.CSS.empty) Host(org.jboss.hal.core.runtime.host.Host) MEDIUM_TIMEOUT(org.jboss.hal.resources.UIConstants.MEDIUM_TIMEOUT) StaticItem(org.jboss.hal.core.finder.StaticItem) HTMLElement(elemental2.dom.HTMLElement) ArrayList(java.util.ArrayList) NodeList(elemental2.dom.NodeList) Lists.asList(com.google.common.collect.Lists.asList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) FlowContext(org.jboss.hal.flow.FlowContext)

Example 3 with Host

use of org.jboss.hal.core.runtime.host.Host in project console by hal.

the class TopologyPreview method onHostResult.

@Override
public void onHostResult(HostResultEvent event) {
    if (isVisible()) {
        Host host = event.getHost();
        stopProgress(hostSelector(host));
        event.getServers().forEach(server -> stopProgress(serverSelector(server)));
        update(null);
    }
}
Also used : Host(org.jboss.hal.core.runtime.host.Host)

Example 4 with Host

use of org.jboss.hal.core.runtime.host.Host in project console by hal.

the class HostColumn method onHostAction.

@Override
public void onHostAction(HostActionEvent event) {
    if (isVisible()) {
        Host host = event.getHost();
        ItemMonitor.startProgress(Ids.host(host.getAddressName()));
        event.getServers().forEach(server -> ItemMonitor.startProgress(server.getId()));
    }
}
Also used : Host(org.jboss.hal.core.runtime.host.Host)

Example 5 with Host

use of org.jboss.hal.core.runtime.host.Host in project console by hal.

the class HostPresenter method reload.

@Override
protected void reload() {
    ResourceAddress hostAddress = new ResourceAddress().add(HOST, statementContext.selectedHost());
    Operation hostOp = new Operation.Builder(hostAddress, READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).build();
    Operation interfacesOp = new Operation.Builder(hostAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, INTERFACE).param(INCLUDE_RUNTIME, true).build();
    Operation jvmsOp = new Operation.Builder(hostAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, JVM).param(INCLUDE_RUNTIME, true).build();
    Operation pathsOp = new Operation.Builder(hostAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, PATH).param(INCLUDE_RUNTIME, true).build();
    Operation socketBindingGroupsOp = new Operation.Builder(hostAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, SOCKET_BINDING_GROUP).param(INCLUDE_RUNTIME, true).build();
    Operation systemPropertiesOp = new Operation.Builder(hostAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, SYSTEM_PROPERTY).param(INCLUDE_RUNTIME, true).build();
    ResourceAddress coreServiceAddress = hostAddress.add(CORE_SERVICE, MANAGEMENT);
    Operation mgmtInterfacesOp = new Operation.Builder(coreServiceAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, MANAGEMENT_INTERFACE).param(INCLUDE_RUNTIME, true).build();
    Composite composite = new Composite(hostOp, interfacesOp, jvmsOp, pathsOp, socketBindingGroupsOp, systemPropertiesOp, mgmtInterfacesOp);
    dispatcher.execute(composite, (CompositeResult result) -> {
        getView().updateHost(new Host(result.step(0).get(RESULT)));
        getView().updateInterfaces(asNamedNodes(result.step(1).get(RESULT).asPropertyList()));
        getView().updateJvms(asNamedNodes(result.step(2).get(RESULT).asPropertyList()));
        getView().updatePaths(asNamedNodes(result.step(3).get(RESULT).asPropertyList()));
        getView().updateSocketBindingGroups(asNamedNodes(result.step(4).get(RESULT).asPropertyList()));
        getView().updateSystemProperties(asNamedNodes(result.step(5).get(RESULT).asPropertyList()));
        getView().updateManagementInterfaces(asNamedNodes(result.step(6).get(RESULT).asPropertyList()), -1);
    });
}
Also used : Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) Host(org.jboss.hal.core.runtime.host.Host) Operation(org.jboss.hal.dmr.Operation)

Aggregations

Host (org.jboss.hal.core.runtime.host.Host)13 EventBus (com.google.web.bindery.event.shared.EventBus)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Provider (javax.inject.Provider)5 Environment (org.jboss.hal.config.Environment)5 ModelNode (org.jboss.hal.dmr.ModelNode)5 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)5 Flow.series (org.jboss.hal.flow.Flow.series)5 FlowContext (org.jboss.hal.flow.FlowContext)5 Progress (org.jboss.hal.flow.Progress)5 AddressTemplate (org.jboss.hal.meta.AddressTemplate)5 Names (org.jboss.hal.resources.Names)5 Resources (org.jboss.hal.resources.Resources)5 Message (org.jboss.hal.spi.Message)5 MessageEvent (org.jboss.hal.spi.MessageEvent)5 HTMLElement (elemental2.dom.HTMLElement)4 Strings (com.google.common.base.Strings)3 Lists.asList (com.google.common.collect.Lists.asList)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)3