Revision 6d2e83d5

b/lib/backend.py
432 432
    hyper = hypervisor.GetHypervisor(what[constants.NV_HVINFO])
433 433
    result[constants.NV_HVINFO] = hyper.GetNodeInfo()
434 434

  
435
  if constants.NV_DRBDLIST in what:
436
    try:
437
      used_minors = bdev.DRBD8.GetUsedDevs().keys()
438
    except errors.BlockDeviceErrors:
439
      logging.warning("Can't get used minors list", exc_info=True)
440
      used_minors = []
441
    result[constants.NV_DRBDLIST] = used_minors
442

  
435 443
  return result
436 444

  
437 445

  
b/lib/bdev.py
692 692
    return "/dev/drbd%d" % minor
693 693

  
694 694
  @classmethod
695
  def _GetUsedDevs(cls):
695
  def GetUsedDevs(cls):
696 696
    """Compute the list of used DRBD devices.
697 697

  
698 698
    """
......
1343 1343
    /proc).
1344 1344

  
1345 1345
    """
1346
    used_devs = self._GetUsedDevs()
1346
    used_devs = self.GetUsedDevs()
1347 1347
    if self._aminor in used_devs:
1348 1348
      minor = self._aminor
1349 1349
    else:
b/lib/cmdlib.py
613 613
    self.share_locks = dict(((i, 1) for i in locking.LEVELS))
614 614

  
615 615
  def _VerifyNode(self, nodeinfo, file_list, local_cksum,
616
                  node_result, feedback_fn, master_files):
616
                  node_result, feedback_fn, master_files,
617
                  drbd_map):
617 618
    """Run multiple tests against a node.
618 619

  
619 620
    Test list:
......
630 631
    @param node_result: the results from the node
631 632
    @param feedback_fn: function used to accumulate results
632 633
    @param master_files: list of files that only masters should have
634
    @param drbd_map: the useddrbd minors for this node, in
635
        form of minor: (instance, must_exist) which correspond to instances
636
        and their running status
633 637

  
634 638
    """
635 639
    node = nodeinfo.name
......
724 728
        if hv_result is not None:
725 729
          feedback_fn("  - ERROR: hypervisor %s verify failure: '%s'" %
726 730
                      (hv_name, hv_result))
731

  
732
    # check used drbd list
733
    used_minors = node_result.get(constants.NV_DRBDLIST, [])
734
    for minor, (iname, must_exist) in drbd_map.items():
735
      if minor not in used_minors and must_exist:
736
        feedback_fn("  - ERROR: drbd minor %d of instance %s is not active" %
737
                    (minor, iname))
738
        bad = True
739
    for minor in used_minors:
740
      if minor not in drbd_map:
741
        feedback_fn("  - ERROR: unallocated drbd minor %d is in use" % minor)
742
        bad = True
743

  
727 744
    return bad
728 745

  
729 746
  def _VerifyInstance(self, instance, instanceconfig, node_vol_is,
......
867 884
    nodelist = utils.NiceSort(self.cfg.GetNodeList())
868 885
    nodeinfo = [self.cfg.GetNodeInfo(nname) for nname in nodelist]
869 886
    instancelist = utils.NiceSort(self.cfg.GetInstanceList())
887
    instanceinfo = dict((iname, self.cfg.GetInstanceInfo(iname))
888
                        for iname in instancelist)
870 889
    i_non_redundant = [] # Non redundant instances
871 890
    i_non_a_balanced = [] # Non auto-balanced instances
872 891
    n_offline = [] # List of offline nodes
......
900 919
      constants.NV_VGLIST: None,
901 920
      constants.NV_VERSION: None,
902 921
      constants.NV_HVINFO: self.cfg.GetHypervisorType(),
922
      constants.NV_DRBDLIST: None,
903 923
      }
904 924
    all_nvinfo = self.rpc.call_node_verify(nodelist, node_verify_param,
905 925
                                           self.cfg.GetClusterName())
906 926

  
907 927
    cluster = self.cfg.GetClusterInfo()
908 928
    master_node = self.cfg.GetMasterNode()
929
    all_drbd_map = self.cfg.ComputeDRBDMap()
930

  
909 931
    for node_i in nodeinfo:
910 932
      node = node_i.name
911 933
      nresult = all_nvinfo[node].data
......
928 950
        bad = True
929 951
        continue
930 952

  
953
      node_drbd = {}
954
      for minor, instance in all_drbd_map[node].items():
955
        instance = instanceinfo[instance]
956
        node_drbd[minor] = (instance.name, instance.status == "up")
931 957
      result = self._VerifyNode(node_i, file_names, local_checksums,
932
                                nresult, feedback_fn, master_files)
958
                                nresult, feedback_fn, master_files,
959
                                node_drbd)
933 960
      bad = bad or result
934 961

  
935 962
      lvdata = nresult.get(constants.NV_LVLIST, "Missing LV data")
......
985 1012

  
986 1013
    for instance in instancelist:
987 1014
      feedback_fn("* Verifying instance %s" % instance)
988
      inst_config = self.cfg.GetInstanceInfo(instance)
1015
      inst_config = instanceinfo[instance]
989 1016
      result =  self._VerifyInstance(instance, inst_config, node_volume,
990 1017
                                     node_instance, feedback_fn, n_offline)
991 1018
      bad = bad or result
b/lib/config.py
389 389
    self._WriteConfig()
390 390
    return port
391 391

  
392
  def _ComputeDRBDMap(self, instance):
392
  def _UnlockedComputeDRBDMap(self):
393 393
    """Compute the used DRBD minor/nodes.
394 394

  
395 395
    @return: dictionary of node_name: dict of minor: instance_name;
......
422 422
    return my_dict
423 423

  
424 424
  @locking.ssynchronized(_config_lock)
425
  def ComputeDRBDMap(self):
426
    """Compute the used DRBD minor/nodes.
427

  
428
    This is just a wrapper over L{_UnlockedComputeDRBDMap}.
429

  
430
    @return: dictionary of node_name: dict of minor: instance_name;
431
        the returned dict will have all the nodes in it (even if with
432
        an empty list).
433

  
434
    """
435
    return self._UnlockedComputeDRBDMap()
436

  
437
  @locking.ssynchronized(_config_lock)
425 438
  def AllocateDRBDMinor(self, nodes, instance):
426 439
    """Allocate a drbd minor.
427 440

  
......
431 444
    order as the passed nodes.
432 445

  
433 446
    """
434
    d_map = self._ComputeDRBDMap(instance)
447
    d_map = self._UnlockedComputeDRBDMap()
435 448
    result = []
436 449
    for nname in nodes:
437 450
      ndata = d_map[nname]
b/lib/constants.py
351 351
NV_NODENETTEST = "node-net-test"
352 352
NV_VERSION = "version"
353 353
NV_VGLIST = "vglist"
354
NV_DRBDLIST = "drbd-list"
354 355

  
355 356
# Allocator framework constants
356 357
IALLOCATOR_DIR_IN = "in"

Also available in: Unified diff