Commit c950e9f2 authored by Iustin Pop's avatar Iustin Pop

Add blacklisted/hidden OS support in LUDiagnoseOS

This changes the behaviour of LUDiagnoseOS significantly.

The addition of hidden/blacklisted OSes would mean that each user-facing
client would have to filter intentionally such OSes from display, which
is not a good choice. Rather, the patch makes LUDiagnoseOS not return
any hidden or blacklisted OSes unless the hidden or respectively the
blacklisted status is requested.

While unconventional, this makes `gnt-instance reinstall --select-os`
work as intended without any changes; similar for gnt-os list. gnt-os
diagnose/gnt-os info are changed to query for, and display the new
fields.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent fc31fadd
......@@ -3072,9 +3072,11 @@ class LUDiagnoseOS(NoHooksLU):
("names", _EmptyList, _TListOf(_TNonEmptyString)),
]
REQ_BGL = False
_HID = "hidden"
_BLK = "blacklisted"
_FIELDS_STATIC = utils.FieldSet()
_FIELDS_DYNAMIC = utils.FieldSet("name", "valid", "node_status", "variants",
"parameters", "api_versions")
"parameters", "api_versions", _HID, _BLK)
def CheckArguments(self):
if self.op.names:
......@@ -3141,6 +3143,7 @@ class LUDiagnoseOS(NoHooksLU):
node_data = self.rpc.call_os_diagnose(valid_nodes)
pol = self._DiagnoseByOS(node_data)
output = []
cluster = self.cfg.GetClusterInfo()
for os_name, os_data in pol.items():
row = []
......@@ -3161,6 +3164,12 @@ class LUDiagnoseOS(NoHooksLU):
params.intersection_update(node_params)
api_versions.intersection_update(node_api)
is_hid = os_name in cluster.hidden_oss
is_blk = os_name in cluster.blacklisted_oss
if ((self._HID not in self.op.output_fields and is_hid) or
(self._BLK not in self.op.output_fields and is_blk)):
continue
for field in self.op.output_fields:
if field == "name":
val = os_name
......@@ -3177,6 +3186,10 @@ class LUDiagnoseOS(NoHooksLU):
val = list(params)
elif field == "api_versions":
val = list(api_versions)
elif field == self._HID:
val = is_hid
elif field == self._BLK:
val = is_blk
else:
raise errors.ParameterError(field)
row.append(val)
......
......@@ -2,7 +2,7 @@
<!-- Fill in your name for FIRSTNAME and SURNAME. -->
<!-- Please adjust the date whenever revising the manpage. -->
<!ENTITY dhdate "<date>June 08, 2010</date>">
<!ENTITY dhdate "<date>September 20, 2010</date>">
<!-- SECTION should be 1-8, maybe w/ subsection other parameters are
allowed: see man(7), man(1). -->
<!ENTITY dhsection "<manvolnum>8</manvolnum>">
......@@ -69,6 +69,11 @@
as an option.
</para>
<para>
Note that hidden or blacklisted OSes are not displayed by this
command, use <command>diagnose</command> for showing those.
</para>
<cmdsynopsis>
<command>diagnose</command>
</cmdsynopsis>
......
......@@ -82,7 +82,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 +93,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 +101,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):
......@@ -148,7 +151,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:
......@@ -157,7 +161,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 = {}
......@@ -173,6 +177,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)
......@@ -210,7 +215,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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment