Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • Enjoy members-only rewards and discounts
  • Create and access a list of your products
  • Manage your Dell EMC sites, products, and product-level contacts using Company Administration.

超越枚举探索 WSMAN

Summary: 戴尔技术中心中的戴尔操作系统和应用程序解决方案-Project Sputnik、Microsoft Windows、Red Hat Linux、SUSE、Ubuntu等

This article may have been automatically translated. If you have any feedback regarding its quality, please let us know using the form at the bottom of this page.

Article Content


Symptoms

WSMAN是戴尔iDRAC选择的管理API,并且正在做出大量努力,以使远程系统管理尽可能全面和简单。我最近花了一些时间了解 WSMAN 协议来实现插件,在最初的 wsman 枚举操作之后,WSMAN 协议变得有点毛茸茸的。关于如何使用正确的键属性调用 get/put/create/delete/custom 操作,没有简单的文档/示例。  此信息的主要来源是 DMTF 的 WSMAN 规范和 WSMAN-CIM 绑定规范,它们很难遵循。同样,本文的大部分内容都来自 DMTF 规格文档。这是试图通过一些示例(在 Linux 上)使这些信息易于理解。

我已经在以下位置发布了一篇关于如何开始使用 SFCB 和 openwsman 的白皮书: https://linux.dell.com/files/whitepapers/WBEM_based_management_in_Linux.pdf关联。如果您不熟悉 WSMAN/SFCB,pdf 将是比本文更好的起点。与上面的白皮书一样,我们将在本文中主要讨论 openwsman 和 SFCB CIMOM 实现。

现在,给定一个 WSMAN 服务器,有没有办法列出 wsman API 可管理的所有组件?大多数 WSMAN 服务器在后端与 CIMOM 通信,并公开 CIMOM 的管理功能。这意味着,WSMAN 服务器的管理功能依赖于后端向 CIMOM 注册的 CIM 提供程序。CIMOM 具有一个名为 EnumerateClassNames 定义的内部函数,可以调用该函数以列出注册到 CIMOM 的所有类。

Cause

由于 WSMAN 规范中没有 EnumerateClassNames 的一对一映射,因此此方法的调用方式与 WSMAN 中的任何其他自定义函数一样。请注意,这是特定于实现的,适用于 wsmancli 实现。这可能会在将来的版本中有所不同或更新。

Resolution

可以使用 wsmancli 按如下方式调用 CIMOM 的内部 EnumerateClassNames 函数:
wsman invoke -a EnumerateClassNames --hostname=test_host --port=5985 --username=abc --password=password http://schemas.openwsman.org/wbem/wscim/1/instrinsic  --namespace=root/cimv2
   
 <s:Body>

    <n1:EnumerateClassNames>

      <n1:name>root/cimv2:CIM_Service</n1:name>

      <n1:name>root/cimv2:Syslog_RecordInLog</n1:name>

      <n1:name>root/cimv2:Linux_SambaValidUsersForShare</n1:name>

       <n1:name>root/cimv2:Linux_BaseBoard</n1:name>

      <n1:name>root/cimv2:Linux_SambaForceUserForShare</n1:name>

      <n1:name>root/cimv2:Linux_Processor</n1:name>

      <n1:name>root/cimv2:CIM_RecordForLog</n1:name>

      <n1:name>root/cimv2:Linux_SambaShareForService</n1:name>

      <n1:name>root/cimv2:Linux_SambaServiceConfigurationForService</n1:name>

      <n1:name>root/cimv2:Linux_SambaHostsForService</n1:name>

      <n1:name>root/cimv2:Linux_SambaForceUserForGlobal</n1:name>

      <n1:name>root/cimv2:CIM_OSProcess</n1:name>

      <n1:name>root/cimv2:CIM_RunningOS</n1:name>...................
 
输出如上所示,表明在命名空间 root/cimv2 中,Linux_Processor 是注册的类之一。在 root/cimv2 命名空间中注册新类时,会继承许多 CIM 类,上述命令也将列出所有这些类名。作为一般规则,您可以忽略所有带有 CIM_ 前缀的类。所有带有 Linux_ 前缀的类都是由 Linux 系统上安装的提供程序注册的类。在使用 Dell 的 idrac 时,您主要对带有 DCIM_ 前缀的类感兴趣。

现在你已经有了所有类名的列表,你可以使用 getClass 内部函数来提取 Linux_Processor 类的定义,如下所示:
wsman invoke -a GetClass --hostname=test_host --port=5985 --username=abc --password=password http://schemas.openwsman.org/wbem/wscim/1/intrinsic/Linux_Processor  --namespace=root/cimv2
 
 以上命令将列出在 本地Linux_Processor 中定义的所有属性。这意味着从其他 CIM_* 类继承的任何属性都不会与当前实现一起列出。通常,从类的定义中,您可以确定在类中定义了哪些方法,需要将哪些参数传递给这些方法,以及类的哪些属性是关键属性等。但是,由于上述命令仅返回 Local 属性,因此无法标识类中的关键属性。同样,这目前是 wsmancli 中的实现限制。

因此,尽管 GetClass 函数是一个很好的起点,但它的输出不足以确定类的哪些属性可以用作键属性,以便可以调用 get/put/create/custom 操作。那么,还可以使用哪些其他技术来实现这一点呢?这就是 EPR 可以提供帮助的地方。


EPR(端点参考)是指向实例的指针,其中包含两条信息:ResourceURI 和选择器集。ResourceURI 具有创建实例的类名,“选择器集”列出了实例可以唯一标识的属性。可以使用类似于以下内容的命令枚举特定类的 EPR:
wsman enumerate -M epr  http://sblim.sf.net/wbem/wscim/1/cim-schema/2/Linux_Processor -h test_host-P 5985 -u abc -p password -O out

 <?xml version="1.0" encoding="UTF-8"?>

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration" xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">

  <s:Header>

    <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>

    <wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/enumeration/PullResponse</wsa:Action>

    <wsa:RelatesTo>uuid:ca52c9e9-cd47-1d47-8003-a52924d9bed4</wsa:RelatesTo>

    <wsa:MessageID>uuid:ca622bb3-cd47-1d47-8097-a52924d9bed4</wsa:MessageID>

  </s:Header>

  <s:Body>

    <wsen:PullResponse>

      <wsen:EnumerationContext>ca4fdd21-cd47-1d47-8095-a52924d9bed4</wsen:EnumerationContext>

      <wsen:Items>

        <wsa:EndpointReference>

          <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>

          <wsa:ReferenceParameters>

            <wsman:ResourceURI>http://sblim.sf.net/wbem/wscim/1/cim-schema/2/Linux_Processor</wsman:ResourceURI>

            <wsman:SelectorSet>

              <wsman:Selector Name="__cimnamespace">root/cimv2</wsman:Selector>

              <wsman:Selector Name="SystemCreationClassName">Linux_ComputerSystem</wsman:Selector>

              <wsman:Selector Name="SystemName">localhost.localdomain</wsman:Selector>

              <wsman:Selector Name="CreationClassName">Linux_Processor</wsman:Selector>

              <wsman:Selector Name="DeviceID">0</wsman:Selector>

            </wsman:SelectorSet>

          </wsa:ReferenceParameters>

        </wsa:EndpointReference>

      </wsen:Items>

    </wsen:PullResponse>

  </s:Body>

</s:Envelope>
 在目标系统中的所有处理器中,以上输出只有一个处理器。在输出中,resourceURI 列为 http://sblim.sf.net/wbem/wscim/1/cim-schema/2/Linux_Processor,SelectorSet 列出了 __cimnamespace、SystemCreationClassName、SystemName、CreationClassName 和 DeviceID 的值。这意味着 Linux_Processor 类中的所有属性(继承和本地定义)中,这些属性可用于唯一标识实例。

 因此,您可以期待命令的有效响应,如下所示:
wsman get  http://sblim.sf.net/wbem/wscim/1/cim-schema/2/Linux_Processor?SystemCreationClassName="Linux_ComputerSystem",SystemName="localhost.localdomain",CreationClassName="Linux_Processor",DeviceID="3",__cimnamespace="root/cimv2" -h test_host -P 5985 -u abc -p password -O get
 如果上述请求中使用了任何其他属性,则后端的 CIMOM 将无法唯一标识实例。同样,如果有一些自定义方法需要运行实例,则可以使用类的 EPR 来标识要调用方法的关键属性。

也可以枚举关联的 EPR。给定一个类名,我们无法确定它是标准类名还是关联类。由于关联的实例具有指向两个实例的指针,因此关联的 EPR 将具有关联所引用的实例/对象的 EPR。下面是一个相同的示例:
wsman enumerate -M epr  http://sblim.sf.net/wbem/wscim/1/cim-schema/2/Linux_CSProcessor -h test_host -P 5985 -u abc -p password -O out

 <?xml version="1.0" encoding="UTF-8"?>

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration" xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">

  <s:Header>

    <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>

    <wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/enumeration/PullResponse</wsa:Action>

    <wsa:RelatesTo>uuid:2efbfcad-cd4b-1d4b-8003-a52924d9bed4</wsa:RelatesTo>

    <wsa:MessageID>uuid:2efc1c6f-cd4b-1d4b-80b3-a52924d9bed4</wsa:MessageID>

  </s:Header>

  <s:Body>

    <wsen:PullResponse>

      <wsen:EnumerationContext>2ef7f6f5-cd4b-1d4b-80b1-a52924d9bed4</wsen:EnumerationContext>

      <wsen:Items>

        <wsa:EndpointReference>

          <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>

          <wsa:ReferenceParameters>

            <wsman:ResourceURI>http://sblim.sf.net/wbem/wscim/1/cim-schema/2/Linux_CSProcessor</wsman:ResourceURI>

            <wsman:SelectorSet>

              <wsman:Selector Name="__cimnamespace">root/cimv2</wsman:Selector>

              <wsman:Selector Name="GroupComponent">

                <wsa:EndpointReference>

                  <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>

                  <wsa:ReferenceParameters>

                    <wsman:ResourceURI>http://sblim.sf.net/wbem/wscim/1/cim-schema/2/Linux_ComputerSystem</wsman:ResourceURI>

                    <wsman:SelectorSet>

                      <wsman:Selector Name="CreationClassName">Linux_ComputerSystem</wsman:Selector>

                      <wsman:Selector Name="Name">localhost.localdomain</wsman:Selector>

                      <wsman:Selector Name="__cimnamespace">root/cimv2</wsman:Selector>

                    </wsman:SelectorSet>

                  </wsa:ReferenceParameters>

                </wsa:EndpointReference>

              </wsman:Selector>

              <wsman:Selector Name="PartComponent">

                <wsa:EndpointReference>

                  <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>

                  <wsa:ReferenceParameters>

                    <wsman:ResourceURI>http://sblim.sf.net/wbem/wscim/1/cim-schema/2/Linux_Processor</wsman:ResourceURI>

                    <wsman:SelectorSet>

                      <wsman:Selector Name="SystemCreationClassName">Linux_ComputerSystem</wsman:Selector>

                      <wsman:Selector Name="SystemName">localhost.localdomain</wsman:Selector>

                      <wsman:Selector Name="CreationClassName">Linux_Processor</wsman:Selector>

                      <wsman:Selector Name="DeviceID">0</wsman:Selector>

                      <wsman:Selector Name="__cimnamespace">root/cimv2</wsman:Selector>

                    </wsman:SelectorSet>

                  </wsa:ReferenceParameters>

                </wsa:EndpointReference>

              </wsman:Selector>

            </wsman:SelectorSet>

          </wsa:ReferenceParameters>

        </wsa:EndpointReference>

      </wsen:Items>

    </wsen:PullResponse>

  </s:Body>

</s:Envelope>
Linux_CSProcessorLinux_ComputerSystemLinux_Processor 类之间的关联,用于建立处理器包含在计算机系统中的关系,因此 GroupComponent 和 PartComponent 部分。

我不得不花一些时间弄清楚 EPR 以及如何使用它们来访问单个实例,认为它可能对其他人派上用场。请随时在下面给我留下您的意见/建议。

免责声明

以上文章仅供参考。内容来自我对提到的技术/术语的解释。此信息按原样提供,其中可能包含一些印刷错误和/或技术上的不准确之处。

Article Properties


Affected Product

Ubuntu Server LTS

Last Published Date

11 Jun 2024

Version

4

Article Type

Solution