def _VerifyDiskModification(self, op, params, excl_stor, group_access_types):
    disk_type = params.get(
        constants.IDISK_TYPE,
        self.cfg.GetInstanceDiskTemplate(self.instance.uuid))

    if op == constants.DDM_ADD:
      params[constants.IDISK_TYPE] = disk_type

      if disk_type == constants.DT_DISKLESS:
        raise errors.OpPrereqError(
            "Must specify disk type on diskless instance", errors.ECODE_INVAL)

      if disk_type != constants.DT_EXT:
        utils.ForceDictType(params, constants.IDISK_PARAMS_TYPES)

      mode = params.setdefault(constants.IDISK_MODE, constants.DISK_RDWR)
      if mode not in constants.DISK_ACCESS_SET:
        raise errors.OpPrereqError("Invalid disk access mode '%s'" % mode,
                                   errors.ECODE_INVAL)

      size = params.get(constants.IDISK_SIZE, None)
      if size is None:
        raise errors.OpPrereqError("Required disk parameter '%s' missing" %
                                   constants.IDISK_SIZE, errors.ECODE_INVAL)
      size = int(size)

      params[constants.IDISK_SIZE] = size
      name = params.get(constants.IDISK_NAME, None)
      if name is not None and name.lower() == constants.VALUE_NONE:
        params[constants.IDISK_NAME] = None

    # This check is necessary both when adding and attaching disks
    if op in (constants.DDM_ADD, constants.DDM_ATTACH):
      CheckSpindlesExclusiveStorage(params, excl_stor, True)
      CheckDiskExtProvider(params, disk_type)

      # Make sure we do not add syncing disks to instances with inactive disks
      if not self.op.wait_for_sync and not self.instance.disks_active:
        raise errors.OpPrereqError("Can't %s a disk to an instance with"
                                   " deactivated disks and --no-wait-for-sync"
                                   " given" % op, errors.ECODE_INVAL)

      # Check disk access param (only for specific disks)
      if disk_type in constants.DTS_HAVE_ACCESS:
        access_type = params.get(constants.IDISK_ACCESS,
                                 group_access_types[disk_type])
        if not IsValidDiskAccessModeCombination(self.instance.hypervisor,
                                                disk_type, access_type):
          raise errors.OpPrereqError("Selected hypervisor (%s) cannot be"
                                     " used with %s disk access param" %
                                     (self.instance.hypervisor, access_type),
                                      errors.ECODE_STATE)

    if op == constants.DDM_ATTACH:
      if len(params) != 1 or ('uuid' not in params and
                              constants.IDISK_NAME not in params):
        raise errors.OpPrereqError("Only one argument is permitted in %s op,"
                                   " either %s or uuid" % (constants.DDM_ATTACH,
                                                           constants.IDISK_NAME,
                                                           ),
                                   errors.ECODE_INVAL)
      self._CheckAttachDisk(params)

    elif op == constants.DDM_MODIFY:
      if constants.IDISK_SIZE in params:
        raise errors.OpPrereqError("Disk size change not possible, use"
                                   " grow-disk", errors.ECODE_INVAL)

      disk_info = self.cfg.GetInstanceDisks(self.instance.uuid)

      # Disk modification supports changing only the disk name and mode.
      # Changing arbitrary parameters is allowed only for ext disk template",
      if not utils.AllDiskOfType(disk_info, [constants.DT_EXT]):
        utils.ForceDictType(params, constants.MODIFIABLE_IDISK_PARAMS_TYPES)
      else:
        # We have to check that the 'access' and 'disk_provider' parameters
        # cannot be modified
        for param in [constants.IDISK_ACCESS, constants.IDISK_PROVIDER]:
          if param in params:
            raise errors.OpPrereqError("Disk '%s' parameter change is"
                                       " not possible" % param,
                                       errors.ECODE_INVAL)

      name = params.get(constants.IDISK_NAME, None)
      if name is not None and name.lower() == constants.VALUE_NONE:
        params[constants.IDISK_NAME] = None
Verifies a disk modification.
dataset/ETHPy150Open ganeti/ganeti/lib/cmdlib/instance_set_params.py/LUInstanceSetParams._VerifyDiskModification