Revision 58bc6241

b/lib/cmdlib.py
1121 1121
      raise errors.OpExecError(msg)
1122 1122

  
1123 1123

  
1124
def _CheckNodePVs(nresult, exclusive_storage):
1125
  """Check node PVs.
1126

  
1127
  """
1128
  pvlist_dict = nresult.get(constants.NV_PVLIST, None)
1129
  if pvlist_dict is None:
1130
    return (["Can't get PV list from node"], None)
1131
  pvlist = map(objects.LvmPvInfo.FromDict, pvlist_dict)
1132
  errlist = []
1133
  # check that ':' is not present in PV names, since it's a
1134
  # special character for lvcreate (denotes the range of PEs to
1135
  # use on the PV)
1136
  for pv in pvlist:
1137
    if ":" in pv.name:
1138
      errlist.append("Invalid character ':' in PV '%s' of VG '%s'" %
1139
                     (pv.name, pv.vg_name))
1140
  es_pvinfo = None
1141
  if exclusive_storage:
1142
    (errmsgs, es_pvinfo) = utils.LvmExclusiveCheckNodePvs(pvlist)
1143
    errlist.extend(errmsgs)
1144
  return (errlist, es_pvinfo)
1145

  
1146

  
1124 1147
def _GetClusterDomainSecret():
1125 1148
  """Reads the cluster domain secret.
1126 1149

  
......
2465 2488
                                            constants.MIN_VG_SIZE)
2466 2489
      _ErrorIf(vgstatus, constants.CV_ENODELVM, node, vgstatus)
2467 2490

  
2468
    # check pv names (and possibly sizes)
2469
    pvlist_dict = nresult.get(constants.NV_PVLIST, None)
2470
    test = pvlist_dict is None
2471
    _ErrorIf(test, constants.CV_ENODELVM, node, "Can't get PV list from node")
2472
    if not test:
2473
      pvlist = map(objects.LvmPvInfo.FromDict, pvlist_dict)
2474
      # check that ':' is not present in PV names, since it's a
2475
      # special character for lvcreate (denotes the range of PEs to
2476
      # use on the PV)
2477
      for pv in pvlist:
2478
        test = ":" in pv.name
2479
        _ErrorIf(test, constants.CV_ENODELVM, node,
2480
                 "Invalid character ':' in PV '%s' of VG '%s'",
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
2491
    # Check PVs
2492
    (errmsgs, pvminmax) = _CheckNodePVs(nresult, self._exclusive_storage)
2493
    for em in errmsgs:
2494
      self._Error(constants.CV_ENODELVM, node, em)
2495
    if pvminmax is not None:
2496
      (nimg.pv_min, nimg.pv_max) = pvminmax
2488 2497

  
2489 2498
  def _VerifyGroupLVM(self, node_image, vg_name):
2490 2499
    """Check cross-node consistency in LVM.
......
6117 6126
                                   secondary_ip=secondary_ip,
6118 6127
                                   master_candidate=self.master_candidate,
6119 6128
                                   offline=False, drained=False,
6120
                                   group=node_group)
6129
                                   group=node_group, ndparams={})
6121 6130

  
6122 6131
    if self.op.ndparams:
6123 6132
      utils.ForceDictType(self.op.ndparams, constants.NDS_PARAMETER_TYPES)
......
6130 6139

  
6131 6140
    # TODO: If we need to have multiple DnsOnlyRunner we probably should make
6132 6141
    #       it a property on the base class.
6133
    result = rpc.DnsOnlyRunner().call_version([node])[node]
6142
    rpcrunner = rpc.DnsOnlyRunner()
6143
    result = rpcrunner.call_version([node])[node]
6134 6144
    result.Raise("Can't get version information from node %s" % node)
6135 6145
    if constants.PROTOCOL_VERSION == result.payload:
6136 6146
      logging.info("Communication to node %s fine, sw version %s match",
......
6141 6151
                                 (constants.PROTOCOL_VERSION, result.payload),
6142 6152
                                 errors.ECODE_ENVIRON)
6143 6153

  
6154
    vg_name = cfg.GetVGName()
6155
    if vg_name is not None:
6156
      vparams = {constants.NV_PVLIST: [vg_name]}
6157
      excl_stor = _IsExclusiveStorageEnabledNode(cfg, self.new_node)
6158
      if self.op.ndparams:
6159
        excl_stor = self.op.ndparams.get(constants.ND_EXCLUSIVE_STORAGE,
6160
                                         excl_stor)
6161
      cname = self.cfg.GetClusterName()
6162
      result = rpcrunner.call_node_verify_light([node], vparams, cname)[node]
6163
      (errmsgs, _) = _CheckNodePVs(result.payload, excl_stor)
6164
      if errmsgs:
6165
        raise errors.OpPrereqError("Checks on node PVs failed: %s" %
6166
                                   "; ".join(errmsgs), errors.ECODE_ENVIRON)
6167

  
6144 6168
  def Exec(self, feedback_fn):
6145 6169
    """Adds the new node to the cluster.
6146 6170

  

Also available in: Unified diff