Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • 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 通訊協定變得有點難以控制。對於如何使用正確的關鍵屬性叫用 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

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/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,選擇器集則會列出 __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