Revision 525939d9 lib/cmdlib.py

b/lib/cmdlib.py
2213 2213
    @ivar oslist: list of OSes as diagnosed by DiagnoseOS
2214 2214
    @type vm_capable: boolean
2215 2215
    @ivar vm_capable: whether the node can host instances
2216
    @type pv_min: float
2217
    @ivar pv_min: size in MiB of the smallest PVs
2218
    @type pv_max: float
2219
    @ivar pv_max: size in MiB of the biggest PVs
2216 2220

  
2217 2221
    """
2218 2222
    def __init__(self, offline=False, name=None, vm_capable=True):
......
2232 2236
      self.ghost = False
2233 2237
      self.os_fail = False
2234 2238
      self.oslist = {}
2239
      self.pv_min = None
2240
      self.pv_max = None
2235 2241

  
2236 2242
  def ExpandNames(self):
2237 2243
    # This raises errors.OpPrereqError on its own:
......
2433 2439
             "Node time diverges by at least %s from master node time",
2434 2440
             ntime_diff)
2435 2441

  
2436
  def _VerifyNodeLVM(self, ninfo, nresult, vg_name):
2437
    """Check the node LVM results.
2442
  def _UpdateVerifyNodeLVM(self, ninfo, nresult, vg_name, nimg):
2443
    """Check the node LVM results and update info for cross-node checks.
2438 2444

  
2439 2445
    @type ninfo: L{objects.Node}
2440 2446
    @param ninfo: the node to check
2441 2447
    @param nresult: the remote results for the node
2442 2448
    @param vg_name: the configured VG name
2449
    @type nimg: L{NodeImage}
2450
    @param nimg: node image
2443 2451

  
2444 2452
    """
2445 2453
    if vg_name is None:
......
2471 2479
        _ErrorIf(test, constants.CV_ENODELVM, node,
2472 2480
                 "Invalid character ':' in PV '%s' of VG '%s'",
2473 2481
                 pv.name, pv.vg_name)
2482
      if self._exclusive_storage:
2483
        (errmsgs, (pvmin, pvmax)) = utils.LvmExclusiveCheckNodePvs(pvlist)
2484
        for msg in errmsgs:
2485
          self._Error(constants.CV_ENODELVM, node, msg)
2486
        nimg.pv_min = pvmin
2487
        nimg.pv_max = pvmax
2488

  
2489
  def _VerifyGroupLVM(self, node_image, vg_name):
2490
    """Check cross-node consistency in LVM.
2491

  
2492
    @type node_image: dict
2493
    @param node_image: info about nodes, mapping from node to names to
2494
      L{NodeImage} objects
2495
    @param vg_name: the configured VG name
2496

  
2497
    """
2498
    if vg_name is None:
2499
      return
2500

  
2501
    # Only exlcusive storage needs this kind of checks
2502
    if not self._exclusive_storage:
2503
      return
2504

  
2505
    # exclusive_storage wants all PVs to have the same size (approximately),
2506
    # if the smallest and the biggest ones are okay, everything is fine.
2507
    # pv_min is None iff pv_max is None
2508
    vals = filter((lambda ni: ni.pv_min is not None), node_image.values())
2509
    if not vals:
2510
      return
2511
    (pvmin, minnode) = min((ni.pv_min, ni.name) for ni in vals)
2512
    (pvmax, maxnode) = max((ni.pv_max, ni.name) for ni in vals)
2513
    bad = utils.LvmExclusiveTestBadPvSizes(pvmin, pvmax)
2514
    self._ErrorIf(bad, constants.CV_EGROUPDIFFERENTPVSIZE, self.group_info.name,
2515
                  "PV sizes differ too much in the group; smallest (%s MB) is"
2516
                  " on %s, biggest (%s MB) is on %s",
2517
                  pvmin, minnode, pvmax, maxnode)
2474 2518

  
2475 2519
  def _VerifyNodeBridges(self, ninfo, nresult, bridges):
2476 2520
    """Check the node bridges.
......
3373 3417

  
3374 3418
    es_flags = rpc.GetExclusiveStorageForNodeNames(self.cfg, self.my_node_names)
3375 3419
    es_unset_nodes = []
3376
    # The value of exclusive_storage should be the same across the group
3377
    if compat.any(es_flags.values()):
3420
    # The value of exclusive_storage should be the same across the group, so if
3421
    # it's True for at least a node, we act as if it were set for all the nodes
3422
    self._exclusive_storage = compat.any(es_flags.values())
3423
    if self._exclusive_storage:
3378 3424
      es_unset_nodes = [n for (n, es) in es_flags.items()
3379 3425
                        if not es]
3380 3426

  
......
3489 3535
                                   node == master_node)
3490 3536

  
3491 3537
      if nimg.vm_capable:
3492
        self._VerifyNodeLVM(node_i, nresult, vg_name)
3538
        self._UpdateVerifyNodeLVM(node_i, nresult, vg_name, nimg)
3493 3539
        self._VerifyNodeDrbd(node_i, nresult, self.all_inst_info, drbd_helper,
3494 3540
                             all_drbd_map)
3495 3541

  
......
3516 3562
          _ErrorIf(not test, constants.CV_ENODEORPHANINSTANCE, node_i.name,
3517 3563
                   "node is running unknown instance %s", inst)
3518 3564

  
3565
    self._VerifyGroupLVM(node_image, vg_name)
3566

  
3519 3567
    for node, result in extra_lv_nvinfo.items():
3520 3568
      self._UpdateNodeVolumes(self.all_node_info[node], result.payload,
3521 3569
                              node_image[node], vg_name)

Also available in: Unified diff