summaryrefslogtreecommitdiffstats
path: root/deploy/environment.py
diff options
context:
space:
mode:
authorAlex Yang <yangyang1@zte.com.cn>2017-05-19 09:19:17 +0800
committerAlex Yang <yangyang1@zte.com.cn>2017-05-25 13:34:38 +0800
commit24e32399eba20d6b613b654b60b1dcc48a857adc (patch)
tree544247100b7428d3e91f693863e52939089779b9 /deploy/environment.py
parentbfacd100e576a50be19447f7c1b6cea2ac55ebd0 (diff)
Use unified vm template files in python deploy script
Change-Id: I386011a35a9be3e4f1d468744a6945360bb2adb3 Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'deploy/environment.py')
-rw-r--r--deploy/environment.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/deploy/environment.py b/deploy/environment.py
index d18bf550..2adec494 100644
--- a/deploy/environment.py
+++ b/deploy/environment.py
@@ -28,6 +28,7 @@ from libvirt_utils import (
)
from utils import (
WORKSPACE,
+ LD,
LI,
LW,
err_exit,
@@ -45,8 +46,8 @@ VMDEPLOY_DAISY_SERVER_VM = path_join(WORKSPACE, 'templates/virtual_environment/v
BMDEPLOY_DAISY_SERVER_VM = path_join(WORKSPACE, 'templates/physical_environment/vms/daisy.xml')
ALL_IN_ONE_TEMPLATE = path_join(WORKSPACE, 'templates/virtual_environment/vms/all_in_one.xml')
-CONTROLLER_TEMPLATE = path_join(WORKSPACE, 'templates/virtual_environment/vms/controller01.xml')
-COMPUTE_TEMPLATE = path_join(WORKSPACE, 'templates/virtual_environment/vms/computer01.xml')
+CONTROLLER_TEMPLATE = path_join(WORKSPACE, 'templates/virtual_environment/vms/controller.xml')
+COMPUTE_TEMPLATE = path_join(WORKSPACE, 'templates/virtual_environment/vms/computer.xml')
VIRT_NET_TEMPLATE_PATH = path_join(WORKSPACE, 'templates/virtual_environment/networks')
@@ -160,6 +161,27 @@ class BareMetalEnvironment(DaisyEnvironmentBase):
class VirtualEnvironment(DaisyEnvironmentBase):
+ def __init__(self, deploy_struct, net_struct, adapter, pxe_bridge,
+ daisy_server_info, work_dir, storage_dir):
+ super(VirtualEnvironment, self).__init__(deploy_struct, net_struct, adapter, pxe_bridge,
+ daisy_server_info, work_dir, storage_dir)
+ self.check_configuration()
+
+ def check_configuration(self):
+ self.check_nodes_template()
+
+ def check_nodes_template(self):
+ for node in self.deploy_struct['hosts']:
+ template = node.get('template', None)
+ if not template or os.access(template, os.R_OK):
+ continue
+ elif os.access(path_join(WORKSPACE, template), os.R_OK):
+ template_new = path_join(WORKSPACE, template)
+ LD('Template of VM node %s is %s' % (node.get('name', ''), template_new))
+ node['template'] = template_new
+ else:
+ err_exit('The template of vm node %s does not exist.' % node.get('name'))
+
def create_daisy_server_network(self):
net_name = create_virtual_network(VMDEPLOY_DAISY_SERVER_NET)
if net_name != self.pxe_bridge: