Revision 3ecf6786 lib/bdev.py

b/lib/bdev.py
302 302
    vg_name, lv_name = unique_id
303 303
    pvs_info = cls.GetPVInfo(vg_name)
304 304
    if not pvs_info:
305
      raise errors.BlockDeviceError, ("Can't compute PV info for vg %s" %
306
                                      vg_name)
305
      raise errors.BlockDeviceError("Can't compute PV info for vg %s" %
306
                                    vg_name)
307 307
    pvs_info.sort()
308 308
    pvs_info.reverse()
309 309

  
......
313 313
    # The size constraint should have been checked from the master before
314 314
    # calling the create function.
315 315
    if free_size < size:
316
      raise errors.BlockDeviceError, ("Not enough free space: required %s,"
317
                                      " available %s" % (size, free_size))
316
      raise errors.BlockDeviceError("Not enough free space: required %s,"
317
                                    " available %s" % (size, free_size))
318 318
    result = utils.RunCmd(["lvcreate", "-L%dm" % size, "-n%s" % lv_name,
319 319
                           vg_name] + pvlist)
320 320
    if result.failed:
......
469 469

  
470 470
    pvs_info = self.GetPVInfo(self._vg_name)
471 471
    if not pvs_info:
472
      raise errors.BlockDeviceError, ("Can't compute PV info for vg %s" %
473
                                      self._vg_name)
472
      raise errors.BlockDeviceError("Can't compute PV info for vg %s" %
473
                                    self._vg_name)
474 474
    pvs_info.sort()
475 475
    pvs_info.reverse()
476 476
    free_size, pv_name = pvs_info[0]
477 477
    if free_size < size:
478
      raise errors.BlockDeviceError, ("Not enough free space: required %s,"
479
                                      " available %s" % (size, free_size))
478
      raise errors.BlockDeviceError("Not enough free space: required %s,"
479
                                    " available %s" % (size, free_size))
480 480

  
481 481
    result = utils.RunCmd(["lvcreate", "-L%dm" % size, "-s",
482 482
                           "-n%s" % snap_name, self.dev_path])
483 483
    if result.failed:
484
      raise errors.BlockDeviceError, ("command: %s error: %s" %
485
                                      (result.cmd, result.fail_reason))
484
      raise errors.BlockDeviceError("command: %s error: %s" %
485
                                    (result.cmd, result.fail_reason))
486 486

  
487 487
    return snap_name
488 488

  
......
503 503
    result = utils.RunCmd(["lvchange", "--addtag", text,
504 504
                           self.dev_path])
505 505
    if result.failed:
506
      raise errors.BlockDeviceError, ("Command: %s error: %s" %
507
                                      (result.cmd, result.fail_reason))
506
      raise errors.BlockDeviceError("Command: %s error: %s" %
507
                                    (result.cmd, result.fail_reason))
508 508

  
509 509

  
510 510
class MDRaid1(BlockDev):
......
659 659

  
660 660
    """
661 661
    if self.minor is None and not self.Attach():
662
      raise errors.BlockDeviceError, "Can't attach to device"
662
      raise errors.BlockDeviceError("Can't attach to device")
663 663
    if device.dev_path is None:
664
      raise errors.BlockDeviceError, "New child is not initialised"
664
      raise errors.BlockDeviceError("New child is not initialised")
665 665
    result = utils.RunCmd(["mdadm", "-a", self.dev_path, device.dev_path])
666 666
    if result.failed:
667
      raise errors.BlockDeviceError, ("Failed to add new device to array: %s" %
668
                                      result.output)
667
      raise errors.BlockDeviceError("Failed to add new device to array: %s" %
668
                                    result.output)
669 669
    new_len = len(self._children) + 1
670 670
    result = utils.RunCmd(["mdadm", "--grow", self.dev_path, "-n", new_len])
671 671
    if result.failed:
672
      raise errors.BlockDeviceError, ("Can't grow md array: %s" %
673
                                      result.output)
672
      raise errors.BlockDeviceError("Can't grow md array: %s" %
673
                                    result.output)
674 674
    self._children.append(device)
675 675

  
676 676

  
......
679 679

  
680 680
    """
681 681
    if self.minor is None and not self.Attach():
682
      raise errors.BlockDeviceError, "Can't attach to device"
682
      raise errors.BlockDeviceError("Can't attach to device")
683 683
    if len(self._children) == 1:
684
      raise errors.BlockDeviceError, ("Can't reduce member when only one"
685
                                      " child left")
684
      raise errors.BlockDeviceError("Can't reduce member when only one"
685
                                    " child left")
686 686
    for device in self._children:
687 687
      if device.dev_path == dev_path:
688 688
        break
689 689
    else:
690
      raise errors.BlockDeviceError, "Can't find child with this path"
690
      raise errors.BlockDeviceError("Can't find child with this path")
691 691
    new_len = len(self._children) - 1
692 692
    result = utils.RunCmd(["mdadm", "-f", self.dev_path, dev_path])
693 693
    if result.failed:
694
      raise errors.BlockDeviceError, ("Failed to mark device as failed: %s" %
695
                                      result.output)
694
      raise errors.BlockDeviceError("Failed to mark device as failed: %s" %
695
                                    result.output)
696 696

  
697 697
    # it seems here we need a short delay for MD to update its
698 698
    # superblocks
699 699
    time.sleep(0.5)
700 700
    result = utils.RunCmd(["mdadm", "-r", self.dev_path, dev_path])
701 701
    if result.failed:
702
      raise errors.BlockDeviceError, ("Failed to remove device from array:"
703
                                      " %s" % result.output)
702
      raise errors.BlockDeviceError("Failed to remove device from array:"
703
                                        " %s" % result.output)
704 704
    result = utils.RunCmd(["mdadm", "--grow", "--force", self.dev_path,
705 705
                           "-n", new_len])
706 706
    if result.failed:
707
      raise errors.BlockDeviceError, ("Can't shrink md array: %s" %
708
                                      result.output)
707
      raise errors.BlockDeviceError("Can't shrink md array: %s" %
708
                                    result.output)
709 709
    self._children.remove(device)
710 710

  
711 711

  
......
1218 1218

  
1219 1219
    minor = self._FindUnusedMinor()
1220 1220
    if minor is None:
1221
      raise errors.BlockDeviceError, "Not enough free minors for DRBD!"
1221
      raise errors.BlockDeviceError("Not enough free minors for DRBD!")
1222 1222
    need_localdev_teardown = False
1223 1223
    if self._children[0]:
1224 1224
      result = self._AssembleLocal(minor, self._children[0].dev_path,

Also available in: Unified diff