From ee844e2001c61fc404e004b8f8f4e4968ea7f9ad Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 9 Feb 2010 14:01:59 +0100
Subject: [PATCH] Add a generic 'debug_level' attribute to opcodes

Also automatically fix opcodes which have this missing in the LU init
routine.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/cmdlib.py  | 4 ++++
 lib/opcodes.py | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 5cf76ad4a..7a466c9c0 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -95,6 +95,10 @@ class LogicalUnit(object):
     self.LogStep = processor.LogStep # pylint: disable-msg=C0103
     # support for dry-run
     self.dry_run_result = None
+    # support for generic debug attribute
+    if (not hasattr(self.op, "debug_level") or
+        not isinstance(self.op.debug_level, int)):
+      self.op.debug_level = 0
 
     # Tasklets
     self.tasklets = None
diff --git a/lib/opcodes.py b/lib/opcodes.py
index 2520101dc..b72204f23 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -120,7 +120,7 @@ class OpCode(BaseOpCode):
 
   """
   OP_ID = "OP_ABSTRACT"
-  __slots__ = ["dry_run"]
+  __slots__ = ["dry_run", "debug_level"]
 
   def __getstate__(self):
     """Specialized getstate for opcodes.
-- 
GitLab