Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit db7237e

Browse files
authored
Merge pull request #934 from besawn/csm_bds_python
Update the CSM BDS python use cases to support python3 on RHEL8
2 parents 5c89619 + 58edba9 commit db7237e

File tree

11 files changed

+112
-42
lines changed

11 files changed

+112
-42
lines changed

csm_big_data/logstash/plugins/csm_event_correlator/logstash-filter-csm_event_correlator.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-filter-csm-event-correlator'
33
s.version = "0.1.0"
4-
s.licenses = ["Eclipse Public License v1.0"]
4+
s.licenses = ["EPL-1.0"]
55
s.summary = "A filter for generating RAS events in response to log patterns."
66
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
77
s.authors = ["John Dunham"]

csm_big_data/python/cast_helper.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/python2
1+
#!/bin/sh
22
# encoding: utf-8
33
#================================================================================
44
#
55
# cast_helper.py
66
#
7-
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
7+
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
88
#
99
# This program is licensed under the terms of the Eclipse Public License
1010
# v1.0 as published by the Eclipse Foundation and available at
@@ -15,6 +15,15 @@
1515
#
1616
#================================================================================
1717

18+
# The beginning of this script is both valid shell and valid python,
19+
# such that the script starts with the shell and is reexecuted with
20+
# the right python.
21+
#
22+
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
23+
#
24+
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
25+
'''
26+
1827
'''
1928
.. module:: cast_helper
2029
:platform: Linux
@@ -30,6 +39,7 @@
3039
from elasticsearch.serializer import JSONSerializer
3140
from elasticsearch import exceptions
3241
from datetime import datetime
42+
from functools import reduce
3343
3444
TARGET_ENV='CAST_ELASTIC'
3545
@@ -307,15 +317,15 @@ def search_job( es, allocation_id=0, primary_job_id=0, secondary_job_id=0, size=
307317

308318
query={ "bool" : { "should" : [] } }
309319

310-
if allocation_id > 0 :
320+
if int(allocation_id) > 0 :
311321
query={
312322
"bool" : {
313323
"should" : [
314324
{ "match" : { "data.allocation_id" : allocation_id } }
315325
]
316326
}
317327
}
318-
elif primary_job_id > 0 and secondary_job_id >= 0:
328+
elif int(primary_job_id) > 0 and int(secondary_job_id) >= 0:
319329
query={
320330
"bool" : {
321331
"should" : [

csm_big_data/python/findJobKeys.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/python2
1+
#!/bin/sh
22
# encoding: utf-8
33
#================================================================================
44
#
55
# findJobKeys.py
66
#
7-
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
7+
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
88
#
99
# This program is licensed under the terms of the Eclipse Public License
1010
# v1.0 as published by the Eclipse Foundation and available at
@@ -15,6 +15,14 @@
1515
#
1616
#================================================================================
1717

18+
# The beginning of this script is both valid shell and valid python,
19+
# such that the script starts with the shell and is reexecuted with
20+
# the right python.
21+
#
22+
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
23+
#
24+
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
25+
'''
1826
1927
import argparse
2028
import sys

csm_big_data/python/findJobMetrics.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/python2
1+
#!/bin/sh
22
# encoding: utf-8
33
#================================================================================
44
#
55
# findJobMetrics.py
66
#
7-
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
7+
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
88
#
99
# This program is licensed under the terms of the Eclipse Public License
1010
# v1.0 as published by the Eclipse Foundation and available at
@@ -15,6 +15,15 @@
1515
#
1616
#================================================================================
1717

18+
# The beginning of this script is both valid shell and valid python,
19+
# such that the script starts with the shell and is reexecuted with
20+
# the right python.
21+
#
22+
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
23+
#
24+
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
25+
'''
26+
1827
import argparse
1928
import sys
2029
import os

csm_big_data/python/findJobTimeRange.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/python2
1+
#!/bin/sh
22
# encoding: utf-8
33
#================================================================================
44
#
55
# findJobTimeRange.py
66
#
7-
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
7+
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
88
#
99
# This program is licensed under the terms of the Eclipse Public License
1010
# v1.0 as published by the Eclipse Foundation and available at
@@ -15,6 +15,14 @@
1515
#
1616
#================================================================================
1717

18+
# The beginning of this script is both valid shell and valid python,
19+
# such that the script starts with the shell and is reexecuted with
20+
# the right python.
21+
#
22+
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
23+
#
24+
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
25+
'''
1826
1927
import argparse
2028
import sys

csm_big_data/python/findJobsInRange.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/python2
1+
#!/bin/sh
22
# encoding: utf-8
33
#================================================================================
44
#
55
# findJobsInRange.py
66
#
7-
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
7+
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
88
#
99
# This program is licensed under the terms of the Eclipse Public License
1010
# v1.0 as published by the Eclipse Foundation and available at
@@ -15,6 +15,15 @@
1515
#
1616
#================================================================================
1717

18+
# The beginning of this script is both valid shell and valid python,
19+
# such that the script starts with the shell and is reexecuted with
20+
# the right python.
21+
#
22+
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
23+
#
24+
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
25+
'''
26+
1827
import argparse
1928
import sys
2029
import os

csm_big_data/python/findJobsRunning.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/python2
1+
#!/bin/sh
22
# encoding: utf-8
33
#================================================================================
44
#
55
# findJobsRunning.py
66
#
7-
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
7+
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
88
#
99
# This program is licensed under the terms of the Eclipse Public License
1010
# v1.0 as published by the Eclipse Foundation and available at
@@ -15,6 +15,15 @@
1515
#
1616
#================================================================================
1717

18+
# The beginning of this script is both valid shell and valid python,
19+
# such that the script starts with the shell and is reexecuted with
20+
# the right python.
21+
#
22+
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
23+
#
24+
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
25+
'''
26+
1827
import argparse
1928
import sys
2029
import os

csm_big_data/python/findUserJobs.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/python2
1+
#!/bin/sh
22
# encoding: utf-8
33
#================================================================================
44
#
55
# findUserJobs.py
66
#
7-
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
7+
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
88
#
99
# This program is licensed under the terms of the Eclipse Public License
1010
# v1.0 as published by the Eclipse Foundation and available at
@@ -15,6 +15,14 @@
1515
#
1616
#================================================================================
1717

18+
# The beginning of this script is both valid shell and valid python,
19+
# such that the script starts with the shell and is reexecuted with
20+
# the right python.
21+
#
22+
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
23+
#
24+
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
25+
'''
1826
1927
import argparse
2028
import sys
@@ -147,7 +155,7 @@ def main(args):
147155
print("{0:>{1}} : {2}".format("node", max_width, "common count"))
148156

149157
node_count=int(args.commonnodes)
150-
for key,value in sorted( node_collisions.iteritems(), key=lambda (k,v): (v,k), reverse=False):
158+
for key,value in sorted( node_collisions.iteritems(), key=lambda k_v: (k_v[1],k_v[0]), reverse=False):
151159
if int(value) > node_count:
152160
collision_found = True
153161
print("{0:>{1}} : {2}".format(key, max_width, value))

csm_big_data/python/findWeightedErrors.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/python2
1+
#!/bin/sh
22
# encoding: utf-8
33
#================================================================================
44
#
55
# findWeightedErrors.py
66
#
7-
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
7+
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
88
#
99
# This program is licensed under the terms of the Eclipse Public License
1010
# v1.0 as published by the Eclipse Foundation and available at
@@ -15,10 +15,17 @@
1515
#
1616
#================================================================================
1717

18+
# The beginning of this script is both valid shell and valid python,
19+
# such that the script starts with the shell and is reexecuted with
20+
# the right python.
21+
#
22+
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
23+
#
24+
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
25+
'''
1826
1927
import argparse
2028
import json
21-
import sets
2229
import sys
2330
import os
2431
@@ -235,8 +242,8 @@ def main(args):
235242

236243
print(" ")
237244
# Print the results.
238-
for category, response in sorted(results.iteritems(),
239-
key=lambda (k, v): cast.deep_get( v, "hits", "max_score" ), reverse=True ):
245+
for category, response in sorted(results.iteritems(),
246+
key=lambda k_v1: cast.deep_get( k_v1[1], "hits", "max_score" ), reverse=True ):
240247

241248
# Get aggregations.
242249
aggregations = response.get("aggregations", [])
@@ -249,7 +256,7 @@ def main(args):
249256
if aggregations is not None:
250257
# Sort aggregations by document count.
251258
for (aggregation,value) in sorted(aggregations.iteritems(),
252-
key=lambda (k, v): v.get("doc_count"), reverse=True):
259+
key=lambda k_v2: k_v2[1].get("doc_count"), reverse=True):
253260
print(" \"{0}\" : {1}".format( aggregation, value.get("doc_count") ) )
254261

255262
if args.verbose:

csm_big_data/setupRPM.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#================================================================================
22
#
3-
# csm_big_data/castBDS.cmake
3+
# csm_big_data/setupRPM.cmake
44
#
5-
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
5+
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
66
#
77
# This program is licensed under the terms of the Eclipse Public License
88
# v1.0 as published by the Eclipse Foundation and available at
@@ -20,6 +20,8 @@ set( CPACK_RPM_csm-bds_PRE_UNINSTALL_SCRIPT_FILE
2020
"${CMAKE_CURRENT_SOURCE_DIR}/csm_big_data/rpmscripts/cast-bds.pre.uninstall" )
2121
if(${EXPLICIT_PYTHON_VERSION})
2222
set(CPACK_RPM_csm-bds_PACKAGE_REQUIRES "python2-psycopg2 >= 2.5.1")
23+
set(CPACK_RPM_csm-bds_PACKAGE_REQUIRES "python3-dateutil >= 2.6")
24+
set(CPACK_RPM_csm-bds_PACKAGE_REQUIRES "python3-elasticsearch >= 7.0")
2325
else()
2426
set(CPACK_RPM_csm-bds_PACKAGE_REQUIRES "python-psycopg2 >= 2.5.1")
2527
endif()

0 commit comments

Comments
 (0)