Show Table of Contents
3.5.8. 在管理 CLI 里使用操作和命令
过程 3.12. 创建、配置和执行请求
构造操作请求
操作请求允许和管理模型的低层交互。它们提供一种可控的方式来编辑服务器配置。操作请求由三部分组成:- 地址,前缀为斜杠(
/)。 - 操作名称,前缀为冒号(
:)。 - 可选的参数,包含在括号(
())里。
确定地址
配置以有地址的资源层级树型出现。每个资源节点都提供了一系列不同的操作。地址指定哪些资源可以执行操作。地址使用下面的语法:/node-type=node-name
- node-type 是资源节点的类型。它映射配置 XML 文件里的元素名称。
- node-name 是资源节点的名称。它映射配置 XML 文件里的元素的
name属性。 - 用斜杠(
/)分隔资源树的每个级别。
要确定所需的地址,请参考 XML 配置文件。EAP_HOME/standalone/configuration/standalone.xml文件保存独立服务器的配置信息,EAP_HOME/domain/configuration/domain.xml和EAP_HOME/domain/configuration/host.xml文件保存受管域的配置信息。例 3.3. 操作地址示例
要执行 Logging 子系统上的操作,请使用操作请求里的下列地址:/subsystem=logging
要执行 Java 数据源上的操作,请使用操作请求里的下列地址:/subsystem=datasources/data-source=java
确定操作
对于不同类型的资源节点,操作会有所不同。操作使用下面的语法::operation-name
- operation-name 是要请求的操作的名称。
在独立服务器上的任何资源地址上使用read-operation-names操作来列出可用的操作。例 3.4. 可用的操作
要列出 Logging 子系统到所有可用的操作,在独立服务器里输入下列请求:[standalone@localhost:9999 /] /subsystem=logging:read-operation-names { "outcome" => "success", "result" => [ "add", "read-attribute", "read-children-names", "read-children-resources", "read-children-types", "read-operation-description", "read-operation-names", "read-resource", "read-resource-description", "remove", "undefine-attribute", "whoami", "write-attribute" ] }确定任何参数
每个操作可能需要不同的参数。参数使用下面的语法:(parameter-name=parameter-value)
- parameter-name 是参数的名称。
- parameter-value 是参数的值。
- 多个参数用逗号隔开(
,)。
要确定所需的参数,在资源节点上执行read-operation-description命令,将操作名称作为参数传入。详情请参考 例 3.5 “确定操作的参数”。例 3.5. 确定操作的参数
要确定 logging 子系统上的read-children-types操作的必需参数,请输入read-operation-description命令:[standalone@localhost:9999 /] /subsystem=logging:read-operation-description(name=read-children-types) { "outcome" => "success", "result" => { "operation-name" => "read-children-types", "description" => "Gets the type names of all the children under the selected resource", "reply-properties" => { "type" => LIST, "description" => "The children types", "value-type" => STRING }, "read-only" => true } }
输入完整的操作请求
一旦确定了地址、操作和所有参数,请输入完整的操作请求。例 3.6. 操作请求示例
[standalone@localhost:9999 /]
/subsystem=web/connector=http:read-resource(recursive=true)
结果
管理接口执行服务器配置里的操作请求。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.