PowerEdge:探索枚举之外的 WSMAN
Summary: 戴尔技术中心中的戴尔操作系统和应用程序解决方案 - Project Sputnik、Microsoft Windows、Red Hat Linux、SUSE、Ubuntu 等
Symptoms
的 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
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 系统上安装的提供程序注册的类。
在使用戴尔的 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、put、create 或自定义操作的关键属性。
那么,还有哪些其他技术可以做到这一点呢?这正是 EPR 可以提供帮助的地方。
端点参考 (EPR) 是指向包含两条信息的实例的指针: ResourceURI 和选择器集。The 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 列为 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 及其用于访问实例的用途,认为这可能会对其他人有所帮助。欢迎在下面给我留下您的意见或建议。
免责声明:
以上文章仅供参考。内容来自我对上述技术和术语的解释。此信息按原样提供,可能包含一些印刷错误和/或技术不准确之处。