Revision a1f445d3

b/lib/bdev.py
2086 2086
  constants.LD_LV: LogicalVolume,
2087 2087
  constants.LD_MD_R1: MDRaid1,
2088 2088
  constants.LD_DRBD7: DRBDev,
2089
  constants.LD_DRBD8: DRBD8,
2089 2090
  }
2090 2091

  
2091 2092

  
b/lib/cmdlib.py
2460 2460
      raise errors.OpPrereqError("Instance '%s' not known" %
2461 2461
                                 self.op.instance_name)
2462 2462

  
2463
    if instance.disk_template != constants.DT_REMOTE_RAID1:
2463
    if instance.disk_template not in constants.DTS_NET_MIRROR:
2464 2464
      raise errors.OpPrereqError("Instance's disk layout is not"
2465
                                 " remote_raid1.")
2465
                                 " network mirrored, cannot failover.")
2466 2466

  
2467 2467
    secondary_nodes = instance.secondary_nodes
2468 2468
    if not secondary_nodes:
......
2636 2636
  return drbd_dev
2637 2637

  
2638 2638

  
2639
def _GenerateDRBD8Branch(cfg, primary, secondary, size, names, iv_name):
2640
  """Generate a drbd8 device complete with its children.
2641

  
2642
  """
2643
  port = cfg.AllocatePort()
2644
  vgname = cfg.GetVGName()
2645
  dev_data = objects.Disk(dev_type=constants.LD_LV, size=size,
2646
                          logical_id=(vgname, names[0]))
2647
  dev_meta = objects.Disk(dev_type=constants.LD_LV, size=128,
2648
                          logical_id=(vgname, names[1]))
2649
  drbd_dev = objects.Disk(dev_type=constants.LD_DRBD8, size=size,
2650
                          logical_id = (primary, secondary, port),
2651
                          children = [dev_data, dev_meta],
2652
                          iv_name=iv_name)
2653
  return drbd_dev
2654

  
2639 2655
def _GenerateDiskTemplate(cfg, template_name,
2640 2656
                          instance_name, primary_node,
2641 2657
                          secondary_nodes, disk_sz, swap_sz):
......
2696 2712
    md_sdb_dev = objects.Disk(dev_type=constants.LD_MD_R1, iv_name="sdb",
2697 2713
                              children = [drbd_sdb_dev], size=swap_sz)
2698 2714
    disks = [md_sda_dev, md_sdb_dev]
2715
  elif template_name == constants.DT_DRBD8:
2716
    if len(secondary_nodes) != 1:
2717
      raise errors.ProgrammerError("Wrong template configuration")
2718
    remote_node = secondary_nodes[0]
2719
    names = _GenerateUniqueNames(cfg, [".sda_data", ".sda_meta",
2720
                                       ".sdb_data", ".sdb_meta"])
2721
    drbd_sda_dev = _GenerateDRBD8Branch(cfg, primary_node, remote_node,
2722
                                         disk_sz, names[0:2], "sda")
2723
    drbd_sdb_dev = _GenerateDRBD8Branch(cfg, primary_node, remote_node,
2724
                                         swap_sz, names[2:4], "sdb")
2725
    disks = [drbd_sda_dev, drbd_sdb_dev]
2699 2726
  else:
2700 2727
    raise errors.ProgrammerError("Invalid disk template '%s'" % template_name)
2701 2728
  return disks
......
2872 2899
    if self.op.disk_template not in constants.DISK_TEMPLATES:
2873 2900
      raise errors.OpPrereqError("Invalid disk template name")
2874 2901

  
2875
    if self.op.disk_template == constants.DT_REMOTE_RAID1:
2902
    if self.op.disk_template in constants.DTS_NET_MIRROR:
2876 2903
      if getattr(self.op, "snode", None) is None:
2877
        raise errors.OpPrereqError("The 'remote_raid1' disk template needs"
2904
        raise errors.OpPrereqError("The networked disk templates need"
2878 2905
                                   " a mirror node")
2879 2906

  
2880 2907
      snode_name = self.cfg.ExpandNodeName(self.op.snode)
......
2897 2924
      constants.DT_LOCAL_RAID1: (self.op.disk_size + self.op.swap_size) * 2,
2898 2925
      # 256 MB are added for drbd metadata, 128MB for each drbd device
2899 2926
      constants.DT_REMOTE_RAID1: self.op.disk_size + self.op.swap_size + 256,
2927
      constants.DT_DRBD8: self.op.disk_size + self.op.swap_size + 256,
2900 2928
    }
2901 2929

  
2902 2930
    if self.op.disk_template not in req_size_dict:
......
3006 3034

  
3007 3035
    if self.op.wait_for_sync:
3008 3036
      disk_abort = not _WaitForSync(self.cfg, iobj)
3009
    elif iobj.disk_template == constants.DT_REMOTE_RAID1:
3037
    elif iobj.disk_template in constants.DTS_NET_MIRROR:
3010 3038
      # make sure the disks are not degraded (still sync-ing is ok)
3011 3039
      time.sleep(15)
3012 3040
      feedback_fn("* checking mirrors status")
......
3486 3514
    """
3487 3515
    self.cfg.SetDiskID(dev, instance.primary_node)
3488 3516
    dev_pstatus = rpc.call_blockdev_find(instance.primary_node, dev)
3489
    if dev.dev_type == constants.LD_DRBD7:
3517
    if dev.dev_type in constants.LDS_DRBD:
3490 3518
      # we change the snode then (otherwise we use the one passed in)
3491 3519
      if dev.logical_id[0] == instance.primary_node:
3492 3520
        snode = dev.logical_id[1]
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 == constants.LD_DRBD7:
201
    if disk.dev_type in constants.LDS_DRBD:
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
78 78
DT_PLAIN = "plain"
79 79
DT_LOCAL_RAID1 = "local_raid1"
80 80
DT_REMOTE_RAID1 = "remote_raid1"
81
DT_DRBD8 = "drbd"
82

  
83
# the set of network-mirrored disk templates
84
DTS_NET_MIRROR = frozenset([DT_REMOTE_RAID1, DT_DRBD8])
81 85

  
82 86
# logical disk types
83 87
LD_LV = "lvm"
84 88
LD_MD_R1 = "md_raid1"
85 89
LD_DRBD7 = "drbd"
90
LD_DRBD8 = "drbd8"
91

  
92
# the set of drbd-like disk types
93
LDS_DRBD = frozenset([LD_DRBD7, LD_DRBD8])
86 94

  
87 95
# instance creation modem
88 96
INSTANCE_CREATE = "create"
89 97
INSTANCE_IMPORT = "import"
90 98

  
91 99
DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
92
                            DT_LOCAL_RAID1, DT_REMOTE_RAID1])
100
                            DT_LOCAL_RAID1, DT_REMOTE_RAID1,
101
                            DT_DRBD8])
93 102

  
94 103
# import/export config options
95 104
INISECT_EXP = "export"
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 (constants.LD_DRBD7, constants.LD_LV)
317
    return self.dev_type in (constants.LD_DRBD7, constants.LD_DRBD8,
318
                             constants.LD_LV)
318 319

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

  
323 325
  def OpenOnSecondary(self):
324 326
    """Test if this device needs to be opened on a secondary node."""
......
335 337
    """
336 338
    if self.dev_type == constants.LD_LV or self.dev_type == constants.LD_MD_R1:
337 339
      result = [node]
338
    elif self.dev_type == constants.LD_DRBD7:
340
    elif self.dev_type in constants.LDS_DRBD:
339 341
      result = [self.logical_id[0], self.logical_id[1]]
340 342
      if node not in result:
341 343
        raise errors.ConfigurationError("DRBD device passed unknown node")
......
436 438
    """
437 439
    def _Helper(primary, sec_nodes, device):
438 440
      """Recursively computes secondary nodes given a top device."""
439
      if device.dev_type == constants.LD_DRBD7:
441
      if device.dev_type in constants.LDS_DRBD:
440 442
        nodea, nodeb, dummy = device.logical_id
441 443
        if nodea == primary:
442 444
          candidate = nodeb
......
488 490
      if dev.dev_type == constants.LD_LV:
489 491
        lvmap[node].append(dev.logical_id[1])
490 492

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

  
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 (constants.LD_MD_R1, constants.LD_DRBD7):
506
      if dtype in (constants.LD_MD_R1, constants.LD_DRBD7, constants.LD_DRBD8):
507 507
        if syncp is not None:
508 508
          sync_text = "*RECOVERING* %5.2f%%," % syncp
509 509
          if estt:
......
661 661
  make_option("-p", "--cpu", dest="vcpus", help="Number of virtual CPUs",
662 662
              default=1, type="int", metavar="<PROC>"),
663 663
  make_option("-t", "--disk-template", dest="disk_template",
664
              help="Custom disk setup (diskless, plain, local_raid1 or"
665
              " remote_raid1)", default=None, metavar="TEMPL"),
664
              help="Custom disk setup (diskless, plain, local_raid1,"
665
              " remote_raid1 or drbd)", default=None, metavar="TEMPL"),
666 666
  make_option("-i", "--ip", dest="ip",
667 667
              help="IP address ('none' [default], 'auto', or specify address)",
668 668
              default='none', type="string", metavar="<ADDRESS>"),

Also available in: Unified diff