Java Code Examples for org.jboss.as.controller.client.helpers.Operations#readResult()
The following examples show how to use
org.jboss.as.controller.client.helpers.Operations#readResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrustedDomainsConfigurator.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void create(ModelControllerClient client, CLIWrapper cli) throws Exception { final PathAddress domainAddress = PathAddress.pathAddress().append("subsystem", "elytron").append("security-domain", name); ModelNode op = Util.createEmptyOperation("read-attribute", domainAddress); op.get("name").set("trusted-security-domains"); ModelNode result = client.execute(op); if (Operations.isSuccessfulOutcome(result)) { result = Operations.readResult(result); originalDomains = result.isDefined() ? result : null; } else { throw new RuntimeException("Reading existing value of trusted-security-domains attribute failed: " + Operations.getFailureDescription(result)); } op = Util.createEmptyOperation("write-attribute", domainAddress); op.get("name").set("trusted-security-domains"); for (String domain : trustedSecurityDomains) { op.get("value").add(domain); } CoreUtils.applyUpdate(op, client); }
Example 2
Source File: TrustedDomainsConfigurator.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void create(ModelControllerClient client, CLIWrapper cli) throws Exception { final PathAddress domainAddress = PathAddress.pathAddress().append("subsystem", "elytron").append("security-domain", name); ModelNode op = Util.createEmptyOperation("read-attribute", domainAddress); op.get("name").set("trusted-security-domains"); ModelNode result = client.execute(op); if (Operations.isSuccessfulOutcome(result)) { result = Operations.readResult(result); originalDomains = result.isDefined() ? result : null; } else { throw new RuntimeException("Reading existing value of trusted-security-domains attribute failed: " + Operations.getFailureDescription(result)); } op = Util.createEmptyOperation("write-attribute", domainAddress); op.get("name").set("trusted-security-domains"); for (String domain : trustedSecurityDomains) { op.get("value").add(domain); } CoreUtils.applyUpdate(op, client); }
Example 3
Source File: CliCapabilityCompletionTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testDynamicRequirements() throws Exception { ModelNode req = new ModelNode(); req.get(Util.OPERATION).set("read-resource-description"); req.get(Util.ADDRESS).set(PathAddress.pathAddress(PathElement.pathElement("socket-binding-group", "standard-sockets"), PathElement.pathElement("socket-binding", "test")).toModelNode()); ModelNode result = Operations.readResult(ctx.execute(req, "")); assertTrue(result.require("capabilities").asList().size() == 1); ModelNode capability = result.require("capabilities").asList().get(0); assertEquals("We should have a socket-binding capability provided", "org.wildfly.network.socket-binding", capability.require("name").asString()); assertTrue("We should have a dynamic capability provided", capability.require("dynamic").asBoolean()); List<ModelNode> dynamicElts = capability.require("dynamic-elements").asList(); assertEquals(1, dynamicElts.size()); assertEquals("We should have a socket-binding capability provided", "socket-binding", dynamicElts.get(0).asString()); assertEquals("We should have an interface capability requirement", "org.wildfly.network.interface", result.require("attributes").require("interface").require("capability-reference").asString()); }
Example 4
Source File: RemoveManagementRealmTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Before public void beforeTest() throws Exception { container.start(); String jbossDist = TestSuiteEnvironment.getSystemProperty("jboss.dist"); source = Paths.get(jbossDist, "standalone", "configuration", "standalone.xml"); target = Paths.get(temporaryUserHome.getRoot().getAbsolutePath(), "standalone.xml"); Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); // Determine the command to use final ModelControllerClient client = container.getClient().getControllerClient(); ModelNode op = Operations.createReadResourceOperation(Operations.createAddress("core-service", "management", "management-interface", "http-interface")); ModelNode result = client.execute(op); if (Operations.isSuccessfulOutcome(result)) { result = Operations.readResult(result); if (result.hasDefined("http-upgrade")) { final ModelNode httpUpgrade = result.get("http-upgrade"); if (httpUpgrade.hasDefined("sasl-authentication-factory")) { // We could query this further to get the actual name of the configurable-sasl-server-factory. Since this // is a test we're making some assumptions to limit the number of query calls made to the server. removeLocalAuthCommand = "/subsystem=elytron/configurable-sasl-server-factory=configured:map-remove(name=properties, key=wildfly.sasl.local-user.default-user)"; } } } else { fail(Operations.getFailureDescription(result).asString()); } }
Example 5
Source File: AbstractDeploymentManagerTest.java From wildfly-maven-plugin with GNU Lesser General Public License v2.1 | 5 votes |
ModelNode executeOp(final ModelNode op) throws IOException { final ModelNode result = getClient().execute(op); if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result); } Assert.fail(String.format("Operation %s failed: %s", op, Operations.getFailureDescription(result))); // Should never be reached return new ModelNode(); }
Example 6
Source File: DefaultContainerDescription.java From wildfly-maven-plugin with GNU Lesser General Public License v2.1 | 5 votes |
/** * Queries the running container and attempts to lookup the information from the running container. * * @param client the client used to execute the management operation * * @return the container description * * @throws IOException if an error occurs while executing the management operation * @throws OperationExecutionException if the operation used to query the container fails */ static DefaultContainerDescription lookup(final ModelControllerClient client) throws IOException, OperationExecutionException { final ModelNode op = Operations.createReadResourceOperation(new ModelNode().setEmptyList()); op.get(ClientConstants.INCLUDE_RUNTIME).set(true); final ModelNode result = client.execute(op); if (Operations.isSuccessfulOutcome(result)) { final ModelNode model = Operations.readResult(result); final String productName = getValue(model, "product-name", "WildFly"); final String productVersion = getValue(model, "product-version"); final String releaseVersion = getValue(model, "release-version"); final String launchType = getValue(model, "launch-type"); return new DefaultContainerDescription(productName, productVersion, releaseVersion, launchType, "DOMAIN".equalsIgnoreCase(launchType)); } throw new OperationExecutionException(op, result); }
Example 7
Source File: ServerHelper.java From wildfly-maven-plugin with GNU Lesser General Public License v2.1 | 5 votes |
private static boolean isDomainRunning(final ModelControllerClient client, boolean shutdown) { final DomainClient domainClient = (client instanceof DomainClient ? (DomainClient) client : DomainClient.Factory.create(client)); try { // Check for admin-only final ModelNode hostAddress = determineHostAddress(domainClient); final CompositeOperationBuilder builder = CompositeOperationBuilder.create() .addStep(Operations.createReadAttributeOperation(hostAddress, "running-mode")) .addStep(Operations.createReadAttributeOperation(hostAddress, "host-state")); ModelNode response = domainClient.execute(builder.build()); if (Operations.isSuccessfulOutcome(response)) { response = Operations.readResult(response); if ("ADMIN_ONLY".equals(Operations.readResult(response.get("step-1")).asString())) { if (Operations.isSuccessfulOutcome(response.get("step-2"))) { final String state = Operations.readResult(response).asString(); return !CONTROLLER_PROCESS_STATE_STARTING.equals(state) && !CONTROLLER_PROCESS_STATE_STOPPING.equals(state); } } } final Map<ServerIdentity, ServerStatus> servers = new HashMap<>(); final Map<ServerIdentity, ServerStatus> statuses = domainClient.getServerStatuses(); for (ServerIdentity id : statuses.keySet()) { final ServerStatus status = statuses.get(id); switch (status) { case DISABLED: case STARTED: { servers.put(id, status); break; } } } if (shutdown) { return statuses.isEmpty(); } return statuses.size() == servers.size(); } catch (Exception e) { LOGGER.trace("Interrupted determining if domain is running", e); } return false; }
Example 8
Source File: ExplodedDeploymentTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode readDeploymentResource(PathAddress address) { ModelNode operation = Operations.createReadResourceOperation(address.toModelNode()); operation.get(INCLUDE_RUNTIME).set(true); operation.get(INCLUDE_DEFAULTS).set(true); AsyncFuture<ModelNode> future = masterClient.executeAsync(operation, null); ModelNode result = awaitSimpleOperationExecution(future); assertTrue(Operations.isSuccessfulOutcome(result)); return Operations.readResult(result); }
Example 9
Source File: FullReplaceUndeployTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static ModelNode execute(final ModelControllerClient client, final Operation op, final boolean expectFailure) throws IOException { final ModelNode result = client.execute(op); if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result); } if (!expectFailure) { throw new RuntimeException(String.format("Failed to execute operation: %s%n%s", op.getOperation(), Operations.getFailureDescription(result))); } return Operations.getFailureDescription(result); }
Example 10
Source File: DeploymentOverlayTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode readDeploymentResource(PathAddress address) { ModelNode operation = Operations.createReadResourceOperation(address.toModelNode()); operation.get(INCLUDE_RUNTIME).set(true); operation.get(INCLUDE_DEFAULTS).set(true); AsyncFuture<ModelNode> future = masterClient.executeAsync(operation, null); ModelNode result = awaitSimpleOperationExecution(future); assertTrue(Operations.isSuccessfulOutcome(result)); return Operations.readResult(result); }
Example 11
Source File: ScriptTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static ModelNode executeOperation(final ModelControllerClient client, final Operation op) throws IOException { final ModelNode result = client.execute(op); if (!Operations.isSuccessfulOutcome(result)) { Assert.fail(String.format("Failed to execute op: %s%nFailure Description: %s", op, Operations.getFailureDescription(result))); } return Operations.readResult(result); }
Example 12
Source File: AbstractLogFieldsOfLogTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ModelNode executeForSuccess(final ModelControllerClient client, final Operation op) throws IOException { final ModelNode result = client.execute(op); if (!Operations.isSuccessfulOutcome(result)) { Assert.fail(Operations.getFailureDescription(result).asString()); } return Operations.readResult(result); }
Example 13
Source File: ManagementAuthenticationUsersServerSetupTask.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode executeForSuccess(final ModelControllerClient client, final ModelNode op) throws IOException { final ModelNode result = client.execute(op); if (!Operations.isSuccessfulOutcome(result)) { Assert.fail(Operations.getFailureDescription(result).asString()); } return Operations.readResult(result); }
Example 14
Source File: SocketHandlerTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode executeOperation(final ManagementClient managementClient, final ModelNode op) throws IOException { final ModelNode result = managementClient.getControllerClient().execute(op); if (!Operations.isSuccessfulOutcome(result)) { throw new RuntimeException(Operations.getFailureDescription(result).toString()); } return Operations.readResult(result); }
Example 15
Source File: DisableLocalAuthServerSetupTask.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode executeForSuccess(final ModelControllerClient client, final Operation op) throws IOException { final ModelNode result = client.execute(op); if (!Operations.isSuccessfulOutcome(result)) { Assert.fail(Operations.getFailureDescription(result).asString()); } return Operations.readResult(result); }
Example 16
Source File: AbstractTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static ModelNode executeOperation(final ModelControllerClient client, final Operation op) throws IOException { final ModelNode result = client.execute(op); if (!Operations.isSuccessfulOutcome(result)) { Assert.fail(String.format("Failed to execute op: %s%nFailure Description: %s", op, Operations.getFailureDescription(result))); } return Operations.readResult(result); }
Example 17
Source File: HttpMgmtConfigurator.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private String readAttribute(ModelControllerClient client, String name) throws Exception { String originalVal; ModelNode op = Util.createEmptyOperation("read-attribute", HTTP_IFACE_ADDR); op.get("name").set(name); ModelNode result = client.execute(op); if (Operations.isSuccessfulOutcome(result)) { result = Operations.readResult(result); originalVal = result.isDefined() ? result.asString() : null; } else { throw new RuntimeException( "Reading existing value of attribute " + name + " failed: " + Operations.getFailureDescription(result)); } return originalVal; }
Example 18
Source File: AccessIdentityConfigurator.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private String setAccessIdentity(ModelControllerClient client, String domainToSet) throws Exception { String origDomainValue = null; ModelNode op = Util.createEmptyOperation("read-attribute", IDENTITY_ADDR); op.get("name").set("security-domain"); ModelNode result = client.execute(op); boolean identityExists = Operations.isSuccessfulOutcome(result); op = null; if (identityExists) { result = Operations.readResult(result); origDomainValue = result.isDefined() ? result.asString() : null; if (domainToSet == null) { op = Util.createRemoveOperation(IDENTITY_ADDR); } else if (!domainToSet.equals(origDomainValue)) { op = Util.createEmptyOperation("write-attribute", IDENTITY_ADDR); op.get("name").set("security-domain"); op.get("value").set(domainToSet); } } else if (domainToSet != null) { op = Util.createAddOperation(IDENTITY_ADDR); op.get("security-domain").set(domainToSet); } if (op!=null) { CoreUtils.applyUpdate(op, client); } return origDomainValue; }
Example 19
Source File: ServerHelper.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * Checks to see if a domain server is running. * * @param client the client used to communicate with the server * @param forShutdown if this is checking for a shutdown * * @return {@code true} if the server, and it's auto-start servers, are running, otherwise {@code false} */ public static boolean isDomainRunning(final ModelControllerClient client, final boolean forShutdown) { final DomainClient domainClient = (client instanceof DomainClient ? (DomainClient) client : DomainClient.Factory.create(client)); try { // Check for admin-only final ModelNode hostAddress = determineHostAddress(domainClient); final Operations.CompositeOperationBuilder builder = Operations.CompositeOperationBuilder.create() .addStep(Operations.createReadAttributeOperation(hostAddress, "running-mode")) .addStep(Operations.createReadAttributeOperation(hostAddress, "host-state")); ModelNode response = domainClient.execute(builder.build()); if (Operations.isSuccessfulOutcome(response)) { response = Operations.readResult(response); if ("ADMIN_ONLY".equals(Operations.readResult(response.get("step-1")).asString())) { if (Operations.isSuccessfulOutcome(response.get("step-2"))) { final String state = Operations.readResult(response).asString(); return !CONTROLLER_PROCESS_STATE_STARTING.equals(state) && !CONTROLLER_PROCESS_STATE_STOPPING.equals(state); } } } final Map<ServerIdentity, ServerStatus> servers = new HashMap<>(); final Map<ServerIdentity, ServerStatus> statuses = domainClient.getServerStatuses(); for (ServerIdentity id : statuses.keySet()) { final ServerStatus status = statuses.get(id); switch (status) { case DISABLED: case STARTED: { servers.put(id, status); break; } } } if (forShutdown) { return statuses.isEmpty(); } return statuses.size() == servers.size(); } catch (IllegalStateException | IOException ignore) { } return false; }
Example 20
Source File: AbstractLoggingTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 3 votes |
/** * Reads the deployment resource. * * @param deploymentName the name of the deployment * @param configurationName the name of the configuration for the address * * @return the model for the deployment * * @throws IOException if an error occurs connecting to the server */ public static ModelNode readDeploymentResource(final String deploymentName, final String configurationName) throws IOException { ModelNode address = Operations.createAddress("deployment", deploymentName, "subsystem", "logging", "configuration", configurationName); ModelNode op = Operations.createReadResourceOperation(address, true); op.get("include-runtime").set(true); final ModelNode result = Operations.readResult(executeOperation(op)); // Add the address on the result as the tests might need it result.get(ModelDescriptionConstants.OP_ADDR).set(address); return result; }