def _available_commands(): ''' List available commands based on 'zfs help'. Returns a dict. ''' zfs_path = _check_zfs() if not zfs_path: return False ret = {} res = salt_cmd.run_stderr( '{0} help'.format(zfs_path), output_loglevel='trace', ignore_retcode=True ) # This bit is dependent on specific output from `zfs help` - any major changes # in how this works upstream will require a change. for line in res.splitlines(): if re.match(' [a-zA-Z]', line): cmds = line.split(' ')[0].split('|') doc = ' '.join(line.split(' ')[1:]) for cmd in [cmd.strip() for cmd in cmds]: if cmd not in ret: ret[cmd] = doc return ret
def _available_commands(): ''' List available commands based on 'zfs -?'. Returns a dict. ''' zfs_path = _check_zfs() if not zfs_path: return False ret = {} res = salt_cmd.run_stderr( '{0} -?'.format(zfs_path), output_loglevel='trace', ignore_retcode=True ) # This bit is dependent on specific output from `zfs -?` - any major changes # in how this works upstream will require a change. for line in res.splitlines(): if re.match(' [a-zA-Z]', line): cmds = line.split(' ')[0].split('|') doc = ' '.join(line.split(' ')[1:]) for cmd in [cmd.strip() for cmd in cmds]: if cmd not in ret: ret[cmd] = doc return ret
def _available_commands(): ''' List available commands based on 'zfs help'. Returns a dict. ''' zfs_path = _check_zfs() if not zfs_path: return False ret = {} # Note that we append '|| :' as a unix hack to force return code to be 0. res = salt_cmd.run_stderr( '{0} help || :'.format(zfs_path), output_loglevel='debug' ) # This bit is dependent on specific output from `zfs help` - any major changes # in how this works upstream will require a change. for line in res.splitlines(): if re.match(' [a-zA-Z]', line): cmds = line.split(' ')[0].split('|') doc = ' '.join(line.split(' ')[1:]) for cmd in [cmd.strip() for cmd in cmds]: if cmd not in ret: ret[cmd] = doc return ret