// Helper: convert stdout into dict by merging lines with a colon
FUNCTION parse_stdout_to_dict(stdout):
result = {}
IF stdout is None: RETURN result
FOR line IN split_lines(stdout):
IF ':' IN line:
key, value = split_at_first_colon(line)
result[trim(key)] = trim(value)
RETURN result
// Helper: extract value after first colon from first line containing a colon
FUNCTION first_colon_line_value(stdout):
IF stdout is None: RETURN None
FOR line IN split_lines(stdout):
IF ':' IN line:
value = substring_after_first_colon(line)
RETURN trim(value)
RETURN None
// 1) dirinfo(path)
FUNCTION dirinfo(path):
cmd = build_dirinfo_command(path) // MooseFS CLI command for directory info
res = salt'cmd.run_all'
stdout = res.get('stdout', '')
parsed = parse_stdout_to_dict(stdout)
RETURN parsed
// 2) fileinfo(path)
FUNCTION fileinfo(path):
cmd = build_fileinfo_command(path) // MooseFS CLI command for file info
res = salt'cmd.run_all'
stdout = res.get('stdout', '')
parsed = parse_stdout_to_dict(stdout)
RETURN parsed
// 3) mounts()
FUNCTION mounts():
cmd = build_mounts_command() // MooseFS CLI command to list mounts
res = salt'cmd.run_all'
stdout = res.get('stdout', '')
parsed = parse_stdout_to_dict(stdout)
RETURN parsed
// 4) getgoal(path)
FUNCTION getgoal(path):
cmd = build_getgoal_command(path) // MooseFS CLI command to fetch goal for path
res = salt'cmd.run_all'
stdout = res.get('stdout', '')
value = first_colon_line_value(stdout)
IF value IS None:
RETURN {}
ELSE:
RETURN {'goal': value}
NOTES:
Parsing rule for dirinfo, fileinfo, mounts: merge all lines containing a colon by using the first colon as separator, trimming whitespace on key and value, and ignoring lines without a colon.
Empty stdout yields {} for dirinfo, fileinfo, mounts; and {} for getgoal.
Implementation relies on salt['cmd.run_all'] to execute underlying commands; tests will patch salt to control stdout.
Module should be importable as salt.modules.moosefs with proper docstrings and conventions.