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())));
});
}
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())));
}
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()))));
});
}
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);
}
}
}
}
}
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);
}
Aggregations