From f8f590c8b78964587553a4bdef13bb1fa89f20a8 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 23 Jun 2010 19:51:37 +0200
Subject: [PATCH] Convert TestDelay repeat to the type system

Turns out with the current implementation of the type system a variable
can both be required and not required. Interesting (but perhaps worth a
further look).

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/cmdlib.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index d4a6c5531..51e3941e6 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -9668,15 +9668,13 @@ class LUTestDelay(NoHooksLU):
     ("duration", _TFloat),
     ("on_master", _TBool),
     ("on_nodes", _TListOf(_TNonEmptyString)),
+    ("repeat", _TPositiveInt)
+    ]
+  _OP_DEFS = [
+    ("repeat", 0),
     ]
   REQ_BGL = False
 
-  def CheckArguments(self):
-    # TODO: convert to the type system
-    self.op.repeat = getattr(self.op, "repeat", 0)
-    if self.op.repeat < 0:
-      raise errors.OpPrereqError("Repetition count cannot be negative")
-
   def ExpandNames(self):
     """Expand names and set required locks.
 
-- 
GitLab