Commit 15fd9fd5 authored by Oleksiy Mishchenko's avatar Oleksiy Mishchenko
Browse files

RAPI Implement DELETE for tags

Reviewed-by: imsnah
parent 441e7cfd
......@@ -78,32 +78,33 @@ def MapFields(names, data):
return dict(zip(names, data))
def _Tags_GET(kind, name=None):
def _Tags_GET(kind, name=""):
"""Helper function to retrieve tags.
"""
if name is None:
# Do not cause "missing parameter" error, which happens if a parameter
# is None.
name = ""
op = ganeti.opcodes.OpGetTags(kind=kind, name=name)
tags = ganeti.cli.SubmitOpCode(op)
return list(tags)
def _Tags_POST(kind, tags, name=None):
def _Tags_POST(kind, tags, name=""):
"""Helper function to set tags.
"""
if name is None:
# Do not cause "missing parameter" error, which happens if a parameter
# is None.
name = ""
cl = luxi.Client()
return cl.SubmitJob([ganeti.opcodes.OpAddTags(kind=kind, name=name,
tags=tags)])
def _Tags_DELETE(kind, tags, name=""):
"""Helper function to delete tags.
"""
cl = luxi.Client()
return cl.SubmitJob([ganeti.opcodes.OpDelTags(kind=kind, name=name,
tags=tags)])
def MapBulkFields(itemslist, fields):
"""Map value to field name in to one dictionary.
......
......@@ -24,9 +24,9 @@
"""
import ganeti.opcodes
from ganeti import http
from ganeti import luxi
from ganeti import constants
from ganeti.rapi import baserlib
from ganeti.rapi.rlib1 import I_FIELDS, N_FIELDS
......@@ -223,3 +223,17 @@ class R_2_instances_name_tags(baserlib.R_Generic):
"""
return baserlib._Tags_POST(constants.TAG_INSTANCE,
self.post_data, name=self.items[0])
def DELETE(self):
"""Delete a tag.
In order to delete a set of tags from a instance, DELETE request should be
addressed to URI like: /2/instances/[instance_name]/tags?tag=[tag]&tag=[tag]
"""
if 'tag' not in self.queryargs:
# no we not gonna delete all tags from an instance
raise http.HTTPNotImplemented
return baserlib._Tags_DELETE(constants.TAG_INSTANCE,
self.queryargs['tag'],
name=self.items[0])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment