Revision 25e39bfa
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 |
|
b/lib/ssconf.py | ||
---|---|---|
250 | 250 |
nl = data.splitlines(False) |
251 | 251 |
return nl |
252 | 252 |
|
253 |
def GetClusterTags(self): |
|
254 |
"""Return the cluster tags. |
|
255 |
|
|
256 |
""" |
|
257 |
data = self._ReadFile(constants.SS_CLUSTER_TAGS) |
|
258 |
nl = data.splitlines(False) |
|
259 |
return nl |
|
260 |
|
|
253 | 261 |
|
254 | 262 |
def GetMasterAndMyself(ss=None): |
255 | 263 |
"""Get the master node and my own hostname. |
Also available in: Unified diff