public final ModelNodeResult forBatchStep(int stepIndex) { if (stepIndex < 1) { throw new IllegalArgumentException("Step number must be > 0 (first step has index 1)"); } List<Property> steps = this.value().asPropertyList(); if (stepIndex > steps.size()) { throw new IllegalArgumentException("No step " + stepIndex + ": " + this.asString()); } return new ModelNodeResult(steps.get(stepIndex - 1).getValue()); }
ModelNodeResult result = new ModelNodeResult(client.execute(op)); ModelNodeResult result = new ModelNodeResult(client.execute(op)); if (!result.isSuccess()) { throw new TimeoutException("Waiting for server to boot timed out");
/** * Returns the part of the operation result that is in fact a result of an operation performed on one single server * in a domain. The server is identified by the {@code host} name and the {@code server} name. It's not needed * to specify the server group, because one host can only belong to one server group. * @throws IllegalArgumentException if {@code this} is not an operation result from domain or if no such * {@code host} + {@code server} combination is present in {@code this} */ public final ModelNodeResult forServer(String host, String server) { if (!isFromDomain()) { throw new IllegalArgumentException("Can't call forServer on a result that isn't from domain"); } List<Property> serverGroups = this.get(Constants.SERVER_GROUPS).asPropertyList(); for (Property serverGroup : serverGroups) { ModelNode response = serverGroup.getValue().get(Constants.HOST, host, server, Constants.RESPONSE); if (response.isDefined()) { return new ModelNodeResult(response); } } throw new IllegalArgumentException("No such host or server: host = " + host + ", server = " + server); } }
/** * Returns the management version of the server which the {@code client} is connected to. * @throws IOException if an I/O error occurs during any management operation */ static ServerVersion discover(ModelControllerClient client) throws IOException { ModelNode op = new ModelNode(); op.get(Constants.OP).set(Constants.READ_RESOURCE_OPERATION); op.get(Constants.OP_ADDR).setEmptyList(); // this would be preferrable, as it means transferring less data, but it is not supported on older versions //op.get(Constants.ATTRIBUTES_ONLY).set(true); ModelNodeResult result = new ModelNodeResult(client.execute(op)); result.assertSuccess(); ModelNode resultValue = result.get(Constants.RESULT); return ServerVersion.from( readPart(resultValue, ManagementVersionPart.MAJOR), readPart(resultValue, ManagementVersionPart.MINOR), readPart(resultValue, ManagementVersionPart.MICRO) ); }
@Override public ModelNodeResult execute(String operation) throws CliException, IOException { checkClosed(); operation = adjustOperationForDomain.adjust(operation); log.debugf("Executing operation %s", operation); ModelNode parsedOperation; try { parsedOperation = cliContext.buildRequest(operation); } catch (CommandFormatException e) { throw new CliException(e); } ModelNode result = client.execute(parsedOperation); return new ModelNodeResult(result); }
@Override public ModelNodeResult execute(ModelNode operation) throws IOException { checkClosed(); operation = adjustOperationForDomain.adjust(operation); log.debugf("Executing operation %s", ModelNodeOperationToCliString.convert(operation)); log.tracef("JSON format:%n%s", operation.toJSONString(false)); ModelNode result = client.execute(operation); return new ModelNodeResult(result); }
@Override public ModelNodeResult execute(Operation operation) throws IOException { checkClosed(); operation = adjustOperationForDomain.adjust(operation); log.debugf("Executing operation %s", ModelNodeOperationToCliString.convert(operation.getOperation())); log.tracef("JSON format:%n%s", operation.getOperation().toJSONString(false)); ModelNode result = client.execute(operation); return new ModelNodeResult(result); }