Skip to content

Commit

Permalink
added ipmi lan info section to 45Drives-system module
Browse files Browse the repository at this point in the history
  • Loading branch information
markdhooper committed Aug 23, 2021
1 parent b326c17 commit 60277f2
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
* added ipmi lan info section to 45Drives-system module
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "cockpit-45drives-hardware",
"prerelease": false,
"version": "2.0.1",
"buildVersion": "4",
"buildVersion": "5",
"author": "Mark Hooper <[email protected]>",
"url": "https://github.com/45Drives/cockpit-hardware",
"category": "utils",
Expand Down Expand Up @@ -63,7 +63,7 @@
"changelog": {
"urgency": "medium",
"version": "2.0.1",
"buildVersion": "4",
"buildVersion": "5",
"ignore": [],
"date": null,
"packager": "Mark Hooper <[email protected]>",
Expand Down
2 changes: 2 additions & 0 deletions packaging/el7/main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ make DESTDIR=%{buildroot} install
/usr/share/cockpit/45drives-system/*

%changelog
* Mon Aug 23 2021 Mark Hooper <[email protected]> 2.0.1-5
- added ipmi lan info section to 45Drives-system module
* Mon Aug 23 2021 Mark Hooper <[email protected]> 2.0.1-4
- updated unsupported motherboard message in 45Drives-motherboard module
* Mon Aug 23 2021 Mark Hooper <[email protected]> 2.0.1-3
Expand Down
2 changes: 2 additions & 0 deletions packaging/el8/main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ make DESTDIR=%{buildroot} install
/usr/share/cockpit/45drives-system/*

%changelog
* Mon Aug 23 2021 Mark Hooper <[email protected]> 2.0.1-5
- added ipmi lan info section to 45Drives-system module
* Mon Aug 23 2021 Mark Hooper <[email protected]> 2.0.1-4
- updated unsupported motherboard message in 45Drives-motherboard module
* Mon Aug 23 2021 Mark Hooper <[email protected]> 2.0.1-3
Expand Down
6 changes: 6 additions & 0 deletions packaging/focal/changelog
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@
<div class="info_box_content_col" id="network_content">
<div class="loader"></div></div>
</div>

<div class="info_box" id="ipmi_info_box">
<div class="info_box_content_row">
<div class="info_box_header">
IPMI LAN
</div>
<div class="info_box_refresh_icon">
<i class="fa fa-refresh fa-clickable" id="ipmi_refresh"></i>
</div>
</div>
<div class="info_box_content_col" id="ipmi_content">
<div class="loader"></div></div>
</div>

</div>
</div>
Expand Down
70 changes: 70 additions & 0 deletions src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 = "<div class=\"loader\"></div></div>"
mobo_info = null;
Expand All @@ -409,6 +471,12 @@ function network_refresh(){
network();
}

function ipmi_refresh(){
document.getElementById("ipmi_content").innerHTML = "<div class=\"loader\"></div></div>"
ipmi_info = null;
ipmi();
}

function get_server_info(){
var server_info_promise = cockpit.defer();
// get the server_info.json file
Expand Down Expand Up @@ -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.
Expand Down
46 changes: 46 additions & 0 deletions src/fakeroot/usr/share/cockpit/45drives-system/helper_scripts/ipmi
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
# 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()

0 comments on commit 60277f2

Please sign in to comment.