Comment 11 for bug 1336462

Revision history for this message
Thierry FAUCK (thierry-j) wrote :

Here is a new version of the python file: (It runs now).

import os, re, os.path, sys, platform

import apport.packaging
import apport.hookutils

from glob import glob
from apport.hookutils import command_output, attach_root_command_outputs, attach_file, attach_file_if_exists, command_available

""" IBM Power System related information
"""

def add_copy_spec(report,path):
    for file in os.listdir(path):
        attach_file(report,file,key="test")

def add_info(report,ui):
    arch = platform.machine()
    if arch in [ "ppc64", "ppc64le"]:
        print("Processing query for power architecture %s" %arch)
    else:
        return

    try:
        print("try")
        with open('/proc/cpuinfo', 'r') as fp:
            contents = fp.read()
            ispSeries = "pSeries" in contents
            isPowerNV = "PowerNV" in contents
            isPowerKVM = "emulated by qemu" in contents
        print("got flags ispSeries/isPowerNV/isPowerKVM: ", ispSeries, isPowerNV, isPowerKVM, end="\n" )
    except IOError:
        print("Error")
        ispSeries = False
        isPowerNV = False
        isPowerKVM = False

    if ispSeries or isPowerNV:
        print("Processing pSeries or PowerNV")
        add_copy_spec(report,"/proc/device-tree/")
        attach_file(report, '/proc/misc', 'ProcMisc')
        attach_file(report, '/proc/locks', 'ProcLocks')
        attach_file(report, '/proc/loadavg', 'ProcLoadAvg')
        attach_file(report, '/proc/swaps', 'ProcSwaps')
        attach_file(report, '/proc/version', 'ProcVersion')
        report['cpu_smt'] = command_output(['ppc64_cpu', '--smt'])
        report['cpu_cores'] = command_output(['ppc64_cpu', '--cores-present'])
        report['cpu_coreson'] = command_output(['ppc64_cpu', '--cores-on'])
        # To be executed as root
        attach_root_command_outputs(report, {
            'cpu_runmode': 'ppc64_cpu --run-mode',
            'cpu_freq': 'ppc64_cpu --frequency',
            'cpu_dscr': 'ppc64_cpu --dscr'
        })
        attach_file_if_exists(report,"/var/log/platform")
        #add_copy_spec(report,"/dev/nvram")

    if ispSeries and not isPowerKVM:
        print("Processing pSeries addons")
        attach_file(report, '/proc/ppc64/lparcfg', 'ProcLparCfg')
        attach_file(report, '/proc/ppc64/eeh', 'ProcEeh')
        attach_file(report, '/proc/ppc64/systemcfg', 'ProcSystemCfg')
        report['lscfg_vp'] = command_output(['lscfg', '-vp'])
        report['lsmcode'] = command_output(['lsmcode', '-A'])
        report['bootlist'] = command_output(['bootlist', '-m', 'both', '-r'])
        report['lparstat'] = command_output(['lparstat', '-i'])
        if command_available('lsvpd'):
            report['lsvpd'] = command_output(['lsvpd', '--debug'])
        if command_available('lsvio'):
            report['lsvio'] = command_output(['lsvio', '-des'])
        if command_available('servicelog'):
            report['servicelog_dump'] = command_output(['servicelog', '--dump'])
        if command_available('servicelog_notify'):
            report['servicelo_list'] = command_output(['servicelog_notify', '--list'])
        if command_available('usysattn'):
            report['usysattn'] = command_output(['usysattn'])
        if command_available('usysident'):
            report['usysident'] = command_output(['usysident'])
        if command_available('serv_config'):
            report['serv_config'] = command_output(['serv_config', '-l'])

    if isPowerNV:
        add_copy_spec(report,"/proc/ppc64/")