fabtools.system

System settings

OS detection

fabtools.system.distrib_id()[source]

Get the OS distribution ID.

Returns one of "Debian", "Ubuntu", "RHEL", "CentOS", "Fedora", "Archlinux", "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, 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.set_hostname(hostname, persist=True)[source]

Set the hostname.

Kernel parameters

fabtools.system.get_sysctl(key)[source]

Get a kernel parameter.

Example:

from fabtools.system import get_sysctl

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()

Read the Docs v: 0.17.0
Versions
latest
0.17.0
0.16.0
0.15.0
0.14.0
0.13.0
0.12.0
0.11.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.