diff options
author | vamahaja <vamahaja@redhat.com> | 2018-08-28 16:11:33 +0530 |
---|---|---|
committer | vamahaja <vamahaja@redhat.com> | 2018-09-20 15:47:52 +0530 |
commit | fb9f48770333d0cd5b881e8e441153ac4da90101 (patch) | |
tree | 6011e9a7dd209dd8a383c4d0bffaae6e6c617fdb /cns-libs/cnslibs/common/dynamic_provisioning.py | |
parent | 77a65dab844055fef3a043d40dc3b35f71a7d84f (diff) |
Added library for scalling jenkins
Change-Id: I49932f43ac4e41f06c559d1d18d142b8a084278e
Signed-off-by: vamahaja <vamahaja@redhat.com>
Diffstat (limited to 'cns-libs/cnslibs/common/dynamic_provisioning.py')
-rw-r--r-- | cns-libs/cnslibs/common/dynamic_provisioning.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/cns-libs/cnslibs/common/dynamic_provisioning.py b/cns-libs/cnslibs/common/dynamic_provisioning.py index 70dffa4f..7580eb77 100644 --- a/cns-libs/cnslibs/common/dynamic_provisioning.py +++ b/cns-libs/cnslibs/common/dynamic_provisioning.py @@ -1,4 +1,5 @@ from collections import OrderedDict +from string import Template import json import os import tempfile @@ -14,6 +15,41 @@ from cnslibs.common.waiter import Waiter TEMPLATE_DIR = os.path.abspath(os.path.dirname(__file__)) +def create_script_template_file(hostname, template_file_path, src_dir_path, + dest_dir_path, params): + """Update the templates with the parameters and upload to openshift + master node + Args: + template_file_path (str): template file which need to be updated + src_dir_path (str): source path of template file + dest_dir_path (str): directory path to which template file + to be generated + params (dict): key, val pair to update template file + Raises: + Raises AssertionError in case of failure + """ + + src_path = os.path.join(src_dir_path, template_file_path) + contents = Template(open(src_path).read()) + contents = contents.safe_substitute(params) + + dest_path = os.path.join(dest_dir_path, template_file_path) + try: + conn = g.rpyc_get_connection(hostname, user="root") + if conn is None: + g.log.error("Failed to get rpyc connection of node %s" + % hostname) + raise AssertionError("Failed to get rpyc connection of node %s" + % hostname) + with conn.builtin.open(dest_path, 'w') as data_file: + data_file.write(contents) + except Exception as err: + g.log.error("failed to create script file %s" % err) + raise + finally: + g.rpyc_close_connection(hostname, user="root") + + def create_pvc_file(hostname, claim_name, storage_class, size): ''' This function creates pvc file |