| Trees | Indices | Help |
|
|---|
|
|
Ganeti utility module.
This module holds functions that can be used in both daemons (all) and the command line scripts.
|
|||
|
RunResult Holds the result of running external programs. |
|||
|
HostInfo Class implementing resolver and hostname functionality |
|||
|
FileLock Utility class for file locks. |
|||
|
SignalHandler Generic signal handler class. |
|||
|
FieldSet A simple field set. |
|||
|
|||
| RunResult |
|
||
| tuple |
|
||
| int |
|
||
|
|||
|
|||
| str |
|
||
| dict |
|
||
|
|||
|
|||
| boolean |
|
||
| int |
|
||
| None or str |
|
||
| dict |
|
||
| boolean |
|
||
| list |
|
||
|
|||
| a regular expression match object |
|
||
| boolean |
|
||
| str |
|
||
| str |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
| str |
|
||
| str |
|
||
| str |
|
||
|
|||
| bool |
|
||
| list |
|
||
|
|||
| str |
|
||
| str |
|
||
|
|||
| str |
|
||
| None or int |
|
||
| int |
|
||
|
|||
|
|||
| list |
|
||
| boolean |
|
||
| boolean |
|
||
|
|||
|
|||
| int |
|
||
| str |
|
||
|
|||
|
|||
|
|||
| str or None |
|
||
| None or str |
|
||
|
|||
|
|||
| int |
|
||
|
|||
|
|||
| str |
|
||
|
|||
|
|||
|
|||
|
|||
sha1 = sha.new
|
|||
_locksheld = []
|
|||
_re_shell_unquoted = re.compile('^[-.,=:/_+@A-Za-z0-9]+$')
|
|||
debug_locks = False
|
|||
no_fork = False
|
|||
Imports: os, time, subprocess, re, socket, tempfile, shutil, errno, pwd, itertools, select, fcntl, resource, logging, signal, StringIO, sha, errors, constants
|
|||
Execute a (shell) command. The command should not read from its standard input, as it will be closed.
|
Run a command and return its output.
|
Run a command and save its output to a file.
|
Remove a file ignoring some errors. Remove a file, ignoring non-existing ones or directories. Other errors are passed.
|
Renames a file.
|
Compute the fingerprint of a file. If the file does not exist, a None will be returned instead.
|
Compute fingerprints for a list of files.
|
Ensure a dictionary has a required set of keys. For the given dictionaries target and template, ensure target has all the keys from template. Missing keys are added with values from template.
|
Force the values of a dict to have certain types.
|
Check if a given pid exists on the system.
Note: zombie status is not handled, so zombie processes will be returned as alive |
Read a pid from a file.
|
Try to match a name against a list. This function will try to match a name like test1 against a list like
|
List volume groups and their size
|
Check whether the given bridge exists in the system
|
Sort a list of strings based on digit and non-digit groupings. Given a list of names The sort algorithm breaks each name in groups of either only-digits or no-digits. Only the first eight such groups are considered, and after that we just use what's left of the string.
|
Try to convert a value ignoring errors. This function tries to apply function fn to val. If no
|
Verifies the syntax of an IPv4 address. This function checks if the IPv4 address passes is valid or not based on syntax (not IP range, class calculations, etc.).
|
Verifies is the given word is safe from the shell's p.o.v. This means that we can pass this to a command via the shell and be sure that it doesn't alter the command line and is passed as such to the actual command. Note that we are overly restrictive here, in order to be on the safe side.
|
Build a safe shell command line from the given arguments. This function will check all arguments in the args list so that they are valid shell parameters (i.e. they don't contain shell metacharacters). If everything is ok, it will return the result of template % args.
|
Formats an incoming number of MiB with the appropriate unit.
|
Tries to extract number and scale from the given string. Input must be in the format |
Adds an SSH public key to an authorized_keys file.
|
Removes an SSH public key from an authorized_keys file.
|
Sets the name of an IP address and hostname in /etc/hosts.
|
Wrapper around SetEtcHostsEntry.
|
Removes a hostname from /etc/hosts. IP addresses without names are removed from the file.
|
Wrapper around RemoveEtcHostsEntry.
|
Creates a backup of a file.
|
Quotes shell argument according to POSIX.
|
Quotes a list of shell arguments.
|
Simple ping implementation using TCP connect(2). Check if the given IP is reachable by doing attempting a TCP connect to it.
|
Check if the current host has the the given IP address. Currently this is done by TCP-pinging the address from the loopback address.
|
Returns a list of visible files in a directory.
|
Try to get the homedir of the given user. The user can be passed either as a string (denoting the name) or as an integer (denoting the user id). If the user is not found, the 'default' argument is returned, which defaults to None. |
Returns a random UUID.
Note: This is a Linux-specific method as it uses the /proc filesystem. |
Generates a random secret. This will generate a pseudo-random secret, and return its sha digest (so that it can be used where an ASCII string is needed).
|
Make required directories, if they don't exist.
|
Reads a file.
|
(Over)write a file atomically. The file_name and either fn (a function taking one argument, the file descriptor, and which should write the data to it) or data (the contents of the file) must be passed. The other arguments are optional and allow setting the file mode, owner and group, and the mtime/atime of the file. If the function doesn't raise an exception, it has succeeded and the target file has the new contents. If the function has raised an exception, an existing target file should be unmodified and the temporary file should be removed.
|
Returns the first non-existing integer from seq. The seq argument should be a sorted list of positive integers. The first time the index of an element is smaller than the element value, the index will be returned. The base argument is used to start at a different offset, i.e.
Example:
|
Returns a list with unique elements. Element order is preserved.
|
Predicate to check if a MAC address is valid. Checks whether the supplied MAC address is formally correct, only accepts colon separated format.
|
Sleep for a fixed amount of time.
|
Close a file descriptor ignoring errors.
|
Close file descriptors. This closes all file descriptors above 2 (i.e. except stdin/out/err).
|
Daemonize the current process. This detaches the current process from the controlling terminal and runs it in the background as a daemon.
|
Compute a ganeti pid file absolute path
|
Write the current process pidfile. The file will be written to constants.RUN_GANETI_DIR/name.pid
|
Remove the current process pidfile. Any errors are ignored.
|
Kill a process given by its pid.
|
Look for a filesystem object in a given path. This is an abstract method to search for filesystem object (files, dirs) under a given search path.
|
Checks if the volume group list is valid. The function will check if a given volume group is in the list of volume groups and has a minimum size.
|
Splits time as floating point number into a tuple.
|
Merges a tuple into time as a floating point number.
|
Get the node daemon port for this cluster. Note that this routine does not read a ganeti-specific file, but
instead uses
|
Configures the logging module.
|
Return the last lines from a file.
Note: this function will only read and parse the last 4KB of the file; if the lines are very long, it could be that less than the requested number of lines are returned |
Return a 'safe' version of a source string. This function mangles the input string and returns a version that should be safe to display/encode as ASCII. To this end, we first convert it to ASCII using the 'backslashreplace' encoding which should get rid of any non-ASCII chars, and then we process it through a loop copied from the string repr sources in the python; we don't use string_escape anymore since that escape single quotes and backslashes too, and that is too much; and that escaping is not stable, i.e. string_escape(string_escape(x)) != string_escape(x).
|
Nicely join a set of identifiers.
|
Synchronized object access decorator. This decorator is intended to protect access to an object using the object's own lock which is hardcoded to '_lock'. |
Locks a file using POSIX locks.
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Fri Sep 3 12:34:35 2010 | http://epydoc.sourceforge.net |