Revision ea7693c1 qa/qa_utils.py

b/qa/qa_utils.py
653 653
  """Gets group names which shouldn't exist on the cluster.
654 654

  
655 655
  @param count: Number of groups to get
656
  @rtype: list
656
  @rtype: integer
657 657

  
658 658
  """
659
  groups = qa_config.get("groups", {})
659
  return GetNonexistentEntityNames(count, "groups", "group")
660 660

  
661
  default = ["group1", "group2", "group3"]
661

  
662
def GetNonexistentEntityNames(count, name_config, name_prefix):
663
  """Gets entity names which shouldn't exist on the cluster.
664

  
665
  The actualy names can refer to arbitrary entities (for example
666
  groups, networks).
667

  
668
  @param count: Number of names to get
669
  @rtype: integer
670
  @param name_config: name of the leaf in the config containing
671
    this entity's configuration, including a 'inexistent-'
672
    element
673
  @rtype: string
674
  @param name_prefix: prefix of the entity's names, used to compose
675
    the default values; for example for groups, the prefix is
676
    'group' and the generated names are then group1, group2, ...
677
  @rtype: string
678

  
679
  """
680
  entities = qa_config.get(name_config, {})
681

  
682
  default = [name_prefix + str(i) for i in range(count)]
662 683
  assert count <= len(default)
663 684

  
664
  candidates = groups.get("inexistent-groups", default)[:count]
685
  name_config_inexistent = "inexistent-" + name_config
686
  candidates = entities.get(name_config_inexistent, default)[:count]
665 687

  
666 688
  if len(candidates) < count:
667
    raise Exception("At least %s non-existent groups are needed" % count)
689
    raise Exception("At least %s non-existent %s are needed" %
690
                    (count, name_config))
668 691

  
669 692
  return candidates

Also available in: Unified diff