Revision 4040a784 lib/cli.py
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 |
|
Also available in: Unified diff