Allow update node properties in RSD 2.3

Change-Id: I15c4ffa56d17adb49188b006d0f5f3060dc495f5
This commit is contained in:
Lin Yang 2019-03-11 17:25:35 -07:00
parent bc8655f501
commit 7cb166fdb6
2 changed files with 30 additions and 0 deletions

View File

@ -57,6 +57,25 @@ class Node(v2_1_node.Node):
_actions = NodeActionsField('Actions', required=True)
def update(self, clear_tpm_on_delete):
"""Update properties of this composed node
:param clear_tpm_on_delete: This is used to specify if TPM module
should be cleared on composed node DELETE request.
:raises: InvalidParameterValueError, if any information passed is
invalid.
"""
if not isinstance(clear_tpm_on_delete, bool):
raise exceptions.InvalidParameterValueError(
parameter='clear_tpm_on_delete', value=clear_tpm_on_delete,
valid_values=[True, False])
data = {
'ClearTPMOnDelete': clear_tpm_on_delete
}
self._conn.patch(self.path, data=data)
def _get_attach_endpoint_action_element(self):
attach_endpoint_action = self._actions.attach_endpoint
if not attach_endpoint_action:

View File

@ -40,6 +40,17 @@ class NodeTestCase(testtools.TestCase):
self.node_inst._parse_attributes()
self.assertEqual(True, self.node_inst.clear_tpm_on_delete)
def test_update_node(self):
self.node_inst.update(clear_tpm_on_delete=True)
self.node_inst._conn.patch.assert_called_once_with(
'/redfish/v1/Nodes/Node1', data={'ClearTPMOnDelete': True})
def test_update_node_with_invalid_parameter(self):
with self.assertRaisesRegex(
exceptions.InvalidParameterValueError,
'The parameter "clear_tpm_on_delete" value "fake-value" is'):
self.node_inst.update(clear_tpm_on_delete='fake-value')
def test__get_attach_endpoint_action_element(self):
with open('rsd_lib/tests/unit/json_samples/v2_3/'
'attach_action_info.json', 'r') as f: