Merge "Adding fix for nic_capacity calculation"
This commit is contained in:
commit
563044e408
@ -25,6 +25,10 @@ DRIVER.
|
|||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from proliantutils import log
|
||||||
|
|
||||||
|
LOG = log.get_logger(__name__)
|
||||||
|
|
||||||
MIN_SUGGESTED_FW_REV = 2.3
|
MIN_SUGGESTED_FW_REV = 2.3
|
||||||
DEFAULT_FW_REV = 2.1
|
DEFAULT_FW_REV = 2.1
|
||||||
|
|
||||||
@ -47,7 +51,12 @@ def _exec_ipmitool(driver_info, command):
|
|||||||
|
|
||||||
out = None
|
out = None
|
||||||
try:
|
try:
|
||||||
out = subprocess.check_output(ipmi_cmd, shell=True)
|
process = subprocess.Popen(ipmi_cmd, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE, shell=True)
|
||||||
|
out, err = process.communicate()
|
||||||
|
LOG.debug(("IPMI Command output: %(out)s and "
|
||||||
|
"IPMI Command error: %(err)s and returncode: (code)s"),
|
||||||
|
{'out': out, 'err': err, 'code': process.returncode})
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return out
|
return out
|
||||||
|
@ -16,6 +16,20 @@
|
|||||||
|
|
||||||
"""Test Utils for iLO test modules."""
|
"""Test Utils for iLO test modules."""
|
||||||
|
|
||||||
|
NIC_FRU_OUT_TUPLE = ((
|
||||||
|
"Board Mfg Date : Mon Apr 28 23:16:00 2014\n"
|
||||||
|
"Board Mfg : HP\n"
|
||||||
|
"Board Product : HP Ethernet 1Gb 4-port 331FLR Adapter\n"
|
||||||
|
"Board Serial : CN84170RX5\n"
|
||||||
|
"Board Part Number : 634025-001\n"
|
||||||
|
"Board Extra : d23041\n"
|
||||||
|
"Board Extra : d5629133b001\n"
|
||||||
|
"Product Manufacturer : HP\n"
|
||||||
|
"Product Name : HP Ethernet 1Gb 4-port 331FLR Adapter\n"
|
||||||
|
"Product Part Number : 629135-B21\n"
|
||||||
|
"Product Version : 00\n"
|
||||||
|
"Product Serial : CN84170RX5"), None)
|
||||||
|
|
||||||
NIC_FRU_OUT = (
|
NIC_FRU_OUT = (
|
||||||
"Board Mfg Date : Mon Apr 28 23:16:00 2014\n"
|
"Board Mfg Date : Mon Apr 28 23:16:00 2014\n"
|
||||||
"Board Mfg : HP\n"
|
"Board Mfg : HP\n"
|
||||||
|
@ -157,17 +157,19 @@ class IloIpmiTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(ipmi_mock.call_count, 9)
|
self.assertEqual(ipmi_mock.call_count, 9)
|
||||||
self.assertEqual(expected_out, actual_out)
|
self.assertEqual(expected_out, actual_out)
|
||||||
|
|
||||||
@mock.patch.object(subprocess, 'check_output')
|
@mock.patch.object(subprocess, 'Popen')
|
||||||
def test__exec_ipmitool(self, check_mock):
|
def test__exec_ipmitool(self, popen_mock):
|
||||||
check_mock.return_value = constants.NIC_FRU_OUT
|
pro_obj = mock.MagicMock()
|
||||||
|
popen_mock.return_value = pro_obj
|
||||||
|
pro_obj.communicate.return_value = constants.NIC_FRU_OUT_TUPLE
|
||||||
expected_output = constants.NIC_FRU_OUT
|
expected_output = constants.NIC_FRU_OUT
|
||||||
cmd = "fru print 0x64"
|
cmd = "fru print 0x64"
|
||||||
actual_out = ipmi._exec_ipmitool(self.info, cmd)
|
actual_out = ipmi._exec_ipmitool(self.info, cmd)
|
||||||
self.assertEqual(expected_output, actual_out)
|
self.assertEqual(expected_output, actual_out)
|
||||||
|
|
||||||
@mock.patch.object(subprocess, 'check_output')
|
@mock.patch.object(subprocess, 'Popen')
|
||||||
def test__exec_ipmitool_none(self, check_mock):
|
def test__exec_ipmitool_none(self, popen_mock):
|
||||||
check_mock.side_effect = Exception
|
popen_mock.side_effect = Exception
|
||||||
cmd = "fru print 0x2"
|
cmd = "fru print 0x2"
|
||||||
actual_out = ipmi._exec_ipmitool(self.info, cmd)
|
actual_out = ipmi._exec_ipmitool(self.info, cmd)
|
||||||
self.assertIsNone(actual_out)
|
self.assertIsNone(actual_out)
|
||||||
|
Loading…
Reference in New Issue
Block a user