Menu Close
Settings Close

Language and Page Formatting Options

3.6. 管理 CLI 操作

3.6.1. 用管理 CLI 显示资源属性

概述

read-attribute 操作是一个用来读取选定属性的当前 runtime 值的全局操作。它可以用来只开放用户设置的值而忽略任何默认或未定义的值。请求属性包括下列参数。

请求属性

name
获取所选资源下的值的属性的名称。
include-defaults
布尔型参数,可以设置为 false 来限制操作结果,只显示用户设置的属性并忽略默认的值。

过程 3.13. 显示所选属性的当前 Runtime 值

read-attribute 操作的优势是开放专有属性的当前 runtime 值的能力。用 read-resource 操作可获得类似的结果,但只能通过 include-runtime 请求属性,而且只作为该节点的所有可用资源的列表的一部分。read-attribute 操作用于细颗粒度的属性查询,如下例所示。

例 3.7. 运行 read-attribute 操作来开放公共的接口 IP。

如果您知道要开放的属性的名称,您可以使用 read-attribute 来获取当前 runtime 里的确切的值。
[standalone@localhost:9999 /] /interface=public:read-attribute(name=resolved-address)
{
    "outcome" => "success",
    "result" => "127.0.0.1"
}

resolved-address 属性是一个 runtime 值,所以不会显示在标准的 read-resource 操作的结果里。
[standalone@localhost:9999 /] /interface=public:read-resource                        
{
    "outcome" => "success",
    "result" => {
        "any" => undefined,
        "any-address" => undefined,
        "any-ipv4-address" => undefined,
        "any-ipv6-address" => undefined,
        "inet-address" => expression "${jboss.bind.address:127.0.0.1}",
        "link-local-address" => undefined,
        "loopback" => undefined,
        "loopback-address" => undefined,
        "multicast" => undefined,
        "name" => "public",
        "nic" => undefined,
        "nic-match" => undefined,
        "not" => undefined,
        "point-to-point" => undefined,
        "public-address" => undefined,
        "site-local-address" => undefined,
        "subnet-match" => undefined,
        "up" => undefined,
        "virtual" => undefined
    }
}

要显示 resolved-address 和其他 runtime 值,您必须使用 include-runtime 请求属性。
[standalone@localhost:9999 /] /interface=public:read-resource(include-runtime=true)
{
    "outcome" => "success",
    "result" => {
        "any" => undefined,
        "any-address" => undefined,
        "any-ipv4-address" => undefined,
        "any-ipv6-address" => undefined,
        "inet-address" => expression "${jboss.bind.address:127.0.0.1}",
        "link-local-address" => undefined,
        "loopback" => undefined,
        "loopback-address" => undefined,
        "multicast" => undefined,
        "name" => "public",
        "nic" => undefined,
        "nic-match" => undefined,
        "not" => undefined,
        "point-to-point" => undefined,
        "public-address" => undefined,
        "resolved-address" => "127.0.0.1",
        "site-local-address" => undefined,
        "subnet-match" => undefined,
        "up" => undefined,
        "virtual" => undefined
    }
}

结果

显示当前的 runtime 属性值。