Add method to update chassis properties
Change-Id: Ibb07235b93c003e58e63dc6f6679bfbc92f43a81
This commit is contained in:
parent
d9b65a4433
commit
d9c59bba76
@ -132,6 +132,30 @@ class Chassis(base.ResourceBase):
|
||||
"""
|
||||
super(Chassis, self).__init__(connector, identity, redfish_version)
|
||||
|
||||
def update(self, asset_tag=None, location_id=None):
|
||||
"""Update AssetTag and Location->Id properties
|
||||
|
||||
:param asset_tag: The user assigned asset tag for this chassis
|
||||
:param location_id: The user assigned location id for this chassis.
|
||||
It can be changed only for a Rack Chassis
|
||||
"""
|
||||
|
||||
data = {}
|
||||
|
||||
if asset_tag is not None:
|
||||
data['AssetTag'] = asset_tag
|
||||
|
||||
if location_id is not None:
|
||||
data['Oem'] = {
|
||||
"Intel_RackScale": {
|
||||
"Location": {
|
||||
"Id": location_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self._conn.patch(self.path, data=data)
|
||||
|
||||
|
||||
class ChassisCollection(base.ResourceCollectionBase):
|
||||
@property
|
||||
|
@ -77,6 +77,34 @@ class TestChassis(base.TestCase):
|
||||
self.assertEqual('Unique ID', self.chassis_inst.oem.uuid)
|
||||
self.assertEqual('54.348103, 18.645172', self.chassis_inst.oem.geo_tag)
|
||||
|
||||
def test_update(self):
|
||||
self.chassis_inst.update(asset_tag='Rack#1', location_id='1234')
|
||||
self.chassis_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Chassis/chassis1',
|
||||
data={
|
||||
"AssetTag": "Rack#1",
|
||||
"Oem": {
|
||||
"Intel_RackScale": {
|
||||
"Location": {
|
||||
"Id": "1234"}}}})
|
||||
|
||||
self.chassis_inst._conn.patch.reset_mock()
|
||||
self.chassis_inst.update(asset_tag='Rack#1')
|
||||
self.chassis_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Chassis/chassis1',
|
||||
data={
|
||||
"AssetTag": "Rack#1"})
|
||||
|
||||
self.chassis_inst._conn.patch.reset_mock()
|
||||
self.chassis_inst.update(location_id='1234')
|
||||
self.chassis_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Chassis/chassis1',
|
||||
data={
|
||||
"Oem": {
|
||||
"Intel_RackScale": {
|
||||
"Location": {
|
||||
"Id": "1234"}}}})
|
||||
|
||||
|
||||
class TestChassisCollection(base.TestCase):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user