Revision 36ccc662

b/lib/cmdlib/tags.py
127 127
      raise errors.OpPrereqError("Invalid search pattern '%s': %s" %
128 128
                                 (self.op.pattern, err), errors.ECODE_INVAL)
129 129

  
130
  @staticmethod
131
  def _ExtendTagTargets(targets, object_type_name, object_info_dict):
132
    return targets.extend(("/%s/%s" % (object_type_name, o.name), o)
133
                          for o in object_info_dict.values())
134

  
130 135
  def Exec(self, feedback_fn):
131 136
    """Returns the tag list.
132 137

  
133 138
    """
134 139
    cfg = self.cfg
135 140
    tgts = [("/cluster", cfg.GetClusterInfo())]
136
    ilist = cfg.GetAllInstancesInfo().values()
137
    tgts.extend([("/instances/%s" % i.name, i) for i in ilist])
138
    nlist = cfg.GetAllNodesInfo().values()
139
    tgts.extend([("/nodes/%s" % n.name, n) for n in nlist])
140
    tgts.extend(("/nodegroup/%s" % n.name, n)
141
                for n in cfg.GetAllNodeGroupsInfo().values())
141

  
142
    LUTagsSearch._ExtendTagTargets(tgts, "instances", cfg.GetAllInstancesInfo())
143
    LUTagsSearch._ExtendTagTargets(tgts, "nodes", cfg.GetAllNodesInfo())
144
    LUTagsSearch._ExtendTagTargets(tgts, "nodegroup",
145
                                   cfg.GetAllNodeGroupsInfo())
146
    LUTagsSearch._ExtendTagTargets(tgts, "network", cfg.GetAllNetworksInfo())
147

  
142 148
    results = []
143 149
    for path, target in tgts:
144 150
      for tag in target.GetTags():

Also available in: Unified diff