Revision c711d09e

b/lib/cmdlib.py
1389 1389
    }
1390 1390
    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
1391 1391

  
1392
  def CheckPrereq(self):
1393
    self.all_node_info = self.cfg.GetAllNodesInfo()
1394
    self.all_inst_info = self.cfg.GetAllInstancesInfo()
1395
    self.my_node_names = utils.NiceSort(list(self.all_node_info))
1396
    self.my_node_info = self.all_node_info
1397
    self.my_inst_names = utils.NiceSort(list(self.all_inst_info))
1398
    self.my_inst_info = self.all_inst_info
1399

  
1392 1400
  def _Error(self, ecode, item, msg, *args, **kwargs):
1393 1401
    """Format an error message.
1394 1402

  
......
2224 2232
    the output be logged in the verify output and the verification to fail.
2225 2233

  
2226 2234
    """
2227
    cfg = self.cfg
2228

  
2229 2235
    env = {
2230
      "CLUSTER_TAGS": " ".join(cfg.GetClusterInfo().GetTags())
2236
      "CLUSTER_TAGS": " ".join(self.cfg.GetClusterInfo().GetTags())
2231 2237
      }
2232 2238

  
2233 2239
    env.update(("NODE_TAGS_%s" % node.name, " ".join(node.GetTags()))
2234
               for node in cfg.GetAllNodesInfo().values())
2240
               for node in self.my_node_info.values())
2235 2241

  
2236 2242
    return env
2237 2243

  
......
2239 2245
    """Build hooks nodes.
2240 2246

  
2241 2247
    """
2242
    return ([], self.cfg.GetNodeList())
2248
    assert self.my_node_names, ("Node list not gathered,"
2249
      " has CheckPrereq been executed?")
2250
    return ([], self.my_node_names)
2243 2251

  
2244 2252
  def Exec(self, feedback_fn):
2245 2253
    """Verify integrity of cluster, performing various test on nodes.
......
2263 2271
    drbd_helper = self.cfg.GetDRBDHelper()
2264 2272
    hypervisors = self.cfg.GetClusterInfo().enabled_hypervisors
2265 2273
    cluster = self.cfg.GetClusterInfo()
2266
    nodeinfo_byname = self.cfg.GetAllNodesInfo()
2267
    nodelist = utils.NiceSort(nodeinfo_byname.keys())
2268
    nodeinfo = [nodeinfo_byname[nname] for nname in nodelist]
2269
    instanceinfo = self.cfg.GetAllInstancesInfo()
2270
    instancelist = utils.NiceSort(instanceinfo.keys())
2271 2274
    groupinfo = self.cfg.GetAllNodeGroupsInfo()
2275
    node_data_list = [self.my_node_info[name] for name in self.my_node_names]
2276

  
2272 2277
    i_non_redundant = [] # Non redundant instances
2273 2278
    i_non_a_balanced = [] # Non auto-balanced instances
2274 2279
    n_offline = 0 # Count of offline nodes
......
2295 2300
        full_params = cluster.GetHVDefaults(hv_name, os_name=os_name)
2296 2301
        hvp_data.append(("os %s" % os_name, hv_name, full_params))
2297 2302
    # TODO: collapse identical parameter values in a single one
2298
    for instance in instanceinfo.values():
2303
    for instance in self.my_inst_info.values():
2299 2304
      if not instance.hvparams:
2300 2305
        continue
2301 2306
      hvp_data.append(("instance %s" % instance.name, instance.hypervisor,
......
2303 2308
    # and verify them locally
2304 2309
    self._VerifyHVP(hvp_data)
2305 2310

  
2306
    feedback_fn("* Gathering data (%d nodes)" % len(nodelist))
2311
    feedback_fn("* Gathering data (%d nodes)" % len(self.my_node_names))
2307 2312
    node_verify_param = {
2308 2313
      constants.NV_FILELIST:
2309 2314
        utils.UniqueSequence(filename
2310 2315
                             for files in filemap
2311 2316
                             for filename in files),
2312
      constants.NV_NODELIST: [node.name for node in nodeinfo
2317
      constants.NV_NODELIST: [node.name for node in node_data_list
2313 2318
                              if not node.offline],
2314 2319
      constants.NV_HYPERVISOR: hypervisors,
2315 2320
      constants.NV_HVPARAMS: hvp_data,
2316
      constants.NV_NODENETTEST: [(node.name, node.primary_ip,
2317
                                  node.secondary_ip) for node in nodeinfo
2321
      constants.NV_NODENETTEST: [(node.name, node.primary_ip, node.secondary_ip)
2322
                                 for node in node_data_list
2318 2323
                                 if not node.offline],
2319 2324
      constants.NV_INSTANCELIST: hypervisors,
2320 2325
      constants.NV_VERSION: None,
......
2354 2359
    node_image = dict((node.name, self.NodeImage(offline=node.offline,
2355 2360
                                                 name=node.name,
2356 2361
                                                 vm_capable=node.vm_capable))
2357
                      for node in nodeinfo)
2362
                      for node in node_data_list)
2358 2363

  
2359 2364
    # Gather OOB paths
2360 2365
    oob_paths = []
2361
    for node in nodeinfo:
2366
    for node in node_data_list:
2362 2367
      path = _SupportsOob(self.cfg, node)
2363 2368
      if path and path not in oob_paths:
2364 2369
        oob_paths.append(path)
......
2366 2371
    if oob_paths:
2367 2372
      node_verify_param[constants.NV_OOB_PATHS] = oob_paths
2368 2373

  
2369
    for instance in instancelist:
2370
      inst_config = instanceinfo[instance]
2374
    for instance in self.my_inst_names:
2375
      inst_config = self.my_inst_info[instance]
2371 2376

  
2372 2377
      for nname in inst_config.all_nodes:
2373 2378
        if nname not in node_image:
......
2396 2401
    # time before and after executing the request, we can at least have a time
2397 2402
    # window.
2398 2403
    nvinfo_starttime = time.time()
2399
    all_nvinfo = self.rpc.call_node_verify(nodelist, node_verify_param,
2404
    all_nvinfo = self.rpc.call_node_verify(self.my_node_names,
2405
                                           node_verify_param,
2400 2406
                                           self.cfg.GetClusterName())
2401 2407
    nvinfo_endtime = time.time()
2402 2408

  
2403 2409
    all_drbd_map = self.cfg.ComputeDRBDMap()
2404 2410

  
2405
    feedback_fn("* Gathering disk information (%s nodes)" % len(nodelist))
2406
    instdisk = self._CollectDiskInfo(nodelist, node_image, instanceinfo)
2411
    feedback_fn("* Gathering disk information (%s nodes)" %
2412
                len(self.my_node_names))
2413
    instdisk = self._CollectDiskInfo(self.my_node_names, node_image,
2414
                                     self.my_inst_info)
2407 2415

  
2408 2416
    feedback_fn("* Verifying configuration file consistency")
2409
    self._VerifyFiles(_ErrorIf, nodeinfo, master_node, all_nvinfo, filemap)
2417
    self._VerifyFiles(_ErrorIf, self.my_node_info.values(), master_node,
2418
                      all_nvinfo, filemap)
2410 2419

  
2411 2420
    feedback_fn("* Verifying node status")
2412 2421

  
2413 2422
    refos_img = None
2414 2423

  
2415
    for node_i in nodeinfo:
2424
    for node_i in node_data_list:
2416 2425
      node = node_i.name
2417 2426
      nimg = node_image[node]
2418 2427

  
......
2449 2458

  
2450 2459
      if nimg.vm_capable:
2451 2460
        self._VerifyNodeLVM(node_i, nresult, vg_name)
2452
        self._VerifyNodeDrbd(node_i, nresult, instanceinfo, drbd_helper,
2461
        self._VerifyNodeDrbd(node_i, nresult, self.my_inst_info, drbd_helper,
2453 2462
                             all_drbd_map)
2454 2463

  
2455 2464
        self._UpdateNodeVolumes(node_i, nresult, nimg, vg_name)
......
2463 2472
        self._VerifyNodeBridges(node_i, nresult, bridges)
2464 2473

  
2465 2474
    feedback_fn("* Verifying instance status")
2466
    for instance in instancelist:
2475
    for instance in self.my_inst_names:
2467 2476
      if verbose:
2468 2477
        feedback_fn("* Verifying instance %s" % instance)
2469
      inst_config = instanceinfo[instance]
2478
      inst_config = self.my_inst_info[instance]
2470 2479
      self._VerifyInstance(instance, inst_config, node_image,
2471 2480
                           instdisk[instance])
2472 2481
      inst_nodes_offline = []
......
2501 2510
        instance_groups = {}
2502 2511

  
2503 2512
        for node in instance_nodes:
2504
          instance_groups.setdefault(nodeinfo_byname[node].group,
2513
          instance_groups.setdefault(self.my_node_info[node].group,
2505 2514
                                     []).append(node)
2506 2515

  
2507 2516
        pretty_list = [
......
2543 2552
    self._VerifyOrphanVolumes(node_vol_should, node_image, reserved)
2544 2553

  
2545 2554
    feedback_fn("* Verifying orphan instances")
2546
    self._VerifyOrphanInstances(instancelist, node_image)
2555
    self._VerifyOrphanInstances(self.my_inst_names, node_image)
2547 2556

  
2548 2557
    if constants.VERIFY_NPLUSONE_MEM not in self.op.skip_checks:
2549 2558
      feedback_fn("* Verifying N+1 Memory redundancy")
2550
      self._VerifyNPlusOneMemory(node_image, instanceinfo)
2559
      self._VerifyNPlusOneMemory(node_image, self.my_inst_info)
2551 2560

  
2552 2561
    feedback_fn("* Other Notes")
2553 2562
    if i_non_redundant:

Also available in: Unified diff