Revision 1f14b07e

b/lib/cmdlib.py
9736 9736
                      " %s", disk, node, result.fail_msg)
9737 9737

  
9738 9738

  
9739
def _CreateDisks(lu, instance, to_skip=None, target_node=None):
9739
def _CreateDisks(lu, instance, to_skip=None, target_node=None, disks=None):
9740 9740
  """Create all disks for an instance.
9741 9741

  
9742 9742
  This abstracts away some work from AddInstance.
......
9749 9749
  @param to_skip: list of indices to skip
9750 9750
  @type target_node: string
9751 9751
  @param target_node: if passed, overrides the target node for creation
9752
  @type disks: list of {objects.Disk}
9753
  @param disks: the disks to create; if not specified, all the disks of the
9754
      instance are created
9752 9755
  @return: information about the created disks, to be used to call
9753 9756
      L{_UndoCreateDisks}
9754 9757
  @raise errors.OpPrereqError: in case of error
......
9762 9765
    pnode = target_node
9763 9766
    all_nodes = [pnode]
9764 9767

  
9768
  if disks is None:
9769
    disks = instance.disks
9770

  
9765 9771
  if instance.disk_template in constants.DTS_FILEBASED:
9766 9772
    file_storage_dir = os.path.dirname(instance.disks[0].logical_id[1])
9767 9773
    result = lu.rpc.call_file_storage_dir_create(pnode, file_storage_dir)
......
9770 9776
                 " node %s" % (file_storage_dir, pnode))
9771 9777

  
9772 9778
  disks_created = []
9773
  # Note: this needs to be kept in sync with adding of disks in
9774
  # LUInstanceSetParams
9775
  for idx, device in enumerate(instance.disks):
9779
  for idx, device in enumerate(disks):
9776 9780
    if to_skip and idx in to_skip:
9777 9781
      continue
9778 9782
    logging.info("Creating disk %s for instance '%s'", idx, instance.name)
9779
    #HARDCODE
9780 9783
    for node in all_nodes:
9781 9784
      f_create = node == pnode
9782 9785
      try:
......
14162 14165
                            [params], file_path, file_driver, idx,
14163 14166
                            self.Log, self.diskparams)[0]
14164 14167

  
14165
    info = _GetInstanceInfoText(instance)
14166

  
14167
    logging.info("Creating volume %s for instance %s",
14168
                 disk.iv_name, instance.name)
14169
    # Note: this needs to be kept in sync with _CreateDisks
14170
    #HARDCODE
14171
    for node in instance.all_nodes:
14172
      f_create = (node == instance.primary_node)
14173
      try:
14174
        _CreateBlockDev(self, node, instance, disk, f_create, info, f_create)
14175
      except errors.OpExecError, err:
14176
        self.LogWarning("Failed to create volume %s (%s) on node '%s': %s",
14177
                        disk.iv_name, disk, node, err)
14168
    new_disks = _CreateDisks(self, instance, disks=[disk])
14178 14169

  
14179 14170
    if self.cluster.prealloc_wipe_disks:
14180 14171
      # Wipe new disk
14181
      _WipeDisks(self, instance,
14182
                 disks=[(idx, disk, 0)])
14172
      _WipeOrCleanupDisks(self, instance,
14173
                          disks=[(idx, disk, 0)],
14174
                          cleanup=new_disks)
14183 14175

  
14184 14176
    return (disk, [
14185 14177
      ("disk/%d" % idx, "add:size=%s,mode=%s" % (disk.size, disk.mode)),

Also available in: Unified diff