Merge "Expose current clean step in the API"
This commit is contained in:
commit
2d9584b46c
@ -61,7 +61,8 @@ MIN_VER_STR = '1.1'
|
||||
# v1.4: Add MANAGEABLE state
|
||||
# v1.5: Add logical node names
|
||||
# v1.6: Add INSPECT* states
|
||||
MAX_VER_STR = '1.6'
|
||||
# v1.7: Add node.clean_step
|
||||
MAX_VER_STR = '1.7'
|
||||
|
||||
|
||||
MIN_VER = base.Version({base.Version.string: MIN_VER_STR},
|
||||
|
@ -68,6 +68,9 @@ def hide_fields_in_newer_versions(obj):
|
||||
obj.inspection_finished_at = wsme.Unset
|
||||
obj.inspection_started_at = wsme.Unset
|
||||
|
||||
if pecan.request.version.minor < 7:
|
||||
obj.clean_step = wsme.Unset
|
||||
|
||||
|
||||
def assert_juno_provision_state_name(obj):
|
||||
# if requested version is < 1.2, convert AVAILABLE to the old NOSTATE
|
||||
@ -99,7 +102,7 @@ class NodePatchType(types.JsonPatchType):
|
||||
'/target_power_state', '/target_provision_state',
|
||||
'/provision_updated_at', '/maintenance_reason',
|
||||
'/driver_internal_info', '/inspection_finished_at',
|
||||
'/inspection_started_at', ]
|
||||
'/inspection_started_at', '/clean_step']
|
||||
|
||||
@staticmethod
|
||||
def mandatory_attrs():
|
||||
@ -530,6 +533,9 @@ class Node(base.APIBase):
|
||||
readonly=True)
|
||||
"""This driver's internal configuration"""
|
||||
|
||||
clean_step = wsme.wsattr({wtypes.text: types.jsontype}, readonly=True)
|
||||
"""The current clean step"""
|
||||
|
||||
extra = {wtypes.text: types.jsontype}
|
||||
"""This node's meta data"""
|
||||
|
||||
@ -628,7 +634,7 @@ class Node(base.APIBase):
|
||||
provision_updated_at=time, instance_info={},
|
||||
maintenance=False, maintenance_reason=None,
|
||||
inspection_finished_at=None, inspection_started_at=time,
|
||||
console_enabled=False, clean_step='')
|
||||
console_enabled=False, clean_step={})
|
||||
# NOTE(matty_dubs): The chassis_uuid getter() is based on the
|
||||
# _chassis_uuid variable:
|
||||
sample._chassis_uuid = 'edcad704-b2da-41d5-96d9-afd580ecfa12'
|
||||
@ -788,7 +794,8 @@ class NodesController(rest.RestController):
|
||||
}
|
||||
|
||||
invalid_sort_key_list = ['properties', 'driver_info', 'extra',
|
||||
'instance_info', 'driver_internal_info']
|
||||
'instance_info', 'driver_internal_info',
|
||||
'clean_step']
|
||||
|
||||
def _get_nodes_collection(self, chassis_uuid, instance_uuid, associated,
|
||||
maintenance, marker, limit, sort_key, sort_dir,
|
||||
|
@ -106,6 +106,7 @@ class TestListNodes(test_api_base.FunctionalTest):
|
||||
self.assertNotIn('target_provision_state', data['nodes'][0])
|
||||
self.assertNotIn('provision_updated_at', data['nodes'][0])
|
||||
self.assertNotIn('maintenance_reason', data['nodes'][0])
|
||||
self.assertNotIn('clean_step', data['nodes'][0])
|
||||
# never expose the chassis_id
|
||||
self.assertNotIn('chassis_id', data['nodes'][0])
|
||||
|
||||
@ -129,6 +130,7 @@ class TestListNodes(test_api_base.FunctionalTest):
|
||||
self.assertIn('name', data)
|
||||
self.assertIn('inspection_finished_at', data)
|
||||
self.assertIn('inspection_started_at', data)
|
||||
self.assertIn('clean_step', data)
|
||||
# never expose the chassis_id
|
||||
self.assertNotIn('chassis_id', data)
|
||||
|
||||
@ -215,6 +217,18 @@ class TestListNodes(test_api_base.FunctionalTest):
|
||||
self.assertEqual(some_time, started)
|
||||
self.assertEqual(None, data['inspection_finished_at'])
|
||||
|
||||
def test_hide_fields_in_newer_versions_clean_step(self):
|
||||
node = obj_utils.create_test_node(self.context,
|
||||
clean_step={"foo": "bar"})
|
||||
data = self.get_json(
|
||||
'/nodes/%s' % node.uuid,
|
||||
headers={api_base.Version.string: str(api_v1.MIN_VER)})
|
||||
self.assertNotIn('clean_step', data)
|
||||
|
||||
data = self.get_json('/nodes/%s' % node.uuid,
|
||||
headers={api_base.Version.string: "1.7"})
|
||||
self.assertEqual({"foo": "bar"}, data['clean_step'])
|
||||
|
||||
def test_many(self):
|
||||
nodes = []
|
||||
for id in range(5):
|
||||
@ -291,7 +305,8 @@ class TestListNodes(test_api_base.FunctionalTest):
|
||||
|
||||
def test_sort_key_invalid(self):
|
||||
invalid_keys_list = ['foo', 'properties', 'driver_info', 'extra',
|
||||
'instance_info', 'driver_internal_info']
|
||||
'instance_info', 'driver_internal_info',
|
||||
'clean_step']
|
||||
for invalid_key in invalid_keys_list:
|
||||
response = self.get_json('/nodes?sort_key=%s' % invalid_key,
|
||||
expect_errors=True)
|
||||
|
Loading…
Reference in New Issue
Block a user