Nir Soffer has uploaded a new change for review. Change subject: iscsiadm: Add debug level option ......................................................................
iscsiadm: Add debug level option VDSM uses iscdiadm to perform iSCSI operations which are often complicated to debug. This patch uses iscsiadm --debug-level option to add debugging information to vdsm debug log messages. The debug level is disabled by default and can be enabled in a new iscsiadm section in vdsm.conf. Change-Id: Ibe2d7a3637ea4a0b36ac7aad0890f99dfaa5854e Bug-Url: https://bugzilla.redhat.com/1011075 Signed-off-by: Nir Soffer <nsof...@redhat.com> --- M lib/vdsm/config.py.in M tests/iscsiadmTests.py M vdsm/storage/iscsiadm.py 3 files changed, 31 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/20338/1 diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in index c0bdd53..904058d 100644 --- a/lib/vdsm/config.py.in +++ b/lib/vdsm/config.py.in @@ -288,6 +288,14 @@ ('guests_gateway_ip', '', None), ]), + + # Section: [iscsiadm] + ('iscsiadm', [ + + ('debug_level', '0', + 'Print iscsiadm debugging information (0 - 8).'), + + ]), ] diff --git a/tests/iscsiadmTests.py b/tests/iscsiadmTests.py index c623ecb..216fe5f 100644 --- a/tests/iscsiadmTests.py +++ b/tests/iscsiadmTests.py @@ -19,6 +19,7 @@ # Refer to the README and COPYING files for full details of the license # +import ConfigParser from testrunner import VdsmTestCase as TestCaseBase from vdsm import constants @@ -28,8 +29,16 @@ import fake +def config(debug_level): + c = ConfigParser.ConfigParser() + c.add_section('iscsiadm') + c.set('iscsiadm', 'debug_level', debug_level) + return c + + @MonkeyClass(misc, 'execCmd', fake.Callable()) @MonkeyClass(iscsiadm, '_iscsiadmLock', fake.Scope()) +@MonkeyClass(iscsiadm, 'config', config('0')) class TestRunCommand(TestCaseBase): def testTakeLock(self): @@ -62,6 +71,12 @@ self.assertEqual(misc.execCmd.args, (cmd,)) self.assertEqual(misc.execCmd.kw, {'sudo': True, 'printable': cmd}) + @MonkeyPatch(iscsiadm, 'config', config('8')) + def testWithDebugLevel(self): + iscsiadm._runCmd([]) + self.assertEqual(misc.execCmd.args, + ([constants.EXT_ISCSIADM, '-d', '8'],)) + @MonkeyClass(iscsiadm, '_runCmd', fake.Callable()) class TestCommands(TestCaseBase): diff --git a/vdsm/storage/iscsiadm.py b/vdsm/storage/iscsiadm.py index cd28db8..4f960d0 100644 --- a/vdsm/storage/iscsiadm.py +++ b/vdsm/storage/iscsiadm.py @@ -1,6 +1,7 @@ from threading import Lock import misc from vdsm import constants +from vdsm.config import config # iscsiadm exit statuses ISCSI_ERR_SESS_EXISTS = 15 @@ -76,7 +77,13 @@ # run as root and there is no such feature yet in supervdsm. When such # feature exists please change this. with _iscsiadmLock: - cmd = [constants.EXT_ISCSIADM] + args + cmd = [constants.EXT_ISCSIADM] + + debug_level = config.get('iscsiadm', 'debug_level') + if debug_level != '0': + cmd.extend(('-d', debug_level)) + + cmd.extend(args) printCmd = None if hideValue: -- To view, visit http://gerrit.ovirt.org/20338 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibe2d7a3637ea4a0b36ac7aad0890f99dfaa5854e Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <nsof...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches