Add more details of compose node
Add 'allowed_attach_endpoints', 'allowed_detach_endpoints', 'allowed_boot_source' and 'allowed_reset_node_values' variables, which show all allowed values of each action for composed node. Change-Id: Ie933ad2ed0ba6c4859e8cffbf776efa9328260e0
This commit is contained in:
parent
283d1f80c5
commit
453c208352
@ -65,9 +65,10 @@ class FakeMemorySummary(object):
|
||||
self.health = "OK"
|
||||
|
||||
|
||||
class FakeNode(object):
|
||||
class FakeNode(mock.Mock):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(FakeNode, self).__init__(*args, **kwargs)
|
||||
self.name = "Test"
|
||||
self.description = "Node for testing"
|
||||
self.identity = "1"
|
||||
|
@ -24,6 +24,8 @@ class UtilsTest(testtools.TestCase):
|
||||
def test_extract_attr(self):
|
||||
fake_node = fakes.FakeNode()
|
||||
result = utils.extract_attr(fake_node)
|
||||
# Pop out mock.Mock variable 'method_calls'
|
||||
result.pop('method_calls')
|
||||
expected = fakes.FAKE_NODE_PYTHON_DICT
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
|
@ -50,9 +50,26 @@ class NodeTest(testtools.TestCase):
|
||||
mock_node.delete_node.assert_called_once()
|
||||
|
||||
def test_show_node(self):
|
||||
self.client.get_node.return_value = fakes.FakeNode()
|
||||
node = fakes.FakeNode()
|
||||
node.get_allowed_attach_endpoints.return_value = \
|
||||
('/redfish/v1/Chassis/3-c-1/Drives/3-c-1-d-1',)
|
||||
node.get_allowed_detach_endpoints.return_value = ()
|
||||
node.get_allowed_node_boot_source_values.return_value = ('pxe', 'hdd')
|
||||
node.get_allowed_reset_node_values.return_value = ('on', 'force off')
|
||||
self.client.get_node.return_value = node
|
||||
|
||||
result = self.mgr.show('1')
|
||||
# Pop out mock.Mock variable 'method_calls'
|
||||
result.pop('method_calls')
|
||||
expected = fakes.FAKE_NODE_PYTHON_DICT
|
||||
expected.update(
|
||||
{
|
||||
"allowed_attach_endpoints":
|
||||
['/redfish/v1/Chassis/3-c-1/Drives/3-c-1-d-1'],
|
||||
"allowed_detach_endpoints": [],
|
||||
"allowed_boot_source": ["pxe", "hdd"],
|
||||
"allowed_reset_node_values": ["on", "force off"]
|
||||
})
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
def test_list_node(self):
|
||||
|
@ -45,7 +45,18 @@ class NodeManager(base.Manager):
|
||||
|
||||
def show(self, node_id):
|
||||
node = self.client.get_node(self._get_node_uri(node_id))
|
||||
return utils.extract_attr(node)
|
||||
node_info = utils.extract_attr(node)
|
||||
|
||||
node_info['allowed_attach_endpoints'] = \
|
||||
list(node.get_allowed_attach_endpoints())
|
||||
node_info['allowed_detach_endpoints'] = \
|
||||
list(node.get_allowed_detach_endpoints())
|
||||
node_info['allowed_boot_source'] = \
|
||||
list(node.get_allowed_node_boot_source_values())
|
||||
node_info['allowed_reset_node_values'] = \
|
||||
list(node.get_allowed_reset_node_values())
|
||||
|
||||
return node_info
|
||||
|
||||
def list(self):
|
||||
node_collection = self.client.get_node_collection()
|
||||
|
Loading…
x
Reference in New Issue
Block a user