def ComputeDiskSize(disks):
  # Required free disk space as a function of disk and swap space
  def size_f(d):
    dev_type = d[constants.IDISK_TYPE]
    req_size_dict = {
      constants.DT_DISKLESS: 0,
      constants.DT_PLAIN: d[constants.IDISK_SIZE],
      # Extra space for drbd metadata is added to each disk
      constants.DT_DRBD8:
        d[constants.IDISK_SIZE] + constants.DRBD_META_SIZE,
      constants.DT_FILE: d[constants.IDISK_SIZE],
      constants.DT_SHARED_FILE: d[constants.IDISK_SIZE],
      constants.DT_GLUSTER: d[constants.IDISK_SIZE],
      constants.DT_BLOCK: 0,
      constants.DT_RBD: d[constants.IDISK_SIZE],
      constants.DT_EXT: d[constants.IDISK_SIZE],
    }
    if dev_type not in req_size_dict:
      raise errors.ProgrammerError("Disk template '%s' size requirement"
                                   " is unknown" % dev_type)
    return req_size_dict[dev_type]

  return sum(map(size_f, disks))
Compute disk size requirements according to disk template
dataset/ETHPy150Open ganeti/ganeti/lib/masterd/instance.py/ComputeDiskSize