Revision 4040a784
b/lib/cli.py | ||
---|---|---|
53 | 53 |
"ValidateBeParams", |
54 | 54 |
"ToStderr", "ToStdout", |
55 | 55 |
"UsesRPC", |
56 |
"GetOnlineNodes", |
|
56 | 57 |
] |
57 | 58 |
|
58 | 59 |
|
... | ... | |
921 | 922 |
return value |
922 | 923 |
|
923 | 924 |
|
925 |
def GetOnlineNodes(nodes, cl=None, nowarn=False): |
|
926 |
"""Returns the names of online nodes. |
|
927 |
|
|
928 |
This function will also log a warning on stderr with the names of |
|
929 |
the online nodes. |
|
930 |
|
|
931 |
@param nodes: if not empty, use only this subset of nodes (minus the |
|
932 |
offline ones) |
|
933 |
@param cl: if not None, luxi client to use |
|
934 |
@type nowarn: boolean |
|
935 |
@param nowarn: by default, this function will output a note with the |
|
936 |
offline nodes that are skipped; if this parameter is True the |
|
937 |
note is not displayed |
|
938 |
|
|
939 |
""" |
|
940 |
if cl is None: |
|
941 |
cl = GetClient() |
|
942 |
|
|
943 |
op = opcodes.OpQueryNodes(output_fields=["name", "offline"], |
|
944 |
names=nodes) |
|
945 |
result = SubmitOpCode(op, cl=cl) |
|
946 |
offline = [row[0] for row in result if row[1]] |
|
947 |
if offline and not nowarn: |
|
948 |
ToStderr("Note: skipping offline node(s): %s" % ", ".join(offline)) |
|
949 |
return [row[0] for row in result if not row[1]] |
|
950 |
|
|
951 |
|
|
924 | 952 |
def _ToStream(stream, txt, *args): |
925 | 953 |
"""Write a message to a stream, bypassing the logging system |
926 | 954 |
|
b/scripts/gnt-cluster | ||
---|---|---|
288 | 288 |
|
289 | 289 |
cluster_name = cl.QueryConfigValues(["cluster_name"])[0] |
290 | 290 |
|
291 |
op = opcodes.OpQueryNodes(output_fields=["name"], names=opts.nodes)
|
|
292 |
results = [row[0] for row in SubmitOpCode(op, cl=cl) if row[0] != myname]
|
|
291 |
results = GetOnlineNodes(nodes=opts.nodes, cl=cl)
|
|
292 |
results = [name for name in results if name != myname]
|
|
293 | 293 |
|
294 | 294 |
srun = ssh.SshRunner(cluster_name=cluster_name) |
295 | 295 |
for node in results: |
... | ... | |
312 | 312 |
cl = GetClient() |
313 | 313 |
|
314 | 314 |
command = " ".join(args) |
315 |
op = opcodes.OpQueryNodes(output_fields=["name"], names=opts.nodes) |
|
316 |
nodes = [row[0] for row in SubmitOpCode(op, cl=cl)]
|
|
315 |
|
|
316 |
nodes = GetOnlineNodes(nodes=opts.nodes, cl=cl)
|
|
317 | 317 |
|
318 | 318 |
cluster_name, master_node = cl.QueryConfigValues(["cluster_name", |
319 | 319 |
"master_node"]) |
Also available in: Unified diff