summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deploy/daisy_server.py31
-rw-r--r--deploy/deploy.py29
-rw-r--r--deploy/environment.py22
3 files changed, 56 insertions, 26 deletions
diff --git a/deploy/daisy_server.py b/deploy/daisy_server.py
index 5fa09577..223b2b1c 100644
--- a/deploy/daisy_server.py
+++ b/deploy/daisy_server.py
@@ -72,7 +72,8 @@ def log_scp(filename, size, send):
class DaisyServer(object):
- def __init__(self, name, address, password, remote_dir, bin_file, adapter):
+ def __init__(self, name, address, password, remote_dir, bin_file,
+ adapter, scenario, deploy_file_name, net_file_name):
self.name = name
self.address = address
self.password = password
@@ -80,6 +81,9 @@ class DaisyServer(object):
self.bin_file = bin_file
self.adapter = adapter
self.ssh_client = None
+ self.scenario = scenario
+ self.deploy_file_name = deploy_file_name
+ self.net_file_name = net_file_name
def connect(self):
LI('Try to connect to Daisy Server ...')
@@ -208,38 +212,39 @@ class DaisyServer(object):
cmd = 'export PYTHONPATH={python_path}; python {script} -nw {net_file}'.format(
python_path=self.remote_dir,
script=path_join(self.remote_dir, 'deploy/prepare/execute.py'),
- net_file=path_join(self.remote_dir, 'network.yml'))
+ net_file=path_join(self.remote_dir, self.net_file_name))
self.ssh_run(cmd)
def prepare_cluster(self, deploy_file, net_file):
LI('Copy cluster configuration files to Daisy Server')
- self.scp_put(deploy_file, path_join(self.remote_dir, 'deploy.yml'))
- self.scp_put(net_file, path_join(self.remote_dir, 'network.yml'))
+ self.scp_put(deploy_file, path_join(self.remote_dir, self.deploy_file_name))
+ self.scp_put(net_file, path_join(self.remote_dir, self.net_file_name))
self.prepare_configurations()
LI('Prepare cluster and PXE')
cmd = "python {script} --dha {deploy_file} --network {net_file} --cluster \'yes\'".format(
script=path_join(self.remote_dir, 'deploy/tempest.py'),
- deploy_file=path_join(self.remote_dir, 'deploy.yml'),
- net_file=path_join(self.remote_dir, 'network.yml'))
+ deploy_file=path_join(self.remote_dir, self.deploy_file_name),
+ net_file=path_join(self.remote_dir, self.net_file_name))
self.ssh_run(cmd, check=True)
def prepare_host_and_pxe(self):
LI('Prepare host and PXE')
- cmd = "python {script} --dha {deploy_file} --network {net_file} --host \'yes\' --isbare {is_bare}".format(
+ cmd = "python {script} --dha {deploy_file} --network {net_file} --host \'yes\' --isbare {is_bare} --scenario {scenarion}".format(
script=path_join(self.remote_dir, 'deploy/tempest.py'),
- deploy_file=path_join(self.remote_dir, 'deploy.yml'),
- net_file=path_join(self.remote_dir, 'network.yml'),
- is_bare=1 if self.adapter == 'ipmi' else 0)
+ deploy_file=path_join(self.remote_dir, self.deploy_file_name),
+ net_file=path_join(self.remote_dir, self.net_file_name),
+ is_bare=1 if self.adapter == 'ipmi' else 0,
+ scenario=self.scenario)
self.ssh_run(cmd, check=True)
def install_virtual_nodes(self):
LI('Daisy install virtual nodes')
cmd = "python {script} --dha {deploy_file} --network {net_file} --install \'yes\'".format(
script=path_join(self.remote_dir, 'deploy/tempest.py'),
- deploy_file=path_join(self.remote_dir, 'deploy.yml'),
- net_file=path_join(self.remote_dir, 'network.yml'))
+ deploy_file=path_join(self.remote_dir, self.deploy_file_name),
+ net_file=path_join(self.remote_dir, self.net_file_name))
self.ssh_run(cmd, check=True)
def check_os_installation(self, nodes_num):
@@ -262,5 +267,5 @@ class DaisyServer(object):
cmd = 'export PYTHONPATH={python_path}; python {script} -nw {net_file}'.format(
python_path=self.remote_dir,
script=path_join(self.remote_dir, 'deploy/post/execute.py'),
- net_file=path_join(self.remote_dir, 'network.yml'))
+ net_file=path_join(self.remote_dir, self.net_file_name))
self.ssh_run(cmd, check=False)
diff --git a/deploy/deploy.py b/deploy/deploy.py
index 88a5cba6..47549b43 100644
--- a/deploy/deploy.py
+++ b/deploy/deploy.py
@@ -20,6 +20,8 @@
import argparse
import yaml
+import time
+import os
from config.schemas import (
@@ -53,11 +55,14 @@ class DaisyDeployment(object):
self.lab_name = lab_name
self.pod_name = pod_name
- self.deploy_file = deploy_file
- self.deploy_struct = self._consturct_final_deploy_conf(deploy_file, scenario)
+ self.src_deploy_file = deploy_file
+ self.scenario = scenario
+ self.deploy_struct = self._construct_final_deploy_conf(deploy_file, scenario)
+ self.deploy_file, self.deploy_file_name = self._construct_final_deploy_file(self.deploy_struct, work_dir)
if not cleanup_only:
self.net_file = net_file
+ self.net_file_name = os.path.basename(net_file)
with open(net_file) as yaml_file:
self.net_struct = yaml.safe_load(yaml_file)
else:
@@ -94,7 +99,9 @@ class DaisyDeployment(object):
self.pxe_bridge,
self.daisy_server_info,
self.work_dir,
- self.storage_dir)
+ self.storage_dir,
+ self.scenario)
+ return
def _get_adapter_info(self):
default_adapter = 'libvirt' if 'virtual' in self.pod_name else 'ipmi'
@@ -116,7 +123,7 @@ class DaisyDeployment(object):
'password': password,
'disk_size': disk_size}
- def _consturct_final_deploy_conf(self, deploy_file, scenario):
+ def _construct_final_deploy_conf(self, deploy_file, scenario):
with open(deploy_file) as yaml_file:
deploy_struct = yaml.safe_load(yaml_file)
scenario_file = path_join(WORKSPACE, 'deploy/scenario/scenario.yaml')
@@ -137,6 +144,17 @@ class DaisyDeployment(object):
deploy_struct['modules'] = modules
return deploy_struct
+ def _construct_final_deploy_file(self, deploy_infor, work_dir):
+ final_deploy_file_name = 'final_deploy.yml'
+ final_deploy_file = path_join(work_dir, 'final_deploy.yml')
+ with open(final_deploy_file, 'w') as f:
+ f.write("\n".join([("title: This file automatically generated"),
+ "created: " + str(time.strftime("%d/%m/%Y")) +
+ " " + str(time.strftime("%H:%M:%S")),
+ "comment: none\n"]))
+ yaml.dump(deploy_infor, f, default_flow_style=False)
+ return final_deploy_file, final_deploy_file_name
+
def run(self):
self.daisy_env.delete_old_environment()
if self.cleanup_only:
@@ -145,7 +163,8 @@ class DaisyDeployment(object):
if self.daisy_only:
log_bar('Create Daisy Server successfully !')
return
- self.daisy_env.install_daisy(self.remote_dir, self.bin_file)
+ self.daisy_env.install_daisy(self.remote_dir, self.bin_file,
+ self.deploy_file_name, self.net_file_name)
self.daisy_env.deploy(self.deploy_file, self.net_file)
log_bar('Daisy deploy successfully !')
diff --git a/deploy/environment.py b/deploy/environment.py
index a6ef4ab5..1cd32980 100644
--- a/deploy/environment.py
+++ b/deploy/environment.py
@@ -53,20 +53,22 @@ VIRT_NET_TEMPLATE_PATH = path_join(WORKSPACE, 'templates/virtual_environment/net
class DaisyEnvironment(object):
def __new__(cls, deploy_struct, net_struct, adapter, pxe_bridge,
- daisy_server_info, work_dir, storage_dir):
+ daisy_server_info, work_dir, storage_dir, scenario):
if adapter == 'libvirt':
return VirtualEnvironment(deploy_struct, net_struct,
adapter, pxe_bridge,
- daisy_server_info, work_dir, storage_dir)
+ daisy_server_info, work_dir,
+ storage_dir, scenario)
else:
return BareMetalEnvironment(deploy_struct, net_struct,
adapter, pxe_bridge,
- daisy_server_info, work_dir, storage_dir)
+ daisy_server_info, work_dir,
+ storage_dir, scenario)
class DaisyEnvironmentBase(object):
def __init__(self, deploy_struct, net_struct, adapter, pxe_bridge,
- daisy_server_info, work_dir, storage_dir):
+ daisy_server_info, work_dir, storage_dir, scenario):
self.deploy_struct = deploy_struct
self.net_struct = net_struct
self.adapter = adapter
@@ -75,6 +77,7 @@ class DaisyEnvironmentBase(object):
self.storage_dir = storage_dir
self.daisy_server_info = daisy_server_info
self.server = None
+ self.scenario = scenario
LI('Daisy Environment Initialized')
def delete_daisy_server(self):
@@ -102,13 +105,16 @@ class DaisyEnvironmentBase(object):
shutil.move(image, self.daisy_server_info['image'])
LI('Daisy Server image is created %s' % self.daisy_server_info['image'])
- def install_daisy(self, remote_dir, bin_file):
+ def install_daisy(self, remote_dir, bin_file, deploy_file_name, net_file_name):
self.server = DaisyServer(self.daisy_server_info['name'],
self.daisy_server_info['address'],
self.daisy_server_info['password'],
remote_dir,
bin_file,
- self.adapter)
+ self.adapter,
+ self.scenario,
+ deploy_file_name,
+ net_file_name)
self.server.connect()
self.server.install_daisy()
@@ -162,9 +168,9 @@ class BareMetalEnvironment(DaisyEnvironmentBase):
class VirtualEnvironment(DaisyEnvironmentBase):
def __init__(self, deploy_struct, net_struct, adapter, pxe_bridge,
- daisy_server_info, work_dir, storage_dir):
+ daisy_server_info, work_dir, storage_dir, scenario):
super(VirtualEnvironment, self).__init__(deploy_struct, net_struct, adapter, pxe_bridge,
- daisy_server_info, work_dir, storage_dir)
+ daisy_server_info, work_dir, storage_dir, scenario)
self.check_configuration()
def check_configuration(self):