Skip to content

Instantly share code, notes, and snippets.

@jtcressy
Created May 19, 2018 12:26
Show Gist options
  • Save jtcressy/b6b23c8bf323cecde8fe32e4caea81e3 to your computer and use it in GitHub Desktop.
Save jtcressy/b6b23c8bf323cecde8fe32e4caea81e3 to your computer and use it in GitHub Desktop.
Dell PowerEdge LCD Updater (via ipmitool)
"""
Dell LCD Updater v0.1
Required Packages: python-ipmi
Also requires that ipmitool be installed on your system
Set the user-defined LCD text of most Dell PowerEdge servers generation 9 and above
Maximum string length is 14 characters
Requires that ipmi over lan be enabled in the DRAC of your server
Example usage:
from draclcdupdater import HostLCDConfig
myhost = HostLCDConfig("0.0.0.0", "myuser", "mypassword", "lcdtext")
LCD text is updated upon instantiation of HostLCDConfig
LCD text is automatically updated when myhost.lcdstring is updated
Example:
myhost = HostLCDConfig("0.0.0.0", "myuser", "mypassword", "lcdtext")
# actual LCD: lcdtext
myhost.lcdstring = "Hello, World!"
# actual LCD: Hello, World!
"""
import pyipmi
import pyipmi.interfaces
import itertools
class LCDString(object):
def __init__(self, initval: str=None):
self.value = str(initval)
def __get__(self, obj, objtype):
return self.value
def __set__(self, obj, value):
if len(value) > 14:
raise AttributeError("LCD String length cannot be more than 14 characters")
self.value = value
if isinstance(obj, HostLCDConfig):
obj._set_lcd_string()
class HostLCDConfig:
lcdstring = LCDString()
def __init__(self, host, user, password, lcdstring, port=623):
self.host = host
self.user = user
self.password = password
self.port = port
self.lcdstring = lcdstring
def _set_lcd_string(self):
interface = pyipmi.interfaces.create_interface('ipmitool', interface_type='lanplus')
connection = pyipmi.create_connection(interface)
connection.target = pyipmi.Target(0x0)
connection.session.set_session_type_rmcp(self.host, port=self.port)
connection.session.set_auth_type_user(self.user, self.password)
connection.session.establish()
retcode = connection.raw_command(
0,
0x06,
[chr(x) for x in itertools.chain([0x58, 193, 0, 1, len(self.lcdstring)], [ord(z) for z in self.lcdstring])]
)
retcode2 = connection.raw_command( # Only works on 9th generation dell servers and older.
0,
0x06,
[chr(x) for x in [0x58, 194, 0]]
)
# iDRAC6 and above require you use the front lcd buttons to choose "User String" as default display.
return retcode == b'\x00'
import time
from draclcdupdater import HostLCDConfig
myhost = HostLCDConfig("127.0.0.1", "root", "root", "myhost") # Replace with your real ip and login
# Front LCD: "myhost"
time.sleep(1)
myhost.lcdstring = "you can update"
time.sleep(0.4)
myhost.lcdstring = "the lcd text"
time.sleep(0.4)
myhost.lcdstring = "on the fly"
time.sleep(0.4)
myhost.lcdstring = "by setting"
time.sleep(0.4)
myhost.lcdstring = "the variable"
time.sleep(0.4)
myhost.lcdstring = "myhost"
# A wealth of data can be displayed on the LCD screen by changing the text fairly rapidly.
# Most elect for displaying load average, but you can combine it with memory and storage
# usage and simply rotate through each display in a loop with a delay interval.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment