Add memory enumeration to InventoryManagement
Change-Id: I0e58122a8d68d927b057aeedd2c127d62d9bae92
This commit is contained in:
parent
f2cd8bbd8a
commit
b87d729dca
|
@ -159,6 +159,16 @@ Required parameters:
|
||||||
|
|
||||||
* ``raid_controller``: id of the RAID controller.
|
* ``raid_controller``: id of the RAID controller.
|
||||||
|
|
||||||
|
Inventory Management
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
list_cpus
|
||||||
|
~~~~~~~~~
|
||||||
|
Returns a list of installed CPUs.
|
||||||
|
|
||||||
|
list_memory
|
||||||
|
~~~~~~~~~~~
|
||||||
|
Returns a list of installed memory modules.
|
||||||
|
|
||||||
Job management
|
Job management
|
||||||
--------------
|
--------------
|
||||||
|
|
|
@ -420,6 +420,18 @@ class DRACClient(object):
|
||||||
"""
|
"""
|
||||||
return self._inventory_mgmt.list_cpus()
|
return self._inventory_mgmt.list_cpus()
|
||||||
|
|
||||||
|
def list_memory(self):
|
||||||
|
"""Returns a list of memory modules
|
||||||
|
|
||||||
|
:returns: a list of Memory objects
|
||||||
|
:raises: WSManRequestFailure on request failures
|
||||||
|
:raises: WSManInvalidResponse when receiving invalid response
|
||||||
|
:raises: DRACOperationFailed on error reported back by the DRAC
|
||||||
|
interface
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self._inventory_mgmt.list_memory()
|
||||||
|
|
||||||
|
|
||||||
class WSManClient(wsman.Client):
|
class WSManClient(wsman.Client):
|
||||||
"""Wrapper for wsman.Client with return value checking"""
|
"""Wrapper for wsman.Client with return value checking"""
|
||||||
|
|
|
@ -21,6 +21,10 @@ CPU = collections.namedtuple(
|
||||||
['id', 'cores', 'speed', 'ht_enabled', 'model', 'status', 'turbo_enabled',
|
['id', 'cores', 'speed', 'ht_enabled', 'model', 'status', 'turbo_enabled',
|
||||||
'vt_enabled'])
|
'vt_enabled'])
|
||||||
|
|
||||||
|
Memory = collections.namedtuple(
|
||||||
|
'Memory',
|
||||||
|
['id', 'size', 'speed', 'manufacturer', 'model', 'status'])
|
||||||
|
|
||||||
PrimaryStatus = {
|
PrimaryStatus = {
|
||||||
'0': 'Unknown',
|
'0': 'Unknown',
|
||||||
'1': 'OK',
|
'1': 'OK',
|
||||||
|
@ -71,3 +75,35 @@ class InventoryManagement(object):
|
||||||
def _get_cpu_attr(self, cpu, attr_name):
|
def _get_cpu_attr(self, cpu, attr_name):
|
||||||
return utils.get_wsman_resource_attr(
|
return utils.get_wsman_resource_attr(
|
||||||
cpu, uris.DCIM_CPUView, attr_name)
|
cpu, uris.DCIM_CPUView, attr_name)
|
||||||
|
|
||||||
|
def list_memory(self):
|
||||||
|
"""Returns the list of installed memory
|
||||||
|
|
||||||
|
:returns: a list of Memory objects
|
||||||
|
:raises: WSManRequestFailure on request failures
|
||||||
|
:raises: WSManInvalidResponse when receiving invalid response
|
||||||
|
:raises: DRACOperationFailed on error reported back by the DRAC
|
||||||
|
"""
|
||||||
|
|
||||||
|
doc = self.client.enumerate(uris.DCIM_MemoryView)
|
||||||
|
|
||||||
|
installed_memory = utils.find_xml(doc, 'DCIM_MemoryView',
|
||||||
|
uris.DCIM_MemoryView,
|
||||||
|
find_all=True)
|
||||||
|
|
||||||
|
return [self._parse_memory(memory) for memory in installed_memory]
|
||||||
|
|
||||||
|
def _parse_memory(self, memory):
|
||||||
|
return Memory(id=self._get_memory_attr(memory, 'FQDD'),
|
||||||
|
size=int(self._get_memory_attr(memory, 'Size')),
|
||||||
|
speed=int(self._get_memory_attr(memory, 'Speed')),
|
||||||
|
manufacturer=self._get_memory_attr(memory,
|
||||||
|
'Manufacturer'),
|
||||||
|
model=self._get_memory_attr(memory, 'Model'),
|
||||||
|
status=PrimaryStatus[self._get_memory_attr(
|
||||||
|
memory,
|
||||||
|
'PrimaryStatus')])
|
||||||
|
|
||||||
|
def _get_memory_attr(self, memory, attr_name):
|
||||||
|
return utils.get_wsman_resource_attr(memory, uris.DCIM_MemoryView,
|
||||||
|
attr_name)
|
||||||
|
|
|
@ -46,6 +46,9 @@ DCIM_CPUView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
||||||
DCIM_LifecycleJob = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
DCIM_LifecycleJob = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
||||||
'DCIM_LifecycleJob')
|
'DCIM_LifecycleJob')
|
||||||
|
|
||||||
|
DCIM_MemoryView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
||||||
|
'DCIM_MemoryView')
|
||||||
|
|
||||||
DCIM_PhysicalDiskView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
DCIM_PhysicalDiskView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
||||||
'DCIM_PhysicalDiskView')
|
'DCIM_PhysicalDiskView')
|
||||||
|
|
||||||
|
|
|
@ -982,3 +982,30 @@ class ClientCPUTestCase(base.BaseTest):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
expected_cpu,
|
expected_cpu,
|
||||||
self.drac_client.list_cpus())
|
self.drac_client.list_cpus())
|
||||||
|
|
||||||
|
|
||||||
|
@requests_mock.Mocker()
|
||||||
|
class ClientMemoryestCase(base.BaseTest):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(ClientMemoryestCase, self).setUp()
|
||||||
|
self.drac_client = dracclient.client.DRACClient(
|
||||||
|
**test_utils.FAKE_ENDPOINT)
|
||||||
|
|
||||||
|
def test_list_memory(self, mock_requests):
|
||||||
|
expected_memory = [inventory.Memory(
|
||||||
|
id='DIMM.Socket.A1',
|
||||||
|
size=16384,
|
||||||
|
speed=2133,
|
||||||
|
manufacturer='Samsung',
|
||||||
|
model='DDR4 DIMM',
|
||||||
|
status='OK',
|
||||||
|
)]
|
||||||
|
|
||||||
|
mock_requests.post(
|
||||||
|
'https://1.2.3.4:443/wsman',
|
||||||
|
text=test_utils.MemoryEnumerations[uris.DCIM_MemoryView]['ok'])
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
expected_memory,
|
||||||
|
self.drac_client.list_memory())
|
||||||
|
|
|
@ -133,6 +133,12 @@ LifecycleControllerEnumerations = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemoryEnumerations = {
|
||||||
|
uris.DCIM_MemoryView: {
|
||||||
|
'ok': load_wsman_xml('memory-enumeration-enum-ok')
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
RAIDEnumerations = {
|
RAIDEnumerations = {
|
||||||
uris.DCIM_ControllerView: {
|
uris.DCIM_ControllerView: {
|
||||||
'ok': load_wsman_xml('controller_view-enum-ok')
|
'ok': load_wsman_xml('controller_view-enum-ok')
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<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"
|
||||||
|
xmlns:n1="http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_MemoryView">
|
||||||
|
<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/EnumerateResponse</wsa:Action>
|
||||||
|
<wsa:RelatesTo>uuid:6a7e85cd-00a9-49a2-a781-d047063b9975</wsa:RelatesTo>
|
||||||
|
<wsa:MessageID>uuid:09c85e7c-2fda-1fda-bf81-f148d4fe83b0</wsa:MessageID>
|
||||||
|
</s:Header>
|
||||||
|
<s:Body>
|
||||||
|
<wsen:EnumerateResponse>
|
||||||
|
<wsman:Items>
|
||||||
|
<n1:DCIM_MemoryView>
|
||||||
|
<n1:BankLabel>A</n1:BankLabel>
|
||||||
|
<n1:CurrentOperatingSpeed>1866</n1:CurrentOperatingSpeed>
|
||||||
|
<n1:DeviceDescription>DIMM A1</n1:DeviceDescription>
|
||||||
|
<n1:FQDD>DIMM.Socket.A1</n1:FQDD>
|
||||||
|
<n1:InstanceID>DIMM.Socket.A1</n1:InstanceID>
|
||||||
|
<n1:LastSystemInventoryTime>20160215025015.000000+000</n1:LastSystemInventoryTime>
|
||||||
|
<n1:LastUpdateTime>20151112191452.000000+000</n1:LastUpdateTime>
|
||||||
|
<n1:ManufactureDate>Mon Sep 22 07:00:00 2014 UTC</n1:ManufactureDate>
|
||||||
|
<n1:Manufacturer>Samsung</n1:Manufacturer>
|
||||||
|
<n1:MemoryType>26</n1:MemoryType>
|
||||||
|
<n1:Model>DDR4 DIMM</n1:Model>
|
||||||
|
<n1:PartNumber>M393A2G40DB0-CPB</n1:PartNumber>
|
||||||
|
<n1:PrimaryStatus>1</n1:PrimaryStatus>
|
||||||
|
<n1:Rank>2</n1:Rank>
|
||||||
|
<n1:SerialNumber>39406867</n1:SerialNumber>
|
||||||
|
<n1:Size>16384</n1:Size>
|
||||||
|
<n1:Speed>2133</n1:Speed>
|
||||||
|
</n1:DCIM_MemoryView>
|
||||||
|
</wsman:Items>
|
||||||
|
<wsen:EnumerationContext/>
|
||||||
|
<wsman:EndOfSequence/>
|
||||||
|
</wsen:EnumerateResponse>
|
||||||
|
</s:Body>
|
||||||
|
</s:Envelope>
|
Loading…
Reference in New Issue