pymtt
 All Classes Namespaces Files Functions Variables Groups
DefaultProfile.py
Go to the documentation of this file.
1 # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: f; python-indent: 4 -*-
2 #
3 # Copyright (c) 2015-2018 Intel, Inc. All rights reserved.
4 # $COPYRIGHT$
5 #
6 # Additional copyrights may follow
7 #
8 # $HEADER$
9 #
10 
11 from __future__ import print_function
12 import os
13 from ProfileMTTStage import *
14 
15 ## @addtogroup Stages
16 # @{
17 # @addtogroup Profile
18 # @section DefaultProfile
19 # Collect hardware and software profile of the system
20 # @param kernelName Kernel name
21 # @param kernelRelease Kernel release string
22 # @param kernelVersion Kernel version string
23 # @param machineName Machine name
24 # @param processorType Processor type
25 # @param nodeName Node name
26 # @}
28 
29  def __init__(self):
30  # initialise parent class
31  ProfileMTTStage.__init__(self)
32  self.options = {}
33  self.options['kernelName'] = (True, "Kernel name", ["uname", "-s"])
34  self.options['kernelRelease'] = (True, "Kernel release string", ["uname", "-r"])
35  self.options['kernelVersion'] = (True, "Kernel version string", ["uname", "-v"])
36  self.options['machineName'] = (True, "Machine name", ["uname", "-m"])
37  self.options['processorType'] = (True, "Processor type", ["uname", "-p"])
38  self.options['nodeName'] = (True, "Node name", ["uname", "-n"])
39  return
40 
41  def activate(self):
42  # get the automatic procedure from IPlugin
43  IPlugin.activate(self)
44  return
45 
46 
47  def deactivate(self):
48  IPlugin.deactivate(self)
49  return
50 
51  def print_name(self):
52  return "DefaultProfile"
53 
54  def print_options(self, testDef, prefix):
55  lines = testDef.printOptions(self.options)
56  for line in lines:
57  print(prefix + line)
58  return
59 
60  def execute(self, log, keyvals, testDef):
61  testDef.logger.verbose_print("Collect system profile")
62  # collect general information on the system
63  myLog = {}
64  # see what they want us to collect
65  cmds = {}
66  testDef.parseOptions(log, self.options, keyvals, cmds)
67  keys = list(cmds.keys())
68  opts = self.options.keys()
69  for key in keys:
70  if cmds[key] and key in opts:
71  status, stdout, stderr, time = testDef.execmd.execute(cmds, self.options[key][2], testDef)
72  if 0 != status:
73  log['status'] = status
74  log['stdout'] = stdout
75  log['stderr'] = stderr
76  # ignore the execution time, if collected
77  return
78  myLog[key] = stdout
79  # add our log to the system log
80  log['profile'] = myLog
81  log['status'] = 0
82  return