Revision fe96220b lib/cmdlib.py

b/lib/cmdlib.py
2620 2620
  """
2621 2621
  port = cfg.AllocatePort()
2622 2622
  vgname = cfg.GetVGName()
2623
  dev_data = objects.Disk(dev_type="lvm", size=size,
2623
  dev_data = objects.Disk(dev_type=constants.LD_LV, size=size,
2624 2624
                          logical_id=(vgname, names[0]))
2625
  dev_meta = objects.Disk(dev_type="lvm", size=128,
2625
  dev_meta = objects.Disk(dev_type=constants.LD_LV, size=128,
2626 2626
                          logical_id=(vgname, names[1]))
2627
  drbd_dev = objects.Disk(dev_type="drbd", size=size,
2627
  drbd_dev = objects.Disk(dev_type=constants.LD_DRBD7, size=size,
2628 2628
                          logical_id = (primary, secondary, port),
2629 2629
                          children = [dev_data, dev_meta])
2630 2630
  return drbd_dev
......
2646 2646
      raise errors.ProgrammerError("Wrong template configuration")
2647 2647

  
2648 2648
    names = _GenerateUniqueNames(cfg, [".sda", ".sdb"])
2649
    sda_dev = objects.Disk(dev_type="lvm", size=disk_sz,
2649
    sda_dev = objects.Disk(dev_type=constants.LD_LV, size=disk_sz,
2650 2650
                           logical_id=(vgname, names[0]),
2651 2651
                           iv_name = "sda")
2652
    sdb_dev = objects.Disk(dev_type="lvm", size=swap_sz,
2652
    sdb_dev = objects.Disk(dev_type=constants.LD_LV, size=swap_sz,
2653 2653
                           logical_id=(vgname, names[1]),
2654 2654
                           iv_name = "sdb")
2655 2655
    disks = [sda_dev, sdb_dev]
......
2660 2660

  
2661 2661
    names = _GenerateUniqueNames(cfg, [".sda_m1", ".sda_m2",
2662 2662
                                       ".sdb_m1", ".sdb_m2"])
2663
    sda_dev_m1 = objects.Disk(dev_type="lvm", size=disk_sz,
2663
    sda_dev_m1 = objects.Disk(dev_type=constants.LD_LV, size=disk_sz,
2664 2664
                              logical_id=(vgname, names[0]))
2665
    sda_dev_m2 = objects.Disk(dev_type="lvm", size=disk_sz,
2665
    sda_dev_m2 = objects.Disk(dev_type=constants.LD_LV, size=disk_sz,
2666 2666
                              logical_id=(vgname, names[1]))
2667
    md_sda_dev = objects.Disk(dev_type="md_raid1", iv_name = "sda",
2667
    md_sda_dev = objects.Disk(dev_type=constants.LD_MD_R1, iv_name = "sda",
2668 2668
                              size=disk_sz,
2669 2669
                              children = [sda_dev_m1, sda_dev_m2])
2670
    sdb_dev_m1 = objects.Disk(dev_type="lvm", size=swap_sz,
2670
    sdb_dev_m1 = objects.Disk(dev_type=constants.LD_LV, size=swap_sz,
2671 2671
                              logical_id=(vgname, names[2]))
2672
    sdb_dev_m2 = objects.Disk(dev_type="lvm", size=swap_sz,
2672
    sdb_dev_m2 = objects.Disk(dev_type=constants.LD_LV, size=swap_sz,
2673 2673
                              logical_id=(vgname, names[3]))
2674
    md_sdb_dev = objects.Disk(dev_type="md_raid1", iv_name = "sdb",
2674
    md_sdb_dev = objects.Disk(dev_type=constants.LD_MD_R1, iv_name = "sdb",
2675 2675
                              size=swap_sz,
2676 2676
                              children = [sdb_dev_m1, sdb_dev_m2])
2677 2677
    disks = [md_sda_dev, md_sdb_dev]
......
2683 2683
                                       ".sdb_data", ".sdb_meta"])
2684 2684
    drbd_sda_dev = _GenerateMDDRBDBranch(cfg, primary_node, remote_node,
2685 2685
                                         disk_sz, names[0:2])
2686
    md_sda_dev = objects.Disk(dev_type="md_raid1", iv_name="sda",
2686
    md_sda_dev = objects.Disk(dev_type=constants.LD_MD_R1, iv_name="sda",
2687 2687
                              children = [drbd_sda_dev], size=disk_sz)
2688 2688
    drbd_sdb_dev = _GenerateMDDRBDBranch(cfg, primary_node, remote_node,
2689 2689
                                         swap_sz, names[2:4])
2690
    md_sdb_dev = objects.Disk(dev_type="md_raid1", iv_name="sdb",
2690
    md_sdb_dev = objects.Disk(dev_type=constants.LD_MD_R1, iv_name="sdb",
2691 2691
                              children = [drbd_sdb_dev], size=swap_sz)
2692 2692
    disks = [md_sda_dev, md_sdb_dev]
2693 2693
  else:
......
3256 3256
      raise errors.OpPrereqError("Can't find this device ('%s') in the"
3257 3257
                                 " instance." % self.op.disk_name)
3258 3258
    for child in disk.children:
3259
      if child.dev_type == "drbd" and child.logical_id[2] == self.op.disk_id:
3259
      if (child.dev_type == constants.LD_DRBD7 and
3260
          child.logical_id[2] == self.op.disk_id):
3260 3261
        break
3261 3262
    else:
3262 3263
      raise errors.OpPrereqError("Can't find the device with this port.")
......
3479 3480
    """
3480 3481
    self.cfg.SetDiskID(dev, instance.primary_node)
3481 3482
    dev_pstatus = rpc.call_blockdev_find(instance.primary_node, dev)
3482
    if dev.dev_type == "drbd":
3483
    if dev.dev_type == constants.LD_DRBD7:
3483 3484
      # we change the snode then (otherwise we use the one passed in)
3484 3485
      if dev.logical_id[0] == instance.primary_node:
3485 3486
        snode = dev.logical_id[1]
......
3741 3742
            logger.Error("could not snapshot block device %s on node %s" %
3742 3743
                         (disk.logical_id[1], src_node))
3743 3744
          else:
3744
            new_dev = objects.Disk(dev_type="lvm", size=disk.size,
3745
            new_dev = objects.Disk(dev_type=constants.LD_LV, size=disk.size,
3745 3746
                                      logical_id=(vgname, new_dev_name),
3746 3747
                                      physical_id=(vgname, new_dev_name),
3747 3748
                                      iv_name=disk.iv_name)

Also available in: Unified diff