def _get_jail_path(jail): """ .. versionadded:: 2016.3.4 Return the jail's root directory (path) as shown in jls jail The jid or jail name """ jls = salt.utils.path.which("jls") if not jls: raise CommandNotFoundError("'jls' command not found") jails = __salt__["cmd.run_stdout"]("{} -n jid name path".format(jls)) for j in jails.splitlines(): jid, jname, path = (x.split("=")[1].strip() for x in j.split()) if jid == jail or jname == jail: return path.rstrip("/") # XΧΧ, TODO, not sure how to handle nonexistent jail return ""
def _get_jail_path(jail): ''' .. versionadded:: 2016.3.4 Return the jail's root directory (path) as shown in jls jail The jid or jail name ''' jls = salt.utils.path.which('jls') if not jls: raise CommandNotFoundError('\'jls\' command not found') jails = __salt__['cmd.run_stdout']('{0} -n jid name path'.format(jls)) for j in jails.splitlines(): jid, jname, path = (x.split('=')[1].strip() for x in j.split()) if jid == jail or jname == jail: return path.rstrip('/') # XΧΧ, TODO, not sure how to handle nonexistent jail return ''