Merge lp:~sophia-wu/opencompute/add-ocp-system-event-log-job into lp:opencompute/checkbox

Proposed by Sophia Wu
Status: Merged
Approved by: Jeff Lane 
Approved revision: 2174
Merged at revision: 2173
Proposed branch: lp:~sophia-wu/opencompute/add-ocp-system-event-log-job
Merge into: lp:opencompute/checkbox
Diff against target: 459 lines (+230/-79)
8 files modified
data/whitelists/opencompute-certify-remoteME.whitelist (+46/-0)
debian/changelog (+0/-79)
debian/checkbox.install (+1/-0)
debian/checkbox.postinst (+1/-0)
examples/me.cfg (+15/-0)
jobs/TC-002-0011-System_Log.txt.in (+11/-0)
jobs/local.txt.in (+9/-0)
scripts/ipmi_sel_entries (+147/-0)
To merge this branch: bzr merge lp:~sophia-wu/opencompute/add-ocp-system-event-log-job
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+213419@code.launchpad.net

This proposal supersedes a proposal from 2014-02-14.

Description of the change

Verify the system event log must be capable of saving at least 256 entries

To post a comment you must log in.
Revision history for this message
Jeff Lane  (bladernr) wrote : Posted in a previous version of this proposal

Hi Sophia.... thanks for submitting this. In general it looks good but there are a couple things:

1: Why is there a separate whitelist for this? Does this need it's own whitelist, or would this be in a general certification remote whitelist? If that's the case, the whitelist should simply be called opencompute-certify-remote.whitelist.

2: if you want the config file me.cfg to be installed, you need to add it to the approrpiate files in the debian directory. here are teh places where the examples directory is referenced:

debian/checkbox-hw-collection.install:usr/share/checkbox/examples/checkbox-hw-collection.ini
debian/checkbox.install:usr/share/checkbox/examples/checkbox.ini
debian/checkbox.install:usr/share/checkbox/examples/network.cfg
debian/checkbox.install:usr/share/checkbox/examples/virtualization.cfg
debian/checkbox.install:usr/share/checkbox/examples/org.freedesktop.policykit.checkbox.policy usr/share/polkit-1/actions/
debian/checkbox-ocp-cli.install:usr/share/checkbox/examples/checkbox-ocp-cli.ini
debian/checkbox-ocp-gtk.install:usr/share/checkbox/examples/checkbox-ocp-gtk.ini
debian/checkbox-ocp-qt.install:usr/share/checkbox/examples/checkbox-ocp-qt.ini
debian/checkbox-ocp-urwid.install:usr/share/checkbox/examples/checkbox-ocp-urwid.ini
debian/checkbox.postinst:cp /usr/share/checkbox/examples/network.cfg /etc/checkbox.d/
debian/checkbox.postinst:cp /usr/share/checkbox/examples/virtualization.cfg /etc/checkbox.d/

You're probably interested in checkbox.install and checkbox.postinst

Without adding it to those files, the config file will not be installed with the package.

3: in the ipmi_sel_entries script, you reference ../examples/me.cfg twice. The proper installed location is /etc/checkbox.d/ (See 2 above).

4: Finally, you also need to update debian/changelog and add an entry under your name that briefly describes the changes you've made. See other entries in the changelog for examples.

Fix those few items (and just let me know more about item 1) and I'll push this through.

Thanks!

review: Needs Fixing
Revision history for this message
Sophia Wu (sophia-wu) wrote : Posted in a previous version of this proposal

Hi Jeff,

Thanks for your feedback. It's very helpful for me.

And about item 1,
Due to some other test cases that we haven't commit now, they will run ME stress test.
I think it's better to separate the whitelists, one is for retrieving ME data and another is for stressing ME.

Thanks,
Sophia

Revision history for this message
Jeff Lane  (bladernr) wrote : Posted in a previous version of this proposal

Hi Sophia...

I'm ready to pass this through and merge it, but I need one additional thing from you.

Whenver you do a merge request, please also update debian/changelog

See the current changelog for examples... So I need you to do the following:

1: update your branch to the latest trunk code using bzr pull:

cd your/local/branch/dir
bzr pull #should update your branch with the latest trunk

edit /your/local/branch/dir/debian/changelog

Look at Nelson's entry and add a similar one to that below his... so ti should look something like this:

[Nelson Chu]
* Item 1
* Item 2
* Itme 3

[Sophia Wu]
* Item 1
* Item 2

If you can do that and resubmit, I'l approve and merge your branch as soon as I see the update.

Thanks!

Jeff

review: Needs Fixing
Revision history for this message
Jeff Lane  (bladernr) wrote : Posted in a previous version of this proposal

Thanks... and in the future, if I haven't gotten to something like this within a couple days, please ping me directly... sometimes these notices get lost in the noise (I get better than 1000 emails a day, most of whcih are automated from Launchpad).

review: Approve
Revision history for this message
Jeff Lane  (bladernr) wrote : Posted in a previous version of this proposal

Attempt to merge into lp:opencompute/checkbox failed due to conflicts:

duplicate in debian/changelog.moved
text conflict in jobs/local.txt.in

Revision history for this message
Jeff Lane  (bladernr) wrote : Posted in a previous version of this proposal

OK, so tarmac tried to merge the code and ran into some conflicts...

First, why did you add a brand new copy of the changelog, or more importantly, how did you manage to do that? You don't need to create a new changelog, simple edit the existing one...

So lets focus on getting this cleared up... do the following:

first, pull a fresh copy of the checkbox code:

bzr branch lp:opencompute/checkbox ocp-checkbox

Next, merge YOUR branch into that:

cd ocp-checkbox
bzr merge lp:~sophia-wu/opencompute/add-ocp-system-event-log-job

And you should see the following:
+N data/whitelists/opencompute-certify-remoteME.whitelist
+N debian/changelog
+N examples/me.cfg
+N jobs/TC-002-0011-System_Log.txt.in
+N scripts/ipmi_sel_entries
R debian/changelog => debian/changelog.moved
 M debian/checkbox.install
 M debian/checkbox.postinst
 M jobs/local.txt.in
Conflict adding file debian/changelog. Moved existing file to debian/changelog.moved.
Text conflict in jobs/local.txt.in
2 conflicts encountered.

The conflicts are what held this up. So first, fix the changelog. As I mentioned above, for some reason, it thinks you've added a brand new copy of the changelog. So we need to do the following:

cd debian
mv changelog changelog.sophia
mv changelog.moved changelog

then take the stuff you added (the Sophia section of changelog.sophia) and add that to changelog.

then delete changelog.sophia

rm changelog.sophia

Now you should be able to resolve the first conflict:

bzr resolve debian/changelog

which should give you this:
1 conflict resolved, 1 remaining

Now run bzr conflicts to see what's left:
Text conflict in jobs/local.txt.in

So lets now look at jobs/local.txt.in. The conflict is at the end:

<<<<<<< TREE
name: __TC-003-0001-Hardware_Information__
=======
name: __TC-002-0011-System_Log__
>>>>>>> MERGE-SOURCE
plugin: local
<<<<<<< TREE
_description: Verify hardware information
=======
description: System Event Log
>>>>>>> MERGE-SOURCE
command:
<<<<<<< TREE
  shopt -s extglob
  cat $CHECKBOX_SHARE/jobs/TC-003-0001-Hardware_Information.txt?(.in)
=======
 shopt -s extglob
 cat $CHECKBOX_SHARE/jobs/TC-002-0011-System_Log.txt?(.in)

>>>>>>> MERGE-SOURCE

So clean that up to look correct:

name: __TC-001-0002-Platform_Controller_Hub__
plugin: local
_description: Verify platform controller hub functionality
command:
 shopt -s extglob
 cat $CHECKBOX_SHARE/jobs/TC-001-0002-Platform_Controller_Hub.txt?(.in)

name: __TC-002-0011-System_Log__
plugin: local
description: System Event Log
command:
 shopt -s extglob
 cat $CHECKBOX_SHARE/jobs/TC-002-0011-System_Log.txt?(.in)

name: __TC-003-0001-Hardware_Information__
plugin: local
_description: Verify hardware information
command:
 shopt -s extglob
 cat $CHECKBOX_SHARE/jobs/TC-003-0001-Hardware_Information.txt?(.in)

Save and exit that file and run bzr resolve and you should see this:
All conflicts resolved.

then resubmit and I'll approve and get this merged.

review: Needs Fixing
2173. By Sophia Wu

resolve conflicts

2174. By Sophia Wu

Add OCP system event log job

Revision history for this message
Jeff Lane  (bladernr) wrote :

Thanks, lets try this again and see what happens.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'data/whitelists/opencompute-certify-remoteME.whitelist'
--- data/whitelists/opencompute-certify-remoteME.whitelist 1970-01-01 00:00:00 +0000
+++ data/whitelists/opencompute-certify-remoteME.whitelist 2014-03-31 08:50:05 +0000
@@ -0,0 +1,46 @@
1## This whitelist is intended for use inside Canonical's test labs. The tests
2## conained in this list are the same as those contained in the
3## server-selftest.whitelist file that OEMs may use. The difference here is that
4## some of these tests depend on a specific network environment and may not run
5## properly in your test environment. To avoid false failures, please use the
6## server-selftest.whitelist instead.
7# Resource Jobs
8block_device
9cdimage
10cpuinfo
11device
12dmi
13dpkg
14efi
15environment
16gconf
17lsb
18meminfo
19module
20optical_drive
21package
22sleep
23uname
24#Info attachment jobs
25__info__
26cpuinfo_attachment
27dmesg_attachment
28dmi_attachment
29dmidecode_attachment
30efi_attachment
31lspci_attachment
32meminfo_attachment
33modprobe_attachment
34modules_attachment
35sysctl_attachment
36sysfs_attachment
37udev_attachment
38lsmod_attachment
39acpi_sleep_attachment
40info/hdparm
41info/hdparm_.*.txt
42installer_debug.gz
43info/disk_partitions
44# Actual test cases
45__TC-002-0011-System_Log__
46TC-002-0011-001-System_Log_Entries
047
=== added file 'debian/changelog'
--- debian/changelog 1970-01-01 00:00:00 +0000
+++ debian/changelog 2014-03-31 08:50:05 +0000
@@ -0,0 +1,86 @@
1checkbox (1.16.13~OCP) UNRELEASED; urgency=low
2
3 [ Sophia Wu ]
4 * data/whitelists/opencompute-certify-remoteME.whitelist - added a new whitelist for Intel ME
5 * jobs/TC-002-0011-System_Log.txt - added a new IPMI out-of-band test which is related to system log on Intel ME
6 * jobs/local.txt.in - added job to parse System Event Log job
7 * scripts/ipmi_sel_entries - added a new script to verify entry number of system event log
8 * examples/me.cfg - added new config file for Intel ME test
9
10 [ Nelson Chu ]
11 * data/whitelists/opencompute-certify-local.whitelist - Added Hardware
12 Information jobs to OCP certification whitelist
13 * jobs/TC-003-0001-Hardware_Information.txt - Added new jobs for Hardware
14 Information test cases
15 * jobs/local.txt.in - Added job to parse new Hardware Information job file
16 * scripts/disk_info - new script to gather disk infomation
17 * scripts/bios_info - new script to gather BIOS infomation
18 * scripts/raid_info - new script to gather RAID infomation
19 * data/whitelists/opencompute-certify-local.whitelist - Added PCH jobs to
20 OCP certification whitelist
21 * jobs/TC-001-0002-Platform_Controller_Hub.txt - Added new jobs for PCH
22 test cases
23 * jobs/local.txt.in - Added job to parse new PCH job file
24 * scripts/check_sata_port - new script to verify SATA port speed
25 * scripts/check_usb_port - new script to verify USB version
26 * data/whitelists/opencompute-certify-local.whitelist - Added CPU and Memory
27 jobs to OCP certification whitelist
28 * jobs/TC-001-0001-CPU_Memory.txt.in - Added new jobs for CPU and Memory
29 test cases
30 * jobs/local.txt.in - Added job to parse new CPU and Memory job file
31 * scripts/cpu_info - new script to gather CPU information
32 * scripts/memory_info - new script to gather memory information
33 * scripts/processor_topology - Revised script to match certification criteria
34
35 [ Jeff Marcom ]
36 * Updated scripts/network script from lp:checkbox
37
38 -- Jeff Marcom <jeff.marcom@canonical.com> Tue, 5 Nov 2013 11:12:04 -0400
39
40checkbox (1.16.12~OCP) UNRELEASED; urgency=low
41
42 [ Jeff Marcom ]
43 * Added googlestress app memory tests
44 * Updated plainbox based on version 0.4.dev in lp:checkbox (16.12)
45 * Updated checkbox OCP intro prompt
46 * Updated Open Compute ready whitelist with new power management, cpu stress, and networking tests"
47 * Added 12hr idle verification test and sylog check for PCI/Device errors
48 * Removed launchpad prompt
49
50 [ Jeff Lane ]
51 * Updated OCP Checkbox to latest checkbox trunk, 0.16.11 revno 2353
52 * Enabled bonnie++ tests after noting that bonnie++ is available via yum and
53 apt. Added new disk io_stress jobs and disk_stress script to add disk
54 testing via stressapptest.
55 * debian/control: promoted several packages from suggest to depends to ensure
56 they are installed along with checkbox-ocp (LP: #1233333)
57 * Cherry pick new iperf functionality in network testing from checkbox trunk
58
59 -- Jeff Marcom <jeff.marcom@canonical.com> Wed, 2 Oct 2013 10:13:04 -0400
60
61checkbox (1.16.6~OCP) UNRELEASED; urgency=low
62
63 [ Jeff Marcom ]
64 * Added checkbox-ocp package
65
66 -- Jeff Marcom <jeff.marcom@canonical.com> Wed, 21 Aug 2013 12:20:24 -0400
67
68
69checkbox (0.16.6~OCPubuntu1) UNRELEASED; urgency=low
70
71 * INITIAL RELEASE:
72 based on checkbox 0.16.6 from lp:checkbox with modificiations specific to
73 the Open Compute Project
74
75 [ Jeff Marcom ]
76 * jobs/ipmi_out_of_band.txt.in - added new out of band ipmi tests
77 * jobs/dcmi_in_band.txt.in - added new inband DCMI tests
78
79 [ Jeff Lane ]
80 * data/ - Cleanup, removed unnecessary data files, dirs and whitelists
81 bin/ - all checkbox launchers now default to
82 opencompute-ready-local.whitelist
83 * jobs/, po/, scripts/ - Cleanup, removed unnecessary job and scritp files
84 and their references in po/POTFILES.in
85 checkbox/tests/ - Cleaned up unit tests that were looking for things
86 removed in this merge.
087
=== removed file 'debian/changelog'
--- debian/changelog 2014-03-18 07:59:11 +0000
+++ debian/changelog 1970-01-01 00:00:00 +0000
@@ -1,79 +0,0 @@
1checkbox (1.16.13~OCP) UNRELEASED; urgency=low
2
3 [ Nelson Chu ]
4 * data/whitelists/opencompute-certify-local.whitelist - Added Hardware
5 Information jobs to OCP certification whitelist
6 * jobs/TC-003-0001-Hardware_Information.txt - Added new jobs for Hardware
7 Information test cases
8 * jobs/local.txt.in - Added job to parse new Hardware Information job file
9 * scripts/disk_info - new script to gather disk infomation
10 * scripts/bios_info - new script to gather BIOS infomation
11 * scripts/raid_info - new script to gather RAID infomation
12 * data/whitelists/opencompute-certify-local.whitelist - Added PCH jobs to
13 OCP certification whitelist
14 * jobs/TC-001-0002-Platform_Controller_Hub.txt - Added new jobs for PCH
15 test cases
16 * jobs/local.txt.in - Added job to parse new PCH job file
17 * scripts/check_sata_port - new script to verify SATA port speed
18 * scripts/check_usb_port - new script to verify USB version
19 * data/whitelists/opencompute-certify-local.whitelist - Added CPU and Memory
20 jobs to OCP certification whitelist
21 * jobs/TC-001-0001-CPU_Memory.txt.in - Added new jobs for CPU and Memory
22 test cases
23 * jobs/local.txt.in - Added job to parse new CPU and Memory job file
24 * scripts/cpu_info - new script to gather CPU information
25 * scripts/memory_info - new script to gather memory information
26 * scripts/processor_topology - Revised script to match certification criteria
27
28 [ Jeff Marcom ]
29 * Updated scripts/network script from lp:checkbox
30
31 -- Jeff Marcom <jeff.marcom@canonical.com> Tue, 5 Nov 2013 11:12:04 -0400
32
33checkbox (1.16.12~OCP) UNRELEASED; urgency=low
34
35 [ Jeff Marcom ]
36 * Added googlestress app memory tests
37 * Updated plainbox based on version 0.4.dev in lp:checkbox (16.12)
38 * Updated checkbox OCP intro prompt
39 * Updated Open Compute ready whitelist with new power management, cpu stress, and networking tests"
40 * Added 12hr idle verification test and sylog check for PCI/Device errors
41 * Removed launchpad prompt
42
43 [ Jeff Lane ]
44 * Updated OCP Checkbox to latest checkbox trunk, 0.16.11 revno 2353
45 * Enabled bonnie++ tests after noting that bonnie++ is available via yum and
46 apt. Added new disk io_stress jobs and disk_stress script to add disk
47 testing via stressapptest.
48 * debian/control: promoted several packages from suggest to depends to ensure
49 they are installed along with checkbox-ocp (LP: #1233333)
50 * Cherry pick new iperf functionality in network testing from checkbox trunk
51
52 -- Jeff Marcom <jeff.marcom@canonical.com> Wed, 2 Oct 2013 10:13:04 -0400
53
54checkbox (1.16.6~OCP) UNRELEASED; urgency=low
55
56 [ Jeff Marcom ]
57 * Added checkbox-ocp package
58
59 -- Jeff Marcom <jeff.marcom@canonical.com> Wed, 21 Aug 2013 12:20:24 -0400
60
61
62checkbox (0.16.6~OCPubuntu1) UNRELEASED; urgency=low
63
64 * INITIAL RELEASE:
65 based on checkbox 0.16.6 from lp:checkbox with modificiations specific to
66 the Open Compute Project
67
68 [ Jeff Marcom ]
69 * jobs/ipmi_out_of_band.txt.in - added new out of band ipmi tests
70 * jobs/dcmi_in_band.txt.in - added new inband DCMI tests
71
72 [ Jeff Lane ]
73 * data/ - Cleanup, removed unnecessary data files, dirs and whitelists
74 bin/ - all checkbox launchers now default to
75 opencompute-ready-local.whitelist
76 * jobs/, po/, scripts/ - Cleanup, removed unnecessary job and scritp files
77 and their references in po/POTFILES.in
78 checkbox/tests/ - Cleaned up unit tests that were looking for things
79 removed in this merge.
800
=== modified file 'debian/checkbox.install'
--- debian/checkbox.install 2013-07-05 20:01:00 +0000
+++ debian/checkbox.install 2014-03-31 08:50:05 +0000
@@ -8,6 +8,7 @@
8usr/share/checkbox/examples/checkbox.ini8usr/share/checkbox/examples/checkbox.ini
9usr/share/checkbox/examples/network.cfg9usr/share/checkbox/examples/network.cfg
10usr/share/checkbox/examples/virtualization.cfg10usr/share/checkbox/examples/virtualization.cfg
11usr/share/checkbox/examples/me.cfg
11usr/share/checkbox/examples/org.freedesktop.policykit.checkbox.policy usr/share/polkit-1/actions/12usr/share/checkbox/examples/org.freedesktop.policykit.checkbox.policy usr/share/polkit-1/actions/
12usr/share/checkbox/install/*13usr/share/checkbox/install/*
13usr/share/checkbox/jobs/*14usr/share/checkbox/jobs/*
1415
=== modified file 'debian/checkbox.postinst'
--- debian/checkbox.postinst 2013-07-05 16:43:48 +0000
+++ debian/checkbox.postinst 2014-03-31 08:50:05 +0000
@@ -5,5 +5,6 @@
55
6cp /usr/share/checkbox/examples/network.cfg /etc/checkbox.d/6cp /usr/share/checkbox/examples/network.cfg /etc/checkbox.d/
7cp /usr/share/checkbox/examples/virtualization.cfg /etc/checkbox.d/7cp /usr/share/checkbox/examples/virtualization.cfg /etc/checkbox.d/
8cp /usr/share/checkbox/examples/me.cfg /etc/checkbox.d/
89
9#DEBHELPER#10#DEBHELPER#
1011
=== added file 'examples/me.cfg'
--- examples/me.cfg 1970-01-01 00:00:00 +0000
+++ examples/me.cfg 2014-03-31 08:50:05 +0000
@@ -0,0 +1,15 @@
1#Please config ME IP of server that you want to test
2#for example, if ME ip of your server is 10.0.0.1,
3#then you must replace x.x.x.x to 10.0.0.1 in [Targets]
4
5[Targets]
6Target1: x.x.x.x
7
8#please config ME account(USER/PASSWORD) of server that you want to test
9#for example, if ME account of your server is ADMIN/ADMIN,
10#then you must replace OCP/OCP to ADMIN/ADMIN in [Account]
11
12[Account]
13USER: OCP
14PASSWORD: OCP
15
016
=== added file 'jobs/TC-002-0011-System_Log.txt.in'
--- jobs/TC-002-0011-System_Log.txt.in 1970-01-01 00:00:00 +0000
+++ jobs/TC-002-0011-System_Log.txt.in 2014-03-31 08:50:05 +0000
@@ -0,0 +1,11 @@
1plugin: shell
2name: TC-002-0011-001-System_Log_Entries
3requires: package.name == 'ipmitool'
4user: root
5command: ipmi_sel_entries
6description:
7 1. Use ipmitool to collect event log information
8 2. Calculate entries number of system event log
9 3. Criteria: the A log must be capable of saving at least 256 entries
10
11
012
=== modified file 'jobs/local.txt.in'
--- jobs/local.txt.in 2014-03-18 07:59:11 +0000
+++ jobs/local.txt.in 2014-03-31 08:50:05 +0000
@@ -124,9 +124,18 @@
124 shopt -s extglob124 shopt -s extglob
125 cat $CHECKBOX_SHARE/jobs/TC-001-0002-Platform_Controller_Hub.txt?(.in)125 cat $CHECKBOX_SHARE/jobs/TC-001-0002-Platform_Controller_Hub.txt?(.in)
126126
127name: __TC-002-0011-System_Log__
128plugin: local
129_description: System Event Log
130command:
131 shopt -s extglob
132 cat $CHECKBOX_SHARE/jobs/TC-002-0011-System_Log.txt?(.in)
133
127name: __TC-003-0001-Hardware_Information__134name: __TC-003-0001-Hardware_Information__
128plugin: local135plugin: local
129_description: Verify hardware information136_description: Verify hardware information
130command:137command:
131 shopt -s extglob138 shopt -s extglob
132 cat $CHECKBOX_SHARE/jobs/TC-003-0001-Hardware_Information.txt?(.in)139 cat $CHECKBOX_SHARE/jobs/TC-003-0001-Hardware_Information.txt?(.in)
140
141
133142
=== added file 'scripts/ipmi_sel_entries'
--- scripts/ipmi_sel_entries 1970-01-01 00:00:00 +0000
+++ scripts/ipmi_sel_entries 2014-03-31 08:50:05 +0000
@@ -0,0 +1,147 @@
1#!/usr/bin/env python3
2"""
3Copyright (C) 2010-2013 by Cloud Computing Center for Mobile Applications
4Industrial Technology Research Institute
5
6File Name
7 ipmi_sel_entries
8 1. Use ipmitool to collect event log information
9 2. Calculate entries number of system event log
10 3. Criteria: the A log must be capable of saving at least 256 entries
11
12Description
13 Use ipmitool to get system event log info and calculate whether
14 total number of entries is more than 256.
15
16Authors
17 Sophia Wu <Sophia.Wu@itri.org.tw>
18
19This program is free software: you can redistribute it and/or modify
20it under the terms of the GNU General Public License version 3,
21as published by the Free Software Foundation.
22
23This program is distributed in the hope that it will be useful,
24but WITHOUT ANY WARRANTY; without even the implied warranty of
25MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26GNU General Public License for more details.
27
28You should have received a copy of the GNU General Public License
29along with this program. If not, see <http://www.gnu.org/licenses/>.
30
31"""
32import sys
33import time
34import shlex
35import re
36import subprocess
37from subprocess import (
38 CalledProcessError,
39 check_call,
40 check_output
41)
42from argparse import (
43 ArgumentParser,
44 RawTextHelpFormatter
45)
46import configparser
47
48#Retrieve entries number that already used
49def get_entry_used(output):
50 entry_used = re.search(r'Entries\D*([0-9 ]+)', output)
51 return entry_used.group(1).strip()
52
53#Retrieve free entries that available
54def get_entry_free(output):
55 entry_free = re.search(r'# Free Units\D*([0-9 ]+)', output)
56 return entry_free.group(1).strip()
57
58#Use ipmitool to retrieve sel information
59def get_sel_info(host_ip, user, password):
60 cmd = 'ipmitool -H {} -U {} -P {} sel'.format(host_ip, user, password)
61 ipmi_sel_return = check_output(shlex.split(cmd), universal_newlines=True)
62 return ipmi_sel_return
63
64def sel_entry_test(args):
65
66 #Default config file to config requirement info for DCMI in-band/out-of-band access
67 DEFAULT_CFG = "/etc/checkbox.d/me.cfg"
68 if not "config" in vars(args):
69 config_file = DEFAULT_CFG
70 else:
71 config_file = args.config
72
73 config = configparser.RawConfigParser()
74
75 try:
76 config.readfp(open(config_file))
77 except IOError:
78 print("No config file found")
79 return 10
80
81 # Acquire ME IP/Credential parameters from config file
82 try:
83 targets_options = config.options('Targets')
84 targets_list = []
85 for target_key in targets_options:
86 targets_list.append(config.get('Targets', target_key))
87 if not targets_list:
88 print("Invalid or Empty targets")
89 return 20
90 except configparser.Error:
91 print("Invalid or Empty targets")
92 return 30
93
94 try:
95 user_value = config.get('Account', 'USER')
96 passwd_value = config.get('Account', 'PASSWORD')
97 except configparser.Error:
98 print("Invalid or Empty credential info")
99 return 40
100
101 for target in targets_list:
102
103 if not target or not user_value or not passwd_value:
104 print("Require Taget IP, Account(USER/PASSWORD) for DCMI out-of-band access")
105 return 50
106 else:
107 print("SUT =", target)
108
109 try:
110 sel_return = get_sel_info(target, user_value, passwd_value)
111 time.sleep(5)
112 except CalledProcessError as command_exception:
113 print("Failed executing ipmi command, Reason: %s." %(command_exception))
114 return 60
115
116 try:
117 print("Used Entry:", int(get_entry_used(sel_return)))
118 print("Free Entry:", int(get_entry_free(sel_return)))
119 except:
120 print("Error to parse SEL info")
121 return 70
122
123 try:
124 entry_space = int(get_entry_used(sel_return))+int(get_entry_free(sel_return))
125 except ArithmeticError:
126 print("Arithmetic Error")
127 return 80
128
129 if entry_space < 256:
130 print("Entries Number:", int(entry_space), "Entries Number is less than 256")
131 return 90
132 else:
133 print("Entries Number of SUT is more than 256.")
134 return 0
135
136def main():
137
138 intro_message = "Default config location is /etc/checkbox.d/me.cfg"
139 parser = ArgumentParser(description=intro_message,
140 formatter_class=RawTextHelpFormatter)
141 parser.add_argument('--config', default="/etc/checkbox.d/me.cfg",
142 help="Supply config file for getting default credential")
143 args = parser.parse_args()
144 return sel_entry_test(args)
145
146if __name__ == "__main__":
147 sys.exit(main())

Subscribers

People subscribed via source and target branches