#!/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
@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:
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)
"""
op = opcodes.OpDiagnoseOS(output_fields=["name", "valid", "variants",
- "parameters", "api_versions"],
+ "parameters", "api_versions",
+ "blacklisted", "hidden"],
names=[])
result = SubmitOpCode(op, opts=opts)
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
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):
else:
return "invalid - %s" % diagnose
+
def DiagnoseOS(opts, args):
"""Analyse all OSes on this cluster.
"""
op = opcodes.OpDiagnoseOS(output_fields=["name", "valid", "variants",
- "node_status"], names=[])
+ "node_status", "hidden",
+ "blacklisted"], names=[])
result = SubmitOpCode(op, opts=opts)
if not result:
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 = {}
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)
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)
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__':