PowerEdge:探索超越列舉的 WSMAN
Summary: Dell TechCenter 上的 Dell 作業系統和應用程式解決方案 - Project Sputnik、Microsoft Windows、Red Hat Linux、SUSE、Ubuntu 等等
Symptoms
的 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
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 是註冊的類之一。當新類註冊時,將繼承多個 CIM 類 root 或 cimv2,然後該命令將列出所有這些類名。通常,您可以忽略所有類 CIM_ 前綴。所有帶有 Linux_ 前綴的類都是由Linux系統上安裝的提供程式註冊的類。
在使用 Dell 的 iDRAC 時,您最感興趣的是 DCIM_ prefix.
使用類別名稱清單時,使用 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>
在目標系統中的所有處理器中,上述輸出是一個處理器。
在輸出中,資源 URI 列為 https://sblim.sourceforge.net/wbem/wscim/1/cim-schema/2/Linux_Processor 與 SelectorSet 列出了 __cimnamespace, SystemCreationClassName, SystemName, CreationClassName, and DeviceID.這意味著繼承和本地定義的類中的所有屬性)這些屬性可用於唯一標識實例。
因此,您可以從以下命令獲得有效的回應:
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_CSProcessor 連結 Linux_ComputerSystem 和 Linux_Processor,顯示處理器在計算機系統中,詳細說明 GroupComponent 和 PartComponent 部分。
我花時間瞭解 EPR 及其用於訪問實例,認為它可能會説明其他人。請隨時在下面給我留下您的意見或建議。
免責聲明:
以上文章僅供參考。內容來自我對上述技術和術語的解釋。此資訊係以現狀提供,可能包含一些打字錯誤和/或技術疏失。