objects: Fix off-by-one in error message
authorMichael Hanselmann <hansmi@google.com>
Tue, 11 Jan 2011 15:29:51 +0000 (16:29 +0100)
committerMichael Hanselmann <hansmi@google.com>
Tue, 11 Jan 2011 15:39:38 +0000 (16:39 +0100)
For an instance with a single disk the message should be “… disks 0 to
0”, not “… 0 to 1”.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

lib/objects.py

index fdda582..274c756 100644 (file)
@@ -808,7 +808,7 @@ class Instance(TaggableObject):
                                  errors.ECODE_INVAL)
     except IndexError:
       raise errors.OpPrereqError("Invalid disk index: %d (instace has disks"
-                                 " 0 to %d" % (idx, len(self.disks)),
+                                 " 0 to %d" % (idx, len(self.disks) - 1),
                                  errors.ECODE_INVAL)
 
   def ToDict(self):