From 9220f97ed71e9401ce259a9bc1153ff589edd9f1 Mon Sep 17 00:00:00 2001 From: Nisha Agarwal Date: Wed, 17 Mar 2021 13:07:40 +0000 Subject: [PATCH] Add runtime gpu capabilities to ilo inspection Add gpu related dynamic capabilities in ilo inspection. It would add following dynamic capabilities: gpu__count : Integer gpu__count : Integer gpu_ : boolean story: 2008702 task: 42023 Change-Id: Ic785fbe8a40d8a999e7e319a6505b46f82ba8344 --- doc/source/admin/drivers/ilo.rst | 15 +++++++++++++++ driver-requirements.txt | 2 +- ironic/drivers/modules/ilo/inspect.py | 7 +++++++ .../unit/drivers/modules/ilo/test_inspect.py | 12 ++++++++++++ ...gpu_dynamic_capabilities-b56b90549882b6c2.yaml | 7 +++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/gpu_dynamic_capabilities-b56b90549882b6c2.yaml diff --git a/doc/source/admin/drivers/ilo.rst b/doc/source/admin/drivers/ilo.rst index 24ac8c2c4c..17d356d0e0 100644 --- a/doc/source/admin/drivers/ilo.rst +++ b/doc/source/admin/drivers/ilo.rst @@ -941,6 +941,21 @@ Inspection can also discover the following extra capabilities for iLO driver: This is disable/enable login to the iLO using credentials. This can be toggled only by physical visit to the bare metal. +* ``gpu__count``: Integer value. The capability name is dynamically formed as + gpu__count. The vendor name is replaced in the "". If the vendor name + is not returned by the hardware, then vendor ID in hexadecimal form is replaced + in the capability name. Examples: {'gpu_Nvidia_count': 1}, {'gpu_0x102b_count': 1}. + +* ``gpu__count``: Integer value. The capability name is formed + dynamically by replacing the gpu device name as returned by ilo in + "". Examples: {'gpu_Nvidia_Tesla_M10_count': 1}, + {'gpu_Embedded_Video_Controller_count': 1} + +* ``gpu_``: Boolean. The capability name is formed + dynamically by replacing the gpu device name as returned by ilo in + "". Examples: {'gpu_Nvidia_Tesla_M10': True}, + {'gpu_Embedded_Video_Controller': True} + .. note:: * The capability ``nic_capacity`` can only be discovered if ipmitool diff --git a/driver-requirements.txt b/driver-requirements.txt index 7673c281c4..1bd25844a1 100644 --- a/driver-requirements.txt +++ b/driver-requirements.txt @@ -4,7 +4,7 @@ # python projects they should package as optional dependencies for Ironic. # These are available on pypi -proliantutils>=2.10.0 +proliantutils>=2.11.0 pysnmp>=4.3.0,<5.0.0 python-scciclient>=0.8.0 python-dracclient>=5.1.0,<6.0.0 diff --git a/ironic/drivers/modules/ilo/inspect.py b/ironic/drivers/modules/ilo/inspect.py index 625cf8e129..1e41a12261 100644 --- a/ironic/drivers/modules/ilo/inspect.py +++ b/ironic/drivers/modules/ilo/inspect.py @@ -123,6 +123,13 @@ def _create_supported_capabilities_dict(capabilities): """ valid_cap = {} + + # Add the capabilities starting with "gpu_" to the supported capabilities + # keys set as they are runtime generated keys and cannot be hardcoded. + for k in capabilities: + if k.startswith("gpu_"): + valid_cap[k] = capabilities.get(k) + for key in CAPABILITIES_KEYS.intersection(capabilities): valid_cap[key] = capabilities.get(key) return valid_cap diff --git a/ironic/tests/unit/drivers/modules/ilo/test_inspect.py b/ironic/tests/unit/drivers/modules/ilo/test_inspect.py index a10c34bd9d..ce81a2e474 100644 --- a/ironic/tests/unit/drivers/modules/ilo/test_inspect.py +++ b/ironic/tests/unit/drivers/modules/ilo/test_inspect.py @@ -466,3 +466,15 @@ class TestInspectPrivateMethods(test_common.BaseIloTest): expected.update({key: 'true'}) cap = ilo_inspect._create_supported_capabilities_dict(capabilities) self.assertEqual(expected, cap) + + def test___create_supported_capabilities_dict_gpu_capabilities(self): + capabilities = {'gpu_Nvidia_count': 1, 'gpu_Nvidia_Tesla_M10_count': 1, + 'gpu_Nvidia_Tesla_M10': True} + expected = {} + expected.update(capabilities) + for key in ilo_inspect.CAPABILITIES_KEYS: + capabilities.update({key: 'true'}) + expected.update({key: 'true'}) + capabilities.update({'unknown_property': 'true'}) + cap = ilo_inspect._create_supported_capabilities_dict(capabilities) + self.assertEqual(expected, cap) diff --git a/releasenotes/notes/gpu_dynamic_capabilities-b56b90549882b6c2.yaml b/releasenotes/notes/gpu_dynamic_capabilities-b56b90549882b6c2.yaml new file mode 100644 index 0000000000..4bf8ec54df --- /dev/null +++ b/releasenotes/notes/gpu_dynamic_capabilities-b56b90549882b6c2.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Adds new GPU dynamic capabilities to ``ilo`` drivers inspection. + gpu__count: Integer + gpu__count: Integer + gpu_: Boolean