diff --git a/CHANGELOG.md b/CHANGELOG.md index 54dedf3..5902f32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,3 @@ -## cockpit-45drives-hardware 2.0.1-4 +## cockpit-45drives-hardware 2.0.1-5 -* updated unsupported motherboard message in 45Drives-motherboard module \ No newline at end of file +* added ipmi lan info section to 45Drives-system module \ No newline at end of file diff --git a/manifest.json b/manifest.json index 85bba2f..d851924 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "title": "cockpit-45drives-hardware", "prerelease": false, "version": "2.0.1", - "buildVersion": "4", + "buildVersion": "5", "author": "Mark Hooper ", "url": "https://github.com/45Drives/cockpit-hardware", "category": "utils", @@ -63,7 +63,7 @@ "changelog": { "urgency": "medium", "version": "2.0.1", - "buildVersion": "4", + "buildVersion": "5", "ignore": [], "date": null, "packager": "Mark Hooper ", diff --git a/packaging/el7/main.spec b/packaging/el7/main.spec index e74613a..6009d82 100644 --- a/packaging/el7/main.spec +++ b/packaging/el7/main.spec @@ -40,6 +40,8 @@ make DESTDIR=%{buildroot} install /usr/share/cockpit/45drives-system/* %changelog +* Mon Aug 23 2021 Mark Hooper 2.0.1-5 +- added ipmi lan info section to 45Drives-system module * Mon Aug 23 2021 Mark Hooper 2.0.1-4 - updated unsupported motherboard message in 45Drives-motherboard module * Mon Aug 23 2021 Mark Hooper 2.0.1-3 diff --git a/packaging/el8/main.spec b/packaging/el8/main.spec index e74613a..6009d82 100644 --- a/packaging/el8/main.spec +++ b/packaging/el8/main.spec @@ -40,6 +40,8 @@ make DESTDIR=%{buildroot} install /usr/share/cockpit/45drives-system/* %changelog +* Mon Aug 23 2021 Mark Hooper 2.0.1-5 +- added ipmi lan info section to 45Drives-system module * Mon Aug 23 2021 Mark Hooper 2.0.1-4 - updated unsupported motherboard message in 45Drives-motherboard module * Mon Aug 23 2021 Mark Hooper 2.0.1-3 diff --git a/packaging/focal/changelog b/packaging/focal/changelog index 2834d1a..6e8974c 100644 --- a/packaging/focal/changelog +++ b/packaging/focal/changelog @@ -1,3 +1,9 @@ +cockpit-45drives-hardware (2.0.1-5focal) focal; urgency=medium + + * added ipmi lan info section to 45Drives-system module + + -- Mark Hooper Mon, 23 Aug 2021 14:18:53 -0300 + cockpit-45drives-hardware (2.0.1-4focal) focal; urgency=medium * updated unsupported motherboard message in 45Drives-motherboard module diff --git a/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.html b/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.html index 1252b84..0925440 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.html +++ b/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.html @@ -123,6 +123,19 @@
+ +
+
+
+ IPMI LAN +
+
+ +
+
+
+
+
diff --git a/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.js b/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.js index 6ed0494..9373825 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.js +++ b/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.js @@ -4,6 +4,7 @@ let cpu_info = null; let pci_info = null; let ram_info = null; let network_info = null; +let ipmi_info = null; var product_img_lut = {}; product_img_lut[""] = "img/products/45dlogo.svg"; @@ -197,6 +198,39 @@ function pci(){ } } +function ipmi(){ + if(!ipmi_info){ + var ipmi_promise = cockpit.defer(); + // load the ipmi information + var ipmi_proc = cockpit.spawn( + [ + "/usr/share/cockpit/45drives-system/helper_scripts/ipmi" + ], + {err: "out",superuser: "require"} + ); + + ipmi_proc.stream( + function(data){ + try { + ipmi_info = JSON.parse(data); + } catch (error) { + ipmi_info = { + "IP Address": "-", + "Subnet Mask": "-", + "MAC Address": "-", + "Default Gateway IP": "-" + } + } + let ipmi_content = document.getElementById("ipmi_content"); + ipmi_content.innerHTML = ""; + let ipmi_table = buildIPMITable(); + ipmi_content.appendChild(ipmi_table); + ipmi_promise.resolve(); + } + ); + } +} + function ram(){ if(!ram_info){ var ram_promise = cockpit.defer(); @@ -385,6 +419,34 @@ function buildPCITable(){ return pciTable; } +function buildIPMITable(){ + let ipmiTable = document.createElement("table"); + ipmiTable.className = "info_box_table"; + let tr = ipmiTable.insertRow(0); + tr.className = "info_box_table_element"; + let headers = ["IP Address","Subnet Mask","MAC Address","Default Gateway IP"]; + for(let i = 0; i < headers.length; i++){ + th = document.createElement("th"); + th.className = "info_box_table_element"; + th.innerHTML = headers[i]; + tr.appendChild(th); + } + + tr = ipmiTable.insertRow(-1); + tr.className = "info_box_table_element"; + for(let j = 0; j < headers.length; j++){ + let cell = tr.insertCell(-1); + cell.className = "info_box_table_element"; + if(ipmi_info.hasOwnProperty(headers[j])){ + cell.innerHTML = ipmi_info[headers[j]]; + }else{ + cell.innerHTML = "-"; + } + } + + return ipmiTable; +} + function cpu_refresh(){ document.getElementById("cpu_content").innerHTML = "
" mobo_info = null; @@ -409,6 +471,12 @@ function network_refresh(){ network(); } +function ipmi_refresh(){ + document.getElementById("ipmi_content").innerHTML = "
" + ipmi_info = null; + ipmi(); +} + function get_server_info(){ var server_info_promise = cockpit.defer(); // get the server_info.json file @@ -494,10 +562,12 @@ function main() if(!pci_info){pci();} if(!ram_info){ram();} if(!network_info){network();} + if(!ipmi_info){ipmi();} document.getElementById("cpu_refresh").addEventListener("click",cpu_refresh); document.getElementById("pci_refresh").addEventListener("click",pci_refresh); document.getElementById("ram_refresh").addEventListener("click",ram_refresh); document.getElementById("network_refresh").addEventListener("click",network_refresh); + document.getElementById("ipmi_refresh").addEventListener("click",ipmi_refresh); }else{ //user is not an administrator, inform them of this by //displaying a message on each tab page. diff --git a/src/fakeroot/usr/share/cockpit/45drives-system/helper_scripts/ipmi b/src/fakeroot/usr/share/cockpit/45drives-system/helper_scripts/ipmi new file mode 100755 index 0000000..c2a3f2e --- /dev/null +++ b/src/fakeroot/usr/share/cockpit/45drives-system/helper_scripts/ipmi @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +################################################################################ +# ram: +# used to return information about the ram configuration in a .json +# format. This is a helper sctipt for use with the +# cockpit-hardware package (https://github.com/45Drives/cockpit-hardware) +# +# Copyright (C) 2020, Mark Hooper +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +################################################################################ +import subprocess +import re +import json + + +def ipmi_lan(): + try: + ipmi_lan_result = subprocess.Popen( + ["ipmitool","lan","print","1"],stdout=subprocess.PIPE,stderr=subprocess.PIPE,universal_newlines=True).stdout + except: + return None + + ipmi_lan_dict = { + "IP Address": "-", + "Subnet Mask": "-", + "MAC Address": "-", + "Default Gateway IP": "-" + } + + for line in ipmi_lan_result: + for field in ipmi_lan_dict.keys(): + regex = re.search("^({fld})\s+:\s+(\S+)".format(fld=field),line) + if regex != None: + ipmi_lan_dict[regex.group(1)] = regex.group(2) + return ipmi_lan_dict + +def main(): + ipmi_lan_dict = ipmi_lan() + print(json.dumps(ipmi_lan_dict,indent = 4)) + +if __name__ == "__main__": + main() \ No newline at end of file