System settings

OS detection

fabtools.system.distrib_id()[source]
Get the OS distribution ID.
Returns a string such as “Debian”, “Ubuntu”, “RHEL”, “CentOS”, “SLES”, “Fedora”, “Arch”, “Gentoo”, “SunOS”
Example:
from fabtools.system import distrib_id if distrib_id() != ‘Debian’: abort(u”Distribution is not supported”)
fabtools.system.distrib_family()[source]
Get the distribution family.
Returns one of debian, redhat, arch, gentoo, sun, other.
fabtools.system.distrib_release()[source]
Get the release number of the distribution.
Example:
from fabtools.system import distrib_id, distrib_release if distrib_id() == ‘CentOS’ and distrib_release() == ‘6.1’: print(u”CentOS 6.2 has been released. Please upgrade.”)
fabtools.system.distrib_codename()[source]
Get the codename of the Linux distribution.
Example:
from fabtools.deb import distrib_codename if distrib_codename() == ‘precise’: print(u”Ubuntu 12.04 LTS detected”)
fabtools.system.distrib_desc()[source]
Get the description of the Linux distribution.
For example: Debian GNU/Linux 6.0.7 (squeeze).

Hardware detection

fabtools.system.get_arch()[source]
Get the CPU architecture.
Example:
from fabtools.system import get_arch if get_arch() == ‘x86_64’: print(u”Running on a 64-bit Intel/AMD system”)
fabtools.system.cpus()[source]
Get the number of CPU cores.
Example:
from fabtools.system import cpus nb_workers = 2 * cpus() + 1

Hostname

fabtools.system.get_hostname()[source]
Get the fully qualified hostname.
fabtools.system.sethostname(_hostname, persist=True)[source]
Set the hostname.

Kernel parameters

fabtools.system.getsysctl(_key)[source]
Get a kernel parameter.
Example:
from fabtools.system import getsysctl print “Max number of open files:”, get_sysctl(‘fs.file-max’)
**fabtools.system.set_sysctl(_key
, value)**[source]
Set a kernel parameter.
Example:
import fabtools # Protect from SYN flooding attack fabtools.system.set_sysctl(‘net.ipv4.tcp_syncookies’, 1)

Locales

fabtools.system.supported_locales()[source]
Gets the list of supported locales.
Each locale is returned as a (locale, charset) tuple.

Time

fabtools.system.time()[source]
Return the current time in seconds since the Epoch.
Same as time.time()