Commit c7d04a6b authored by Iustin Pop's avatar Iustin Pop
Browse files

Add reading of OS parameters from disk

The patch also modifies the internal methods in LUDiagnoseOS and gnt-os
to deal with the format change of call_os_diagnose.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
parent b41b3516
......@@ -1781,6 +1781,7 @@ def DiagnoseOS(top_dirs=None):
- status True/False is the validity of the OS
- diagnose is the error message for an invalid OS, otherwise empty
- variants is a list of supported OS variants, if any
- parameters is a list of (name, help) parameters, if any
if top_dirs is None:
......@@ -1800,10 +1801,11 @@ def DiagnoseOS(top_dirs=None):
if status:
diagnose = ""
variants = os_inst.supported_variants
parameters = os_inst.supported_parameters
diagnose = os_inst
variants = []
result.append((name, os_path, status, diagnose, variants))
variants = parameters = []
result.append((name, os_path, status, diagnose, variants, parameters))
return result
......@@ -1845,6 +1847,11 @@ def _TryOSFromDisk(name, base_dir=None):
if max(api_versions) >= constants.OS_API_V15:
os_files[constants.OS_VARIANTS_FILE] = ''
if max(api_versions) >= constants.OS_API_V20:
os_files[constants.OS_PARAMETERS_FILE] = ''
del os_files[constants.OS_SCRIPT_VERIFY]
for filename in os_files:
os_files[filename] = utils.PathJoin(os_dir, filename)
......@@ -1874,12 +1881,24 @@ def _TryOSFromDisk(name, base_dir=None):
if not variants:
return False, ("No supported os variant found")
parameters = []
if constants.OS_PARAMETERS_FILE in os_files:
parameters_file = os_files[constants.OS_PARAMETERS_FILE]
parameters = utils.ReadFile(parameters_file).splitlines()
except EnvironmentError, err:
return False, ("Error while reading the OS parameters file at %s: %s" %
(parameters_file, _ErrnoOrStr(err)))
parameters = [v.split(None, 1) for v in parameters]
os_obj = objects.OS(name=name, path=os_dir,
return True, os_obj
......@@ -2736,12 +2736,13 @@ class LUDiagnoseOS(NoHooksLU):
@param rlist: a map with node names as keys and OS objects as values
@rtype: dict
@return: a dictionary with osnames as keys and as value another map, with
nodes as keys and tuples of (path, status, diagnose) as values, eg::
@return: a dictionary with osnames as keys and as value another
map, with nodes as keys and tuples of (path, status, diagnose,
variants, parameters) as values, eg::
{"debian-etch": {"node1": [(/usr/lib/..., True, ""),
{"debian-etch": {"node1": [(/usr/lib/..., True, "", [], []),
(/srv/..., False, "invalid api")],
"node2": [(/srv/..., True, "")]}
"node2": [(/srv/..., True, "", [], [])]}
......@@ -2754,14 +2755,15 @@ class LUDiagnoseOS(NoHooksLU):
for node_name, nr in rlist.items():
if nr.fail_msg or not nr.payload:
for name, path, status, diagnose, variants in nr.payload:
for name, path, status, diagnose, variants, params in nr.payload:
if name not in all_os:
# build a list of nodes for this os containing empty lists
# for each node in node_list
all_os[name] = {}
for nname in good_nodes:
all_os[name][nname] = []
all_os[name][node_name].append((path, status, diagnose, variants))
all_os[name][node_name].append((path, status, diagnose,
variants, params))
return all_os
def Exec(self, feedback_fn):
......@@ -114,7 +114,7 @@ def DiagnoseOS(opts, args):
nodes_hidden[node_name] = []
if node_info: # at least one entry in the per-node list
(first_os_path, first_os_status, first_os_msg,
first_os_variants) = node_info.pop(0)
first_os_variants, _) = node_info.pop(0)
if not first_os_variants:
first_os_variants = []
first_os_msg = ("%s (path: %s) [variants: %s]" %
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