summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2019-04-02 22:35:45 +0530
committervponomar <vponomar@redhat.com>2019-04-11 11:56:38 +0000
commit0b2c88ee59b52312c86bcceea1645a57671894af (patch)
tree4379ea502d11cea577ec4c3de9c606b9bfc231a4 /openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
parent5fe05c3d09126453423a3d2ee97a4586ec6592c1 (diff)
Fix support of OCP3.6 and 3.7
Project has lots of inconsistencies with OCP3.6 and 3.7 So, fix it. Change-Id: I8d38773637b779e1c2e1631568f100c1ab1fdd50
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs/openshift_ops.py')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index ae0de98..26d7d0b 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -1298,9 +1298,29 @@ def get_events(hostname,
field_selector.append('reason=%s' % event_reason)
if event_type:
field_selector.append('type=%s' % event_type)
- cmd = "oc get events -o yaml --field-selector %s" % ",".join(
- field_selector or "''")
- return yaml.load(command.cmd_run(cmd, hostname=hostname))['items']
+ cmd = "oc get events -o yaml"
+ if openshift_version.get_openshift_version() >= '3.9':
+ cmd.append(" --field-selector %s" % ",".join(field_selector or "''"))
+ objects = yaml.load(command.cmd_run(cmd, hostname=hostname))['items']
+ if openshift_version.get_openshift_version() >= '3.9':
+ return objects
+
+ # Backup approach for OCP3.6 and OCP3.7 which do not have
+ # '--field-selector' feature.
+ filtered_objects = []
+ for o in objects:
+ if obj_name and o["involvedObject"]["name"] != obj_name:
+ continue
+ if obj_namespace and o["involvedObject"]["namespace"] != obj_namespace:
+ continue
+ if obj_type and o["involvedObject"]["kind"] != obj_type:
+ continue
+ if event_reason and o["reason"] != event_reason:
+ continue
+ if event_type and o["type"] != event_type:
+ continue
+ filtered_objects.append(o)
+ return filtered_objects
def wait_for_events(hostname,