Browse Source

Add video enumeration to InventoryManagement

Change-Id: Ia14ae67fea9d69ba27ebd43f6043b817f6cc5eff
Closes-Bug: #1894940
(cherry picked from commit d341ab4b3c)
changes/97/757697/1
Mudit 7 months ago
parent
commit
6cf36ac8b7
6 changed files with 147 additions and 0 deletions
  1. +11
    -0
      dracclient/client.py
  2. +42
    -0
      dracclient/resources/inventory.py
  3. +3
    -0
      dracclient/resources/uris.py
  4. +30
    -0
      dracclient/tests/test_inventory.py
  5. +3
    -0
      dracclient/tests/utils.py
  6. +58
    -0
      dracclient/tests/wsman_mocks/video_view-enum-ok.xml

+ 11
- 0
dracclient/client.py View File

@ -1021,6 +1021,17 @@ class DRACClient(object):
"""
return self._inventory_mgmt.list_cpus()
def list_video_controllers(self):
"""Returns the list of video controllers
:returns: a list of Video 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_video_controllers()
def list_memory(self):
"""Returns a list of memory modules


+ 42
- 0
dracclient/resources/inventory.py View File

@ -57,6 +57,11 @@ NIC = collections.namedtuple(
'NIC',
['id', 'mac', 'model', 'speed_mbps', 'duplex', 'media_type'])
Video = collections.namedtuple(
'Video',
['id', 'description', 'function_number', 'manufacturer', 'pci_device_id',
'pci_vendor_id', 'pci_subdevice_id', 'pci_subvendor_id'])
System = collections.namedtuple(
'System',
['id', 'lcc_version', 'model', 'service_tag', 'uuid'])
@ -188,6 +193,43 @@ class InventoryManagement(object):
return utils.get_wsman_resource_attr(drac_nic, uris.DCIM_NICView,
attr_name)
def list_video_controllers(self):
"""Returns the list of video controllers
:returns: a list of Video 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_VideoView)
controllers = utils.find_xml(doc, 'DCIM_VideoView',
uris.DCIM_VideoView,
find_all=True)
return [self._parse_video_controllers(controller)
for controller in controllers]
def _parse_video_controllers(self, controller):
return Video(
id=self._get_video_attr(controller, 'FQDD'),
description=self._get_video_attr(controller, 'Description'),
function_number=int(self._get_video_attr(controller,
'FunctionNumber')),
manufacturer=self._get_video_attr(controller, 'Manufacturer'),
pci_device_id=self._get_video_attr(controller, 'PCIDeviceID'),
pci_vendor_id=self._get_video_attr(controller, 'PCIVendorID'),
pci_subdevice_id=self._get_video_attr(controller,
'PCISubDeviceID'),
pci_subvendor_id=self._get_video_attr(controller,
'PCISubVendorID'))
def _get_video_attr(self, controller, attr_name, allow_missing=False):
return utils.get_wsman_resource_attr(
controller, uris.DCIM_VideoView, attr_name,
allow_missing=allow_missing)
def get_system(self):
"""Returns a System object


+ 3
- 0
dracclient/resources/uris.py View File

@ -119,5 +119,8 @@ DCIM_SystemString = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
DCIM_SystemView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
'DCIM_SystemView')
DCIM_VideoView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
'DCIM_VideoView')
DCIM_VirtualDiskView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
'DCIM_VirtualDiskView')

+ 30
- 0
dracclient/tests/test_inventory.py View File

@ -132,6 +132,36 @@ class ClientInventoryManagementTestCase(base.BaseTest):
expected_nics,
self.drac_client.list_nics())
def test_list_video_controllers(self, mock_requests,
mock_wait_until_idrac_is_ready):
expected_video_controllers = [
inventory.Video(
id='Video.Embedded.1-1',
description='Integrated Matrox G200eW3 Graphics Controller',
function_number=0,
manufacturer='Matrox Electronics Systems Ltd.',
pci_device_id='0536',
pci_vendor_id='102B',
pci_subdevice_id='0737',
pci_subvendor_id='1028'),
inventory.Video(
id='Video.Slot.7-1',
description='TU104GL [Tesla T4]',
function_number=0,
manufacturer='NVIDIA Corporation',
pci_device_id='1EB8',
pci_vendor_id='10DE',
pci_subdevice_id='12A2',
pci_subvendor_id='10DE')]
mock_requests.post(
'https://1.2.3.4:443/wsman',
text=test_utils.InventoryEnumerations[uris.DCIM_VideoView]['ok'])
self.assertEqual(
expected_video_controllers,
self.drac_client.list_video_controllers())
def test_get_system(self, mock_requests, mock_wait_until_idrac_is_ready):
expected_system = inventory.System(
id='System.Embedded.1',


+ 3
- 0
dracclient/tests/utils.py View File

@ -109,6 +109,9 @@ InventoryEnumerations = {
},
uris.DCIM_NICView: {
'ok': load_wsman_xml('nic_view-enum-ok')
},
uris.DCIM_VideoView: {
'ok': load_wsman_xml('video_view-enum-ok'),
}
}


+ 58
- 0
dracclient/tests/wsman_mocks/video_view-enum-ok.xml View File

@ -0,0 +1,58 @@
<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_VideoView">
<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:dd7ea19a-8633-4fa4-a43a-66ae8220f689</wsa:RelatesTo>
<wsa:MessageID>uuid:247e710c-29de-19de-93c9-f148d4fe83b0</wsa:MessageID>
</s:Header>
<s:Body>
<wsen:EnumerateResponse>
<wsman:Items>
<n1:DCIM_VideoView>
<n1:BusNumber>3</n1:BusNumber>
<n1:DataBusWidth>0002</n1:DataBusWidth>
<n1:Description>Integrated Matrox G200eW3 Graphics Controller</n1:Description>
<n1:DeviceDescription>Embedded Video Controller 1</n1:DeviceDescription>
<n1:DeviceNumber>0</n1:DeviceNumber>
<n1:FQDD>Video.Embedded.1-1</n1:FQDD>
<n1:FunctionNumber>0</n1:FunctionNumber>
<n1:InstanceID>Video.Embedded.1-1</n1:InstanceID>
<n1:LastSystemInventoryTime>20200811163707.000000+000</n1:LastSystemInventoryTime>
<n1:LastUpdateTime>20200520203243.000000+000</n1:LastUpdateTime>
<n1:Manufacturer>Matrox Electronics Systems Ltd.</n1:Manufacturer>
<n1:PCIDeviceID>0536</n1:PCIDeviceID>
<n1:PCISubDeviceID>0737</n1:PCISubDeviceID>
<n1:PCISubVendorID>1028</n1:PCISubVendorID>
<n1:PCIVendorID>102B</n1:PCIVendorID>
<n1:SlotLength>0002</n1:SlotLength>
<n1:SlotType>0002</n1:SlotType>
</n1:DCIM_VideoView>
<n1:DCIM_VideoView>
<n1:BusNumber>135</n1:BusNumber>
<n1:DataBusWidth>000B</n1:DataBusWidth>
<n1:Description>TU104GL [Tesla T4]</n1:Description>
<n1:DeviceDescription>Video Controller in Slot 7</n1:DeviceDescription>
<n1:DeviceNumber>0</n1:DeviceNumber>
<n1:FQDD>Video.Slot.7-1</n1:FQDD>
<n1:FunctionNumber>0</n1:FunctionNumber>
<n1:InstanceID>Video.Slot.7-1</n1:InstanceID>
<n1:LastSystemInventoryTime>20200811163707.000000+000</n1:LastSystemInventoryTime>
<n1:LastUpdateTime>20200710054947.000000+000</n1:LastUpdateTime>
<n1:Manufacturer>NVIDIA Corporation</n1:Manufacturer>
<n1:PCIDeviceID>1EB8</n1:PCIDeviceID>
<n1:PCISubDeviceID>12A2</n1:PCISubDeviceID>
<n1:PCISubVendorID>10DE</n1:PCISubVendorID>
<n1:PCIVendorID>10DE</n1:PCIVendorID>
<n1:SlotLength>0004</n1:SlotLength>
<n1:SlotType>00B6</n1:SlotType>
</n1:DCIM_VideoView>
</wsman:Items>
<wsen:EnumerationContext/>
<wsman:EndOfSequence/>
</wsen:EnumerateResponse>
</s:Body>
</s:Envelope>

Loading…
Cancel
Save