X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/ccadf1ffee93f892165e8c88f82148bb4bcd1ead..b44bd844c54573e7801fc1ef6b4f8007f193555d:/scripts/gnt-os diff --git a/scripts/gnt-os b/scripts/gnt-os index fd96cbe..f74213a 100755 --- a/scripts/gnt-os +++ b/scripts/gnt-os @@ -1,7 +1,7 @@ #!/usr/bin/python # -# Copyright (C) 2006, 2007 Google Inc. +# Copyright (C) 2006, 2007, 2010 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,8 +44,7 @@ def ListOS(opts, args): @return: the desired exit code """ - op = opcodes.OpDiagnoseOS(output_fields=["name", "valid", "variants"], - names=[]) + op = opcodes.OpDiagnoseOS(output_fields=["name", "variants"], names=[]) result = SubmitOpCode(op, opts=opts) if not result: @@ -58,9 +57,8 @@ def ListOS(opts, args): headers = None os_names = [] - for (name, valid, variants) in result: - if valid: - os_names.extend([[n] for n in CalculateOSNames(name, variants)]) + for (name, variants) in result: + os_names.extend([[n] for n in CalculateOSNames(name, variants)]) data = GenerateTable(separator=None, headers=headers, fields=["name"], data=os_names, units=None) @@ -82,7 +80,8 @@ def ShowOSInfo(opts, args): """ op = opcodes.OpDiagnoseOS(output_fields=["name", "valid", "variants", - "parameters", "api_versions"], + "parameters", "api_versions", + "blacklisted", "hidden"], names=[]) result = SubmitOpCode(op, opts=opts) @@ -92,7 +91,7 @@ def ShowOSInfo(opts, args): do_filter = bool(args) - for (name, valid, variants, parameters, api_versions) in result: + for (name, valid, variants, parameters, api_versions, blk, hid) in result: if do_filter: if name not in args: continue @@ -100,6 +99,8 @@ def ShowOSInfo(opts, args): args.remove(name) ToStdout("%s:", name) ToStdout(" - valid: %s", valid) + ToStdout(" - hidden: %s", hid) + ToStdout(" - blacklisted: %s", blk) if valid: ToStdout(" - API versions:") for version in sorted(api_versions): @@ -136,6 +137,7 @@ def _OsStatus(status, diagnose): else: return "invalid - %s" % diagnose + def DiagnoseOS(opts, args): """Analyse all OSes on this cluster. @@ -147,7 +149,8 @@ def DiagnoseOS(opts, args): """ op = opcodes.OpDiagnoseOS(output_fields=["name", "valid", "variants", - "node_status"], names=[]) + "node_status", "hidden", + "blacklisted"], names=[]) result = SubmitOpCode(op, opts=opts) if not result: @@ -156,7 +159,7 @@ def DiagnoseOS(opts, args): has_bad = False - for os_name, _, os_variants, node_data in result: + for os_name, _, os_variants, node_data, hid, blk in result: nodes_valid = {} nodes_bad = {} nodes_hidden = {} @@ -172,6 +175,7 @@ def DiagnoseOS(opts, args): else: max_os_api = 0 fo_msg += " [no API versions declared]" + if max_os_api >= constants.OS_API_V15: if fo_variants: fo_msg += " [variants: %s]" % utils.CommaJoin(fo_variants) @@ -209,7 +213,12 @@ def DiagnoseOS(opts, args): for msg in nodes_hidden[node_name]: ToStdout(msg) - ToStdout("OS: %s [global status: %s]", os_name, status) + st_msg = "OS: %s [global status: %s]" % (os_name, status) + if hid: + st_msg += " [hidden]" + if blk: + st_msg += " [blacklisted]" + ToStdout(st_msg) if os_variants: ToStdout(" Variants: [%s]" % utils.CommaJoin(os_variants)) _OutputPerNodeOSStatus(nodes_valid) @@ -241,36 +250,52 @@ def ModifyOS(opts, args): else: osp = None - if not (os_hvp or osp): + if opts.hidden is not None: + if opts.hidden: + ohid = [(constants.DDM_ADD, os)] + else: + ohid = [(constants.DDM_REMOVE, os)] + else: + ohid = None + + if opts.blacklisted is not None: + if opts.blacklisted: + oblk = [(constants.DDM_ADD, os)] + else: + oblk = [(constants.DDM_REMOVE, os)] + else: + oblk = None + + if not (os_hvp or osp or ohid or oblk): ToStderr("At least one of OS parameters or hypervisor parameters" " must be passed") return 1 - op = opcodes.OpSetClusterParams(vg_name=None, - enabled_hypervisors=None, - hvparams=None, - beparams=None, - nicparams=None, - candidate_pool_size=None, - os_hvp=os_hvp, - osparams=osp) - SubmitOpCode(op) + op = opcodes.OpSetClusterParams(os_hvp=os_hvp, + osparams=osp, + hidden_os=ohid, + blacklisted_os=oblk) + SubmitOpCode(op, opts=opts) return 0 commands = { 'list': ( - ListOS, ARGS_NONE, [NOHDR_OPT], "", "Lists all valid operating systems" - " on the cluster"), + ListOS, ARGS_NONE, [NOHDR_OPT, PRIORITY_OPT], + "", "Lists all valid operating systems on the cluster"), 'diagnose': ( - DiagnoseOS, ARGS_NONE, [], "", "Diagnose all operating systems"), + DiagnoseOS, ARGS_NONE, [PRIORITY_OPT], + "", "Diagnose all operating systems"), 'info': ( - ShowOSInfo, [ArgOs()], [], "", "Show detailed information about " + ShowOSInfo, [ArgOs()], [PRIORITY_OPT], + "", "Show detailed information about " "operating systems"), 'modify': ( - ModifyOS, ARGS_ONE_OS, [HVLIST_OPT, OSPARAMS_OPT], "", - "Modify the OS parameters"), + ModifyOS, ARGS_ONE_OS, + [HVLIST_OPT, OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT, + HID_OS_OPT, BLK_OS_OPT], + "", "Modify the OS parameters"), } if __name__ == '__main__':