def _LookupDiskIndex(self, idx):
    """Looks up uuid or name of disk if necessary."""
    try:
      return int(idx)
    except __HOLE__:
      pass
    for i, d in enumerate(self.cfg.GetInstanceDisks(self.instance.uuid)):
      if d.name == idx or d.uuid == idx:
        return i
    raise errors.OpPrereqError("Lookup of disk %r failed" % idx)
dataset/ETHPy150Open ganeti/ganeti/lib/cmdlib/instance_set_params.py/LUInstanceSetParams._LookupDiskIndex