Disallow variants for OSes that don't support them
authorIustin Pop <iustin@google.com>
Wed, 27 Jul 2011 11:53:24 +0000 (13:53 +0200)
committerIustin Pop <iustin@google.com>
Wed, 27 Jul 2011 12:50:55 +0000 (14:50 +0200)
Otherwise we get no variant checks at all, but the variant is still
recorded.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/cmdlib.py

index 76187f4..6b8da0c 100644 (file)
@@ -1097,9 +1097,13 @@ def _CheckOSVariant(os_obj, name):
   @param name: OS name passed by the user, to check for validity
 
   """
+  variant = objects.OS.GetVariant(name)
   if not os_obj.supported_variants:
+    if variant:
+      raise errors.OpPrereqError("OS '%s' doesn't support variants ('%s'"
+                                 " passed)" % (os_obj.name, variant),
+                                 errors.ECODE_INVAL)
     return
-  variant = objects.OS.GetVariant(name)
   if not variant:
     raise errors.OpPrereqError("OS name must include a variant",
                                errors.ECODE_INVAL)