From 9bc5ac44cd244690f5a16ddb01c747e25a07749a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com> Date: Fri, 28 Sep 2012 11:17:08 +0200 Subject: [PATCH] Provide a custom Validate for OpInstanceMultiAlloc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is needed, as we're not strictly separating validation from populating the defaults. We do this all in one function. If we now receive a non complete OpInstanceCreate opcode in instances, we would run into AttributeErrors on those. So we run the validation + recursively on all instances opcodes. Signed-off-by: RenΓ© Nussbaumer <rn@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/opcodes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/opcodes.py b/lib/opcodes.py index 4c427d533..5d14bcdb7 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -1256,6 +1256,17 @@ class OpInstanceMultiAlloc(OpCode): state["instances"] = insts return OpCode.__setstate__(self, state) + def Validate(self, set_defaults): + """Validates this opcode. + + We do this recursively. + + """ + OpCode.Validate(self, set_defaults) + + for inst in self.instances: + inst.Validate(set_defaults) + class OpInstanceReinstall(OpCode): """Reinstall an instance's OS.""" -- GitLab