Revision cc9e1230 lib/cmdlib.py

b/lib/cmdlib.py
647 647

  
648 648
  def _VerifyNode(self, nodeinfo, file_list, local_cksum,
649 649
                  node_result, feedback_fn, master_files,
650
                  drbd_map):
650
                  drbd_map, vg_name):
651 651
    """Run multiple tests against a node.
652 652

  
653 653
    Test list:
......
667 667
    @param drbd_map: the useddrbd minors for this node, in
668 668
        form of minor: (instance, must_exist) which correspond to instances
669 669
        and their running status
670
    @param vg_name: Ganeti Volume Group (result of self.cfg.GetVGName())
670 671

  
671 672
    """
672 673
    node = nodeinfo.name
......
700 701
                  (constants.RELEASE_VERSION, node, remote_version[1]))
701 702

  
702 703
    # checks vg existence and size > 20G
703

  
704
    vglist = node_result.get(constants.NV_VGLIST, None)
705
    if not vglist:
706
      feedback_fn("  - ERROR: unable to check volume groups on node %s." %
707
                      (node,))
708
      bad = True
709
    else:
710
      vgstatus = utils.CheckVolumeGroupSize(vglist, self.cfg.GetVGName(),
711
                                            constants.MIN_VG_SIZE)
712
      if vgstatus:
713
        feedback_fn("  - ERROR: %s on node %s" % (vgstatus, node))
704
    if vg_name is not None:
705
      vglist = node_result.get(constants.NV_VGLIST, None)
706
      if not vglist:
707
        feedback_fn("  - ERROR: unable to check volume groups on node %s." %
708
                        (node,))
714 709
        bad = True
710
      else:
711
        vgstatus = utils.CheckVolumeGroupSize(vglist, vg_name,
712
                                              constants.MIN_VG_SIZE)
713
        if vgstatus:
714
          feedback_fn("  - ERROR: %s on node %s" % (vgstatus, node))
715
          bad = True
715 716

  
716 717
    # checks config file checksum
717 718

  
......
773 774
                      (hv_name, hv_result))
774 775

  
775 776
    # check used drbd list
776
    used_minors = node_result.get(constants.NV_DRBDLIST, [])
777
    if not isinstance(used_minors, (tuple, list)):
778
      feedback_fn("  - ERROR: cannot parse drbd status file: %s" %
779
                  str(used_minors))
780
    else:
781
      for minor, (iname, must_exist) in drbd_map.items():
782
        if minor not in used_minors and must_exist:
783
          feedback_fn("  - ERROR: drbd minor %d of instance %s is not active" %
784
                      (minor, iname))
785
          bad = True
786
      for minor in used_minors:
787
        if minor not in drbd_map:
788
          feedback_fn("  - ERROR: unallocated drbd minor %d is in use" % minor)
789
          bad = True
777
    if vg_name is not None:
778
      used_minors = node_result.get(constants.NV_DRBDLIST, [])
779
      if not isinstance(used_minors, (tuple, list)):
780
        feedback_fn("  - ERROR: cannot parse drbd status file: %s" %
781
                    str(used_minors))
782
      else:
783
        for minor, (iname, must_exist) in drbd_map.items():
784
          if minor not in used_minors and must_exist:
785
            feedback_fn("  - ERROR: drbd minor %d of instance %s is not active" %
786
                        (minor, iname))
787
            bad = True
788
        for minor in used_minors:
789
          if minor not in drbd_map:
790
            feedback_fn("  - ERROR: unallocated drbd minor %d is in use" % minor)
791
            bad = True
790 792

  
791 793
    return bad
792 794

  
......
962 964
      constants.NV_NODENETTEST: [(node.name, node.primary_ip,
963 965
                                  node.secondary_ip) for node in nodeinfo
964 966
                                 if not node.offline],
965
      constants.NV_LVLIST: vg_name,
966 967
      constants.NV_INSTANCELIST: hypervisors,
967
      constants.NV_VGLIST: None,
968 968
      constants.NV_VERSION: None,
969 969
      constants.NV_HVINFO: self.cfg.GetHypervisorType(),
970
      constants.NV_DRBDLIST: None,
971 970
      }
971
    if vg_name is not None:
972
      node_verify_param[constants.NV_VGLIST] = None
973
      node_verify_param[constants.NV_LVLIST] = vg_name
974
      node_verify_param[constants.NV_DRBDLIST] = None
972 975
    all_nvinfo = self.rpc.call_node_verify(nodelist, node_verify_param,
973 976
                                           self.cfg.GetClusterName())
974 977

  
......
1007 1010
        node_drbd[minor] = (instance.name, instance.admin_up)
1008 1011
      result = self._VerifyNode(node_i, file_names, local_checksums,
1009 1012
                                nresult, feedback_fn, master_files,
1010
                                node_drbd)
1013
                                node_drbd, vg_name)
1011 1014
      bad = bad or result
1012 1015

  
1013 1016
      lvdata = nresult.get(constants.NV_LVLIST, "Missing LV data")
1014
      if isinstance(lvdata, basestring):
1017
      if vg_name is None:
1018
        node_volume[node] = {}
1019
      elif isinstance(lvdata, basestring):
1015 1020
        feedback_fn("  - ERROR: LVM problem on node %s: %s" %
1016 1021
                    (node, utils.SafeEncode(lvdata)))
1017 1022
        bad = True
......
1043 1048
      try:
1044 1049
        node_info[node] = {
1045 1050
          "mfree": int(nodeinfo['memory_free']),
1046
          "dfree": int(nresult[constants.NV_VGLIST][vg_name]),
1047 1051
          "pinst": [],
1048 1052
          "sinst": [],
1049 1053
          # dictionary holding all instances this node is secondary for,
......
1054 1058
          # secondary.
1055 1059
          "sinst-by-pnode": {},
1056 1060
        }
1061
        # FIXME: devise a free space model for file based instances as well
1062
        if vg_name is not None:
1063
          node_info[node]["dfree"] = int(nresult[constants.NV_VGLIST][vg_name])
1057 1064
      except ValueError:
1058 1065
        feedback_fn("  - ERROR: invalid value returned from node %s" % (node,))
1059 1066
        bad = True

Also available in: Unified diff