Revision f27302fa

b/lib/cmdlib.py
3730 3730
    return self.target.GetTags()
3731 3731

  
3732 3732

  
3733
class LUAddTag(TagsLU):
3733
class LUAddTags(TagsLU):
3734 3734
  """Sets a tag on a given object.
3735 3735

  
3736 3736
  """
3737
  _OP_REQP = ["kind", "name", "tag"]
3737
  _OP_REQP = ["kind", "name", "tags"]
3738 3738

  
3739 3739
  def CheckPrereq(self):
3740 3740
    """Check prerequisites.
......
3743 3743

  
3744 3744
    """
3745 3745
    TagsLU.CheckPrereq(self)
3746
    objects.TaggableObject.ValidateTag(self.op.tag)
3746
    for tag in self.op.tags:
3747
      objects.TaggableObject.ValidateTag(tag)
3747 3748

  
3748 3749
  def Exec(self, feedback_fn):
3749 3750
    """Sets the tag.
3750 3751

  
3751 3752
    """
3752 3753
    try:
3753
      self.target.AddTag(self.op.tag)
3754
      for tag in self.op.tags:
3755
        self.target.AddTag(tag)
3754 3756
    except errors.TagError, err:
3755 3757
      raise errors.OpExecError("Error while setting tag: %s" % str(err))
3756 3758
    try:
......
3761 3763
                                " aborted. Please retry.")
3762 3764

  
3763 3765

  
3764
class LUDelTag(TagsLU):
3765
  """Delete a tag from a given object.
3766
class LUDelTags(TagsLU):
3767
  """Delete a list of tags from a given object.
3766 3768

  
3767 3769
  """
3768
  _OP_REQP = ["kind", "name", "tag"]
3770
  _OP_REQP = ["kind", "name", "tags"]
3769 3771

  
3770 3772
  def CheckPrereq(self):
3771 3773
    """Check prerequisites.
......
3774 3776

  
3775 3777
    """
3776 3778
    TagsLU.CheckPrereq(self)
3777
    objects.TaggableObject.ValidateTag(self.op.tag)
3778
    if self.op.tag not in self.target.GetTags():
3779
      raise errors.OpPrereqError("Tag not found")
3779
    for tag in self.op.tags:
3780
      objects.TaggableObject.ValidateTag(tag)
3781
    del_tags = frozenset(self.op.tags)
3782
    cur_tags = self.target.GetTags()
3783
    if not del_tags <= cur_tags:
3784
      diff_tags = del_tags - cur_tags
3785
      diff_names = ["'%s'" % tag for tag in diff_tags]
3786
      diff_names.sort()
3787
      raise errors.OpPrereqError("Tag(s) %s not found" %
3788
                                 (",".join(diff_names)))
3780 3789

  
3781 3790
  def Exec(self, feedback_fn):
3782 3791
    """Remove the tag from the object.
3783 3792

  
3784 3793
    """
3785
    self.target.RemoveTag(self.op.tag)
3794
    for tag in self.op.tags:
3795
      self.target.RemoveTag(tag)
3786 3796
    try:
3787 3797
      self.cfg.Update(self.target)
3788 3798
    except errors.ConfigurationError:
b/lib/mcpu.py
79 79
    opcodes.OpExportInstance: cmdlib.LUExportInstance,
80 80
    # tags lu
81 81
    opcodes.OpGetTags: cmdlib.LUGetTags,
82
    opcodes.OpSetTag: cmdlib.LUAddTag,
83
    opcodes.OpDelTag: cmdlib.LUDelTag,
82
    opcodes.OpAddTags: cmdlib.LUAddTags,
83
    opcodes.OpDelTags: cmdlib.LUDelTags,
84 84
    }
85 85

  
86 86

  
b/lib/opcodes.py
256 256
  __slots__ = ["kind", "name"]
257 257

  
258 258

  
259
class OpSetTag(OpCode):
260
  """Sets the value of a tag on a given object."""
259
class OpAddTags(OpCode):
260
  """Add a list of tags on a given object."""
261 261
  OP_ID = "OP_TAGS_SET"
262
  __slots__ = ["kind", "name", "tag"]
262
  __slots__ = ["kind", "name", "tags"]
263 263

  
264 264

  
265
class OpDelTag(OpCode):
266
  """Remove a tag from a given object."""
265
class OpDelTags(OpCode):
266
  """Remove a list of tags from a given object."""
267 267
  OP_ID = "OP_TAGS_DEL"
268
  __slots__ = ["kind", "name", "tag"]
268
  __slots__ = ["kind", "name", "tags"]

Also available in: Unified diff