Commit 7f37f0ca authored by Dimitris Bliablias's avatar Dimitris Bliablias Committed by Michele Tartara
Browse files

Show OS variant information in gnt-os info



Currently, the non-standard/modified per-OS hypervisor parameters, or
OS specific parameters can be listed only by the 'gnt-cluster info'
command, which is a non-standard place to show them. Extend the
'gnt-os info' command to display the available/supported OS variants
in the cluster.

This fixes issue 266.
Signed-off-by: default avatarDimitris Bliablias <bl.dimitris@gmail.com>
Signed-off-by: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent b5e82a96
......@@ -75,7 +75,8 @@ def ShowOSInfo(opts, args):
"""
op = opcodes.OpOsDiagnose(output_fields=["name", "valid", "variants",
"parameters", "api_versions",
"blacklisted", "hidden"],
"blacklisted", "hidden", "os_hvp",
"osparams"],
names=[])
result = SubmitOpCode(op, opts=opts)
......@@ -85,7 +86,13 @@ def ShowOSInfo(opts, args):
do_filter = bool(args)
for (name, valid, variants, parameters, api_versions, blk, hid) in result:
total_os_hvp = {}
total_osparams = {}
for (name, valid, variants, parameters, api_versions, blk, hid, os_hvp,
osparams) in result:
total_os_hvp.update(os_hvp)
total_osparams.update(osparams)
if do_filter:
if name not in args:
continue
......@@ -108,8 +115,18 @@ def ShowOSInfo(opts, args):
ToStdout("")
if args:
all_names = total_os_hvp.keys() + total_osparams.keys()
for name in args:
ToStdout("%s: ", name)
if not name in all_names:
ToStdout("%s: ", name)
else:
info = [
(name, [
("OS-specific hypervisor parameters", total_os_hvp.get(name, {})),
("OS parameters", total_osparams.get(name, {})),
]),
]
PrintGenericInfo(info)
ToStdout("")
return 0
......
......@@ -104,7 +104,8 @@ class OsQuery(QueryBase):
for (os_name, os_data) in pol.items():
info = query.OsInfo(name=os_name, valid=True, node_status=os_data,
hidden=(os_name in cluster.hidden_os),
blacklisted=(os_name in cluster.blacklisted_os))
blacklisted=(os_name in cluster.blacklisted_os),
os_hvp={}, osparams={})
variants = set()
parameters = set()
......@@ -131,6 +132,13 @@ class OsQuery(QueryBase):
info.parameters = list(parameters)
info.api_versions = list(api_versions)
for variant in variants:
name = "+".join([os_name, variant])
if name in cluster.os_hvp.keys():
info.os_hvp[name] = cluster.os_hvp.get(name)
if name in cluster.osparams.keys():
info.osparams[name] = cluster.osparams.get(name)
data[os_name] = info
# Prepare data in requested order
......
......@@ -2446,6 +2446,8 @@ class OsInfo(objects.ConfigObject):
"api_versions",
"parameters",
"node_status",
"os_hvp",
"osparams"
]
......@@ -2478,6 +2480,12 @@ def _BuildOsFields():
(_MakeField("node_status", "NodeStatus", QFT_OTHER,
"Status from node"),
None, 0, _GetItemAttr("node_status")),
(_MakeField("os_hvp", "OsHypervisorParams", QFT_OTHER,
"Operating system specific hypervisor parameters"),
None, 0, _GetItemAttr("os_hvp")),
(_MakeField("osparams", "OsParameters", QFT_OTHER,
"Operating system specific parameters"),
None, 0, _GetItemAttr("osparams")),
]
return _PrepareFieldList(fields, [])
......
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