summaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
authorAlex Yang <yangyang1@zte.com.cn>2017-08-17 19:01:29 +0800
committerAlex Yang <yangyang1@zte.com.cn>2017-08-17 19:01:29 +0800
commit0bb23f06dc12422b032ec081caf99ef6d2218fef (patch)
tree9cf1db20cba4682a8acaf9a354c9e4b8b1936ee3 /deploy
parentcf379370addba64f090387eed27f8b91ae82e875 (diff)
Modify schemas.py
1. add schemas for elements added recently in deploy.yml 2. remove daisy_ip from required list, prepare for generate it auto 3. add main() function to make this file useful in bash Change-Id: Ic7a3a87305f96b064260967862f976e33cdea294 Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'deploy')
-rw-r--r--deploy/config/schemas.py36
1 files changed, 33 insertions, 3 deletions
diff --git a/deploy/config/schemas.py b/deploy/config/schemas.py
index d2fd7ef6..3096d017 100644
--- a/deploy/config/schemas.py
+++ b/deploy/config/schemas.py
@@ -8,6 +8,8 @@
##############################################################################
from jsonschema import Draft4Validator, FormatChecker
+import sys
+import yaml
MIN_DAISY_DISK_SIZE = 50
@@ -28,8 +30,19 @@ hosts_schema = {
'enum': ['COMPUTER', 'CONTROLLER_LB', 'CONTROLLER_HA']
}
},
- 'template': {'type': 'string', 'minLength': 1}
- }
+ 'template': {'type': 'string', 'minLength': 1},
+ 'ipmi_ip': {'type': 'string', 'format': 'ip-address'},
+ 'ipmi_user': {'type': 'string'},
+ 'ipmi_pass': {'type': 'string'},
+ 'mac_addresses': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'string',
+ 'pattern': '^([0-9a-fA-F]{2})((:[0-9a-fA-F]{2}){5})$'
+ }
+ }
+ },
+ 'required': ['roles']
}
}
@@ -51,12 +64,13 @@ schema_mapping = {
'daisy_ip': {'type': 'string', 'format': 'ip-address'},
'daisy_gateway': {'type': 'string', 'format': 'ip-address'},
'ceph_disk_name': {'type': 'string'},
+ 'modules': {'type': ['array', 'null']}
}
deploy_schema = {
'type': 'object',
'properties': schema_mapping,
- 'required': ['hosts', 'daisy_passwd', 'daisy_ip', 'daisy_gateway']
+ 'required': ['hosts', 'daisy_passwd', 'daisy_gateway']
}
@@ -75,3 +89,19 @@ def item_validate(data, schema_type):
def deploy_schema_validate(data):
return _validate(data, deploy_schema)
+
+
+def _main():
+ if 2 != len(sys.argv):
+ sys.exit(1)
+ try:
+ data = yaml.safe_load(open(sys.argv[1], 'r'))
+ errors = deploy_schema_validate(data)
+ except Exception as e:
+ errors = 'Exception occured: ' + str(e)
+ if errors:
+ sys.exit(errors)
+
+
+if __name__ == '__main__':
+ _main()