summaryrefslogtreecommitdiffstats
path: root/deploy/config
diff options
context:
space:
mode:
authorAlex Yang <yangyang1@zte.com.cn>2017-09-05 17:32:23 +0800
committerAlex Yang <yangyang1@zte.com.cn>2017-09-06 10:08:28 +0800
commit95aec0a10931ecc61981dba49c93c5bea8d48960 (patch)
tree638ad1910ec68a1f58f9c1006439938525595b77 /deploy/config
parent81c6480386c45b9909b1de50970717a5f5f3533e (diff)
Eliminate hard coding about ipmi info
1. Eliminate hard coding 2. Add ipmi info in schemas 3. Add unit test Change-Id: I4561bbc9454e02fd1de2106645db341a4129245b Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'deploy/config')
-rw-r--r--deploy/config/schemas.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/deploy/config/schemas.py b/deploy/config/schemas.py
index 3096d017..0e013eb9 100644
--- a/deploy/config/schemas.py
+++ b/deploy/config/schemas.py
@@ -7,6 +7,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import copy
from jsonschema import Draft4Validator, FormatChecker
import sys
import yaml
@@ -73,6 +74,10 @@ deploy_schema = {
'required': ['hosts', 'daisy_passwd', 'daisy_gateway']
}
+deploy_schema_bm = copy.deepcopy(deploy_schema)
+deploy_schema_bm['properties']['hosts']['items']['required'] = \
+ ['roles', 'ipmi_ip', 'ipmi_user', 'ipmi_pass']
+
def _validate(data, schema):
v = Draft4Validator(schema, format_checker=FormatChecker())
@@ -80,15 +85,11 @@ def _validate(data, schema):
return errors
-def item_validate(data, schema_type):
- if schema_type not in schema_mapping:
- return str('Schema Type %s does not exist' % schema_type)
- else:
- return _validate(data, schema_mapping.get(schema_type))
-
-
def deploy_schema_validate(data):
- return _validate(data, deploy_schema)
+ if data.get('adapter', 'libvirt') == 'ipmi':
+ return _validate(data, deploy_schema_bm)
+ else:
+ return _validate(data, deploy_schema)
def _main():