Revision fe96220b

b/lib/backend.py
1093 1093
        if child.size == disk.size:
1094 1094
          # return implies breaking the loop
1095 1095
          return SnapshotBlockDevice(child)
1096
  elif disk.dev_type == "lvm":
1096
  elif disk.dev_type == constants.LD_LV:
1097 1097
    r_dev = _RecursiveFindBD(disk)
1098 1098
    if r_dev is not None:
1099 1099
      # let's stay on the safe side and ask for the full size, for now
b/lib/bdev.py
28 28
from ganeti import utils
29 29
from ganeti import logger
30 30
from ganeti import errors
31
from ganeti import constants
31 32

  
32 33

  
33 34
class BlockDev(object):
......
1522 1523

  
1523 1524

  
1524 1525
DEV_MAP = {
1525
  "lvm": LogicalVolume,
1526
  "md_raid1": MDRaid1,
1527
  "drbd": DRBDev,
1526
  constants.LD_LV: LogicalVolume,
1527
  constants.LD_MD_R1: MDRaid1,
1528
  constants.LD_DRBD7: DRBDev,
1528 1529
  }
1529 1530

  
1530 1531

  
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)
b/lib/config.py
198 198

  
199 199
    if disk.logical_id is None and disk.physical_id is not None:
200 200
      return
201
    if disk.dev_type == "drbd":
201
    if disk.dev_type == constants.LD_DRBD7:
202 202
      pnode, snode, port = disk.logical_id
203 203
      if node_name not in (pnode, snode):
204 204
        raise errors.ConfigurationError("DRBD device not knowing node %s" %
b/lib/constants.py
79 79
DT_LOCAL_RAID1 = "local_raid1"
80 80
DT_REMOTE_RAID1 = "remote_raid1"
81 81

  
82
# logical disk types
83
LD_LV = "lvm"
84
LD_MD_R1 = "md_raid1"
85
LD_DRBD7 = "drbd"
86

  
82 87
# instance creation modem
83 88
INSTANCE_CREATE = "create"
84 89
INSTANCE_IMPORT = "import"
b/lib/objects.py
314 314

  
315 315
  def CreateOnSecondary(self):
316 316
    """Test if this device needs to be created on a secondary node."""
317
    return self.dev_type in ("drbd", "lvm")
317
    return self.dev_type in (constants.LD_DRBD7, constants.LD_LV)
318 318

  
319 319
  def AssembleOnSecondary(self):
320 320
    """Test if this device needs to be assembled on a secondary node."""
321
    return self.dev_type in ("drbd", "lvm")
321
    return self.dev_type in (constants.LD_DRBD7, constants.LD_LV)
322 322

  
323 323
  def OpenOnSecondary(self):
324 324
    """Test if this device needs to be opened on a secondary node."""
325
    return self.dev_type in ("lvm",)
325
    return self.dev_type in (constants.LD_LV,)
326 326

  
327 327
  def GetNodes(self, node):
328 328
    """This function returns the nodes this device lives on.
......
333 333
    devices needs to (or can) be assembled.
334 334

  
335 335
    """
336
    if self.dev_type == "lvm" or self.dev_type == "md_raid1":
336
    if self.dev_type == constants.LD_LV or self.dev_type == constants.LD_MD_R1:
337 337
      result = [node]
338
    elif self.dev_type == "drbd":
338
    elif self.dev_type == constants.LD_DRBD7:
339 339
      result = [self.logical_id[0], self.logical_id[1]]
340 340
      if node not in result:
341 341
        raise errors.ConfigurationError("DRBD device passed unknown node")
......
436 436
    """
437 437
    def _Helper(primary, sec_nodes, device):
438 438
      """Recursively computes secondary nodes given a top device."""
439
      if device.dev_type == 'drbd':
439
      if device.dev_type == constants.LD_DRBD7:
440 440
        nodea, nodeb, dummy = device.logical_id
441 441
        if nodea == primary:
442 442
          candidate = nodeb
......
485 485
      devs = self.disks
486 486

  
487 487
    for dev in devs:
488
      if dev.dev_type == "lvm":
488
      if dev.dev_type == constants.LD_LV:
489 489
        lvmap[node].append(dev.logical_id[1])
490 490

  
491
      elif dev.dev_type == "drbd":
491
      elif dev.dev_type == constants.LD_DRBD7:
492 492
        if dev.logical_id[0] not in lvmap:
493 493
          lvmap[dev.logical_id[0]] = []
494 494

  
b/scripts/gnt-instance
503 503
    else:
504 504
      (path, major, minor, syncp, estt, degr) = status
505 505
      buf.write("%s (%d:%d)" % (path, major, minor))
506
      if dtype in ("md_raid1", "drbd"):
506
      if dtype in (constants.LD_MD_R1, constants.LD_DRBD7):
507 507
        if syncp is not None:
508 508
          sync_text = "*RECOVERING* %5.2f%%," % syncp
509 509
          if estt:

Also available in: Unified diff