salt.modules.sysfs module

Module for interfacing with SysFS

2016.3.0 新版功能.

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

Access/write a SysFS attribute. If the attribute is a symlink, it's destination is returned

返回: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' 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

参数:key -- file or path in SysFS; if key is a list then root will be prefixed on each key
返回: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

参数:
  • key -- the location to resolve within SysFS
  • full -- full path instead of basename
返回:

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'