cleanup db model 'links' fields

This patch replaces the 'redfish_link' field to resource_uri to store
the relative uri of the node or podmanger.

Change-Id: Ib586e69a04ab2f8c1ea4ae17df958479a7921896
This commit is contained in:
Anusha Ramineni 2017-09-04 11:28:40 +05:30
parent eeadbaeb33
commit 78de3b7ba7
5 changed files with 18 additions and 36 deletions

View File

@ -29,7 +29,7 @@ class Node(object):
@staticmethod
def _show_node_brief_info(node_info):
return {key: node_info[key] for key in node_info.keys()
if key in ["uuid", "name", "index", "links"]}
if key in ["uuid", "name", "index", "uri"]}
@staticmethod
def _create_compose_request(name, description, requirements):
@ -95,7 +95,7 @@ class Node(object):
node_db = {"uuid": composed_node["uuid"],
"name": composed_node["name"],
"index": composed_node["index"],
"links": composed_node["links"]}
"uri": composed_node["resource_uri"]}
db_api.Connection.create_composed_node(node_db)
return cls._show_node_brief_info(composed_node)
@ -129,7 +129,7 @@ class Node(object):
node_db = {"uuid": composed_node["uuid"],
"name": composed_node["name"],
"index": composed_node["index"],
"links": composed_node["links"]}
"uri": composed_node["resource_uri"]}
db_api.Connection.create_composed_node(node_db)
return cls._show_node_brief_info(composed_node)

View File

@ -150,12 +150,9 @@ class PodManager(ModelBaseWithTimeStamp):
'location': {
'validate': types.Text.validate
},
'redfish_link': {
'resource_uri': {
'validate': types.Text.validate
},
'bookmark_link': {
'validate': types.Text.validate
}
}
@ -211,8 +208,8 @@ class ComposedNode(ModelBaseWithTimeStamp):
'index': {
'validate': types.Text.validate
},
'links': {
'validate': types.List(types.Dict).validate
'resource_uri': {
'validate': types.Text.validate
},
'managed_by': {
'validate': types.Text.validate

View File

@ -28,16 +28,12 @@ class TestAPINodes(unittest.TestCase):
def test_show_node_brief_info(self):
"""Test only show node brief info"""
node_info = node_fakes.get_test_composed_node()
node_info['uri'] = 'nodes/7be5bc10-dcdf-11e6-bd86-934bc6947c55/'
expected = {
"index": "1",
"name": "fake_name",
"uuid": "ea8e2a25-2901-438d-8157-de7ffd68d051",
"links": [{'href': 'http://127.0.0.1:8181/v1/nodes/'
'7be5bc10-dcdf-11e6-bd86-934bc6947c55/',
'rel': 'self'},
{'href': 'http://127.0.0.1:8181/nodes/'
'7be5bc10-dcdf-11e6-bd86-934bc6947c55/',
'rel': 'bookmark'}]
"uri": 'nodes/7be5bc10-dcdf-11e6-bd86-934bc6947c55/',
}
self.assertEqual(expected,
nodes.Node._show_node_brief_info(node_info))
@ -93,7 +89,7 @@ class TestAPINodes(unittest.TestCase):
node_db = {"uuid": manage_node["uuid"],
"index": manage_node["index"],
"name": manage_node["name"],
"links": manage_node["links"]}
"uri": manage_node["resource_uri"]}
nodes.Node.manage_node({"node_index": "1"})
mock_db_create_composed_node.assert_called_once_with(node_db)
@ -123,7 +119,7 @@ class TestAPINodes(unittest.TestCase):
node_db = {"uuid": node_hw["uuid"],
"index": node_hw["index"],
"name": node_hw["name"],
"links": node_hw["links"]}
"uri": node_hw["resource_uri"]}
mock_redfish_compose_node.return_value = node_hw
uuid = 'ea8e2a25-2901-438d-8157-de7ffd68d051'
@ -150,7 +146,7 @@ class TestAPINodes(unittest.TestCase):
node_db = {"uuid": node_hw["uuid"],
"index": node_hw["index"],
"name": node_hw["name"],
"links": node_hw["links"]}
"uri": node_hw["resource_uri"]}
mock_redfish_compose_node.return_value = node_hw
uuid = 'ea8e2a25-2901-438d-8157-de7ffd68d051'

View File

@ -57,8 +57,7 @@ def get_test_podmanager(**kwargs):
'status': kwargs.get('size', 'fake_status'),
'description': kwargs.get('description', 'fake_description'),
'location': kwargs.get('location', 'fake_location'),
'redfish_link': kwargs.get('redfish_link', 'fake_redfish_link'),
'bookmark_link': kwargs.get('bookmark_link', 'fake_bookmark_link'),
'resource_uri': kwargs.get('resource_uri', 'fake_redfish_link'),
'created_at': kwargs.get('created_at', '2016-01-01 00:00:00 UTC'),
'updated_at': kwargs.get('updated_at', '2016-01-01 00:00:00 UTC'),
}
@ -88,14 +87,9 @@ def get_test_composed_node_db_info(**kwargs):
'uuid': kwargs.get('uuid', 'ea8e2a25-2901-438d-8157-de7ffd68d051'),
'name': kwargs.get('name', 'fake_name'),
'index': kwargs.get('index', '1'),
'links': kwargs.get(
'links',
[{'href': 'http://127.0.0.1:8181/v1/nodes/'
'7be5bc10-dcdf-11e6-bd86-934bc6947c55/',
'rel': 'self'},
{'href': 'http://127.0.0.1:8181/nodes/'
'7be5bc10-dcdf-11e6-bd86-934bc6947c55/',
'rel': 'bookmark'}]),
'resource_uri': kwargs.get(
'resource_uri',
'/v1/nodes/7be5bc10-dcdf-11e6-bd86-934bc6947c55/'),
'created_at': kwargs.get('created_at', '2016-01-01 00:00:00 UTC'),
'updated_at': kwargs.get('updated_at', '2016-01-01 00:00:00 UTC')
}

View File

@ -23,14 +23,9 @@ def get_test_composed_node(**kwargs):
'node_state': kwargs.get('node_state', 'Assembling'),
'pooled_group_id': kwargs.get('bookmark_link', 'None'),
'target_boot_source': kwargs.get('target_boot_source', 'Hdd'),
'links': kwargs.get(
'links',
[{'href': 'http://127.0.0.1:8181/v1/nodes/'
'7be5bc10-dcdf-11e6-bd86-934bc6947c55/',
'rel': 'self'},
{'href': 'http://127.0.0.1:8181/nodes/'
'7be5bc10-dcdf-11e6-bd86-934bc6947c55/',
'rel': 'bookmark'}]),
'resource_uri': kwargs.get(
'resource_uri',
'nodes/7be5bc10-dcdf-11e6-bd86-934bc6947c55/'),
'metadata': kwargs.get(
'metadata',
{'memory': [{'data_width_bit': 0,