diff options
author | Alex Yang <yangyang1@zte.com.cn> | 2017-05-09 11:11:53 +0800 |
---|---|---|
committer | Alex Yang <yangyang1@zte.com.cn> | 2017-05-10 23:14:42 +0800 |
commit | fb09a7ed97707b6a007721ff4b72a904c4204e93 (patch) | |
tree | ba626025fdb12d185a183521c9313dea5a14976f /deploy/deploy.py | |
parent | 568edb9d5ed462672d5a5c53ac735e04d8f687c4 (diff) |
refacort deploy.yml and add jsonschema to validate it
1. add adapter type in deploy.yml
Do not rely on the pod's name to detemine whether impi or libvirt
should be used.
2. increase disk size in deploy.yml
The disk sizes should be bigger than 102400 mega-bytes according to
the minimum of root_lv_size in upstream openstack/daisycloud-core.
3. add schemas.py
Use jsonschema to validate deploy.yml
Change-Id: I3f197f93403caece75460147c8df49b95e0ae9d3
Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'deploy/deploy.py')
-rw-r--r-- | deploy/deploy.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/deploy/deploy.py b/deploy/deploy.py index 23464b5a..5926a74d 100644 --- a/deploy/deploy.py +++ b/deploy/deploy.py @@ -20,10 +20,17 @@ import argparse import yaml + +from config.schemas import ( + MIN_DAISY_DISK_SIZE, + deploy_schema_validate +) from utils import ( WORKSPACE, save_log_to_file, LI, + LE, + err_exit, log_bar, path_join, check_sudo_privilege, @@ -31,7 +38,6 @@ from utils import ( make_file_executable, confirm_dir_exists ) - from environment import ( DaisyEnvironment, ) @@ -64,6 +70,11 @@ class DaisyDeployment(object): self.pxe_bridge = pxe_bridge self.deploy_log = deploy_log + result = deploy_schema_validate(self.deploy_struct) + if result: + LE(result) + err_exit('Configuration deploy.yml check failed!') + self.adapter = self._get_adapter_info() LI('The adapter is %s' % self.adapter) @@ -84,19 +95,14 @@ class DaisyDeployment(object): self.storage_dir) def _get_adapter_info(self): - # TODO: specify the adapter info in deploy.yml - if 'adapter' in self.deploy_struct: - return self.deploy_struct['adapter'] - elif self.pod_name and 'virtual' in self.pod_name: - return 'libvirt' - else: - return 'ipmi' + default_adapter = 'libvirt' if 'virtual' in self.pod_name else 'ipmi' + return self.deploy_struct.get('adapter', default_adapter) def _get_daisy_server_info(self): address = self.deploy_struct.get('daisy_ip', '10.20.11.2') gateway = self.deploy_struct.get('daisy_gateway', '10.20.11.1') password = self.deploy_struct.get('daisy_passwd', 'r00tme') - disk_size = self.deploy_struct.get('disks', {'daisy': 50})['daisy'] + disk_size = self.deploy_struct.get('disks', {}).get('daisy', MIN_DAISY_DISK_SIZE) # TODO: get VM name of daisy server from deploy.yml or vm template name = 'daisy' image = path_join(self.storage_dir, name + '.qcow2') |