Merge "IPMI driver (bug fixes)."

This commit is contained in:
Jenkins 2013-02-04 22:35:09 +00:00 committed by Gerrit Code Review
commit 5e8395e7ec
1 changed files with 21 additions and 6 deletions

View File

@ -16,6 +16,7 @@
import subprocess
import time
import uuid
from driver import Driver
@ -29,10 +30,24 @@ class Ipmi(Driver):
Keyword arguments:
probe_ids -- list containing the probes IDs
(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)
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):
"""Starts the driver thread."""
@ -45,11 +60,11 @@ class Ipmi(Driver):
def get_watts(self):
"""Returns the power consumption."""
command = 'ipmitool '
command += '-S ' + kwargs.get('cache_file') + ' '
command += '-I ' + kwargs.get('interface') + ' '
command += '-H ' + kwargs.get('host') + ' '
command += '-U ' + kwargs.get('username', 'root') + ' '
command += '-P ' + kwargs.get('password') + ' '
command += '-S ' + self.cache_file + ' '
command += '-I ' + self.kwargs.get('interface') + ' '
command += '-H ' + self.kwargs.get('host') + ' '
command += '-U ' + self.kwargs.get('username', 'root') + ' '
command += '-P ' + self.kwargs.get('password') + ' '
command += 'sensor reading "System Level" | cut -f2 -d"|"'
output, error = subprocess.Popen(command,
shell=True,