Search in sources :

Example 6 with Operation

use of org.jboss.hal.dmr.Operation in project console by hal.

the class ServerActions method destroy.

public void destroy(Server server) {
    DialogFactory.showConfirmation(resources.messages().destroy(server.getName()), resources.messages().destroyServerQuestion(server.getName()), () -> {
        prepare(server, Action.DESTROY);
        Operation operation = new Operation.Builder(server.getServerConfigAddress(), DESTROY).build();
        dispatcher.execute(operation, result -> repeatOperationUntil(dispatcher, SERVER_DESTROY_TIMEOUT, readServerConfigStatus(server), checkServerConfigStatus(STOPPED, DISABLED)).subscribe(new ServerTimeoutCallback(server, Action.DESTROY, resources.messages().destroyServerSuccess(server.getName()))), new ServerFailedCallback(server, resources.messages().destroyServerError(server.getName())), new ServerExceptionCallback(server, resources.messages().destroyServerError(server.getName())));
    });
}
Also used : Operation(org.jboss.hal.dmr.Operation)

Example 7 with Operation

use of org.jboss.hal.dmr.Operation in project console by hal.

the class ServerActions method stopNow.

/**
 * Call <code>/host={host}/server-config={sever}:stop(blocking=false)</code> the intended action is to immediately stop the
 * server.
 *
 * @param server
 */
public void stopNow(Server server) {
    prepare(server, Action.STOP);
    Operation operation = new Operation.Builder(server.getServerConfigAddress(), STOP).param(BLOCKING, false).build();
    dispatcher.execute(operation, result -> repeatOperationUntil(dispatcher, SERVER_STOP_TIMEOUT, readServerConfigStatus(server), checkServerConfigStatus(STOPPED, DISABLED)).subscribe(new ServerTimeoutCallback(server, Action.STOP, resources.messages().stopServerSuccess(server.getName()))), new ServerFailedCallback(server, resources.messages().stopServerError(server.getName())), new ServerExceptionCallback(server, resources.messages().stopServerError(server.getName())));
}
Also used : OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Operation(org.jboss.hal.dmr.Operation)

Example 8 with Operation

use of org.jboss.hal.dmr.Operation in project console by hal.

the class ServerGroupActions method remove.

public void remove(ServerGroup serverGroup) {
    List<Server> stoppedServers = serverGroup.getServers(Server::isStopped);
    DialogFactory.showConfirmation(resources.messages().removeConfirmationTitle(Names.SERVER_GROUP), resources.messages().removeConfirmationQuestion(serverGroup.getName()), () -> {
        prepare(serverGroup, stoppedServers, Action.REMOVE);
        Composite comp = new Composite();
        for (Server server : stoppedServers) {
            comp.add(new Operation.Builder(server.getServerConfigAddress(), REMOVE).build());
        }
        Operation operation = new Operation.Builder(serverGroup.getAddress(), REMOVE).build();
        comp.add(operation);
        dispatcher.execute(comp, (CompositeResult result) -> finish(serverGroup, stoppedServers, Result.SUCCESS, Message.success(resources.messages().removeResourceSuccess(Names.SERVER_GROUP, serverGroup.getName()))), (operation1, failure) -> finish(serverGroup, stoppedServers, Result.ERROR, Message.error(resources.messages().removeError(serverGroup.getName(), failure))), (operation1, exception) -> finish(serverGroup, stoppedServers, Result.ERROR, Message.error(resources.messages().removeError(serverGroup.getName(), exception.getMessage()))));
    });
}
Also used : Server(org.jboss.hal.core.runtime.server.Server) Composite(org.jboss.hal.dmr.Composite) CompositeResult(org.jboss.hal.dmr.CompositeResult) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Operation(org.jboss.hal.dmr.Operation)

Example 9 with Operation

use of org.jboss.hal.dmr.Operation in project console by hal.

the class ServerGroupActions method addChildOperations.

private static void addChildOperations(Composite composite, ModelNode rootModel, ModelNode baseAddress, int depth) {
    if (depth <= 0) {
        return;
    }
    for (Property property : rootModel.asPropertyList()) {
        if (ModelType.OBJECT.equals(property.getValue().getType())) {
            for (Property resource : property.getValue().asPropertyList()) {
                if (ModelType.OBJECT.equals(resource.getValue().getType())) {
                    ModelNode resourceAddress = baseAddress.clone().add(property.getName(), resource.getName());
                    Operation operation = new Operation.Builder(new ResourceAddress(resourceAddress), ADD).payload(resource.getValue()).build();
                    composite.add(operation);
                    addChildOperations(composite, resource.getValue(), resourceAddress, depth - 1);
                }
            }
        }
    }
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Operation(org.jboss.hal.dmr.Operation) ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property)

Example 10 with Operation

use of org.jboss.hal.dmr.Operation in project console by hal.

the class ServerGroupActions method copy.

public void copy(ServerGroup serverGroup, FormItemValidation<String> nameItemValidator) {
    NameItem newNameItem = new NameItem();
    newNameItem.setValue(serverGroup.getName() + "_" + COPY);
    newNameItem.addValidationHandler(nameItemValidator);
    ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(COPY, serverGroup.getName(), Ids.FORM), Metadata.empty()).fromRequestProperties().unboundFormItem(newNameItem, 0).requiredOnly().build();
    AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(Names.SERVER_GROUP), form, (resource, payload) -> {
        // read server-config recursively to retrieve nested resources
        Operation opReadServerGroup = new Operation.Builder(serverGroup.getAddress(), READ_RESOURCE_OPERATION).param(RECURSIVE, true).build();
        dispatcher.execute(opReadServerGroup, serverGroupModel -> {
            ServerGroup newServerGroup = new ServerGroup(newNameItem.getValue(), serverGroupModel);
            Operation opAddServer = new Operation.Builder(newServerGroup.getAddress(), ADD).payload(serverGroupModel).build();
            Composite comp = new Composite();
            comp.add(opAddServer);
            addChildOperations(comp, newServerGroup, newServerGroup.getAddress(), 2);
            dispatcher.execute(comp, (CompositeResult result) -> finish(serverGroup, Collections.emptyList(), Result.SUCCESS, Message.success(resources.messages().addResourceSuccess(Names.SERVER_GROUP, newNameItem.getValue()))), (operation1, failure) -> finish(serverGroup, Collections.emptyList(), Result.ERROR, Message.error(resources.messages().addResourceError(newNameItem.getValue(), failure))), (operation1, exception) -> finish(serverGroup, Collections.emptyList(), Result.ERROR, Message.error(resources.messages().addResourceError(newNameItem.getValue(), exception.getMessage()))));
        });
    });
    dialog.show();
    ModelNode model = new ModelNode();
    model.get(TIMEOUT).set(0);
    form.edit(model);
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) Composite(org.jboss.hal.dmr.Composite) CompositeResult(org.jboss.hal.dmr.CompositeResult) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Operation(org.jboss.hal.dmr.Operation) ModelNode(org.jboss.hal.dmr.ModelNode)

Aggregations

Operation (org.jboss.hal.dmr.Operation)246 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)162 ModelNode (org.jboss.hal.dmr.ModelNode)106 Composite (org.jboss.hal.dmr.Composite)63 CompositeResult (org.jboss.hal.dmr.CompositeResult)54 Metadata (org.jboss.hal.meta.Metadata)51 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)49 AddressTemplate (org.jboss.hal.meta.AddressTemplate)48 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)46 ArrayList (java.util.ArrayList)44 List (java.util.List)44 Resources (org.jboss.hal.resources.Resources)44 EventBus (com.google.web.bindery.event.shared.EventBus)42 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)42 StatementContext (org.jboss.hal.meta.StatementContext)42 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)41 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)40 Inject (javax.inject.Inject)39 Ids (org.jboss.hal.resources.Ids)39 Message (org.jboss.hal.spi.Message)37