Statistics
| Branch: | Tag: | Revision:

root / lib / utils @ 6915fe26

# Date Author Comment
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...

af7b6689 04/07/2011 01:24 pm Michael Hanselmann

Merge branch 'devel-2.4'

  • devel-2.4:
    LUInstanceQueryData: Don't acquire locks unless requested
    Increase the lock timeouts before we block-acquire
    daemon.py: move startup log message before prep_fn
    Display the actual memory values in N+1 failures...
76ae1d65 04/07/2011 12:46 pm Michael Hanselmann

Merge branch 'stable-2.4' into devel-2.4

  • stable-2.4:
    Add error checking and merging for cluster params
    Clarify --force-join parameter message
    Treat empty oob_program param as default
    Fix bug in instance listing with orphan instances
    Fix bug related to log opening failures...
bbfed756 04/06/2011 02:05 pm Michael Hanselmann

utils: Add function generating regex for DNS name globbing

The intent of this function is to be able to provide a globbing operator
or query filters. One should be able to say, for example, something to
the effect of “gnt-instance shutdown '*.site'”.

Also rename a variable in MatchNameComponent....

c7d3a832 03/31/2011 07:24 pm Iustin Pop

Add a simple wrapper over utils.Retry

The new wrapper makes moving legacy code to utils.Retry or adding
retries in existing code simpler.

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

d6491981 03/31/2011 12:44 pm René Nussbaumer

test.ganeti.process_unittest: Fix race condition

There was a race condition on heavily loaded testsystem causing randomly
to fail the timeout unittests as the signal handler is not yet setup but
the timeout has already hit.

Therefore we introduce a workaround to wait until a program reached a...

7d4da09e 03/15/2011 02:50 pm Michael Hanselmann

utils: Export NiceSortKey function

The ability to split a string into a list of strings and integers can be
handy elsewhere and is necessary for sorting query results by names.

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

c24e519e 03/10/2011 04:29 pm Iustin Pop

Fix bug related to log opening failures

If opening the log file fails, then we shouldn't attempt to use that
variable.

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

ee7f592e 03/07/2011 06:06 pm Iustin Pop

Log log-file reopening

This makes the log files get an record notifying of the reopen, so as
to force creation of the log files soon after rotation.

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

f47941f8 02/25/2011 11:55 am Michael Hanselmann

utils: Export NiceSortKey function

The ability to split a string into a list of strings and integers can be
handy elsewhere and is necessary for sorting query results by names.

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

92ea69bf 02/24/2011 03:25 pm Michael Hanselmann

Add function to format ordinals

See [1] for the rules.

[1] http://en.wikipedia.org/wiki/Names_of_numbers_in_English#Ordinal_numbers

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

9a6813ac 02/02/2011 06:02 pm Michael Hanselmann

utils.SetupLogging: Return function to reopen log file

This function can be used from a SIGHUP handler to reopen log files.
Initial, simple unittests are included.

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

8cabf472 02/02/2011 06:02 pm Michael Hanselmann

Reopen log files upon SIGHUP in daemons

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

cfcc79c6 02/02/2011 06:02 pm Michael Hanselmann

utils.SetupLogging: Make program a mandatory argument

It's passed in by most users (daemons, CLI scripts) and for the others
(burnin, watcher) it certainly doesn't hurt, especially when using
syslog.

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

aa0cc3e5 02/02/2011 05:57 pm Michael Hanselmann

utils.log: Restrict I/O error handling coverage

The I/O error will occur while opening the file, not while adding
and configuring the handler.

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

d24bc000 02/02/2011 05:57 pm Michael Hanselmann

utils.log: Split formatter building into separate function

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

b6fa9a44 01/31/2011 02:53 pm Michael Hanselmann

Introduce re-openable log record handler

This patch adds a new log handler class based on the standard library's
BaseRotatingHandler. This new class allows the log file to be re-opened,
e.g. upon receiving a SIGHUP signal. The latter will be implemented in...

58a59652 01/27/2011 06:39 pm Iustin Pop

cluster verify: add hvparams verification

Currently, the validity of the hypervisor parameters is only checked
at init/modification time, and not in the cluster verify. This is bad,
as it can lead to inconsistent state that is only detected when the
next modification (which can be unrelated) is made, leading to...

a3d32770 01/18/2011 01:47 pm Iustin Pop

Rename OpVerifyCluster and LUVerifyCluster

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

7b0bf9cd 01/11/2011 07:33 pm Apollon Oikonomopoulos

Add ability to retain specified fds open in RunCmd

Passing tap devices to KVM as file descriptors requires that the respective
file decriptors remain open during utils.RunCmd execution. To this direction,
we add a “noclose_fds” keyword argument to utils.RunCmd, accepting a list of...

63fc4229 01/11/2011 05:33 pm Michael Hanselmann

utils: Cleanup and sort wildcard imports

Also convert the per-line pylint instructions to one per-module
instruction.

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

79b60c1c 01/11/2011 05:33 pm Michael Hanselmann

utils: Drop RemovePidFile

It's equivalent to a simple RemoveFile now.

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

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

44c9b4fe 01/11/2011 05:32 pm Michael Hanselmann

utils: Move ResetTempfileModule to wrappers module

It's not exactly a wrapper, but this seemed like the best place.

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

1ae4c5a1 01/10/2011 06:16 pm Michael Hanselmann

utils: Move logging-related code into separate file

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

71ab9dbe 01/10/2011 06:16 pm Michael Hanselmann

utils: Rename _CloseFDNoErr to CloseFdNoError

This makes it a public function, which is necessary for
moving code into separate files.

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

4d130f34 01/10/2011 06:16 pm Michael Hanselmann

utils: Remove unused variables

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

36a4acd4 01/10/2011 06:15 pm Michael Hanselmann

utils: Move Mlockall into separate file

The unittest file is renamed to match the other utils.* tests.

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

c047a981 01/10/2011 06:15 pm Michael Hanselmann

utils: Move to separate module

This is preparing for splitting the whole units module.

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