X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/57d0151e9a1885304a70c8d3bc720abfb3aa1502..560428be4f5852813972cd2791f425cf708ca7c6:/scripts/gnt-os?ds=inline diff --git a/scripts/gnt-os b/scripts/gnt-os index 873f09f..a0c09a7 100755 --- a/scripts/gnt-os +++ b/scripts/gnt-os @@ -19,27 +19,34 @@ # 02110-1301, USA. +# pylint: disable-msg=W0401,W0614 +# W0401: Wildcard import ganeti.cli +# W0614: Unused import %s from wildcard import (since we need cli) + import sys from optparse import make_option from ganeti.cli import * from ganeti import opcodes -from ganeti import logger -from ganeti import objects from ganeti import utils -from ganeti import errors from ganeti import constants def ListOS(opts, args): - """List the OSes existing on this node. + """List the valid OSes in the cluster. + + @param opts: the command line options selected by the user + @type args: list + @param args: should be an empty list + @rtype: int + @return: the desired exit code """ op = opcodes.OpDiagnoseOS(output_fields=["name", "valid"], names=[]) result = SubmitOpCode(op) if not result: - logger.ToStdout("Can't get the OS list") + ToStderr("Can't get the OS list") return 1 if not opts.no_headers: @@ -48,10 +55,11 @@ def ListOS(opts, args): headers = None data = GenerateTable(separator=None, headers=headers, fields=["name"], - data=[[row[0]] for row in result if row[1]]) + data=[[row[0]] for row in result if row[1]], + units=None) for line in data: - logger.ToStdout(line) + ToStdout(line) return 0 @@ -59,13 +67,19 @@ def ListOS(opts, args): def DiagnoseOS(opts, args): """Analyse all OSes on this cluster. + @param opts: the command line options selected by the user + @type args: list + @param args: should be an empty list + @rtype: int + @return: the desired exit code + """ op = opcodes.OpDiagnoseOS(output_fields=["name", "valid", "node_status"], names=[]) result = SubmitOpCode(op) if not result: - logger.ToStdout("Can't get the OS list") + ToStderr("Can't get the OS list") return 1 has_bad = False @@ -102,23 +116,22 @@ def DiagnoseOS(opts, args): def _OutputPerNodeOSStatus(msg_map): map_k = utils.NiceSort(msg_map.keys()) for node_name in map_k: - logger.ToStdout(" Node: %s, status: %s" % - (node_name, msg_map[node_name])) + ToStdout(" Node: %s, status: %s", node_name, msg_map[node_name]) for msg in nodes_hidden[node_name]: - logger.ToStdout(msg) + ToStdout(msg) - logger.ToStdout("OS: %s [global status: %s]" % (os_name, status)) + ToStdout("OS: %s [global status: %s]", os_name, status) _OutputPerNodeOSStatus(nodes_valid) _OutputPerNodeOSStatus(nodes_bad) - logger.ToStdout("") + ToStdout("") return int(has_bad) commands = { - 'list': (ListOS, ARGS_NONE, [DEBUG_OPT, NOHDR_OPT], + 'list': (ListOS, ARGS_NONE, [DEBUG_OPT, NOHDR_OPT], "", "Lists all valid OSes on the master"), - 'diagnose': (DiagnoseOS, ARGS_NONE, [DEBUG_OPT], + 'diagnose': (DiagnoseOS, ARGS_NONE, [DEBUG_OPT], "", "Diagnose all OSes"), }