summaryrefslogtreecommitdiffstats
path: root/cns-libs/cnslibs/common/heketi_libs.py
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2018-12-25 21:09:09 +0530
committerValerii Ponomarov <vponomar@redhat.com>2018-12-25 23:20:48 +0530
commita118c991bfd5368aee517cc26188b1e3fee82d1f (patch)
treea4f966c1ce2fa649b6081d9c08b11028ec23a052 /cns-libs/cnslibs/common/heketi_libs.py
parent8b6107b62dacf5edc264f4f0206771d8fa07f7bf (diff)
Refactor config options
Doing following: - Rename top-level config option group called 'cns' to the 'openshift'. - Rename 'cns.setup.cns_project_name' option to the 'openshift.storage_project_name'. - Rename 'scale' option to the 'openshift.scale'. - Delete ''devices' and 'zone' options from 'gluster_servers' config group. - Delete 'cns.setup.cnd_username' option as unneeded. - Delete 'cns.setup.cnd_password' option as unneeded. - Delete 'oc_login' common function as unneeded after deletion of 'cns.setup.cnd_username' and 'cns.setup.cnd_password' options. - Remove 'Cns' word from base classes. - Keep backwards compatibility for old options to make transition be smooth. Change-Id: I04ddbbad5f64ffeac79a6744480d33a263d63001
Diffstat (limited to 'cns-libs/cnslibs/common/heketi_libs.py')
-rw-r--r--cns-libs/cnslibs/common/heketi_libs.py34
1 files changed, 8 insertions, 26 deletions
diff --git a/cns-libs/cnslibs/common/heketi_libs.py b/cns-libs/cnslibs/common/heketi_libs.py
index 7ac5c6a6..745ab229 100644
--- a/cns-libs/cnslibs/common/heketi_libs.py
+++ b/cns-libs/cnslibs/common/heketi_libs.py
@@ -1,4 +1,3 @@
-from collections import OrderedDict
import datetime
import unittest
@@ -25,14 +24,16 @@ class HeketiBaseClass(unittest.TestCase):
super(HeketiBaseClass, cls).setUpClass()
- # Initializes heketi config variables
- cls.cns_username = g.config['cns']['setup']['cns_username']
- cls.cns_password = g.config['cns']['setup']['cns_password']
- cls.cns_project_name = g.config['cns']['setup']['cns_project_name']
+ # Initializes config variables
+ openshift_config = g.config.get("cns", g.config.get("openshift"))
+ cls.storage_project_name = openshift_config.get(
+ 'storage_project_name',
+ openshift_config.get('setup', {}).get('cns_project_name'))
+
cls.ocp_master_nodes = g.config['ocp_servers']['master'].keys()
cls.ocp_master_node = cls.ocp_master_nodes[0]
- heketi_config = g.config['cns']['heketi_config']
+ heketi_config = openshift_config['heketi_config']
cls.heketi_dc_name = heketi_config['heketi_dc_name']
cls.heketi_service_name = heketi_config['heketi_service_name']
cls.heketi_client_node = heketi_config['heketi_client_node']
@@ -41,21 +42,6 @@ class HeketiBaseClass(unittest.TestCase):
cls.heketi_cli_key = heketi_config['heketi_cli_key']
cls.gluster_servers = g.config['gluster_servers'].keys()
cls.gluster_servers_info = g.config['gluster_servers']
- cls.topo_info = g.config['cns']['trusted_storage_pool_list']
-
- # Constructs topology info dictionary
- cls.topology_info = OrderedDict()
- for i in range(len(cls.topo_info)):
- cluster = 'cluster' + str(i + 1)
- cls.topology_info[cluster] = OrderedDict()
- for index, node in enumerate(cls.topo_info[i]):
- node_name = 'gluster_node' + str(index + 1)
- cls.topology_info[cluster][node_name] = {
- 'manage': cls.gluster_servers_info[node]['manage'],
- 'storage': cls.gluster_servers_info[node]['storage'],
- 'zone': cls.gluster_servers_info[node]['zone'],
- 'devices': cls.gluster_servers_info[node]['devices'],
- }
# Checks if heketi server is alive
if not hello_heketi(cls.heketi_client_node, cls.heketi_server_url):
@@ -63,12 +49,8 @@ class HeketiBaseClass(unittest.TestCase):
% cls.heketi_server_url)
# Switch to the storage project
- if not openshift_ops.oc_login(
- cls.ocp_master_node, cls.cns_username, cls.cns_password):
- raise ExecutionError("Failed to do oc login on node %s"
- % cls.ocp_master_node)
if not openshift_ops.switch_oc_project(
- cls.ocp_master_node, cls.cns_project_name):
+ cls.ocp_master_node, cls.storage_project_name):
raise ExecutionError("Failed to switch oc project on node %s"
% cls.ocp_master_node)