public final ModelNode headers() { return this.get(Constants.RESPONSE_HEADERS); }
public final ModelNode value() { return get(Constants.RESULT); }
public final boolean isFailed() { if (!this.hasDefined(Constants.OUTCOME)) { return false; } String outcome = this.get(Constants.OUTCOME).asString(); return Constants.FAILED.equals(outcome); }
public final boolean isSuccess() { if (!this.hasDefined(Constants.OUTCOME)) { return false; } String outcome = this.get(Constants.OUTCOME).asString(); return Constants.SUCCESS.equals(outcome); }
String failureDescription = result.get(Constants.FAILURE_DESCRIPTION).asString(); for (String code : Constants.RESULT_CODES_FOR_BOOT_IN_PROGRESS) { if (failureDescription.startsWith(code)) {
static boolean isResultUnknownOrNotFound(ModelNodeResult result) { result.assertFailed(); ModelNode failureDescription = result.get(Constants.FAILURE_DESCRIPTION); if (failureDescription.hasDefined(Constants.HOST_FAILURE_DESCRIPTIONS)) { List<Property> hostFailures = failureDescription.get(Constants.HOST_FAILURE_DESCRIPTIONS).asPropertyList(); for (Property hostFailure : hostFailures) { if (isFailureDesriptionUnknownOrNotFound(hostFailure.getValue().asString())) { return true; } } return false; } else { if (failureDescription.hasDefined(Constants.DOMAIN_FAILURE_DESCRIPTION)) { failureDescription = failureDescription.get(Constants.DOMAIN_FAILURE_DESCRIPTION); } return isFailureDesriptionUnknownOrNotFound(failureDescription.asString()); } }
/** * 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) ); }