From ef6f7095ec6db0aee25816304da92c431773f6a7 Mon Sep 17 00:00:00 2001 From: Aparna Date: Mon, 6 Jun 2016 05:28:04 +0000 Subject: [PATCH] Passing 'process_input' to the running hpssacli process This commit adds support to pass 'process_input' param of processutils to the running hpssacli process while executing hpssacli commands. The hpssacli process waits for the input as 'y' or 'n' to proceed further which leads to 'OutofMemory Error' if not provided with the input. Closes-Bug: #1589373 Change-Id: Ie3b1a2a42552a347aa0ab548b37d467577440d8b --- proliantutils/hpssa/objects.py | 2 +- proliantutils/tests/hpssa/test_manager.py | 20 ++++++++++++-------- proliantutils/tests/hpssa/test_objects.py | 8 ++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/proliantutils/hpssa/objects.py b/proliantutils/hpssa/objects.py index c6f385bc..aff18e3e 100644 --- a/proliantutils/hpssa/objects.py +++ b/proliantutils/hpssa/objects.py @@ -392,7 +392,7 @@ class Controller(object): size_mb = logical_drive_info['size_gb'] * 1024 cmd_args.append("size=%s" % size_mb) - self.execute_cmd(*cmd_args) + self.execute_cmd(*cmd_args, process_input='y') def delete_all_logical_drives(self): """Deletes all logical drives on trh controller. diff --git a/proliantutils/tests/hpssa/test_manager.py b/proliantutils/tests/hpssa/test_manager.py index 2d374c34..1f2661ae 100644 --- a/proliantutils/tests/hpssa/test_manager.py +++ b/proliantutils/tests/hpssa/test_manager.py @@ -49,13 +49,15 @@ class ManagerTestCases(testtools.TestCase): "type=logicaldrive", "drives=%s" % ld2_drives, "raid=5", - "size=%d" % (100*1024)) + "size=%d" % (100*1024), + process_input='y') # Verify that we created the 50GB disk the last. controller_exec_cmd_mock.assert_called_with("create", "type=logicaldrive", "drives=%s" % ld1_drives, "raid=1", - "size=%d" % (50*1024)) + "size=%d" % (50*1024), + process_input='y') ld1_ret = [x for x in current_config['logical_disks'] if x['raid_level'] == '1'][0] @@ -128,13 +130,15 @@ class ManagerTestCases(testtools.TestCase): "type=logicaldrive", mock.ANY, "raid=5", - "size=%d" % (100*1024)) + "size=%d" % (100*1024), + process_input='y') # Verify that we created the 50GB disk the last. controller_exec_cmd_mock.assert_called_with("create", "type=logicaldrive", mock.ANY, "raid=1", - "size=%d" % (50*1024)) + "size=%d" % (50*1024), + process_input='y') ld1_ret = [x for x in current_config['logical_disks'] if x['raid_level'] == '1'][0] @@ -193,13 +197,13 @@ class ManagerTestCases(testtools.TestCase): sorted(ld2['physical_disks'])) controller_exec_cmd_mock.assert_any_call( 'create', 'type=logicaldrive', 'drives=5I:1:1,5I:1:2', - 'raid=1', 'size=51200') + 'raid=1', 'size=51200', process_input='y') controller_exec_cmd_mock.assert_any_call( 'array', 'A', 'create', 'type=logicaldrive', 'raid=1', 'size=?', dont_transform_to_hpssa_exception=True) controller_exec_cmd_mock.assert_any_call( 'array', 'A', 'create', 'type=logicaldrive', 'raid=1', - 'size=51200') + 'size=51200', process_input='y') @mock.patch.object(objects.Controller, 'execute_cmd') def test_create_configuration_max_as_size_gb( @@ -225,10 +229,10 @@ class ManagerTestCases(testtools.TestCase): sorted(ld2['physical_disks'])) controller_exec_cmd_mock.assert_any_call( 'create', 'type=logicaldrive', 'drives=5I:1:1,5I:1:2', - 'raid=1', 'size=51200') + 'raid=1', 'size=51200', process_input='y') controller_exec_cmd_mock.assert_any_call( 'create', 'type=logicaldrive', 'drives=5I:1:3,5I:1:4,6I:1:5', - 'raid=5') + 'raid=5', process_input='y') @mock.patch.object(manager, 'get_configuration') @mock.patch.object(objects.Controller, 'execute_cmd') diff --git a/proliantutils/tests/hpssa/test_objects.py b/proliantutils/tests/hpssa/test_objects.py index d872fc27..47d95515 100644 --- a/proliantutils/tests/hpssa/test_objects.py +++ b/proliantutils/tests/hpssa/test_objects.py @@ -230,7 +230,7 @@ class ControllerTest(testtools.TestCase): "type=logicaldrive", "drives=5I:1:1,5I:1:2,5I:1:3", "raid=1", - "size=51200") + "size=51200", process_input='y') @mock.patch.object(objects.Controller, 'execute_cmd') def test_create_logical_drive_max_size_gb(self, execute_mock, @@ -252,7 +252,7 @@ class ControllerTest(testtools.TestCase): execute_mock.assert_called_once_with("create", "type=logicaldrive", "drives=5I:1:1,5I:1:2,5I:1:3", - "raid=1") + "raid=1", process_input='y') @mock.patch.object(objects.Controller, 'execute_cmd') def test_create_logical_drive_with_raid_array(self, execute_mock, @@ -275,7 +275,7 @@ class ControllerTest(testtools.TestCase): "create", "type=logicaldrive", "raid=1", - "size=51200") + "size=51200", process_input='y') @mock.patch.object(objects.Controller, 'execute_cmd') def test_create_logical_drive_raid_level_mapping(self, execute_mock, @@ -302,7 +302,7 @@ class ControllerTest(testtools.TestCase): execute_mock.assert_called_once_with( "create", "type=logicaldrive", "drives=5I:1:1,5I:1:2,5I:1:3,5I:1:4,5I:1:5,6I:1:6", - "raid=50", "size=51200") + "raid=50", "size=51200", process_input='y') @mock.patch.object(objects.Controller, 'execute_cmd') def test_delete_all_logical_drives(self, execute_mock,