From 02d137a777ec750f4cfe9846c5386bbc9f28a30d Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 30 Mar 2017 08:42:59 -0700 Subject: [PATCH] Validate flavor specification in config Validate that at least one of min-ram or flavor-name are present. Change-Id: I2e42b0d6176e5a15e1ceb2a77b9d557bc0704d50 --- nodepool/cmd/config_validator.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nodepool/cmd/config_validator.py b/nodepool/cmd/config_validator.py index 666824e2b..cff69ecd0 100644 --- a/nodepool/cmd/config_validator.py +++ b/nodepool/cmd/config_validator.py @@ -24,13 +24,21 @@ class ConfigValidator: self.config_file = config_file def validate(self): - pool_label = { + label_min_ram = v.Schema({v.Required('min-ram'): int}, extra=True) + + label_flavor_name = v.Schema({v.Required('flavor-name'): str}, + extra=True) + + pool_label_main = { v.Required('name'): str, v.Required('diskimage'): str, 'min-ram': int, 'flavor-name': str, } + pool_label = v.All(pool_label_main, + v.Any(label_min_ram, label_flavor_name)) + pool = { 'name': str, 'networks': [str],