Merge "Expand Drive schema"

This commit is contained in:
Zuul 2019-04-17 14:58:00 +00:00 committed by Gerrit Code Review
commit dc6197ca2a
3 changed files with 29 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
features:
- |
Adds ``CapacityBites``, ``Manufacturer``, ``Model``, ``PartNumber``,
``SerialNumber`` and ``Status`` properties to the ``Drive`` resource.

View File

@ -17,6 +17,7 @@ import logging
from sushy import exceptions
from sushy.resources import base
from sushy.resources import common
from sushy.resources import mappings as res_maps
from sushy import utils
@ -26,6 +27,9 @@ LOG = logging.getLogger(__name__)
class Drive(base.ResourceBase):
"""This class represents a disk drive or other physical storage medium."""
capacity_bytes = base.Field('CapacityBytes', adapter=utils.int_or_none)
"""The size in bytes of this Drive"""
identity = base.Field('Id', required=True)
"""The Drive identity string"""
@ -33,11 +37,23 @@ class Drive(base.ResourceBase):
res_maps.INDICATOR_LED_VALUE_MAP)
"""Whether the indicator LED is lit or off"""
manufacturer = base.Field('Manufacturer')
"""This is the manufacturer of this drive"""
model = base.Field('Model')
"""This is the model number for the drive"""
name = base.Field('Name')
"""The name of the resource"""
capacity_bytes = base.Field('CapacityBytes', adapter=utils.int_or_none)
"""The size in bytes of this Drive"""
part_number = base.Field('PartNumber')
"""The part number for this drive"""
serial_number = base.Field('SerialNumber')
"""The serial number for this drive"""
status = common.StatusField('Status')
"""This type describes the status and health of the drive"""
def set_indicator_led(self, state):
"""Set IndicatorLED to the given state.

View File

@ -39,6 +39,12 @@ class DriveTestCase(base.TestCase):
self.assertEqual('32ADF365C6C1B7BD', self.stor_drive.identity)
self.assertEqual('Drive Sample', self.stor_drive.name)
self.assertEqual(899527000000, self.stor_drive.capacity_bytes)
self.assertEqual('Contoso', self.stor_drive.manufacturer)
self.assertEqual('C123', self.stor_drive.model)
self.assertEqual('C123-1111', self.stor_drive.part_number)
self.assertEqual('1234570', self.stor_drive.serial_number)
self.assertEqual(sushy.STATE_ENABLED, self.stor_drive.status.state)
self.assertEqual(sushy.HEALTH_OK, self.stor_drive.status.health)
def test_set_indicator_led(self):
with mock.patch.object(