Revision 938adc87 lib/cmdlib.py

b/lib/cmdlib.py
7302 7302
    # TODO: Implement support changing VG while recreating
7303 7303
    constants.IDISK_VG,
7304 7304
    constants.IDISK_METAVG,
7305
    constants.IDISK_PROVIDER,
7305 7306
    ]))
7306 7307

  
7307 7308
  def _RunAllocator(self):
......
9192 9193
    elif template_name == constants.DT_RBD:
9193 9194
      logical_id_fn = lambda idx, _, disk: ("rbd", names[idx])
9194 9195
    elif template_name == constants.DT_EXT:
9195
      logical_id_fn = lambda idx, _, disk: ("ext", names[idx])
9196
      def logical_id_fn(idx, _, disk):
9197
        provider = disk.get(constants.IDISK_PROVIDER, None)
9198
        if provider is None:
9199
          raise errors.ProgrammerError("Disk template is %s, but '%s' is"
9200
                                       " not found", constants.DT_EXT,
9201
                                       constants.IDISK_PROVIDER)
9202
        return (provider, names[idx])
9196 9203
    else:
9197 9204
      raise errors.ProgrammerError("Unknown disk template '%s'" % template_name)
9198 9205

  
9199 9206
    dev_type = _DISK_TEMPLATE_DEVICE_TYPE[template_name]
9200 9207

  
9201 9208
    for idx, disk in enumerate(disk_info):
9209
      params = {}
9210
      # Only for the Ext template add disk_info to params
9211
      if template_name == constants.DT_EXT:
9212
        params[constants.IDISK_PROVIDER] = disk[constants.IDISK_PROVIDER]
9213
        for key in disk:
9214
          if key not in constants.IDISK_PARAMS:
9215
            params[key] = disk[key]
9202 9216
      disk_index = idx + base_index
9203 9217
      size = disk[constants.IDISK_SIZE]
9204 9218
      feedback_fn("* disk %s, size %s" %
......
9207 9221
                                logical_id=logical_id_fn(idx, disk_index, disk),
9208 9222
                                iv_name="disk/%d" % disk_index,
9209 9223
                                mode=disk[constants.IDISK_MODE],
9210
                                params={}))
9224
                                params=params))
9211 9225

  
9212 9226
  return disks
9213 9227

  
......
9657 9671
  @param op: The instance opcode
9658 9672
  @param default_vg: The default_vg to assume
9659 9673

  
9660
  @return: The computer disks
9674
  @return: The computed disks
9661 9675

  
9662 9676
  """
9663 9677
  disks = []
......
9675 9689
      raise errors.OpPrereqError("Invalid disk size '%s'" % size,
9676 9690
                                 errors.ECODE_INVAL)
9677 9691

  
9692
    ext_provider = disk.get(constants.IDISK_PROVIDER, None)
9693
    if ext_provider and op.disk_template != constants.DT_EXT:
9694
      raise errors.OpPrereqError("The '%s' option is only valid for the %s"
9695
                                 " disk template, not %s" %
9696
                                 (constants.IDISK_PROVIDER, constants.DT_EXT,
9697
                                 op.disk_template), errors.ECODE_INVAL)
9698

  
9678 9699
    data_vg = disk.get(constants.IDISK_VG, default_vg)
9679 9700
    new_disk = {
9680 9701
      constants.IDISK_SIZE: size,
9681 9702
      constants.IDISK_MODE: mode,
9682 9703
      constants.IDISK_VG: data_vg,
9683 9704
      }
9705

  
9684 9706
    if constants.IDISK_METAVG in disk:
9685 9707
      new_disk[constants.IDISK_METAVG] = disk[constants.IDISK_METAVG]
9686 9708
    if constants.IDISK_ADOPT in disk:
9687 9709
      new_disk[constants.IDISK_ADOPT] = disk[constants.IDISK_ADOPT]
9710

  
9711
    # For extstorage, demand the `provider' option and add any
9712
    # additional parameters (ext-params) to the dict
9713
    if op.disk_template == constants.DT_EXT:
9714
      if ext_provider:
9715
        new_disk[constants.IDISK_PROVIDER] = ext_provider
9716
        for key in disk:
9717
          if key not in constants.IDISK_PARAMS:
9718
            new_disk[key] = disk[key]
9719
      else:
9720
        raise errors.OpPrereqError("Missing provider for template '%s'" %
9721
                                   constants.DT_EXT, errors.ECODE_INVAL)
9722

  
9688 9723
    disks.append(new_disk)
9689 9724

  
9690 9725
  return disks
......
9751 9786
    # check disks. parameter names and consistent adopt/no-adopt strategy
9752 9787
    has_adopt = has_no_adopt = False
9753 9788
    for disk in self.op.disks:
9754
      utils.ForceDictType(disk, constants.IDISK_PARAMS_TYPES)
9789
      if self.op.disk_template != constants.DT_EXT:
9790
        utils.ForceDictType(disk, constants.IDISK_PARAMS_TYPES)
9755 9791
      if constants.IDISK_ADOPT in disk:
9756 9792
        has_adopt = True
9757 9793
      else:
......
10544 10580

  
10545 10581
    _CheckNicsBridgesExist(self, self.nics, self.pnode.name)
10546 10582

  
10583
    #TODO: _CheckExtParams (remotely)
10584
    # Check parameters for extstorage
10585

  
10547 10586
    # memory check on primary node
10548 10587
    #TODO(dynmem): use MINMEM for checking
10549 10588
    if self.op.start:

Also available in: Unified diff