diff options
author | Apeksha D Khakharia <akhakhar@redhat.com> | 2018-02-05 11:14:21 +0530 |
---|---|---|
committer | Apeksha D Khakharia <akhakhar@redhat.com> | 2018-02-21 17:20:04 +0530 |
commit | 1aba0134455b846ffb3a9a4dd9b4ba622c6515ca (patch) | |
tree | d7c95e1a678a34eb07122b11574c3a90324d8eb3 /cns-libs | |
parent | 3ecdfb197aeb68665ff3264d8effe32af6066240 (diff) |
CNS: heketi_url change
Change-Id: I927166d4649a5318cea221219d471534bd258545
Signed-off-by: Apeksha D Khakharia <akhakhar@redhat.com>
Diffstat (limited to 'cns-libs')
-rw-r--r-- | cns-libs/cnslibs/cns/cns_baseclass.py | 46 | ||||
-rw-r--r-- | cns-libs/cnslibs/common/cns_libs.py | 22 |
2 files changed, 46 insertions, 22 deletions
diff --git a/cns-libs/cnslibs/cns/cns_baseclass.py b/cns-libs/cnslibs/cns/cns_baseclass.py index 5a9106a5..a6edfdd0 100644 --- a/cns-libs/cnslibs/cns/cns_baseclass.py +++ b/cns-libs/cnslibs/cns/cns_baseclass.py @@ -105,6 +105,13 @@ class CnsBaseClass(unittest.TestCase): ['start_count_for_pvc']) cls.app_pvc_count_dict = (g.config['cns']['dynamic_provisioning'] ['app_pvc_count_dict']) + cmd = "echo -n %s | base64" % cls.heketi_cli_key + ret, out, err = g.run(cls.ocp_master_node[0], cmd, "root") + if ret != 0: + raise ExecutionError("failed to execute cmd %s on %s out: %s " + "err: %s" % ( + cmd, cls.ocp_master_node[0], out, err)) + cls.secret_data_key = out.strip() if 'glustotest_run_id' not in g.config: g.config['glustotest_run_id'] = ( @@ -158,6 +165,9 @@ class CnsSetupBaseClass(CnsBaseClass): raise ExecutionError("failed to execute cmd %s on %s out: " "%s err: %s" % ( cmd, node, out, err)) + if not edit_master_config_file(cls.ocp_master_node[0], + cls.routingconfig_subdomain): + raise ExecutionError("failed to edit master.conf file") cmd = "systemctl restart atomic-openshift-node.service" cmd_results = g.run_parallel(cls.ocp_nodes, cmd, "root") for node, ret_values in cmd_results.iteritems(): @@ -166,9 +176,6 @@ class CnsSetupBaseClass(CnsBaseClass): raise ExecutionError("failed to execute cmd %s on %s out: " "%s err: %s" % ( cmd, node, out, err)) - if not edit_master_config_file(cls.ocp_master_node[0], - cls.routingconfig_subdomain): - raise ExecutionError("failed to edit master.conf file") cmd = ("systemctl restart atomic-openshift-master-api " "atomic-openshift-master-controllers") ret, out, err = g.run(cls.ocp_master_node[0], cmd, "root") @@ -227,7 +234,8 @@ class CnsSetupBaseClass(CnsBaseClass): if not setup_router(cls.ocp_client[0], cls.router_name): raise ExecutionError("failed to setup router") if not update_router_ip_dnsmasq_conf(cls.ocp_client[0], - cls.router_name): + cls.router_name, + cls.routingconfig_subdomain): raise ExecutionError("failed to update router ip in dnsmasq.conf") cmd = "systemctl restart dnsmasq.service" ret, out, err = g.run(cls.ocp_client[0], cmd, "root") @@ -242,7 +250,8 @@ class CnsSetupBaseClass(CnsBaseClass): "%s err: %s" % ( cmd, cls.ocp_master_node[0], out, err)) if not update_router_ip_dnsmasq_conf(cls.ocp_master_node[0], - cls.router_name): + cls.router_name, + cls.routingconfig_subdomain): raise ExecutionError("failed to update router ip in dnsmasq.conf") cmd = "systemctl restart dnsmasq.service" ret, out, err = g.run(cls.ocp_master_node[0], cmd, "root") @@ -250,10 +259,11 @@ class CnsSetupBaseClass(CnsBaseClass): raise ExecutionError("failed to execute cmd %s on %s out: " "%s err: %s" % ( cmd, cls.ocp_master_node[0], out, err)) - if not update_nameserver_resolv_conf(cls.ocp_client[0]): - raise ExecutionError("failed to update namserver in resolv.conf") if not update_nameserver_resolv_conf(cls.ocp_master_node[0], "EOF"): raise ExecutionError("failed to update namserver in resolv.conf") + if cls.ocp_master_node[0] != cls.ocp_client[0]: + if not update_nameserver_resolv_conf(cls.ocp_client[0]): + raise ExecutionError("failed to update namserver in resolv.conf") @classmethod def cns_deploy(cls): @@ -261,14 +271,21 @@ class CnsSetupBaseClass(CnsBaseClass): This function runs the cns-deploy ''' ret = heketi_create_topology(cls.heketi_client_node, - cls.topology_info, - topology_file="/tmp/topology.json") + cls.topology_info) if not ret: raise ConfigError("Failed to create heketi topology file on %s" % cls.heketi_client_node) - cmd = ("cns-deploy -n %s -g /tmp/topology.json -c oc -t " - "/usr/share/heketi/templates -l cns_deploy.log " - "-v -w 600 -y") % cls.cns_project_name + # temporary workaround till we get fix for bug - + # https://bugzilla.redhat.com/show_bug.cgi?id=1505948 + cmd = "sed -i s/'exec -it'/'exec -i'/g /usr/bin/cns-deploy" + ret, out, err = g.run(cls.ocp_client[0], cmd, "root") + if ret != 0: + raise ExecutionError("failed to execute cmd %s on %s out: " + "%s err: %s" % ( + cmd, cls.ocp_client[0], out, err)) + cmd = ("cns-deploy -n %s -g -c oc -t /usr/share/heketi/templates -l " + "cns_deploy.log -v -w 600 -y /usr/share/heketi/topology.json" % ( + cls.cns_project_name)) ret, out, err = g.run(cls.ocp_client[0], cmd, "root") if ret != 0: raise ExecutionError("failed to execute cmd %s on %s out: " @@ -290,6 +307,11 @@ class CnsGlusterBlockBaseClass(CnsBaseClass): Glusterblock setup on CNS ''' super(CnsGlusterBlockBaseClass, cls).setUpClass() + for node in cls.ocp_all_nodes: + if not edit_iptables_cns(node): + raise ExecutionError("failed to edit iptables") + cmd = "systemctl reload iptables" + cmd_results = g.run_parallel(cls.ocp_all_nodes, cmd, "root") gluster_pod_list = get_ocp_gluster_pod_names(cls.ocp_master_node[0]) g.log.info("gluster_pod_list - %s" % gluster_pod_list) for pod in gluster_pod_list: diff --git a/cns-libs/cnslibs/common/cns_libs.py b/cns-libs/cnslibs/common/cns_libs.py index f32acf0d..d949ddfe 100644 --- a/cns-libs/cnslibs/common/cns_libs.py +++ b/cns-libs/cnslibs/common/cns_libs.py @@ -68,7 +68,8 @@ def setup_router(hostname, router_name, timeout=1200, wait_step=60): bool: True if successful, otherwise False ''' - cmd = "oc get pods | grep '%s'| awk '{print $3}'" % router_name + cmd = ("oc get pods | grep '%s'| grep -v deploy | " + "awk '{print $3}'" % router_name) ret, out, err = g.run(hostname, cmd, "root") if ret != 0: g.log.error("failed to execute cmd %s" % cmd) @@ -99,21 +100,22 @@ def setup_router(hostname, router_name, timeout=1200, wait_step=60): g.log.error("failed to execute cmd %s" % cmd) break status = out.strip().split("\n")[0].strip() - if status == "ContainerCreating": + if status == "ContainerCreating" or status == "Pending": g.log.info("container creating for router %s sleeping for" " %s seconds" % (router_name, wait_step)) continue elif status == "Running": + router_flag = True g.log.info("router %s is up and running" % router_name) - break + return router_flag elif status == "Error": g.log.error("error while setting up router %s" % ( router_name)) - return False + return router_flag else: g.log.error("%s router pod has different status - " "%s" % (router_name, status)) - break + return router_flag if w.expired: g.log.error("failed to setup '%s' router in " "%s seconds" % (router_name, timeout)) @@ -123,7 +125,7 @@ def setup_router(hostname, router_name, timeout=1200, wait_step=60): return True -def update_router_ip_dnsmasq_conf(hostname, router_name): +def update_router_ip_dnsmasq_conf(hostname, router_name, router_domain): ''' This function updates the router-ip in /etc/dnsmasq.conf file Args: @@ -134,14 +136,14 @@ def update_router_ip_dnsmasq_conf(hostname, router_name): bool: True if successful, otherwise False ''' - cmd = ("oc get pods -o wide| grep '%s'| awk '{print $6}' " - "| cut -d ':' -f 1") % router_name + cmd = ("oc get pods -o wide | grep '%s'| grep -v deploy | " + "awk '{print $6}' | cut -d ':' -f 1") % router_name ret, out, err = g.run(hostname, cmd, "root") if ret != 0: g.log.error("failed to execute cmd %s" % cmd) return False router_ip = out.strip().split("\n")[0].strip() - data_to_write = "address=/.cloudapps.mystorage.com/%s" % router_ip + data_to_write = "address=/.%s/%s" % (router_domain, router_ip) try: conn = g.rpyc_get_connection(hostname, user="root") if conn is None: @@ -152,7 +154,7 @@ def update_router_ip_dnsmasq_conf(hostname, router_name): update_flag = False for line in conn.modules.fileinput.input( '/etc/dnsmasq.conf', inplace=True): - if "mystorage" in line: + if router_domain in line: conn.modules.sys.stdout.write(line.replace(line, data_to_write)) update_flag = True |