From c0769691bdebc1670f886454daf025620bc6fd9d Mon Sep 17 00:00:00 2001 From: Jacob McCann Date: Wed, 1 Jul 2015 15:08:18 +0000 Subject: [PATCH] Convert Int to String for shred execute Was running into 'expected string, int found' when calling shred with an Int for iterations. Change-Id: Iffce247caba5b0d62ac89b6411402c8d975cfd2f Closes-Bug: #1469838 --- ironic_python_agent/hardware.py | 2 +- ironic_python_agent/tests/hardware.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index ff1bfbeb0..bdec99424 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -457,7 +457,7 @@ class GenericHardwareManager(HardwareManager): npasses = info.get('agent_erase_devices_iterations', 1) try: utils.execute('shred', '--force', '--zero', '--verbose', - '--iterations', npasses, block_device.name) + '--iterations', str(npasses), block_device.name) except (processutils.ProcessExecutionError, OSError) as e: msg = ("Erasing block device %(dev)s failed with error %(err)s ", {'dev': block_device.name, 'err': e}) diff --git a/ironic_python_agent/tests/hardware.py b/ironic_python_agent/tests/hardware.py index 335d566b5..a7c1616c5 100644 --- a/ironic_python_agent/tests/hardware.py +++ b/ironic_python_agent/tests/hardware.py @@ -438,7 +438,7 @@ class TestGenericHardwareManager(test_base.BaseTestCase): mocked_execute.assert_has_calls([ mock.call('hdparm', '-I', '/dev/sda'), mock.call('shred', '--force', '--zero', '--verbose', - '--iterations', 2, '/dev/sda') + '--iterations', '2', '/dev/sda') ]) @mock.patch.object(utils, 'execute') @@ -461,7 +461,7 @@ class TestGenericHardwareManager(test_base.BaseTestCase): mocked_execute.assert_has_calls([ mock.call('hdparm', '-I', '/dev/sda'), mock.call('shred', '--force', '--zero', '--verbose', - '--iterations', 1, '/dev/sda') + '--iterations', '1', '/dev/sda') ]) @mock.patch.object(hardware.GenericHardwareManager, @@ -519,7 +519,7 @@ class TestGenericHardwareManager(test_base.BaseTestCase): res = self.hardware._shred_block_device(self.node, block_device) self.assertFalse(res) mocked_execute.assert_called_once_with('shred', '--force', '--zero', - '--verbose', '--iterations', 1, '/dev/sda') + '--verbose', '--iterations', '1', '/dev/sda') @mock.patch.object(utils, 'execute') def test_erase_block_device_shred_fail_processerror(self, mocked_execute): @@ -529,7 +529,7 @@ class TestGenericHardwareManager(test_base.BaseTestCase): res = self.hardware._shred_block_device(self.node, block_device) self.assertFalse(res) mocked_execute.assert_called_once_with('shred', '--force', '--zero', - '--verbose', '--iterations', 1, '/dev/sda') + '--verbose', '--iterations', '1', '/dev/sda') @mock.patch.object(utils, 'execute') def test_erase_block_device_ata_security_enabled(self, mocked_execute):