Fix Processor.sub_processors
Change-Id: Ibeac9db891a11e0565ffbc3d5878d325e69a07a2
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes ``Processor.sub_processors`` for "'Processor' object has no attribute
|
||||||
|
'conn'" error.
|
@@ -106,20 +106,20 @@ class Processor(base.ResourceBase):
|
|||||||
super(Processor, self).__init__(
|
super(Processor, self).__init__(
|
||||||
connector, identity, redfish_version, registries)
|
connector, identity, redfish_version, registries)
|
||||||
|
|
||||||
def _get_processor_collection_path(self):
|
def _get_subprocessor_collection_path(self):
|
||||||
"""Helper function to find the ProcessorCollection path"""
|
"""Helper function to find the SubProcessors path"""
|
||||||
pro_col = self.json.get('ProcessorCollection')
|
subproc_col = self.json.get('SubProcessors')
|
||||||
if not pro_col:
|
if not subproc_col:
|
||||||
raise exceptions.MissingAttributeError(
|
raise exceptions.MissingAttributeError(
|
||||||
attribute='ProcessorCollection', resource=self._path)
|
attribute='SubProcessors', resource=self._path)
|
||||||
return pro_col.get('@odata.id')
|
return subproc_col.get('@odata.id')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@utils.cache_it
|
@utils.cache_it
|
||||||
def sub_processors(self):
|
def sub_processors(self):
|
||||||
"""A reference to the collection of Sub-Processors"""
|
"""A reference to the collection of Sub-Processors"""
|
||||||
return ProcessorCollection(
|
return ProcessorCollection(
|
||||||
self.conn, self._get_processor_collection_path,
|
self._conn, self._get_subprocessor_collection_path(),
|
||||||
redfish_version=self.redfish_version)
|
redfish_version=self.redfish_version)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,6 +23,9 @@
|
|||||||
"Health": "OK",
|
"Health": "OK",
|
||||||
"HealthRollup": "OK"
|
"HealthRollup": "OK"
|
||||||
},
|
},
|
||||||
|
"SubProcessors": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Processors/CPU1/SubProcessors"
|
||||||
|
},
|
||||||
"@odata.context": "/redfish/v1/$metadata#Systems/Members/437XR1138R2/Processors/Members/$entity",
|
"@odata.context": "/redfish/v1/$metadata#Systems/Members/437XR1138R2/Processors/Members/$entity",
|
||||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Processors/CPU1",
|
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Processors/CPU1",
|
||||||
"@Redfish.Copyright": "Copyright 2014-2016 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
|
"@Redfish.Copyright": "Copyright 2014-2016 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
|
||||||
|
9
sushy/tests/unit/json_samples/subprocessor.json
Normal file
9
sushy/tests/unit/json_samples/subprocessor.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/system/Processors/CPU1/SubProcessors/Core1",
|
||||||
|
"@odata.type": "#Processor.v1_3_0.Processor",
|
||||||
|
"Id": "Core1",
|
||||||
|
"Status": {
|
||||||
|
"State": "Enabled",
|
||||||
|
"Health": "OK"
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/437XR1138R2Processors/CPU1/SubProcessors",
|
||||||
|
"@odata.type": "#ProcessorCollection.ProcessorCollection",
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/system/Processors/CPU1/SubProcessors/Core1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -17,6 +17,7 @@ from unittest import mock
|
|||||||
|
|
||||||
|
|
||||||
import sushy
|
import sushy
|
||||||
|
from sushy import exceptions
|
||||||
from sushy.resources import constants as res_cons
|
from sushy.resources import constants as res_cons
|
||||||
from sushy.resources.system import processor
|
from sushy.resources.system import processor
|
||||||
from sushy.tests.unit import base
|
from sushy.tests.unit import base
|
||||||
@@ -76,6 +77,28 @@ class ProcessorTestCase(base.TestCase):
|
|||||||
self.assertEqual(res_cons.HEALTH_OK,
|
self.assertEqual(res_cons.HEALTH_OK,
|
||||||
self.sys_processor.status.health_rollup)
|
self.sys_processor.status.health_rollup)
|
||||||
|
|
||||||
|
def test_sub_processors(self):
|
||||||
|
self.conn.get.return_value.json.reset_mock()
|
||||||
|
with open('sushy/tests/unit/json_samples/'
|
||||||
|
'subprocessor_collection.json') as f:
|
||||||
|
subproc_col = json.load(f)
|
||||||
|
with open('sushy/tests/unit/json_samples/subprocessor.json') as f:
|
||||||
|
subproc1 = json.load(f)
|
||||||
|
|
||||||
|
self.conn.get.return_value.json.side_effect = [subproc_col, subproc1]
|
||||||
|
|
||||||
|
sub_processors = self.sys_processor.sub_processors
|
||||||
|
self.assertIsInstance(sub_processors,
|
||||||
|
processor.ProcessorCollection)
|
||||||
|
self.assertEqual((0, None), sub_processors.summary)
|
||||||
|
self.assertEqual('Core1', sub_processors.get_members()[0].identity)
|
||||||
|
|
||||||
|
def test_sub_processors_missing(self):
|
||||||
|
self.sys_processor.json.pop('SubProcessors')
|
||||||
|
with self.assertRaisesRegex(
|
||||||
|
exceptions.MissingAttributeError, 'attribute SubProcessors'):
|
||||||
|
self.sys_processor.sub_processors
|
||||||
|
|
||||||
|
|
||||||
class ProcessorCollectionTestCase(base.TestCase):
|
class ProcessorCollectionTestCase(base.TestCase):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user