Revision 6c626518

b/lib/backend.py
1016 1016
        # be assembled
1017 1017
        crdev.Open()
1018 1018
      clist.append(crdev)
1019
  try:
1020
    device = bdev.FindDevice(disk.dev_type, disk.physical_id, clist)
1021
    if device is not None:
1022
      logging.info("removing existing device %s", disk)
1023
      device.Remove()
1024
  except errors.BlockDeviceError, err:
1025
    pass
1026 1019

  
1027
  device = bdev.Create(disk.dev_type, disk.physical_id,
1028
                       clist, size)
1029
  if device is None:
1030
    raise ValueError("Can't create child device for %s, %s" %
1031
                     (disk, size))
1020
  device = bdev.Create(disk.dev_type, disk.physical_id, clist, size)
1021

  
1032 1022
  if on_primary or disk.AssembleOnSecondary():
1033 1023
    if not device.Assemble():
1034 1024
      errorstring = "Can't assemble device after creation"
b/lib/bdev.py
275 275

  
276 276
    """
277 277
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
278
      raise ValueError("Invalid configuration data %s" % str(unique_id))
278
      raise errors.ProgrammerError("Invalid configuration data %s" %
279
                                   str(unique_id))
279 280
    vg_name, lv_name = unique_id
280 281
    pvs_info = cls.GetPVInfo(vg_name)
281 282
    if not pvs_info:
......
295 296
    result = utils.RunCmd(["lvcreate", "-L%dm" % size, "-n%s" % lv_name,
296 297
                           vg_name] + pvlist)
297 298
    if result.failed:
298
      raise errors.BlockDeviceError("%s - %s" % (result.fail_reason,
299
                                                result.output))
299
      raise errors.BlockDeviceError("LV create failed (%s): %s" %
300
                                    (result.fail_reason, result.output))
300 301
    return LogicalVolume(unique_id, children)
301 302

  
302 303
  @staticmethod
......
1646 1647
    @return: an instance of FileStorage
1647 1648

  
1648 1649
    """
1650
    # TODO: decide whether we should check for existing files and
1651
    # abort or not
1649 1652
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
1650 1653
      raise ValueError("Invalid configuration data %s" % str(unique_id))
1651 1654
    dev_path = unique_id[1]
1652 1655
    try:
1653 1656
      f = open(dev_path, 'w')
1654
    except IOError, err:
1655
      raise errors.BlockDeviceError("Could not create '%'" % err)
1656
    else:
1657 1657
      f.truncate(size * 1024 * 1024)
1658 1658
      f.close()
1659
    except IOError, err:
1660
      raise errors.BlockDeviceError("Error in file creation: %" % str(err))
1659 1661

  
1660 1662
    return FileStorage(unique_id, children)
1661 1663

  

Also available in: Unified diff