From ae5b15305e215ef5f52126784af4b9a0d7d86d5c Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 14 Jun 2010 19:42:15 +0200 Subject: [PATCH] Add a new gnt-os info command This can be used to show the actual OS parameters and supported variants, in a global manner (rather than per-node as gnt-os diagnose). Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- man/gnt-os.sgml | 11 +++++++++++ scripts/gnt-os | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/man/gnt-os.sgml b/man/gnt-os.sgml index 596b8f910..7cf9d4d84 100644 --- a/man/gnt-os.sgml +++ b/man/gnt-os.sgml @@ -82,6 +82,17 @@ of all the OSes and the reasons they are or are not valid. </para> + <cmdsynopsis> + <command>info</command> + </cmdsynopsis> + + <para> + This command will list detailed information about each OS + available in the cluster, including its validity status, the + supported API versions, the supported parameters (if any) and + their documentations, etc. + </para> + <cmdsynopsis> <command>modify</command> <arg>-H <replaceable>HYPERVISOR</replaceable><arg>:<arg choice="plain" rep="repeat">option=<replaceable>value</replaceable></arg></arg></arg> diff --git a/scripts/gnt-os b/scripts/gnt-os index ef42106e4..d0df8d25f 100755 --- a/scripts/gnt-os +++ b/scripts/gnt-os @@ -70,6 +70,55 @@ def ListOS(opts, args): return 0 +def ShowOSInfo(opts, args): + """List detailed information about 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", "variants", + "parameters", "api_versions"], + names=[]) + result = SubmitOpCode(op, opts=opts) + + if not result: + ToStderr("Can't get the OS list") + return 1 + + do_filter = bool(args) + + for (name, valid, variants, parameters, api_versions) in result: + if do_filter: + if name not in args: + continue + else: + args.remove(name) + ToStdout("%s:", name) + ToStdout(" - valid: %s", valid) + if valid: + ToStdout(" - API versions:") + for version in sorted(api_versions): + ToStdout(" - %s", version) + ToStdout(" - variants:") + for vname in variants: + ToStdout(" - %s", vname) + ToStdout(" - parameters:") + for pname, pdesc in parameters: + ToStdout(" - %s: %s", pname, pdesc) + ToStdout("") + + if args: + for name in args: + ToStdout("%s: ", name) + ToStdout("") + + return 0 + + def _OsStatus(status, diagnose): """Beautifier function for OS status. @@ -203,6 +252,9 @@ commands = { " on the cluster"), 'diagnose': ( DiagnoseOS, ARGS_NONE, [], "", "Diagnose all operating systems"), + 'info': ( + ShowOSInfo, [ArgOs()], [], "", "Show detailed information about " + "operating systems"), 'modify': ( ModifyOS, ARGS_ONE_OS, [HVLIST_OPT, OSPARAMS_OPT], "", "Modify the OS parameters"), -- GitLab