Implement reading Video Controllers in dracclient

Add support for reading video controller devices (embedded or PCIe)
in dracclient. The draccllient shall maintain a list of relevant
properties of such devices.
This will enable Ironic iDRAC driver to use this to derive server
capabilities such as number of GPU devices and add them as server
capabilities

Change-Id: Ia14ae67fea9d69ba27ebd43f6043b817f6cc5eff
Story: 2008118
Task: 40839
This commit is contained in:
Mudit 2020-09-08 09:34:00 -04:00
parent 3e52db0511
commit 73b4df8286
6 changed files with 143 additions and 0 deletions

View File

@ -1001,6 +1001,17 @@ class DRACClient(object):
"""
return self._inventory_mgmt.list_cpus()
def list_video_units(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_units()
def list_memory(self):
"""Returns a list of memory modules

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_deviceid',
'pci_vendorid', 'pci_subdeviceid', 'pci_subvendorid'])
System = collections.namedtuple(
'System',
['id', 'lcc_version', 'model', 'service_tag', 'uuid'])
@ -188,6 +193,39 @@ class InventoryManagement(object):
return utils.get_wsman_resource_attr(drac_nic, uris.DCIM_NICView,
attr_name)
def list_video_units(self):
"""Returns the list of Video Controllers
:returns: a list of Video Controller 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)
units = utils.find_xml(doc, 'DCIM_VideoView',
uris.DCIM_VideoView,
find_all=True)
return [self._parse_video_units(unit) for unit in units]
def _parse_video_units(self, unit):
return Video(
id=self._get_video_attr(unit, 'FQDD'),
description=self._get_video_attr(unit, 'Description'),
function_number=int(self._get_video_attr(unit, 'FunctionNumber')),
manufacturer=self._get_video_attr(unit, 'Manufacturer'),
pci_deviceid=self._get_video_attr(unit, 'PCIDeviceID'),
pci_vendorid=self._get_video_attr(unit, 'PCIVendorID'),
pci_subdeviceid=self._get_video_attr(unit, 'PCISubDeviceID'),
pci_subvendorid=self._get_video_attr(unit, 'PCISubVendorID'))
def _get_video_attr(self, video_unit, attr_name, allow_missing=False):
return utils.get_wsman_resource_attr(
video_unit, uris.DCIM_VideoView, attr_name,
allow_missing=allow_missing)
def get_system(self):
"""Returns a System object

View File

@ -43,6 +43,9 @@ DCIM_ControllerView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
DCIM_CPUView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
'DCIM_CPUView')
DCIM_VideoView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
'DCIM_VideoView')
DCIM_iDRACCardEnumeration = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/'
'2/DCIM_iDRACCardEnumeration')

View File

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

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'),
}
}

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>