Merge "IPMI driver (bug fixes)."
This commit is contained in:
commit
5e8395e7ec
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
import uuid
|
||||||
|
|
||||||
from driver import Driver
|
from driver import Driver
|
||||||
|
|
||||||
|
@ -29,10 +30,24 @@ class Ipmi(Driver):
|
||||||
Keyword arguments:
|
Keyword arguments:
|
||||||
probe_ids -- list containing the probes IDs
|
probe_ids -- list containing the probes IDs
|
||||||
(a wattmeter monitor sometimes several probes)
|
(a wattmeter monitor sometimes several probes)
|
||||||
kwargs -- keyword (device) defining the device to read (/dev/ttyUSB0)
|
kwargs -- keywords (cache_directory, interface, host, username,
|
||||||
|
password) defining the IPMI parameters
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Driver.__init__(self, probe_ids, kwargs)
|
Driver.__init__(self, probe_ids, kwargs)
|
||||||
|
self.cache_file = kwargs.get('cache_directory') + '/' +
|
||||||
|
str(uuid.uuid5(uuid.NAMESPACE_DNS, probe_ids[0]))
|
||||||
|
command = 'ipmitool '
|
||||||
|
command += '-I ' + kwargs.get('interface') + ' '
|
||||||
|
command += '-H ' + kwargs.get('host') + ' '
|
||||||
|
command += '-U ' + kwargs.get('username', 'root') + ' '
|
||||||
|
command += '-P ' + kwargs.get('password') + ' '
|
||||||
|
command += 'sdr dump ' + cache_file
|
||||||
|
output, error = subprocess.Popen(command,
|
||||||
|
shell=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT
|
||||||
|
).communicate()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Starts the driver thread."""
|
"""Starts the driver thread."""
|
||||||
|
@ -45,11 +60,11 @@ class Ipmi(Driver):
|
||||||
def get_watts(self):
|
def get_watts(self):
|
||||||
"""Returns the power consumption."""
|
"""Returns the power consumption."""
|
||||||
command = 'ipmitool '
|
command = 'ipmitool '
|
||||||
command += '-S ' + kwargs.get('cache_file') + ' '
|
command += '-S ' + self.cache_file + ' '
|
||||||
command += '-I ' + kwargs.get('interface') + ' '
|
command += '-I ' + self.kwargs.get('interface') + ' '
|
||||||
command += '-H ' + kwargs.get('host') + ' '
|
command += '-H ' + self.kwargs.get('host') + ' '
|
||||||
command += '-U ' + kwargs.get('username', 'root') + ' '
|
command += '-U ' + self.kwargs.get('username', 'root') + ' '
|
||||||
command += '-P ' + kwargs.get('password') + ' '
|
command += '-P ' + self.kwargs.get('password') + ' '
|
||||||
command += 'sensor reading "System Level" | cut -f2 -d"|"'
|
command += 'sensor reading "System Level" | cut -f2 -d"|"'
|
||||||
output, error = subprocess.Popen(command,
|
output, error = subprocess.Popen(command,
|
||||||
shell=True,
|
shell=True,
|
||||||
|
|
Loading…
Reference in New Issue