salt.modules.sysfs

Module for interfacing with SysFS

New in version 2016.3.0.

salt.modules.sysfs.attr(key, value=None)

Access/write a SysFS attribute. If the attribute is a symlink, its destination is returned

Returns:

value or bool

CLI Example:

salt '*' sysfs.attr block/sda/queue/logical_block_size
salt.modules.sysfs.interfaces(root)

Generate a dictionary with all available interfaces relative to root. Symlinks are not followed.

CLI Example:

salt '*' sysfs.interfaces block/bcache0/bcache
Output example:
{
   "r": [
     "state",
     "partial_stripes_expensive",
     "writeback_rate_debug",
     "stripe_size",
     "dirty_data",
     "stats_total/cache_hits",
     "stats_total/cache_bypass_misses",
     "stats_total/bypassed",
     "stats_total/cache_readaheads",
     "stats_total/cache_hit_ratio",
     "stats_total/cache_miss_collisions",
     "stats_total/cache_misses",
     "stats_total/cache_bypass_hits",
   ],
   "rw": [
     "writeback_rate",
     "writeback_rate_update_seconds",
     "cache_mode",
     "writeback_delay",
     "label",
     "writeback_running",
     "writeback_metadata",
     "running",
     "writeback_rate_p_term_inverse",
     "sequential_cutoff",
     "writeback_percent",
     "writeback_rate_d_term",
     "readahead"
   ],
   "w": [
     "stop",
     "clear_stats",
     "attach",
     "detach"
   ]
}

Note

  • 'r' interfaces are read-only

  • 'w' interfaces are write-only (e.g. actions)

  • 'rw' are interfaces that can both be read or written

salt.modules.sysfs.read(key, root='')

Read from SysFS

Parameters:

key -- file or path in SysFS; if key is a list then root will be prefixed on each key

Returns:

the full (tree of) SysFS attributes under key

CLI Example:

salt '*' sysfs.read class/net/em1/statistics
salt.modules.sysfs.target(key, full=True)

Return the basename of a SysFS key path

Parameters:
  • key -- the location to resolve within SysFS

  • full -- full path instead of basename

Returns:

fullpath or basename of path

CLI Example:

salt '*' sysfs.read class/ttyS0
salt.modules.sysfs.write(key, value)

Write a SysFS attribute/action

CLI Example:

salt '*' sysfs.write devices/system/cpu/cpu0/cpufreq/scaling_governor 'performance'