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 或其他自定义操作,没有任何文档/示例能够轻松地阐述清楚。  此信息的主要来源是 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

CIMOM 的内部 EnumerateClassNames 函数可通过 wsmancli 按如下方式进行调用:
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 系统上安装的提供程序注册的类。在使用戴尔的 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_* 类继承的任何属性。通常,从类的定义中,您就可以知道类中定义了哪些方法,需要将哪些参数传递给这些方法,以及类的哪些属性是关键属性等。但是,由于上述命令只返回本地属性,因此无法确定类中的关键属性。这目前同样是 wsmancli 中的实现的某个局限性。

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


EPR(端点引用)是指向实例的指针,其中包含两条信息:ResourceURI 和 Selector Set。ResourceURI 包含实例创建时使用的类名,而 Selector Set 列出了可唯一地标识实例的属性。您可以使用类似于以下内容的命令来枚举特定类的 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_ComputerSystem 类和 Linux_Processor 类之间的关联,建立了处理器包含在计算机系统中的关系,因此 GroupComponent 和 PartComponent 部分也是如此。

我不得不花一些时间弄清楚 EPR 以及如何使用它们来访问各个实例,我想这对其他人可能会有用。欢迎在下方给我留下您的意见/建议。

免责声明

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

Article Properties


Affected Product

Ubuntu Server LTS

Last Published Date

11 Jun 2024

Version

4

Article Type

Solution