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: Dell TechCenter 上的 Dell 作業系統和應用程式解決方案 - 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 是 Dell iDRAC 所選擇的管理 API,且目前正投入大量心力,讓遠端系統管理盡可能全面又簡單。我最近花了一些時間瞭解WSMAN協議來實現外掛程式,在最初的wsman枚舉操作之後,WSMAN協定變得有點毛茸茸的。對於如何使用正確的鍵屬性調用獲取/放置/創建/刪除/自定義操作,沒有簡單的文檔/示例。  這些資訊的主要來源是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 規範中沒有 EnumerateClassName 的一對一映射,因此此方法的調用方式與 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系統上的提供程式註冊的類。在使用 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_* 類繼承的任何屬性都不會在當前實現中列出。通常,從類的定義中,您可以弄清楚類中定義了哪些方法,需要將哪些參數傳遞給這些方法以及類的哪些屬性是關鍵屬性等。但是,由於上述命令僅返回本地屬性,因此無法標識類中的關鍵屬性。同樣地,這目前是 wsmancli 中的一個實現限制。

因此,儘管 GetClass 函數是一個很好的起點,但它的輸出不足以確定類的哪些屬性可以用作鍵屬性,以便可以調用 get/放置/創建/自定義操作。那麼,可以使用哪些其他技術來完成此操作呢?這就是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,選擇器集列出 __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 類之間的關聯,建立了處理器包含在計算機系統中的關係,因此是組元件和部件元件部分。

我不得不花一些時間弄清楚 EPR 以及如何使用它們來訪問單個實例,認為它可能會對其他人派上用場。請隨時在下面給我留下您的意見/建議。

免責聲明

以上文章僅供參考。內容來自我對上述技術/術語的解釋。此資訊係以現狀提供,可能包含一些打字錯誤及/或技術疏失。

Article Properties


Affected Product

Ubuntu Server LTS

Last Published Date

11 Jun 2024

Version

4

Article Type

Solution