aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/objects.py
diff options
context:
space:
mode:
authorFrank A. Zdarsky <fzdarsky@redhat.com>2017-01-20 12:53:52 +0100
committerFrank A. Zdarsky <fzdarsky@redhat.com>2017-07-12 22:57:34 +0200
commit9ef9a7a92dc7af2a7d54affd68aaa37539296dd4 (patch)
treefda32c5c2bf1bca4cea722840dbead1db020be18 /os_net_config/objects.py
parent03d3a5dea1b70c62d585dd6de5e3f9c04345e58b (diff)
Add schema-based config data validation
This patch adds a jsonschema for os-net-config's configuration data and a library function to validate configuration data based on this schema. Adding schema-based validation allows catching a larger class of errors (typos, missing required parameters, etc.) for all devices configurable through os-net-config. The validation is run in the os-net-config CLI after loading the config file. If the config file fails to validate, the current default is to just log a warning and try to continue. By providing the new CLI option '--exit-on-validation-errors', this can be changed to log an error and exist instead. This validation is meant to be reusable, for example for pre-deployment validation of network environments (see change Ic16ee0bc353c46f8fe512454176a07ee95347346). Packaging with os-net-config makes it easier to keep object model and schema in sync. Change-Id: Ie4a905863b2d46c88d9cd6c3afc50e7d0a877090 Signed-off-by: Frank A. Zdarsky <fzdarsky@redhat.com>
Diffstat (limited to 'os_net_config/objects.py')
-rw-r--r--os_net_config/objects.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/os_net_config/objects.py b/os_net_config/objects.py
index 5fe6e49..a6d0c03 100644
--- a/os_net_config/objects.py
+++ b/os_net_config/objects.py
@@ -14,6 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+#
+# NOTE: When making changes to the object model, remember to also update
+# schema.yaml to reflect changes to the schema of config files!
+#
+
import logging
import netaddr
from oslo_utils import strutils