summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinn'ya Hoshino <shi-hoshino@yk.jp.nec.com>2015-09-18 23:51:42 +0900
committerShinn'ya Hoshino <shi-hoshino@yk.jp.nec.com>2016-01-14 09:36:07 +0900
commit03904c6fc322eec07f285e024cb811887173155b (patch)
treee6b402c5b8dc52a63293124bb82391d00aff151f
parent1443d4d94448b3f04ecb2d0fbd9ba189ba8dcb44 (diff)
downloadironic-03904c6fc322eec07f285e024cb811887173155b.tar.gz
Fix a bug error by passwords only includes numbers
When an IPMI password consists only of numbers, Ironic fails to create a password file. From the format point of view, these passwords are correct. These are that it is stored to the variable after being converted to an int type, cause errors in the subsequent processing to expect that it is a string type. Change-Id: I85ee2e904fdb0d538f69c7dbfab4c81bb080b8cf Closes-Bug: #1489234 (cherry picked from commit 93f99381acd727f539d3a78c0ae82b95860ba649)
-rw-r--r--ironic/drivers/modules/ipmitool.py2
-rw-r--r--ironic/tests/drivers/test_ipmitool.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py
index 2bf7f844e..0ad34fa89 100644
--- a/ironic/drivers/modules/ipmitool.py
+++ b/ironic/drivers/modules/ipmitool.py
@@ -254,7 +254,7 @@ def _parse_driver_info(node):
address = info.get('ipmi_address')
username = info.get('ipmi_username')
- password = info.get('ipmi_password')
+ password = six.text_type(info.get('ipmi_password', ''))
port = info.get('ipmi_terminal_port')
priv_level = info.get('ipmi_priv_level', 'ADMINISTRATOR')
bridging_type = info.get('ipmi_bridging', 'no')
diff --git a/ironic/tests/drivers/test_ipmitool.py b/ironic/tests/drivers/test_ipmitool.py
index 284ceb958..21e478a7c 100644
--- a/ironic/tests/drivers/test_ipmitool.py
+++ b/ironic/tests/drivers/test_ipmitool.py
@@ -578,6 +578,17 @@ class IPMIToolPrivateMethodTestCase(db_base.DbTestCase):
self.assertEqual(mock.call('single_bridge'),
mock_support.call_args)
+ def test__parse_driver_info_numeric_password(
+ self, mock_sleep):
+ # ipmi_password must not be converted to int / float
+ # even if it includes just numbers.
+ info = dict(INFO_DICT)
+ info['ipmi_password'] = 12345678
+ node = obj_utils.get_test_node(self.context, driver_info=info)
+ ret = ipmi._parse_driver_info(node)
+ self.assertEqual(six.u('12345678'), ret['password'])
+ self.assertIsInstance(ret['password'], six.text_type)
+
def test__parse_driver_info_ipmi_prot_version_1_5(self, mock_sleep):
info = dict(INFO_DICT)
info['ipmi_protocol_version'] = '1.5'