Merge "Let callers ask a Dell manager for a named attribute resource"
This commit is contained in:
commit
ecddf50282
2 files changed
+48
No files matched your search
@@ -570,6 +570,27 @@ VFDD\
|
||||
self.redfish_version,
|
||||
self.registries)
|
||||
|
||||
@property
|
||||
@sushy_utils.cache_it
|
||||
def attribute_resources(self):
|
||||
"""Mapping of `DellAttributes` identity to the resource itself.
|
||||
|
||||
An iDRAC typically exposes ``iDRAC.Embedded.1``,
|
||||
``System.Embedded.1`` and ``LifecycleController.Embedded.1``, so
|
||||
callers need to say which set of attributes they mean::
|
||||
|
||||
manager_oem.attribute_resources.get('iDRAC.Embedded.1')
|
||||
|
||||
Unlike :py:attr:`~attributes`, this can be looked up repeatedly. The
|
||||
resources are keyed by their own ``Id`` rather than by their path,
|
||||
which differs between iDRAC generations, so all of them are
|
||||
retrieved. The result is cached until this manager is refreshed.
|
||||
|
||||
:returns: a dict mapping identity string to
|
||||
:class:`sushy.oem.dell.resources.attributes.DellAttributes`.
|
||||
"""
|
||||
return {resource.identity: resource for resource in self.attributes}
|
||||
|
||||
def _wait_for_idrac_state(self, host, alive=True, required_count=3,
|
||||
retries=24):
|
||||
"""Wait for iDRAC to become reachable or not reachable.
|
||||
|
||||
@@ -679,3 +679,30 @@ class ManagerTestCase(BaseTestCase):
|
||||
result = oem_manager._is_reachable()
|
||||
|
||||
self.assertFalse(result)
|
||||
|
||||
@mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {})
|
||||
def test_attribute_resources(self):
|
||||
oem_manager = self.manager.get_oem_extension('Dell')
|
||||
# Each DellAttributes resource names itself; the identity cannot be
|
||||
# taken from the path, which differs between iDRAC generations.
|
||||
identities = ['iDRAC.Embedded.1', 'System.Embedded.1',
|
||||
'LifecycleController.Embedded.1']
|
||||
|
||||
def get_attributes(path, *args, **kwargs):
|
||||
response = mock.Mock()
|
||||
response.status_code = 200
|
||||
response.json.return_value = {
|
||||
'Id': path.rsplit('/', 2)[-2],
|
||||
'Attributes': {'SSH.1.Port': 22},
|
||||
}
|
||||
return response
|
||||
|
||||
oem_manager._conn.get = mock.Mock(side_effect=get_attributes)
|
||||
|
||||
resources = oem_manager.attribute_resources
|
||||
|
||||
self.assertEqual(sorted(identities), sorted(resources))
|
||||
bmc = resources.get('iDRAC.Embedded.1')
|
||||
self.assertEqual('iDRAC.Embedded.1', bmc.identity)
|
||||
self.assertEqual({'SSH.1.Port': 22}, bmc.attributes)
|
||||
self.assertIsNone(resources.get('Nonexistent.1'))
|
||||
Reference in new issue
Block a user