From 224db335b40da97d2de705a7e7536204862caf92 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Thu, 14 Jul 2022 17:56:31 +0200 Subject: [PATCH] Fix compatibility with jsonschema>=4.0.0 Specify the schema version for network_data and node, otherwise the latest one is used. Also fix one test where the error messages was changed. Change-Id: I4a614d7e73348bbe6c355a40881b013cbfe00b03 (cherry picked from commit 55b9579f14ea08a2dc732336d8f552cc14ab895d) --- ironic/api/controllers/v1/network-data-schema.json | 2 +- ironic/api/controllers/v1/node.py | 1 + .../unit/api/controllers/v1/test_deploy_template.py | 2 +- releasenotes/notes/jsonschema-966f55fc79b916fc.yaml | 9 +++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/jsonschema-966f55fc79b916fc.yaml diff --git a/ironic/api/controllers/v1/network-data-schema.json b/ironic/api/controllers/v1/network-data-schema.json index 7162daf343..c27c848715 100644 --- a/ironic/api/controllers/v1/network-data-schema.json +++ b/ironic/api/controllers/v1/network-data-schema.json @@ -1,5 +1,5 @@ { - "$schema": "http://openstack.org/nova/network_data.json#", + "$schema": "http://json-schema.org/draft-07/schema#", "id": "http://openstack.org/nova/network_data.json", "type": "object", "title": "OpenStack Nova network metadata schema", diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py index f182e2fd28..2ef369e136 100644 --- a/ironic/api/controllers/v1/node.py +++ b/ironic/api/controllers/v1/node.py @@ -140,6 +140,7 @@ def network_data_schema(): def node_schema(): network_data = network_data_schema() return { + '$schema': 'http://json-schema.org/draft-07/schema#', 'type': 'object', 'properties': { 'automated_clean': {'type': ['string', 'boolean', 'null']}, diff --git a/ironic/tests/unit/api/controllers/v1/test_deploy_template.py b/ironic/tests/unit/api/controllers/v1/test_deploy_template.py index b86fb0b1df..63784fef32 100644 --- a/ironic/tests/unit/api/controllers/v1/test_deploy_template.py +++ b/ironic/tests/unit/api/controllers/v1/test_deploy_template.py @@ -883,7 +883,7 @@ class TestPost(BaseDeployTemplatesAPITest): def test_create_invalid_step_field_priority(self): self._test_create_invalid_step_field( 'priority', 'not a number', - "'not a number' is not of type 'integer'") + "'not a number'") # differs between jsonschema versions def test_create_invalid_step_field_negative_priority(self): self._test_create_invalid_step_field( diff --git a/releasenotes/notes/jsonschema-966f55fc79b916fc.yaml b/releasenotes/notes/jsonschema-966f55fc79b916fc.yaml new file mode 100644 index 0000000000..20c1f7247e --- /dev/null +++ b/releasenotes/notes/jsonschema-966f55fc79b916fc.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + Fixes compatibility with ``jsonschema`` package version 4.0.0 or newer + by providing a proper schema version (Draft-07 currently). +issues: + - | + When using ``jsonschema`` 4.0.0 or newer, make sure to include a proper + ``$schema`` field in your custom network data or RAID schemas.