Revision 25e39bfa lib/rapi/baserlib.py

b/lib/rapi/baserlib.py
29 29
from ganeti import luxi
30 30
from ganeti import rapi
31 31
from ganeti import http
32
from ganeti import ssconf
33
from ganeti import constants
32 34

  
33 35

  
34 36
def BuildUriList(ids, uri_format, uri_fields=("name", "uri")):
......
81 83
  """Helper function to retrieve tags.
82 84

  
83 85
  """
84
  op = ganeti.opcodes.OpGetTags(kind=kind, name=name)
85
  tags = ganeti.cli.SubmitOpCode(op)
86
  if kind == constants.TAG_INSTANCE or kind == constants.TAG_NODE:
87
    if not name:
88
      raise HttpBadRequest("Missing name on tag request")
89
    cl = luxi.Client()
90
    if kind == constants.TAG_INSTANCE:
91
      fn = cl.QueryInstances
92
    else:
93
      fn = cl.QueryNodes
94
    result = fn(names=[name], fields=["tags"], use_locking=False)
95
    if not result or not result[0]:
96
      raise http.HttpBadGateway("Invalid response from tag query")
97
    tags = result[0][0]
98
  elif kind == constants.TAG_CLUSTER:
99
    ssc = ssconf.SimpleStore()
100
    tags = ssc.GetClusterTags()
101

  
86 102
  return list(tags)
87 103

  
88 104

  

Also available in: Unified diff