Merge charm-hw-health:add-ipmiseld into charm-hw-health:master

Proposed by James Hebden
Status: Merged
Approved by: Xav Paice
Approved revision: 591583e14b58e1bca230b59a7c29c9758402a4e1
Merge reported by: Xav Paice
Merged at revision: 591583e14b58e1bca230b59a7c29c9758402a4e1
Proposed branch: charm-hw-health:add-ipmiseld
Merge into: charm-hw-health:master
Diff against target: 112 lines (+43/-7)
5 files modified
src/README.md (+2/-0)
src/config.yaml (+4/-0)
src/lib/hwhealth/hwdiscovery.py (+14/-6)
src/lib/hwhealth/tools.py (+20/-0)
src/tests/unit/test_hwdiscovery.py (+3/-1)
Reviewer Review Type Date Requested Status
Xav Paice (community) Approve
Drew Freiberger (community) Approve
Paul Goins Needs Fixing
Review via email: mp+390723@code.launchpad.net

Description of the change

Adds ipmiseld by default. I used the Tools pattern, as that seems the way that this charm has been designed, however it's not strictly necessary as this does not include an NRPE check to ensure seld is running (yet) it just installs the package.

Closes bug 1856625.

To post a comment you must log in.
Revision history for this message
Paul Goins (vultaire) wrote :

Generally looks fine, but I think there's a mismatch in the install/remove actions for IpmiSEL.

review: Needs Fixing
charm-hw-health:add-ipmiseld updated
42382a6... by James Hebden

Fix copypasta in IpmiSEL tools class

Revision history for this message
Peter Sabaini (peter-sabaini) wrote :

The MR itself looks good to me, however I found the freeipmi-ipmiseld packages suffers from this bug:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=793186

We might want to work around this in the charm

charm-hw-health:add-ipmiseld updated
c5393ad... by Peter Sabaini

Add workaround LP#1912347

Package fails to create the cache dir on install, create dir ourselves

591583e... by Peter Sabaini

Fix unittest

Revision history for this message
Drew Freiberger (afreiberger) wrote :

Can someone explain the namespace/stack operation for toolset within/around the _get_tools_os() call?

review: Needs Information
Revision history for this message
Peter Sabaini (peter-sabaini) wrote :

Answered inline -- toolset is a set() which is already a ref var

Revision history for this message
Drew Freiberger (afreiberger) wrote :

Thanks Peter, I see it's passed by reference and is modifying the underlying object in the _get_tools_os() function. This LGTM. +1 Thanks!

review: Approve
Revision history for this message
Xav Paice (xavpaice) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/README.md b/src/README.md
2index d332504..e367400 100644
3--- a/src/README.md
4+++ b/src/README.md
5@@ -18,6 +18,8 @@ Hardware-independent tools:
6 * Linux software RAID (mdadm)
7 * IPMI as implemented by freeipmi (enable_ipmi config option is enabled by
8 default)
9+ * ipmiseld from the freeipmi suite (enable_ipmiseld is enabled by default)
10+ for logging system event log entries to syslog
11
12 In the backlog, hp-health logic still needs to be backported to support
13 Hewlett-Packard gen8 and older equipment (HP Controllers with hpacucli)
14diff --git a/src/config.yaml b/src/config.yaml
15index 2203c1a..30fd452 100644
16--- a/src/config.yaml
17+++ b/src/config.yaml
18@@ -22,6 +22,10 @@ options:
19 type: boolean
20 default: True
21 description: Enable the use of freeipmi tools to monitor hardware status.
22+ enable_ipmiseld:
23+ type: boolean
24+ default: True
25+ description: Enable the logging of IPMI system event log (SEL) data to syslog
26 ipmi_check_options:
27 type: string
28 default: ''
29diff --git a/src/lib/hwhealth/hwdiscovery.py b/src/lib/hwhealth/hwdiscovery.py
30index 1bb8dba..e334cf8 100644
31--- a/src/lib/hwhealth/hwdiscovery.py
32+++ b/src/lib/hwhealth/hwdiscovery.py
33@@ -44,6 +44,19 @@ def get_tools(manufacturer="auto"):
34 raise NotImplementedError
35
36
37+def _get_tools_os(toolset):
38+ """Handle freeipmi and mdadm packages, included with Ubuntu."""
39+
40+ if _supports_mdadm():
41+ toolset.add(tools.Mdadm)
42+
43+ if hookenv.config("enable_ipmi"):
44+ toolset.add(tools.Ipmi)
45+
46+ if hookenv.config("enable_ipmiseld"):
47+ toolset.add(tools.IpmiSEL)
48+
49+
50 def _get_tools():
51 """Return list of tool classes relevent for the current hardware."""
52 hwinfo = Hardware()
53@@ -69,12 +82,7 @@ def _get_tools():
54 continue
55 hookenv.log("Driver not supported: {}".format(driver), hookenv.DEBUG)
56
57- # SW RAID?
58- if _supports_mdadm():
59- toolset.add(tools.Mdadm)
60-
61- if hookenv.config("enable_ipmi"):
62- toolset.add(tools.Ipmi)
63+ _get_tools_os(toolset)
64
65 system_vendor = hwinfo.get_system.get("vendor")
66 tool = SUPPORTED_SYSTEMS.get(system_vendor)
67diff --git a/src/lib/hwhealth/tools.py b/src/lib/hwhealth/tools.py
68index 1ec3255..3da262a 100644
69--- a/src/lib/hwhealth/tools.py
70+++ b/src/lib/hwhealth/tools.py
71@@ -716,6 +716,26 @@ class Ipmi(Tool):
72 return dst
73
74
75+class IpmiSEL(Tool):
76+ """A class representing the ipmiseld utility.
77+
78+ This class represents the ipmiseld utility from the freeipmi package.
79+ ipmiseld is able to forward hardware system event log entries to the host
80+ Operating System's syslog for logging and potentially forwarding alongside
81+ regular system logs.
82+ """
83+
84+ def install(self):
85+ """Install the ipmiseld package."""
86+ # Create cachedir to work around LP#1912347
87+ cache_dir = Path("/var/cache/ipmiseld")
88+ cache_dir.mkdir(parents=True)
89+ fetch.apt_install(["freeipmi-ipmiseld"], fatal=True)
90+
91+ def remove(self):
92+ fetch.apt_purge(["freeipmi-ipmiseld"], fatal=True)
93+
94+
95 class Nvme(Tool):
96 """A class representing the nvme tool (userspace tooling to control NVMe).
97
98diff --git a/src/tests/unit/test_hwdiscovery.py b/src/tests/unit/test_hwdiscovery.py
99index c657ac0..6930898 100644
100--- a/src/tests/unit/test_hwdiscovery.py
101+++ b/src/tests/unit/test_hwdiscovery.py
102@@ -41,7 +41,9 @@ class TestGetTools(unittest.TestCase):
103 lambda: "localhost",
104 ),
105 mock.patch.object(
106- hwhealth.hwdiscovery.hookenv, "config", lambda x: x != "enable_ipmi"
107+ hwhealth.hwdiscovery.hookenv,
108+ "config",
109+ lambda x: x not in {"enable_ipmi", "enable_ipmiseld"},
110 ),
111 mock.patch.object(
112 hwhealth.hwdiscovery.hookenv,

Subscribers

No one subscribed via source and target branches