Revision 3ccafd0e
b/daemons/ganeti-masterd | ||
---|---|---|
252 | 252 |
op = opcodes.OpQueryConfigValues(output_fields=fields) |
253 | 253 |
return self._Query(op) |
254 | 254 |
|
255 |
elif method == luxi.REQ_QUEUE_SET_DRAIN_FLAG: |
|
256 |
drain_flag = args |
|
257 |
return queue.SetDrainFlag(drain_flag) |
|
258 |
|
|
255 | 259 |
else: |
256 | 260 |
raise ValueError("Invalid operation") |
257 | 261 |
|
b/lib/cmdlib.py | ||
---|---|---|
1891 | 1891 |
def ExpandNames(self): |
1892 | 1892 |
self.needed_locks = {} |
1893 | 1893 |
|
1894 |
static_fields = ["cluster_name", "master_node"] |
|
1894 |
static_fields = ["cluster_name", "master_node", "drain_flag"]
|
|
1895 | 1895 |
_CheckOutputFields(static=static_fields, |
1896 | 1896 |
dynamic=[], |
1897 | 1897 |
selected=self.op.output_fields) |
... | ... | |
1909 | 1909 |
values = [] |
1910 | 1910 |
for field in self.op.output_fields: |
1911 | 1911 |
if field == "cluster_name": |
1912 |
values.append(self.cfg.GetClusterName())
|
|
1912 |
entry = self.cfg.GetClusterName()
|
|
1913 | 1913 |
elif field == "master_node": |
1914 |
values.append(self.cfg.GetMasterNode()) |
|
1914 |
entry = self.cfg.GetMasterNode() |
|
1915 |
elif field == "drain_flag": |
|
1916 |
entry = os.path.exists(constants.JOB_QUEUE_DRAIN_FILE) |
|
1915 | 1917 |
else: |
1916 | 1918 |
raise errors.ParameterError(field) |
1919 |
values.append(entry) |
|
1917 | 1920 |
return values |
1918 | 1921 |
|
1919 | 1922 |
|
b/lib/jqueue.py | ||
---|---|---|
574 | 574 |
""" |
575 | 575 |
return os.path.exists(constants.JOB_QUEUE_DRAIN_FILE) |
576 | 576 |
|
577 |
@staticmethod |
|
578 |
def SetDrainFlag(drain_flag): |
|
579 |
"""Sets the drain flag for the queue. |
|
580 |
|
|
581 |
This is similar to the function L{backend.JobQueueSetDrainFlag}, |
|
582 |
and in the future we might merge them. |
|
583 |
|
|
584 |
""" |
|
585 |
if drain_flag: |
|
586 |
utils.WriteFile(constants.JOB_QUEUE_DRAIN_FILE, data="", close=True) |
|
587 |
else: |
|
588 |
utils.RemoveFile(constants.JOB_QUEUE_DRAIN_FILE) |
|
589 |
return True |
|
590 |
|
|
577 | 591 |
@utils.LockedMethod |
578 | 592 |
@_RequireOpenQueue |
579 | 593 |
def SubmitJob(self, ops): |
b/lib/luxi.py | ||
---|---|---|
54 | 54 |
REQ_QUERY_NODES = "QueryNodes" |
55 | 55 |
REQ_QUERY_EXPORTS = "QueryExports" |
56 | 56 |
REQ_QUERY_CONFIG_VALUES = "QueryConfigValues" |
57 |
REQ_QUEUE_SET_DRAIN_FLAG = "SetDrainFlag" |
|
57 | 58 |
|
58 | 59 |
DEF_CTMO = 10 |
59 | 60 |
DEF_RWTO = 60 |
... | ... | |
291 | 292 |
|
292 | 293 |
return result |
293 | 294 |
|
295 |
def SetQueueDrainFlag(self, drain_flag): |
|
296 |
return self.CallMethod(REQ_QUEUE_SET_DRAIN_FLAG, drain_flag) |
|
297 |
|
|
294 | 298 |
def SubmitJob(self, ops): |
295 | 299 |
ops_state = map(lambda op: op.__getstate__(), ops) |
296 | 300 |
return self.CallMethod(REQ_SUBMIT_JOB, ops_state) |
... | ... | |
329 | 333 |
def QueryConfigValues(self, fields): |
330 | 334 |
return self.CallMethod(REQ_QUERY_CONFIG_VALUES, fields) |
331 | 335 |
|
336 |
|
|
332 | 337 |
# TODO: class Server(object) |
b/scripts/gnt-cluster | ||
---|---|---|
343 | 343 |
return 0 |
344 | 344 |
|
345 | 345 |
|
346 |
def QueueOps(opts, args): |
|
347 |
"""Queue operations. |
|
348 |
|
|
349 |
""" |
|
350 |
command = args[0] |
|
351 |
client = GetClient() |
|
352 |
if command in ("drain", "undrain"): |
|
353 |
drain_flag = command == "drain" |
|
354 |
client.SetQueueDrainFlag(drain_flag) |
|
355 |
elif command == "info": |
|
356 |
result = client.QueryConfigValues(["drain_flag"]) |
|
357 |
print "The drain flag is", |
|
358 |
if result[0]: |
|
359 |
print "set" |
|
360 |
else: |
|
361 |
print "unset" |
|
362 |
return 0 |
|
363 |
|
|
346 | 364 |
# this is an option common to more than one command, so we declare |
347 | 365 |
# it here and reuse it |
348 | 366 |
node_option = make_option("-n", "--node", action="append", dest="nodes", |
... | ... | |
443 | 461 |
'search-tags': (SearchTags, ARGS_ONE, |
444 | 462 |
[DEBUG_OPT], "", "Searches the tags on all objects on" |
445 | 463 |
" the cluster for a given pattern (regex)"), |
464 |
'queue': (QueueOps, ARGS_ONE, [DEBUG_OPT], |
|
465 |
"drain|undrain|info", "Change queue properties"), |
|
446 | 466 |
'modify': (SetClusterParams, ARGS_NONE, |
447 | 467 |
[DEBUG_OPT, |
448 | 468 |
make_option("-g", "--vg-name", dest="vg_name", |
Also available in: Unified diff