summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs
diff options
context:
space:
mode:
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/baseclass.py21
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py35
2 files changed, 41 insertions, 15 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/baseclass.py b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
index 24d0499..cca627f 100644
--- a/openshift-storage-libs/openshiftstoragelibs/baseclass.py
+++ b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
@@ -33,6 +33,7 @@ from openshiftstoragelibs.node_ops import (
from openshiftstoragelibs.openshift_ops import (
get_block_provisioner,
get_pod_name_from_dc,
+ get_pod_name_from_rc,
get_pv_name_from_pvc,
oc_create_app_dc_with_io,
oc_create_pvc,
@@ -631,12 +632,20 @@ class GlusterBlockBaseClass(BaseClass):
def get_provisioner_for_sc(self):
return self.get_block_provisioner_for_sc()
- def verify_iscsi_sessions_and_multipath(self, pvc_name, rname, rtype="dc"):
+ def verify_iscsi_sessions_and_multipath(
+ self, pvc_name, rname, rtype='dc', heketi_server_url=None,
+ is_registry_gluster=False):
+ if not heketi_server_url:
+ heketi_server_url = self.heketi_server_url
+
# Get storage ips of glusterfs pods
- keys = self.gluster_servers
+ keys = (list(g.config['gluster_registry_servers'].keys()) if
+ is_registry_gluster else self.gluster_servers)
+ servers_info = (g.config['gluster_registry_servers'] if
+ is_registry_gluster else self.gluster_servers_info)
gluster_ips = []
for key in keys:
- gluster_ips.append(self.gluster_servers_info[key]['storage'])
+ gluster_ips.append(servers_info[key]['storage'])
gluster_ips.sort()
# Find iqn and hacount from volume info
@@ -645,7 +654,7 @@ class GlusterBlockBaseClass(BaseClass):
vol_id = oc_get_custom_resource(
self.ocp_client[0], 'pv', custom, pv_name)[0]
vol_info = heketi_blockvolume_info(
- self.heketi_client_node, self.heketi_server_url, vol_id, json=True)
+ self.heketi_client_node, heketi_server_url, vol_id, json=True)
iqn = vol_info['blockvolume']['iqn']
hacount = int(vol_info['hacount'])
@@ -657,6 +666,10 @@ class GlusterBlockBaseClass(BaseClass):
elif rtype == 'pod':
pod_info = oc_get_pods(self.ocp_client[0], name=rname)
pod_name = rname
+ elif rtype == 'rc':
+ pod_name = get_pod_name_from_rc(self.ocp_client[0], rname)
+ pod_info = oc_get_pods(
+ self.ocp_client[0], selector='name=%s' % rname)
else:
raise NameError("Value of rtype should be either 'dc' or 'pod'")
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index c8460d1..da8225a 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -1102,36 +1102,39 @@ def wait_for_pods_be_ready(
raise exceptions.ExecutionError(err_msg)
-def get_pod_names_from_dc(hostname, dc_name, timeout=180, wait_step=3):
+def get_pod_names_from_dc_or_rc(
+ hostname, rname, rtype='dc', timeout=180, wait_step=3):
"""Return list of POD names by their DC.
Args:
hostname (str): hostname on which 'oc' commands will be executed.
- dc_name (str): deployment_confidg name
+ rname (str): deployment_config name or replication_controller name
+ rtype (str): resource type, 'dc' or 'rc', Default value is 'rc'
timeout (int): timeout value. Default value is 180 sec.
wait_step( int): Wait step, default value is 3 sec.
Returns:
list: list of strings which are POD names
Raises: exceptions.ExecutionError
"""
+ if rtype not in ('dc', 'rc'):
+ raise NameError("Value of rtype should be either 'dc' or 'rc'.")
get_replicas_amount_cmd = (
- "oc get dc --no-headers --all-namespaces "
+ "oc get %s --no-headers --all-namespaces "
"-o=custom-columns=:.spec.replicas,:.metadata.name "
- "| grep '%s' | awk '{print $1}'" % dc_name)
- replicas = int(command.cmd_run(
- get_replicas_amount_cmd, hostname=hostname))
-
+ "| grep '%s' | awk '{print $1}'" % (rtype, rname))
get_pod_names_cmd = (
"oc get pods --all-namespaces -o=custom-columns=:.metadata.name "
- "--no-headers=true --selector deploymentconfig=%s" % dc_name)
+ "--no-headers=true --selector %s=%s" % (
+ "deploymentconfig" if rtype == "dc" else "name", rname))
+ replicas = int(command.cmd_run(get_replicas_amount_cmd, hostname=hostname))
for w in waiter.Waiter(timeout, wait_step):
out = command.cmd_run(get_pod_names_cmd, hostname=hostname)
pod_names = [o.strip() for o in out.split('\n') if o.strip()]
if len(pod_names) != replicas:
continue
g.log.info(
- "POD names for '%s' DC are '%s'. "
- "Expected amount of PODs is '%s'.", dc_name, out, replicas)
+ "POD names for '%s %s' are '%s'. "
+ "Expected amount of PODs is '%s'.", rname, rtype, out, replicas)
return pod_names
if w.expired:
err_msg = ("Exceeded %s sec timeout waiting for PODs to appear "
@@ -1140,11 +1143,21 @@ def get_pod_names_from_dc(hostname, dc_name, timeout=180, wait_step=3):
raise exceptions.ExecutionError(err_msg)
+def get_pod_names_from_dc(hostname, rname, timeout=180, wait_step=3):
+ return get_pod_names_from_dc_or_rc(
+ hostname, rname, timeout=timeout, wait_step=wait_step)
+
+
def get_pod_name_from_dc(hostname, dc_name, timeout=180, wait_step=3):
- return get_pod_names_from_dc(
+ return get_pod_names_from_dc_or_rc(
hostname, dc_name, timeout=timeout, wait_step=wait_step)[0]
+def get_pod_name_from_rc(hostname, rc_name, timeout=180, wait_step=3):
+ return get_pod_names_from_dc_or_rc(
+ hostname, rc_name, rtype='rc', timeout=timeout, wait_step=wait_step)[0]
+
+
def get_pvc_status(hostname, pvc_name):
'''
This function verifies the if pod is running