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

Commit

Permalink
Merge pull request #934 from besawn/csm_bds_python
Browse files Browse the repository at this point in the history
Update the CSM BDS python use cases to support python3 on RHEL8
  • Loading branch information
besawn authored Jun 17, 2020
2 parents 5c89619 + 58edba9 commit db7237e
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'logstash-filter-csm-event-correlator'
s.version = "0.1.0"
s.licenses = ["Eclipse Public License v1.0"]
s.licenses = ["EPL-1.0"]
s.summary = "A filter for generating RAS events in response to log patterns."
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"
s.authors = ["John Dunham"]
Expand Down
18 changes: 14 additions & 4 deletions csm_big_data/python/cast_helper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python2
#!/bin/sh
# encoding: utf-8
#================================================================================
#
# cast_helper.py
#
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
#
# This program is licensed under the terms of the Eclipse Public License
# v1.0 as published by the Eclipse Foundation and available at
Expand All @@ -15,6 +15,15 @@
#
#================================================================================

# The beginning of this script is both valid shell and valid python,
# such that the script starts with the shell and is reexecuted with
# the right python.
#
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
#
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
'''
'''
.. module:: cast_helper
:platform: Linux
Expand All @@ -30,6 +39,7 @@
from elasticsearch.serializer import JSONSerializer
from elasticsearch import exceptions
from datetime import datetime
from functools import reduce
TARGET_ENV='CAST_ELASTIC'
Expand Down Expand Up @@ -307,15 +317,15 @@ def search_job( es, allocation_id=0, primary_job_id=0, secondary_job_id=0, size=

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

if allocation_id > 0 :
if int(allocation_id) > 0 :
query={
"bool" : {
"should" : [
{ "match" : { "data.allocation_id" : allocation_id } }
]
}
}
elif primary_job_id > 0 and secondary_job_id >= 0:
elif int(primary_job_id) > 0 and int(secondary_job_id) >= 0:
query={
"bool" : {
"should" : [
Expand Down
12 changes: 10 additions & 2 deletions csm_big_data/python/findJobKeys.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python2
#!/bin/sh
# encoding: utf-8
#================================================================================
#
# findJobKeys.py
#
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
#
# This program is licensed under the terms of the Eclipse Public License
# v1.0 as published by the Eclipse Foundation and available at
Expand All @@ -15,6 +15,14 @@
#
#================================================================================

# The beginning of this script is both valid shell and valid python,
# such that the script starts with the shell and is reexecuted with
# the right python.
#
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
#
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
'''
import argparse
import sys
Expand Down
13 changes: 11 additions & 2 deletions csm_big_data/python/findJobMetrics.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python2
#!/bin/sh
# encoding: utf-8
#================================================================================
#
# findJobMetrics.py
#
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
#
# This program is licensed under the terms of the Eclipse Public License
# v1.0 as published by the Eclipse Foundation and available at
Expand All @@ -15,6 +15,15 @@
#
#================================================================================

# The beginning of this script is both valid shell and valid python,
# such that the script starts with the shell and is reexecuted with
# the right python.
#
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
#
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
'''
import argparse
import sys
import os
Expand Down
12 changes: 10 additions & 2 deletions csm_big_data/python/findJobTimeRange.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python2
#!/bin/sh
# encoding: utf-8
#================================================================================
#
# findJobTimeRange.py
#
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
#
# This program is licensed under the terms of the Eclipse Public License
# v1.0 as published by the Eclipse Foundation and available at
Expand All @@ -15,6 +15,14 @@
#
#================================================================================

# The beginning of this script is both valid shell and valid python,
# such that the script starts with the shell and is reexecuted with
# the right python.
#
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
#
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
'''
import argparse
import sys
Expand Down
13 changes: 11 additions & 2 deletions csm_big_data/python/findJobsInRange.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python2
#!/bin/sh
# encoding: utf-8
#================================================================================
#
# findJobsInRange.py
#
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
#
# This program is licensed under the terms of the Eclipse Public License
# v1.0 as published by the Eclipse Foundation and available at
Expand All @@ -15,6 +15,15 @@
#
#================================================================================

# The beginning of this script is both valid shell and valid python,
# such that the script starts with the shell and is reexecuted with
# the right python.
#
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
#
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
'''
import argparse
import sys
import os
Expand Down
13 changes: 11 additions & 2 deletions csm_big_data/python/findJobsRunning.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python2
#!/bin/sh
# encoding: utf-8
#================================================================================
#
# findJobsRunning.py
#
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
#
# This program is licensed under the terms of the Eclipse Public License
# v1.0 as published by the Eclipse Foundation and available at
Expand All @@ -15,6 +15,15 @@
#
#================================================================================

# The beginning of this script is both valid shell and valid python,
# such that the script starts with the shell and is reexecuted with
# the right python.
#
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
#
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
'''
import argparse
import sys
import os
Expand Down
14 changes: 11 additions & 3 deletions csm_big_data/python/findUserJobs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python2
#!/bin/sh
# encoding: utf-8
#================================================================================
#
# findUserJobs.py
#
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
#
# This program is licensed under the terms of the Eclipse Public License
# v1.0 as published by the Eclipse Foundation and available at
Expand All @@ -15,6 +15,14 @@
#
#================================================================================

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

node_count=int(args.commonnodes)
for key,value in sorted( node_collisions.iteritems(), key=lambda (k,v): (v,k), reverse=False):
for key,value in sorted( node_collisions.iteritems(), key=lambda k_v: (k_v[1],k_v[0]), reverse=False):
if int(value) > node_count:
collision_found = True
print("{0:>{1}} : {2}".format(key, max_width, value))
Expand Down
19 changes: 13 additions & 6 deletions csm_big_data/python/findWeightedErrors.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python2
#!/bin/sh
# encoding: utf-8
#================================================================================
#
# findWeightedErrors.py
#
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
#
# This program is licensed under the terms of the Eclipse Public License
# v1.0 as published by the Eclipse Foundation and available at
Expand All @@ -15,10 +15,17 @@
#
#================================================================================

# The beginning of this script is both valid shell and valid python,
# such that the script starts with the shell and is reexecuted with
# the right python.
#
# The intent is to run as python3 on RHEL8 and python2 on RHEL7
#
'''which' python3 > /dev/null 2>&1 && exec python3 "$0" "$@" || exec python2 "$0" "$@"
'''
import argparse
import json
import sets
import sys
import os
Expand Down Expand Up @@ -235,8 +242,8 @@ def main(args):

print(" ")
# Print the results.
for category, response in sorted(results.iteritems(),
key=lambda (k, v): cast.deep_get( v, "hits", "max_score" ), reverse=True ):
for category, response in sorted(results.iteritems(),
key=lambda k_v1: cast.deep_get( k_v1[1], "hits", "max_score" ), reverse=True ):

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

if args.verbose:
Expand Down
6 changes: 4 additions & 2 deletions csm_big_data/setupRPM.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#================================================================================
#
# csm_big_data/castBDS.cmake
# csm_big_data/setupRPM.cmake
#
# © Copyright IBM Corporation 2015-2018. All Rights Reserved
# © Copyright IBM Corporation 2015-2020. All Rights Reserved
#
# This program is licensed under the terms of the Eclipse Public License
# v1.0 as published by the Eclipse Foundation and available at
Expand All @@ -20,6 +20,8 @@ set( CPACK_RPM_csm-bds_PRE_UNINSTALL_SCRIPT_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/csm_big_data/rpmscripts/cast-bds.pre.uninstall" )
if(${EXPLICIT_PYTHON_VERSION})
set(CPACK_RPM_csm-bds_PACKAGE_REQUIRES "python2-psycopg2 >= 2.5.1")
set(CPACK_RPM_csm-bds_PACKAGE_REQUIRES "python3-dateutil >= 2.6")
set(CPACK_RPM_csm-bds_PACKAGE_REQUIRES "python3-elasticsearch >= 7.0")
else()
set(CPACK_RPM_csm-bds_PACKAGE_REQUIRES "python-psycopg2 >= 2.5.1")
endif()
Expand Down
Loading

0 comments on commit db7237e

Please sign in to comment.