Statistics
| Branch: | Tag: | Revision:

root / lib / utils @ c1912a48

# Date Author Comment
63c73073 12/21/2012 01:40 pm Bernardo Dal Seno

LVM disk creation uses dedicated PVs

When exclusive_storage is set, PVs are allocated according to the
design-partitioned design doc.

Signed-off-by: Bernardo Dal Seno <>
Reviewed-by: Iustin Pop <>

59726e15 12/21/2012 01:40 pm Bernardo Dal Seno

Added class to contain information about a PV

This makes the code more readable and easier to upgrade.
bdev.LogicalVolume.GetPVInfo and the code that depends on it have been
refactored to use the new class.

utils.CheckVolumeGroupSize() has been moved to lib/utils/lvm.py, where more...

80a0546b 12/20/2012 06:16 pm Michele Tartara

Add function for generating UUIDs in the Haskell codebase

Its first use will be to generate the salt for ConfD requests of the Haskell
client, as in the Python client.

Unit test added as well.

Signed-off-by: Michele Tartara <>
Reviewed-by: Iustin Pop <>

eac9b7b8 12/20/2012 05:08 pm Michael Hanselmann

Add utility to format dictionary as key=value strings

This will be used in QA to format network interface parameters.

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

d242923c 12/04/2012 11:22 am Michael Hanselmann

utils.text: Function to verify MAC address prefix

The network management code needs to verify a MAC address prefix.
Instead of (ab)using NormalizeAndValidateMac, clean code should be used.
Unit tests for NormalizeAndValidateMac are updated and new ones for...

0602cef3 12/03/2012 04:33 pm Michael Hanselmann

Factorize code for checking node daemon certificate

This code is going to be used by a new utility for setting up the node
daemon. Unit tests are updated/added.

Additionally, the certificate and key stored in “server.pem” are
verified, too.

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

86b9a385 11/30/2012 11:44 am Michael Hanselmann

Fix breakage introduced in commit a8b3b09

The order of the calls to “ctx.use_privatekey” and “ctx.use_certificate”
was wrong, leading to an exception being thrown.

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

a8b3b09d 11/30/2012 10:51 am Michael Hanselmann

Factorize SSL context setup for certificate check

This code will also be used by the node daemon setup utility.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Helga Velroyen <>

796b5152 11/27/2012 12:54 pm Michael Hanselmann

Factorize logging setup in tools

Most tools had their own “SetupLogging” function, but they were all
essentially the same. This patch adds a generic version to “utils.log”
and provides unit tests.

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

3c286190 11/20/2012 07:51 pm Dimitris Aragiorgis

Fixes to pass pep8 (make lint)

Signed-off-by: Dimitris Aragiorgis <>
Reviewed-by: Iustin Pop <>

2f18052f 11/14/2012 10:16 am Michael Hanselmann

utils.process.RunResult: Always set "fail_reason" attribute

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

09b72783 11/12/2012 06:51 pm Michael Hanselmann

RunCmd: Expose "postfork" callback

The “_postfork_fn” parameter was only used for tests until now. To
implement a good locking scheme, remote commands must also make use of
this callback to release a lock when the command was successfully
started (but did not yet finish)....

10b86782 11/06/2012 07:59 pm Michael Hanselmann

Add utility to check if file is executable

This replaces direct calls to “os.access” and
“os.path.exists”/“os.path.isfile”.

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

2826897c 11/06/2012 04:00 pm Michael Hanselmann

utils.io: Improve handling of double and single slashes

Up until now “IsBelowDir("/", …)” would never return True. The reason
was that an additional slash was added to the root path resulting in
“//", which is “implementation-defined” in posix and treated specially...

d5d76ab2 10/26/2012 05:27 pm Michael Hanselmann

RunCmd: Support standard input file descriptor

This patch changes “utils.RunCmd” to accept a file-like object or a
numeric file descriptor which will be used as the command's standard
input. One use-case will be to pass all necessary data to
“prepare-node-join”....

6b96df59 10/26/2012 03:37 pm Michael Hanselmann

utils.x509: Factorize code to extract X509 certificate

This will be useful in “gnt-node add”.

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

d12b9f66 10/23/2012 06:32 pm Michael Hanselmann

Add initial implementation of prepare-node-join

This is a new tool as per the design document “design-ssh-setup”. It
receives a JSON data structure on its standard input and configures the
SSH daemon and root's SSH keys accordingly. Unit tests are included....

0232b768 10/19/2012 02:43 pm Michael Hanselmann

Compare significant fields only for simple SSH keys

For simple SSH keys, that is those without options such as
“command="…"”, only the first two parts need to be compared. The third
field is a free-form comment.

This patch changes the comparison used in...

ee045466 10/11/2012 12:56 pm Michael Hanselmann

Move constant for /etc/hosts to pathutils

Needed for coming patches.

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

6a9b9778 10/05/2012 04:52 am Michael Hanselmann

utils.FilterEmptyLinesAndComments: Return list

We don't use generators often and lists are easier to re-use.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Bernardo Dal Seno <>

2cbe9af3 10/04/2012 04:42 pm Michael Hanselmann

Factorize removing comments and empty lines from string

This will also be used for verifying the file storage directory.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Bernardo Dal Seno <>

2b3b41df 09/21/2012 07:07 am Michael Hanselmann

utils.filelock: Remove executable bit from lock files

There's no need for lock files to be executable.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Bernardo Dal Seno <>

4af458e3 09/19/2012 04:54 pm Michael Hanselmann

ShellWriter: Add parameter to disable indentation

This will be used to write a more compact bash completion script.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Bernardo Dal Seno <>

111a7d04 09/18/2012 06:11 pm Michael Hanselmann

Migrate lib/utils/*.py from constants to pathutils

File system paths moved from constants to pathutils.

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

3329f4de 09/18/2012 05:58 pm Michael Hanselmann

constants: Move most paths to separate module

This is inpreparation for the implementation of virtual clusters. Many
paths will change based on an environment variable and are no longer
constant and should no longer be in “constants.py”. Since “constants.py”...

5ae4945a 08/23/2012 02:41 pm Iustin Pop

Bump pep8 version to 1.2

Debian Wheezy will ship with this version, and it has many improved checks compared to 0.6, so let's:

- bump version in the docs
- silence some new checks that are wrong due to our indent=2 instead of 4
- fix lots of errors in the code where the indentation was wrong by 1...

32be86da 06/15/2012 04:48 pm René Nussbaumer

Verify user supplied dicts against defaults

This verifies the user (especially in nested dicts) does not
provide a key which is not seen in the defaults dict for that dict.

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

f97a7ada 05/09/2012 12:12 pm Iustin Pop

Allow clock skews in certificate verification

Currently we allow for up to NODE_MAX_CLOCK_SKEW time difference
between nodes in some operations, but not everywhere: SSL certificate
verification (import/export, both intra and inter-cluster) has a zero
limit (downwards), and a week upwards. This can cause even...

21864565 04/26/2012 05:17 pm Iustin Pop

Log all external commands execution

This logs all external commands in normal (non-debug) mode. This will
leak the DRBD secrets, but in any case we do log failed commands, so
it's not a significant change.

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

dd27bc21 04/19/2012 09:04 pm Michael Hanselmann

utils.algo: Use str.isdigit instead of regular expression

str.isdigit is about 4x faster than using a regular expression ("\d+").
This is in the inner sorting code so speed matters.

$ python -m timeit -s 'import re; s = re.compile("^\d+$")' \
's.match(""); s.match("Hello World"); s.match("1234")'...

26a72a48 03/30/2012 03:02 pm Michael Hanselmann

Merge cli.FormatTimestamp and utils.FormatTime

… to some degree at least. Unittests are included.

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

81f7ea25 03/09/2012 04:46 pm Iustin Pop

Fix lint error in commit 035b33e2

Commit 035b33e2 forgot one blank space, and current pylint in Debian
Sid doesn't run on our code… so I didn't realise this until after
commit, sorry.

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

035b33e2 03/07/2012 10:59 pm Iustin Pop

Fix tempfile reset code & test on newer Python

Python 2.7.3 (rc status) and 3.2.3/3.3 (rc, respectively alpha status)
have fixed http://bugs.python.org/issue12856 which we worked around
ourselves.

This means two things:

- we don't need to manually reset the module...

3ccb3a64 02/21/2012 05:23 pm Michael Hanselmann

Replace single- with double-quotes

In at least two cases "%s" is replaced with str(), too.

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

5401c39d 02/17/2012 05:39 pm Michael Hanselmann

utils.text: Add function to truncate string

The function adds an ellipse if the string was actually truncated. Also
start using it in mcpu for result checks (where the message is also
slightly changed to use a colon).

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

59d81cb3 01/19/2012 03:14 pm Michael Hanselmann

Merge branch 'devel-2.5'

  • devel-2.5:
    Fix wrong option names in QA and cluster-merge
    Bump version to 2.5.0~rc5, update NEWS
    Add UnescapeAndSplit unittest for multi-escapes
    Fix a bug in command line option parsing code
    cli: Disable abbreviation matching for options...
ecabe27e 01/19/2012 02:42 pm Nikos Skalkotos

Fix a bug in command line option parsing code

Fix bug affecting command line options of "keyval" type. Although
escaping commands with \ is supported, it is is not applied to the
input recursively.

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

380bb53a 01/10/2012 05:16 pm Michael Hanselmann

utils.ResetTempfileModule: Improve performance

This function is called for after every fork (e.g. for handling an RPC
request). With the changes in this patch generating the next random
filename is about 30% faster.

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

2635bb04 01/06/2012 01:34 pm Michael Hanselmann

Move helper class from watcher to utils.io

“FileStatHelper” can be used together with “ReadFile” to a file's status
while it's opened. This avoids certain race conditions.

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

aa66c183 12/22/2011 07:16 pm Michael Hanselmann

Merge branch 'devel-2.5'

  • devel-2.5:
    jqueue: Factorize checking job processor's result
    jqueue unittest: Rename simple fake-job class
    jqueue: Fix epylint errors introduced in 37d76f1e4
    jqueue: Fix deadlock between job queue and dependency manager...
eea3b572 12/22/2011 03:12 pm Bernardo Dal Seno

noded: Fix /etc/hosts group ownership

When Ganeti was compiled with the option of running as a different
user/group, the group ownership of /etc/hosts was set to gnt-daemons. Now
permissions for /etc/hosts are preserved (or set correctly).

Signed-off-by: Bernardo Dal Seno <>...

c47eddb8 12/22/2011 03:12 pm Bernardo Dal Seno

utils.WriteFile: Add new parameter to preserve file permissions

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

b6522276 12/08/2011 06:21 pm Michael Hanselmann

utils.io.WritePidFile: Improve error reporting

If the PID file is already locked by another process, try to read
the content and report it as part of the error message.

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

eb93b673 12/08/2011 06:03 pm Guido Trotter

Move ErrnoOnStr backend function to utils

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

2dbc6857 12/08/2011 12:42 pm Michael Hanselmann

utils.ListVisibleFiles: Hide “lost+found” directories

If a “lost+found” directory is found at a filesystem's root path it is
ignored. In all other cases directory entries named “lost+found” are
treated normally. Unittests are included. Fixes issue 153.

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

9c709b31 11/16/2011 10:41 am René Nussbaumer

algo: Make a dict from an flat list

This is in preparation to take deeper dict constructs from the command
line. You can feed the optionslist directly constructed of type
"identkeyval" to it and it returns a fully deflated dict.

This is mainly needed for the resource model changes where we have to...

6d0accae 11/04/2011 08:09 am Michael Hanselmann

utils.algo: Add utility to convert sequence to dictionary

Useful for converting list of query fields to a dictionary and to
convert RPC definitions. Includes duplicate detection.

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

d60946d9 11/02/2011 05:28 pm René Nussbaumer

utils.algo: Add a function to insert a list into a list

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

7dcf333d 10/31/2011 05:54 pm Michael Hanselmann

Merge branch 'devel-2.5'

  • devel-2.5:
    Fix wrong headers and licences
    Update NEWS and increase to 2.4.5
    Fix parameters of RpcResult in hooks unit tests
    Fix a too long line.
    Move RenameFile to the new functions
    ensure_dirs: Move some useful functions into utils....
9c2b3a70 10/26/2011 11:42 am René Nussbaumer

Move RenameFile to the new functions

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

b81b3c96 10/26/2011 11:42 am René Nussbaumer

ensure_dirs: Move some useful functions into utils.

With this change we can easily reuse this functionality where it makes
sense on other parts of Ganeti.

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

cdf71b12 10/25/2011 05:05 pm Andrea Spadaccini

Add the JoinDisjointDicts function to utils.algo

Add a function that joins two dictionaries, enforcing the constraint
that the two key sets should be disjoint. Also, add unit tests for this
function.

Signed-off-by: Andrea Spadaccini <>...

5fe4a65b 10/24/2011 03:50 pm Michael Hanselmann

Un-revert comments in utils.mlock

These updates and clarifications are still useful.

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

dce20078 10/24/2011 03:49 pm Michael Hanselmann

utils.ShellWriter: Don't indent empty lines

Empty lines shouldn't get indented. Unittest included.

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

97298dc9 10/21/2011 04:16 pm René Nussbaumer

Merge branch 'stable-2.5' into devel-2.5

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

833391a0 10/21/2011 04:00 pm René Nussbaumer

Merge branch 'devel-2.4' into stable-2.5

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

8e5a705d 10/20/2011 03:43 pm René Nussbaumer

Fix queue archive creation with wrong permissions

On a master failover some of the archive dirs might have wrong
permissions in the non-root model. This is due to the nature of noded
still running as root and the job queue is synced that way. This patch
will fix this behaviour by setting the permissions accordingly....

8dc76d54 10/20/2011 12:22 pm Guido Trotter

Revert "Rename utils.mlock to utils.cfunc"

The rename is not needed either, since we're not adding more code as of
now.
This reverts commit 57ca011e1cd2681948969724e2646edaac22da28.

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

142c1ad0 10/20/2011 12:22 pm Guido Trotter

Revert "utils.cfunc: Cleanup, more flexibility"

We discussed that this is not needed right now, and it breaks existing
functionality and unittests.

This reverts commit 6915fe26da8dce41fc967d761f005390aa956161.

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

0aee8ee9 10/18/2011 05:21 pm Guido Trotter

Revert "Implementation of TLS-protected SPICE connections"

This reverts commit b6267745ede04b3c943bc02e004bdb9347e0f564.
This commit will be readded on master.

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

6915fe26 10/17/2011 06:05 pm Michael Hanselmann

utils.cfunc: Cleanup, more flexibility

- Split code using ctypes directly into a helper class
- Don't load “libc.so.6”, but use handle for main program instead (see
comment in code)
- Clarify comment on errno with older ctypes versions
- Rename unittest since it can't be used for other functions (modifies...

57ca011e 10/17/2011 06:05 pm Michael Hanselmann

Rename utils.mlock to utils.cfunc

Renaming so that more code using ctypes could be added to the same file.

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

ea9c753d 10/04/2011 09:34 pm Andrea Spadaccini

Merge branch 'devel-2.5'

  • devel-2.5:
    cluster-merge: log an info message at node readd
    Bump version to 2.5.0~rc1
    Fix issue when verifying cluster files
    Revert "utils.log: Write error messages to stderr"
    Fix adding nodes after commit 64c7b3831dc...
a080bab8 10/04/2011 09:32 pm Andrea Spadaccini

Merge branch 'stable-2.5' into devel-2.5

Signed-off-by: Andrea Spadaccini <>
Reviewed-by: René Nussbaumer <>

d728ac75 10/03/2011 01:52 pm Michael Hanselmann

Revert "utils.log: Write error messages to stderr"

This reverts commit 34aa8b7c4bb6f5e2e788108e024c9cd70bdb3431. Writing
error messages to stderr would also include backtraces, something we
tried to avoid in the past.

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

3398bff1 09/30/2011 06:23 pm Andrea Spadaccini

Merge branch 'devel-2.5'

  • devel-2.5:
    Use --yes to deactivate master ip in cluster merge
    Use deactivate-master-ip in cluster-merge
    Add gnt-cluster commands to toggle the master IP
    Split starting and stopping master IP and daemons
    listrunner: Don't pass arguments if there are none...
cea3abbd 09/30/2011 05:45 pm Andrea Spadaccini

Merge branch 'stable-2.5' into devel-2.5

  • stable-2.5:
    listrunner: Don't pass arguments if there are none
    ssh: Quote strings in error message
    utils.log: Write error messages to stderr
    Add signal handling doc to hbal man page
    Fix handling of cluster verify hooks...
34aa8b7c 09/30/2011 01:10 pm Michael Hanselmann

utils.log: Write error messages to stderr

When “gnt-cluster copyfile” failed it would only print “Copy of file …
to node … failed”. A detailed message is written using logging.error.
Writing error messages to stderr can be helpful in figuring out what
went wrong (the messages also go to the log file, but not everyone might...

f8326fca 09/29/2011 12:41 pm Andrea Spadaccini

Move _TimeoutExpired to utils

Signed-off-by: Andrea Spadaccini <>
Reviewed-by: Michael Hanselmann <>

0c1a5b1e 09/26/2011 05:33 pm Agata Murawska

TemporaryFilesManager implementation

Signed-off-by: Agata Murawska <>
Reviewed-by: Michael Hanselmann <>

5916e61a 09/20/2011 06:50 pm Andrea Spadaccini

Merge branch 'devel-2.5'

  • devel-2.5:
    Add tls_ciphers and use_vdagent options
    Updated man pages with new SPICE TLS options
    Implementation of TLS-protected SPICE connections
    Added SPICE TLS option and related cert paths
    Fix OS creation's error handling when pausing sync...
b6267745 09/20/2011 05:04 pm Andrea Spadaccini

Implementation of TLS-protected SPICE connections

Added support for TLS-protected SPICE connections:

client/gnt_cluster.py, cli.py:
  • added three new parameters to renew-crypto (--new-spice-certificate,
    --spice-certificate, --spice-ca-certificate) and their validation....
e4f4896b 09/15/2011 04:40 pm Guido Trotter

Merge branch 'devel-2.5'

  • devel-2.5: (33 commits)
    htools: remove dead code
    hail: don't select the primary as new secondary
    hail: add an extra safety check in relocate
    Fix RAPI documentation for gnt-instance console
    Add SPICE compression and streaming options...
cf00dba0 09/05/2011 05:30 pm René Nussbaumer

Switch other commonprefix to IsBelowDir

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

fb17bebd 09/05/2011 05:30 pm René Nussbaumer

utils: Introduce IsBelowDir

This is mainly a wrapper to overcome the limitation of commonprefix
which makes a string by string comparisation and reports the common
prefix in both strings. However this is bad for directory handling.

IsBelowDir works around this limitation and should be used in favour of...

b459a848 08/30/2011 11:24 am Andrea Spadaccini

DeprecationWarning fixes for pylint

In version 0.21, pylint unified all the disable-* (and enable-*)
directives to disable (resp. enable). This leads to a lot of
DeprecationWarning being emitted even if one uses the recommended
version of pylint (0.21.1, as stated in devnotes.rst)....

72ce3463 08/26/2011 05:53 pm René Nussbaumer

Merge branch 'devel-2.4' into devel-2.5

Conflicts:
NEWS (trivial)
configure.ac (trivial)
daemons/ensure-dirs.in (deleted)

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

e4a48c7b 08/26/2011 03:53 pm Michael Hanselmann

utils: Fix UnescapeAndSplit parsing bug

If a value passed to UnescapeAndSplit ended with a backslash an
exception would be raised:

$ gnt-instance modify -H mem=x\\ inst1.example.com
[…]
e2 = slist.pop(0)
IndexError: pop from empty list

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

8913ab40 08/25/2011 02:13 pm Michael Hanselmann

Merge branch 'devel-2.5'

  • devel-2.5: (32 commits)
    PEP8 style fixes
    Wrap a few long lines
    listrunner: Avoid exception if machine is rebooted
    Remove wrong type declaration from option
    Fix wrong method name in cluster-merge
    Fix --skip-stop-instances help message...
e687ec01 08/25/2011 01:53 pm Michael Hanselmann

PEP8 style fixes

Identified using the “pep8” utility.

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

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

0e5084ee 08/05/2011 02:06 pm Michael Hanselmann

utils.ReadFile: Add pre-read callback

This will be used by the watcher to store the file's fstat(2). It must
be done from the filehandle.

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

2f1fe558 08/05/2011 12:48 pm René Nussbaumer

Merge branch 'stable-2.4'

Signed-off-by: René Nussbaumer <>
Reviewed-by: Iustin Pop <>

eee68d57 08/04/2011 05:56 pm Agata Murawska

Fixed a typo in utils/process.py

Signed-off-by: Agata Murawska <>
Signed-off-by: Iustin Pop <>
Reviewed-by: Iustin Pop <>

d5fca545 08/03/2011 06:27 pm Iustin Pop

Fix small typo in docstring

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

d0c8c01d 07/25/2011 04:55 pm Iustin Pop

Most boring patch ever

s/'/"/ in (hopefully) the right places.

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

0fa044e7 07/25/2011 04:06 pm Michael Hanselmann

Merge branch 'devel-2.4'

  • devel-2.4:
    Reopen daemon's stdio on SIGHUP
    Reopen log file only once after SIGHUP
    Don't leak file descriptors when setting up daemon output
    Fix aliases in bash completion

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

110f49ef 07/25/2011 04:01 pm Michael Hanselmann

Reopen daemon's stdio on SIGHUP

Before this patch daemons would continue to refer to an old logfile for
their standard I/O if they had been asked to reopen the log (SIGHUP).

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

ad88650c 07/25/2011 04:01 pm Michael Hanselmann

Reopen log file only once after SIGHUP

Commit b6fa9a44 added a re-openable log handler. The log file is
reopened when a daemon is sent a HUP signal. Due to a bug in the code,
fixed by this patch, the log file would be reopened for every single log
message thereafter....

638ac34b 07/25/2011 04:01 pm Michael Hanselmann

Don't leak file descriptors when setting up daemon output

When a daemon's output is configured using “utils.SetupDaemonFDs”, the
function must use dup2(2). Unfortunately the code didn't close the
original file descriptors, leaking them in the process.

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

bd614fa4 05/24/2011 07:40 pm Michael Hanselmann

Merge branch 'devel-2.4'

  • devel-2.4:
    RPC/Backend: Make UploadFile uid and gid agnostic
    Resolve uid/gid upon mainloop run
    GetEntResolver: Make it possible to resolve uid/gid to name
    utils.algo: Add InvertDict to invert a dict
    autotools: Add noded group...
0a9a0e5a 05/24/2011 12:37 pm René Nussbaumer

utils.algo: Add InvertDict to invert a dict

Signed-off-by: René Nussbaumer <>
Reviewed-by: Iustin Pop <>

580c971e 04/29/2011 03:38 pm Michael Hanselmann

Merge branch 'devel-2.4'

  • devel-2.4: (24 commits)
    mlock: fail gracefully if libc.so.6 cannot be loaded
    Allow creating the DRBD metadev in a different VG
    Make _GenerateDRBD8Branch accept different VG names
    Fix WriteFile with unicode data
    Replace disks: keep the meta device in the same VG...
adc523ab 04/29/2011 03:05 pm Iustin Pop

mlock: fail gracefully if libc.so.6 cannot be loaded

This allows noded to continue instead of blowing up if the libc major
number changes.

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

55f67cc9 04/28/2011 03:24 pm Iustin Pop

Fix 'unused import' lint error

Sorry!

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

8f9a87c5 04/28/2011 01:06 pm Iustin Pop

SetEtcHostsEntry: maintain existing ordering

Currently RemoveEtcHostsEntry keeps the ordering, but SetEtcHostsEntry
not, as it will always write the new entry at the end of file. I
personally dislike this as it "uglifies" my custom host files, so this
patch makes it update the record instead in-place so to say instead of...

24c855a7 04/28/2011 01:06 pm Iustin Pop

Convert utils.nodesetup to utils.WriteFile(data=…)

It makes no sense to iteratively write the new etc/hosts file, as we
can pre-compute the desired contents (neither the old nor the new
versions are safe against concurrent changes anyway).

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

1d39e245 04/28/2011 01:02 pm Iustin Pop

Fix WriteFile with unicode data

Unicode is fun, indeed:

len(buffer("abc"))

3

len(buffer(u"abc"))

12

So we can't pass unicode data to buffer(), as the result will be to
write the in-memory (usually UTF-32) representation to disk.

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

437c3e77 04/27/2011 06:26 pm Iustin Pop

Fix potential data-loss in utils.WriteFile

os.write can do incomplete writes, as long as at least some bytes have
been written (like write(2)):

os.write(fd, " " * 1300)

1300

os.write(fd, " " * 1300)

1300

os.write(fd, " " * 1300)

1300

os.write(fd, " " * 1300)...

a9d68e40 04/13/2011 01:01 pm Michael Hanselmann

utils.WriteFile: Close file before renaming

Issue 154 (http://code.google.com/p/ganeti/issues/detail?id=154)
reported an “Operation not supported” error when writing instance
exports to a mounted CIFS filesystem. Experimentation showed the error
to only occur when using rename(2) on an opened file. Various references...