Revision 15fd9fd5

b/lib/rapi/baserlib.py
78 78
  return dict(zip(names, data))
79 79

  
80 80

  
81
def _Tags_GET(kind, name=None):
81
def _Tags_GET(kind, name=""):
82 82
  """Helper function to retrieve tags.
83 83

  
84 84
  """
85
  if name is None:
86
    # Do not cause "missing parameter" error, which happens if a parameter
87
    # is None.
88
    name = ""
89 85
  op = ganeti.opcodes.OpGetTags(kind=kind, name=name)
90 86
  tags = ganeti.cli.SubmitOpCode(op)
91 87
  return list(tags)
92 88

  
93 89

  
94
def _Tags_POST(kind, tags, name=None):
90
def _Tags_POST(kind, tags, name=""):
95 91
  """Helper function to set tags.
96 92

  
97 93
  """
98
  if name is None:
99
    # Do not cause "missing parameter" error, which happens if a parameter
100
    # is None.
101
    name = ""
102 94
  cl = luxi.Client()
103 95
  return cl.SubmitJob([ganeti.opcodes.OpAddTags(kind=kind, name=name,
104 96
                                                tags=tags)])
105 97

  
106 98

  
99
def _Tags_DELETE(kind, tags, name=""):
100
  """Helper function to delete tags.
101

  
102
  """
103
  cl = luxi.Client()
104
  return cl.SubmitJob([ganeti.opcodes.OpDelTags(kind=kind, name=name,
105
                                                tags=tags)])
106

  
107

  
107 108
def MapBulkFields(itemslist, fields):
108 109
  """Map value to field name in to one dictionary.
109 110

  
b/lib/rapi/rlib2.py
24 24
"""
25 25

  
26 26
import ganeti.opcodes
27

  
27
from ganeti import http
28 28
from ganeti import luxi
29

  
29
from ganeti import constants
30 30
from ganeti.rapi import baserlib
31 31

  
32 32
from ganeti.rapi.rlib1 import I_FIELDS, N_FIELDS
......
223 223
    """
224 224
    return baserlib._Tags_POST(constants.TAG_INSTANCE,
225 225
                               self.post_data, name=self.items[0])
226

  
227
  def DELETE(self):
228
    """Delete a tag.
229

  
230
    In order to delete a set of tags from a instance, DELETE request should be
231
    addressed to URI like: /2/instances/[instance_name]/tags?tag=[tag]&tag=[tag]
232

  
233
    """
234
    if 'tag' not in self.queryargs:
235
      # no we not gonna delete all tags from an instance
236
      raise http.HTTPNotImplemented
237
    return baserlib._Tags_DELETE(constants.TAG_INSTANCE,
238
                                 self.queryargs['tag'],
239
                                 name=self.items[0])

Also available in: Unified diff