Revision adfa3b26

b/lib/cmdlib.py
1332 1332
  ECLUSTERCFG = (TCLUSTER, "ECLUSTERCFG")
1333 1333
  ECLUSTERCERT = (TCLUSTER, "ECLUSTERCERT")
1334 1334
  ECLUSTERFILECHECK = (TCLUSTER, "ECLUSTERFILECHECK")
1335
  ECLUSTERDANGLINGNODES = (TNODE, "ECLUSTERDANGLINGNODES")
1336
  ECLUSTERDANGLINGINST = (TNODE, "ECLUSTERDANGLINGINST")
1335 1337
  EINSTANCEBADNODE = (TINSTANCE, "EINSTANCEBADNODE")
1336 1338
  EINSTANCEDOWN = (TINSTANCE, "EINSTANCEDOWN")
1337 1339
  EINSTANCELAYOUT = (TINSTANCE, "EINSTANCELAYOUT")
......
1423 1425

  
1424 1426
  def ExpandNames(self):
1425 1427
    self.all_group_info = self.cfg.GetAllNodeGroupsInfo()
1428
    self.all_node_info = self.cfg.GetAllNodesInfo()
1426 1429
    self.all_inst_info = self.cfg.GetAllInstancesInfo()
1427 1430
    self.needed_locks = {}
1428 1431

  
......
1449 1452
    self._VerifyHVP(_GetAllHypervisorParameters(self.cfg.GetClusterInfo(),
1450 1453
                                                self.all_inst_info.values()))
1451 1454

  
1455
    feedback_fn("* Verifying all nodes belong to an existing group")
1456

  
1457
    # We do this verification here because, should this bogus circumstance
1458
    # occur, it would never be catched by VerifyGroup, which only acts on
1459
    # nodes/instances reachable from existing node groups.
1460

  
1461
    dangling_nodes = set(node.name for node in self.all_node_info.values()
1462
                         if node.group not in self.all_group_info)
1463

  
1464
    dangling_instances = {}
1465
    no_node_instances = []
1466

  
1467
    for inst in self.all_inst_info.values():
1468
      if inst.primary_node in dangling_nodes:
1469
        dangling_instances.setdefault(inst.primary_node, []).append(inst.name)
1470
      elif inst.primary_node not in self.all_node_info:
1471
        no_node_instances.append(inst.name)
1472

  
1473
    pretty_dangling = [
1474
        "%s (%s)" %
1475
        (node.name,
1476
         utils.CommaJoin(dangling_instances.get(node.name,
1477
                                                ["no instances"])))
1478
        for node in dangling_nodes]
1479

  
1480
    self._ErrorIf(bool(dangling_nodes), self.ECLUSTERDANGLINGNODES, None,
1481
                  "the following nodes (and their instances) belong to a non"
1482
                  " existing group: %s", utils.CommaJoin(pretty_dangling))
1483

  
1484
    self._ErrorIf(bool(no_node_instances), self.ECLUSTERDANGLINGINST, None,
1485
                  "the following instances have a non-existing primary-node:"
1486
                  " %s", utils.CommaJoin(no_node_instances))
1487

  
1452 1488
    return (not self.bad, [g.name for g in self.all_group_info.values()])
1453 1489

  
1454 1490

  

Also available in: Unified diff