/** * {@inheritDoc} */ @Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) { String name = Operations.getAttributeName(operation); ModelNode legacyOperation = org.jboss.as.controller.client.helpers.Operations.createReadAttributeOperation(this.addressTransformer.transform(address).toModelNode(), name); return new TransformedOperation(legacyOperation, OperationResultTransformer.ORIGINAL_RESULT); } }
private String obtainServerUUID() throws OperationFailedException { try { ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), UUID); operation.get(INCLUDE_RUNTIME).set(true); ModelControllerClient client = env.getClient(); if (client == null) { client = env.getCli().getCommandContext().getModelControllerClient(); } ModelNode result = client.execute(operation); if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result).asString(); } return null; } catch (IOException ex) { return null; } }
private String obtainProductName() { try { ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), PRODUCT_NAME); operation.get(INCLUDE_RUNTIME).set(false); ModelControllerClient client = env.getClient(); if (client == null) { client = env.getCli().getCommandContext().getModelControllerClient(); } ModelNode result = client.execute(operation); if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result).asString(); } return "undefined"; } catch (IOException e) { // This should not be needed since a product name is always returned, even if it doesn't exist. // In that case "undefined" is returned return "undefined"; } }
private String obtainProductVersion() { try { ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), PRODUCT_VERSION); operation.get(INCLUDE_RUNTIME).set(false); ModelControllerClient client = env.getClient(); if (client == null) { client = env.getCli().getCommandContext().getModelControllerClient(); } ModelNode result = client.execute(operation); if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result).asString(); } return "undefined"; } catch (IOException e) { // This should not be needed since a product version is always returned, even if it doesn't exist. // In that case "undefined" is returned return "undefined"; } } }
@Override public String getServerGroupName(final String hostName, final String serverName) { checkState(false); final ModelNode result = runtimeExecuteForSuccess(Operations.createReadAttributeOperation(Operations.createAddress(ClientConstants.HOST, hostName, ClientConstants.SERVER_CONFIG, serverName), "group")); return result.asString(); }
/** * Checks to see if a standalone server is running. * * @param client the client used to communicate with the server * * @return {@code true} if the server is running, otherwise {@code false} */ public static boolean isStandaloneRunning(final ModelControllerClient client) { try { final ModelNode response = client.execute(Operations.createReadAttributeOperation(EMPTY_ADDRESS, "server-state")); if (Operations.isSuccessfulOutcome(response)) { final String state = Operations.readResult(response).asString(); return !CONTROLLER_PROCESS_STATE_STARTING.equals(state) && !CONTROLLER_PROCESS_STATE_STOPPING.equals(state); } } catch (RuntimeException | IOException e) { LOGGER.trace("Interrupted determining if standalone is running", e); } return false; }
private boolean isEnabled(final ModelNode address) { final ModelNode op = Operations.createReadAttributeOperation(address, DeploymentOperations.ENABLED); try { final ModelNode result = client.execute(op); // Check to make sure there is an outcome if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result).asBoolean(); } else { throw new IllegalStateException(Operations.getFailureDescription(result).asString()); } } catch (IOException e) { throw new IllegalStateException(String.format("Could not execute operation '%s'", op), e); } }
/** * Checks the running server to determine if it is a managed domain server. * * @param client the client used to query the server * * @return {@code true} if the running server is a managed domain, otherwise {@code false} * * @throws IOException if an error occurs communicating with the server */ public static boolean isDomainServer(final ModelControllerClient client) throws IOException { boolean result = false; // Check this is really a domain server final ModelNode op = Operations.createReadAttributeOperation(EMPTY_ADDRESS, "launch-type"); final ModelNode opResult = Assert.checkNotNullParam("client", client).execute(op); if (Operations.isSuccessfulOutcome(opResult)) { result = ("DOMAIN".equalsIgnoreCase(Operations.readResult(opResult).asString())); } return result; }
@Override public boolean isServerStarted(final String hostName, final String serverName) { checkState(true); final ModelNode op = Operations.createReadAttributeOperation(Operations.createAddress(ClientConstants.HOST, hostName, ClientConstants.SERVER_CONFIG, serverName), "status"); try { final ModelNode result = getModelControllerClient().execute(op); if (Operations.isSuccessfulOutcome(result)) { return "STARTED".equals(Operations.readResult(result).asString()); } } catch (IOException ignore) { } return false; }
for (ModelNode file : result.asList()) { files.add(file.asString()); builder.addStep(Operations.createReadAttributeOperation(address.clone().add("log-file", file.asString()), "file-size")) .addStep(Operations.createReadAttributeOperation(address.clone().add("log-file", file.asString()), "last-modified-time"));
/** * {@inheritDoc} */ @Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) { String name = Operations.getAttributeName(operation); ModelNode legacyOperation = org.jboss.as.controller.client.helpers.Operations.createReadAttributeOperation(this.addressTransformer.transform(address).toModelNode(), name); return new TransformedOperation(legacyOperation, OperationResultTransformer.ORIGINAL_RESULT); } }
.addStep(Operations.createReadAttributeOperation(hostAddress, "running-mode")) .addStep(Operations.createReadAttributeOperation(hostAddress, "host-state")); ModelNode response = domainClient.execute(builder.build()); if (Operations.isSuccessfulOutcome(response)) {
for (ModelNode file : result.asList()) { files.add(file.asString()); builder.addStep(Operations.createReadAttributeOperation(address.clone().add("log-file", file.asString()), "file-size")) .addStep(Operations.createReadAttributeOperation(address.clone().add("log-file", file.asString()), "last-modified-time"));
/** * Determines the address for the host being used. * * @param client the client used to communicate with the server * * @return the address of the host * * @throws IOException if an error occurs communicating with the server * @throws OperationExecutionException if the operation used to determine the host name fails */ public static ModelNode determineHostAddress(final ModelControllerClient client) throws IOException, OperationExecutionException { final ModelNode op = Operations.createReadAttributeOperation(EMPTY_ADDRESS, "local-host-name"); ModelNode response = client.execute(op); if (Operations.isSuccessfulOutcome(response)) { return DeploymentOperations.createAddress("host", Operations.readResult(response).asString()); } throw new OperationExecutionException(op, response); }
ModelNode op = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), "local-host-name"); ModelNode result = getManagementClient().getControllerClient().execute(op, null); if (Operations.isSuccessfulOutcome(result)) {