Statistics
| Branch: | Tag: | Revision:

root / test / ganeti.utils_unittest.py @ 72bb6b4e

History | View | Annotate | Download (10.6 kB)

# Date Author Comment
538ca33a 08/25/2011 01:49 pm Tsachy Shacham

Added function for parsing multiple CPU pinning mask

Signed-off-by: Tsachy Shacham <>
Reviewed-by: Michael Hanselmann <>

90e234a6 01/11/2011 05:33 pm Michael Hanselmann

utils: Move NewUUID to utils.io

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

7ebd876f 01/11/2011 05:33 pm Michael Hanselmann

utils: Move more text-related code

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

a4ccecf6 01/11/2011 05:33 pm Michael Hanselmann

utils: Move process-related code into separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

7d444d59 01/11/2011 05:32 pm Michael Hanselmann

utils: Move RunningTimeout to utils.algo

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

17b97ab3 01/11/2011 05:32 pm Michael Hanselmann

utils: Move code manipulating /etc/hosts to separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

c50645c0 01/11/2011 04:25 pm Michael Hanselmann

utils: Move X509-related code into separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

3865ca48 01/11/2011 04:25 pm Michael Hanselmann

utils: Move I/O-related code into separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

9d1b963f 01/11/2011 04:25 pm Michael Hanselmann

utils: Move code related to file locking into separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

7831fc5f 01/11/2011 04:25 pm Michael Hanselmann

utils: Move wrappers into separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

7b4baeb1 01/11/2011 04:24 pm Michael Hanselmann

utils: Use function to disable fork

Use a function instead of a variable written by another module.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

8342c325 01/11/2011 04:24 pm Michael Hanselmann

utils: Change RemovePidFile to take path, not name

This avoids having to monkey-patch the utils module for unittests.
Monkey patching is evil and caused a bug while moving code around.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

f21bb4b7 01/10/2011 06:16 pm Michael Hanselmann

utils: Move hashing-related code into separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

4fd029cf 01/10/2011 06:15 pm Michael Hanselmann

utils: Split algorithms into separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

79d22269 01/10/2011 06:15 pm Michael Hanselmann

utils: Split Retry & co. into separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

7fcffe27 01/10/2011 06:15 pm Michael Hanselmann

utils: Move text-related functions into separate file

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

0f9294f7 12/21/2010 08:14 pm Michael Hanselmann

Remove utils.FormatTimestampWithTZ

Long story short: time.strftime("%Z", time.localtime()) doesn't work,
even though it's documented to be equivalent to time.strftime("%Z").

$ TZ=America/Sao_Paulo python -c 'import time; print
time.strftime("%Z"), time.strftime("%Z", time.localtime())'...

9e691184 12/21/2010 08:14 pm Michael Hanselmann

Ensure temp files from RunCmd tests are removed

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

9f37f689 12/21/2010 03:18 pm Michael Hanselmann

utils: Timezone fixes and tests

- Update docstrings to explicitely mention Epoch
- Fix timezone bug in FormatTimestampWithTZ, where it would
use GMT/UTC when it should use the local timezone
- Add unittests for time formatting functions

Signed-off-by: Michael Hanselmann <>...

153533f3 12/17/2010 05:51 pm Michael Hanselmann

utils.NiceSort: Use sorted(), add keyfunc, unittests

This patch changes utils.NiceSort to use the built-in “sorted()” and
gets rid of the intermediate list. Instead of wrapping the items
ourselves, a key function is used. The caller can specify another key...

9f5a3645 12/06/2010 11:22 pm Michael Hanselmann

utils: Add function to find duplicates in sequence

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Adeodato Simo <>

f40ae421 11/28/2010 04:04 pm Iustin Pop

Improve unittests for the utils module

This just a random collection of unittest improvements. Coverage
increases from 73% to 76%.

Signed-off-by: Iustin Pop <>
Reviewed-by: Michael Hanselmann <>

815bf6d5 11/23/2010 12:01 pm Iustin Pop

Fix utils unittest TestRunCmd.testTimeoutKill

Currently the test executes "/bin/sh -c 'trap "" TERM …" via the shell,
which means we have two shells involved (the parent one and the child
one, which does the trap). For some weird reason, this works for older...

7f81e2b9 11/19/2010 06:24 pm Iustin Pop

Temporarily remove the interactive tests

make check < /dev/null breaks these tests. Until we have change RunCmd
to override stdin, we need to remove them.

Signed-off-by: Iustin Pop <>
Reviewed-by: Michael Hanselmann <>

c74cda62 11/19/2010 05:19 pm René Nussbaumer

Support timeouts in RunCmd

Further investigations have to be done for merging some of these bits
together with import-export daemon which uses similiar logic.

Signed-off-by: René Nussbaumer <>
Reviewed-by: Michael Hanselmann <>

e6784773 11/16/2010 05:19 pm René Nussbaumer

Adding unittests for RunningTimeout

Signed-off-by: René Nussbaumer <>
Reviewed-by: Michael Hanselmann <>

4138d39f 10/22/2010 06:22 pm Iustin Pop

Add a "safe" file wrapper over WriteFile

Signed-off-by: Iustin Pop <>
Reviewed-by: Michael Hanselmann <>

9e100285 10/22/2010 06:21 pm Iustin Pop

Add functions to read and compare file 'ID's

Signed-off-by: Iustin Pop <>
Reviewed-by: Michael Hanselmann <>

691c81b7 10/20/2010 03:53 pm Michael Hanselmann

utils: Add function to find items in dictionary using regex

This basically extracts a small piece of code from ganeti-rapi and puts
it into a utility function. RAPI resources are found using a dictionary
in which the keys can either be static strings or compiled regular...

5c4d37f9 10/07/2010 11:31 am Iustin Pop

Use only one version of WritePidFile

This patch merges the pid file handling used for ganeti-* daemons and
impexp daemons. The latter version is used, since it's more reliable:
uses locked pid files as opposed to checking 'live' processes.

Signed-off-by: Iustin Pop <>...

72884fef 10/05/2010 06:08 pm Michael Hanselmann

Merge branch 'devel-2.2'

  • devel-2.2:
    Add simple unittest for utils.CommaJoin
    LUDelTags: Improve formatting of error message
    LUGetTags: Acquire locks in shared mode
    gnt-cluster: Replace hardcoded “xenvg” with value retrieved from master
    Export VG name via LUQueryConfigValues...
750022e0 10/05/2010 05:59 pm Michael Hanselmann

Add simple unittest for utils.CommaJoin

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

05636402 09/29/2010 02:42 pm Guido Trotter

Move the uuid regexp to utils.py

Signed-off-by: Guido Trotter <>
Reviewed-by: Iustin Pop <>

59525e1f 07/30/2010 06:33 pm Michael Hanselmann

Add new parameter type “maybe string”

Before strict checking was implemented, NIC IP addresses could be set
to “None”. Commit bd061c35 added more strict checking, including
enforcing the IP address to be a string. With this new type, it
can again be set to None....

31155d60 07/16/2010 12:47 pm Balazs Lecz

Add ParseCpuMask() utility function

Also adds a generic ParseError exception.

Signed-off-by: Balazs Lecz <>
Reviewed-by: Michael Hanselmann <>

858905fb 07/15/2010 05:38 pm Michael Hanselmann

Move ShellWriter class to utils

Also add unittest.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

9dc71d5a 07/15/2010 05:37 pm Michael Hanselmann

Rename test for utils.IgnoreProcessNotFound

Usually our tests are named “Test…”.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Manuel Franceschini <>

926feaf1 07/12/2010 06:59 pm Manuel Franceschini

Use reserved documentation IPs and domains

Use RFC 5737 IP addresses and RFC 2606 domain names in all
unittests, docs, qa and docstrings.

Signed-off-by: Manuel Franceschini <>
Reviewed-by: Iustin Pop <>

a744b676 07/09/2010 04:37 pm Manuel Franceschini

Introduce lib/netutils.py

This patch moves network utility functions to a dedicated module.

Signed-off-by: Manuel Franceschini <>
Reviewed-by: Iustin Pop <>

1b045f5d 07/06/2010 05:10 pm Balazs Lecz

Add utils.GetMounts()

Signed-off-by: Balazs Lecz <>
Reviewed-by: Michael Hanselmann <>

cf0e6df7 06/30/2010 02:43 pm Manuel Franceschini

IPv6 support for utils.TcpPing()

Signed-off-by: Manuel Franceschini <>
Reviewed-by: Michael Hanselmann <>

2632795d 06/30/2010 02:32 pm Manuel Franceschini

Add function to retrieve family of an ip address

Signed-off-by: Manuel Franceschini <>
Reviewed-by: Guido Trotter <>

c0c3fa27 06/30/2010 02:32 pm Manuel Franceschini

Introduce utils.IsValidIP{4,6}()

This patch introduces functions to check for valid IPv4 and IPv6
addresses and converts IsValidIP() to return True if it is either a IPv4
or a IPv6 address.

For now we do not change the functional behavior and replace IsValidIP...

158206e0 06/30/2010 02:17 pm Manuel Franceschini

User assertFalse instead of assert_(not ...)

Signed-off-by: Manuel Franceschini <>
Reviewed-by: Guido Trotter <>

9769bb78 06/30/2010 01:41 pm Manuel Franceschini

Rename some constants to facilitate IPv6 support

Signed-off-by: Manuel Franceschini <>
Reviewed-by: Guido Trotter <>

b5b8309d 06/15/2010 12:49 pm Guido Trotter

ListVisibleFiles: do not sort output

Among all users, turns out just one may need the output to be sorted.
All the others can cope without.

Signed-off-by: Guido Trotter <>
Reviewed-by: Iustin Pop <>

28f34048 06/14/2010 07:56 pm Michael Hanselmann

utils: Add function to validate service name

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

560cbec1 06/14/2010 07:55 pm Michael Hanselmann

Handle ESRCH when sending signals

Upon sending signals, ESRCH can be reported when the target no
longer exists.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

57d56130 06/11/2010 05:06 pm Guido Trotter

ListVisibleFiles: do optional sorting

Signed-off-by: Guido Trotter <>
Reviewed-by: Michael Hanselmann <>

f8ea4ada 06/04/2010 12:44 pm Michael Hanselmann

utils: Add function to format seconds

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

a01b500b 06/01/2010 07:40 pm Michael Hanselmann

utils: Add function to check whether process handles a signal

This will be used to avoid a race condition between starting a program (dd
for import/export) and sending signals to it.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

d4d1e3dd 06/01/2010 01:37 pm Guido Trotter

Merge branch 'devel-2.1'

  • devel-2.1:
    Convert gnt-instance list and info to use roman
    gnt-cluster info --roman
    FormatUidPool: provide optional roman conversion
    gnt-node: remove latinfriendlyfields
    Move roman conversion to compat
    Add a new opcode timestamp field...
14aeab22 06/01/2010 11:39 am Guido Trotter

Fix IgnoreSignals on socket.error

Some confusion arose handling EINTR on this function: in python 2.6
socket.error is an IOError, and thus:
- It's an EnvironmentError
- It has an .errno member

In 2.4 and 2.5 it's not, and so its errno variable must be extracted...

716a32cb 06/01/2010 11:34 am Guido Trotter

Move hash functions to the compat module

Since the hash functions' changed their module name between python 2.4
and 2.6, and we have to do an try/import/except trick, we'll do it just
once, for both hash functions, and in compat.py. This also fixes a use...

965d0e5b 06/01/2010 11:34 am Guido Trotter

Fix {Ignore, RetryOn}Signals on socket.error

Some confusion arose handling EINTR on those functions: in python 2.6
socket.error is an IOError, and thus:
- It's an EnvironmentError
- It has an .errno member

In 2.4 and 2.5 it's not, and so its errno variable must be extracted...

b73360e3 05/31/2010 01:02 pm Balazs Lecz

Make utils.EnsureDirs() ignore umask

EnsureDirs() should create directories with the exact mode requested
in the arguments, but it currently applies the umask.
This patch makes it independent from the umask.

Signed-off-by: Balazs Lecz <>...

31ff0247 05/17/2010 02:17 pm Michael Hanselmann

Merge branch 'devel-2.1'

  • devel-2.1:
    RAPI: /2/{nodes,instances}/$name should return 404 for unknown items
    ganeti-masterd: Improve error logging for client requests
    Return disk_template from LUQueryInstanceData
    RAPI client: Rename Get{Node,Instance}Info, add new GetInstanceInfo...
a3a5f850 05/17/2010 01:33 pm Iustin Pop

Add checks for master IP in cluster verify

This also updates a comment in the unittest for utils.py. We unittest
the new function for two things: correct reporting on real case (for
localhost), and correct reporting with a mocked-out TcpPing that returns...

232144d0 05/14/2010 06:46 pm Guido Trotter

utils.IgnoreSignals

Remove duplicate code between a couple of asyncore related function by
having a function in charge of handling EINTR errors. Unittests included.

Signed-off-by: Guido Trotter <>
Reviewed-by: Michael Hanselmann <>

40523663 05/12/2010 02:40 pm Guido Trotter

Merge branch 'devel-2.1'

  • devel-2.1:
    Convert some ReadFile calls to ReadOneLineFile
    utils.ReadOneLineFile()
    Remove oneline= parameter from utils.ReadFile
    install.rst: update os version and add KVM notes
    INSTALL: update hypervisor requirements
    RAPI client: Fix SSL error reporting for real...
e587b46a 05/12/2010 02:10 pm Guido Trotter

utils.ReadOneLineFile()

Read the first non-empty file line. When strict is set, abort if more
than one line is non-empty. Some unittests inspired by the reverted ones
from commit b774bb106cc28d008e790ad2666eb64c76866fa0, and some new ones.

Signed-off-by: Guido Trotter <>...

582ed043 05/12/2010 02:01 pm Guido Trotter

Remove oneline= parameter from utils.ReadFile

This partially reverts commit b774bb106cc28d008e790ad2666eb64c76866fa0.
Unittests unrelated to that particular functionality but introduced in
that commit are left untouched. Since the temporary directory is now...

5e26633b 05/11/2010 09:25 pm Michael Hanselmann

Merge branch 'devel-2.1'

  • devel-2.1: (29 commits)
    RAPI client: Improve SSL error reporting
    RAPI client: Don't check node role in client
    RAPI client: Update ReplaceInstanceDisks
    RAPI client: Fix behaviour of “allocatable” storage flag
    RAPI client: Encode boolean and None query values...
b774bb10 05/11/2010 02:01 pm Michael Hanselmann

utils.ReadFile: Add parameter to read only one line

Reading only one line is useful for reading passwords from files. This
also adds unittests for utils.ReadFile.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

01144827 05/10/2010 12:44 pm Guido Trotter

Merge branch 'devel-2.1'

  • devel-2.1: (22 commits)
    NEWS: fix empty lines
    Fix a unittest name and docstring
    Force ssh to allocate a tty
    Fix a unittest docstring
    IsProcessAlive: retry stat() a few times
    Retry{Again,Timeout}: explain reraising
    utils.Retry: pass up timeout arguments...
05489142 05/10/2010 12:23 pm Guido Trotter

Fix a unittest name and docstring

The docstring has been copied by the name, but the name reports a
misspell of the function it is actually testing.

Signed-off-by: Guido Trotter <>
Reviewed-by: Balazs Lecz <>

99729b66 05/10/2010 12:05 pm Guido Trotter

Fix a unittest docstring

Signed-off-by: Guido Trotter <>
Reviewed-by: Balazs Lecz <>

506be7c5 05/10/2010 11:56 am Guido Trotter

utils.Retry: pass up timeout arguments

If Retry has to fail with RetryTimeout, it might be useful to pass the
Retry argument to RetryTimeout, to help debugging outside the Retry
cycle. We also define a RetryTimeout.RaiseInner() helper, to re-raise an
exception passed to RetryAgain. All served with a side of unit tests....

45cc4913 05/10/2010 11:56 am Guido Trotter

Add a few Retry unittests

Check that Retry actually times out, and actually retries.

Signed-off-by: Guido Trotter <>
Reviewed-by: Iustin Pop <>

3718bf6d 05/04/2010 03:38 pm Michael Hanselmann

Add optional “salt” argument to utils.{,Verify}Sha1Hmac

We're using salted hashes all over the place.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

615aaaba 05/04/2010 03:38 pm Michael Hanselmann

Use utility functions for HMAC

HMAC will be used in more places. Centralizing some parts can't hurt.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: René Nussbaumer <>

24d70417 04/29/2010 04:30 pm Michael Hanselmann

Move cmdlib._VerifyCertificate to utils

This function will also be useful for inter-cluster instance
moves for verifying certificates.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: René Nussbaumer <>

1077f25c 04/26/2010 02:30 pm Michael Hanselmann

Merge branch 'devel-2.1'

  • devel-2.1:
    masterd: Log PID, UID and GID of connected client
    qa: Use qa_utils.UploadFile to upload rapi_users file
    devel/upload: add --no-debug option

Conflicts:
lib/utils.py: Trivial

Signed-off-by: Michael Hanselmann <>...

f93f2016 04/23/2010 06:07 pm Michael Hanselmann

masterd: Log PID, UID and GID of connected client

This can be very useful if client programs run as non-root.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

cea881e5 04/21/2010 08:48 pm Michael Hanselmann

Add separate module for backported language functionality

utils.py, where they were before, is already huge.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

fde0203b 04/21/2010 07:26 pm Michael Hanselmann

utils: Add function for partial application of function arguments

The function's code was mostly copied from Python's documentation
and it's equivalent to “functools.partial” in Python 2.5 and above.

Signed-off-by: Michael Hanselmann <>...

debed9ae 04/21/2010 04:57 pm Michael Hanselmann

utils: Add function to read locked PID file

This is useful in combination with utils.StartDaemon and will be used for
reading the import/export daemon's PID file.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

af2ae1c0 04/16/2010 03:06 pm Iustin Pop

Merge branch 'devel-2.1'

  • devel-2.1:
    utils: Add class to split string stream into lines
    Fix cluster behaviour with disabled file storage
    Update docstrings in tools/ and enable epydoc
    Forward-port the ganeti 2.0 cfgupgrade
    Add a new tool: sanitize-config...
339be5a8 04/15/2010 06:24 pm Michael Hanselmann

utils: Add class to split string stream into lines

This will be used by the new import/export daemon to split
output by its child processes into lines.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

cf6fee17 04/07/2010 06:47 pm Michael Hanselmann

Merge branch 'devel-2.1'

  • devel-2.1:
    Fix consistency checks in ConfdFilterCallback
    Fix utils.WaitForFdCondition inner retry loop
    Fix bug introduced in 76e5f8b54: mkdir mode
    utils: Move wrapper code around os.makedirs into separate function
    Fix unittest for the rapi client library...
1b429e2a 04/07/2010 04:55 pm Iustin Pop

Fix utils.WaitForFdCondition inner retry loop

Commit dfdc4060 added WaitForFdCondition which uses utils.Retry without
handling timeout exceptions. This breaks any nested retry loops.

This patch fixes the above function, and also changes utils.Retry to
detect and warn future similar cases. In addition, we add a few small...

76e5f8b5 04/07/2010 04:15 pm Michael Hanselmann

utils: Move wrapper code around os.makedirs into separate function

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

921efbb3 04/06/2010 03:32 pm Michael Hanselmann

Merge remote branch 'devel-2.1'

  • devel-2.1:
    Extend ConfdFilterCallback with consistency checks
    Abstract the confd client creation
    Remove unused import from test file
    kvm_flag hypervisor parameter
    Move the runas user at execution time
    Send "501 Not Implemented" back when method not found...
e065714c 03/31/2010 06:51 pm Guido Trotter

Remove unused import from test file

Signed-off-by: Guido Trotter <>
Reviewed-by: Iustin Pop <>

68857643 03/17/2010 05:18 pm Michael Hanselmann

utils: Add functions to sign and verify X509 certs using HMAC

Certificates exchanged via an untrusted third party should be
signed to ensure they haven't been modified.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

b701a5df 03/15/2010 05:50 pm Iustin Pop

Merge remote branch 'origin/devel-2.1'

  • origin/devel-2.1:
    Implement QA tests for disk template changes
    Update instance modify documentation
    Implement conversion from drbd to plain
    Implement conversion from plain to drbd
    Abstract check that an instance is down...
0babc371 03/15/2010 04:39 pm Michael Hanselmann

utils.RunCmd: Test case with reset_env set and setting variables

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

bb3776b4 03/15/2010 04:25 pm Michael Hanselmann

Merge remote branch 'origin/devel-2.1'

  • origin/devel-2.1: (116 commits)
    Implement replacing cluster certs and keys via “gnt-cluster renew-crypto”
    cli: Add helper function to stop and start whole cluster
    cfgupgrade: Use new bootstrap function for certs and keys...
1d466a4f 03/12/2010 05:44 pm Michael Hanselmann

utils.CreateBackup: Use human-readable instead of seconds since Epoch

Seconds since the Epoch are not easily readable by a human. Using a
formatted timestamp makes it easier (e.g.
“….backup-2010-03-12_14_02_43.…”). This patch also makes OS logfiles use
this formatted timestamp....

27e46076 03/12/2010 05:44 pm Michael Hanselmann

utils: Add function to extract X509 cert validity

X509 uses ASN1 GENERALIZEDTIME or UTCTIME to store certificate validity.
pyOpenSSL 0.7 and above allow us to retrieve both “notBefore” and
“notAfter” as strings. Parsing them turned out to be a challenge since...

b4478d34 03/08/2010 05:15 pm Michael Hanselmann

Support passing in file object in utils.FileLock

This way we can re-use file objects opened in other places. Also add more
unittests.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>
Reviewed-by: Iustin Pop <>

bdefe5dd 03/08/2010 05:15 pm Michael Hanselmann

Support arguments in utils.RunInSeparateProcess

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

26288e68 03/08/2010 03:53 pm Iustin Pop

Add a function to validate and normalize hostnames

This differs slightly from the specification, by allowing names to start
with digits, not checking the length of individual components, and
allowing underscores.

Signed-off-by: Iustin Pop <>...

04a69a18 03/08/2010 03:53 pm Iustin Pop

ListVisibleFiles: require normalized path names

This patch changes ListVisibleFiles to raise ProgrammerError if it's
passed a non-absolute/non-normalized path name, and adds unittests for
this behaviour.

Signed-off-by: Iustin Pop <>
Reviewed-by: Michael Hanselmann <>

4bb678e9 03/08/2010 03:46 pm Iustin Pop

utils: Add a PathJoin function

This will replace os.path.join since it is not safe for directory
traversal issues.

Signed-off-by: Iustin Pop <>
Reviewed-by: Michael Hanselmann <>

6bb65e3a 02/22/2010 06:02 pm Guido Trotter

Implement utils.RunParts and use it for hooks

This function is a generic pythonic version of runparts. We currently
use it in the backend HooksRunner, but we'll use it for running
different directories as well.

Signed-off-by: Guido Trotter <>...

bf4daac9 02/22/2010 06:01 pm Guido Trotter

Add reset_env option to RunCmd

This allows to run a command with only the passed in environment, rather
than just updating the default one with it.

Now with unit testing.

Signed-off-by: Guido Trotter <>
Reviewed-by: Iustin Pop <>

c1dd99d4 02/22/2010 01:46 pm Michael Hanselmann

Add utility function to start daemon

The currently available functions in this direction (utils.RunCmd and
utils.Daemonize) both can not be used to start an external daemon
process. This function takes many steps to ensure the daemon is started
properly and does careful error checking. Unittests are included....

bdd5e420 02/19/2010 04:54 pm Michael Hanselmann

Use OpenSSL module instead of binary to generate certs

This saves us one dependency and saves us from complicated handling of
external files if we need key and certificate separated from each other.

At the same time, the number of bits used for RSA keys is increased from...

287a1740 02/19/2010 04:53 pm Michael Hanselmann

utils: Add function to set O_NONBLOCK on file descriptor

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>