harbor run -t openthoughts/tasktrove-exp-flat25-stackoverflow-v2-5k-stackoverflow-4499harbor download openthoughts/tasktrove-exp-flat25-stackoverflow-v2-5k-stackoverflow-4499Title: Implement MooseFS integration functions in Salt's MooseFS module (dirinfo, fileinfo, mounts, getgoal)
Description: I’m adding four MooseFS helper functions to Salt's module salt.modules.moosefs. Each function should query MooseFS using Salt’s salt['cmd.run_all'] and return parsed, structured results that the existing tests expect. The tests patch salt to control stdout, so the implementation must rely on the command results rather than any external state.
What needs to be implemented (requirements and behavior):
Implementation notes and guarantees:
Code sketch (guidance, not a full patch):
def dirinfo(path): """ Retrieve directory information for a given path on MooseFS. """ cmd = "< MooseFS dir info command for {}>".format(path) res = salt'cmd.run_all' stdout = res.get('stdout', '') data = {} for line in stdout.splitlines(): if ':' in line: key, val = line.split(':', 1) data[key.strip()] = val.strip() return data
def fileinfo(path): """ Retrieve file information for a given path on MooseFS. """ cmd = "< MooseFS file info command for {}>".format(path) res = salt'cmd.run_all' stdout = res.get('stdout', '') data = {} for line in stdout.splitlines(): if ':' in line: key, val = line.split(':', 1) data[key.strip()] = val.strip() return data
def mounts(): """ Retrieve current MooseFS mounts. """ cmd = "< MooseFS mounts list command >" res = salt'cmd.run_all' stdout = res.get('stdout', '') data = {} for line in stdout.splitlines(): if ':' in line: key, val = line.split(':', 1) data[key.strip()] = val.strip() return data
def getgoal(path): """ Retrieve goal(s) for a given path on MooseFS. """ cmd = "< MooseFS getgoal command for {}>".format(path) res = salt'cmd.run_all' stdout = res.get('stdout', '') for line in stdout.splitlines(): if ':' in line: value = line.split(':', 1)[1].strip() return {"goal": value} return {}
Example expectations:
If you can provide a complete, working module implementation that satisfies these parsing rules and integrates with Salt’s module conventions, including docstrings and imports, I’d appreciate it. A patch that passes the existing tests (which patch salt to control stdout) would be ideal.