1. 30 Jul, 2008 2 commits
    • Iustin Pop's avatar
      Fix pylint-detected issues · 38206f3c
      Iustin Pop authored
      This is mostly:
        - whitespace fix (space at EOL in some files, not all, broken
          indentation, etc)
        - variable names overriding others (one is a real bug in there)
        - too-long-lines
        - cleanup of most unused imports (not all)
      Reviewed-by: ultrotter
    • Iustin Pop's avatar
      Expose utils.DaemonPidFileName · 53beffbb
      Iustin Pop authored
      Since we need to compute this from outside utils.py, we change this to a
      public function.
      Reviewed-by: ultrotter
  2. 29 Jul, 2008 2 commits
    • Iustin Pop's avatar
      Add a KillProcess function · b2a1f511
      Iustin Pop authored
      We cannot depend on all environments to have a start-stop-daemon or
      similar tool. We instead implement a KillProcess function that behaves
      similar to “start-stop-daemon --retry”.
      Note that the attached unittest can hang in foreground if the child
      misbehaves (doesn't write to the internal pipe). Since unittest are
      either run in the foreground or are run with a timeout from an automated
      framework, I think this is an acceptable trade-off (against of using
      hardcoded timeouts in the test).
      Reviewed-by: imsnah
    • Iustin Pop's avatar
      Change IsPidFileAlive into ReadPidFile · d9f311d7
      Iustin Pop authored
      We already have a function to test if a PID is alive, so it makes more
      sense to use function composition that force calling (since we need to
      read PIDs from files in other places too). Now IsProcessAlive returns
      False for PIDs <= 0, since this is the error return from ReadPidFile.
      The patch also adds a unittest for checking that WriteFile raises the
      correct exception, and checks that an invalid or missing file causes
      ReadPidFile to return zero. The unittest tearDown method will try to
      cleanup the temp directory too (otherwise it leaves stuff after it).
      Reviewed-by: ultrotter
  3. 28 Jul, 2008 1 commit
  4. 23 Jul, 2008 2 commits
    • Guido Trotter's avatar
      Add utils.{Write,Remove}PidFile · b330ac0b
      Guido Trotter authored
      WritePidFile is a helper function that writes the current pid in a
      pidfile within the ganeti run directory. RemovePidFile tries to delete
      Reviewed-by: iustinp
    • Guido Trotter's avatar
      Add utils.IsPidFileAlive function · fee80e90
      Guido Trotter authored
      This helper function reads a pid from a file containing it and checks
      whether it refers to a live process.
      Reviewed-by: iustinp
  5. 21 Jul, 2008 1 commit
    • Michael Hanselmann's avatar
      Add signal handler class · de499029
      Michael Hanselmann authored
      This signal handler class abstracts some of the code previously
      used in other places. It also uninstalls its handler when Reset()
      is called or the class is destructed, thereby restoring the
      previous behaviour.
      Reviewed-by: iustinp
  6. 10 Jul, 2008 2 commits
  7. 09 Jul, 2008 2 commits
  8. 01 Jul, 2008 1 commit
  9. 23 Jun, 2008 1 commit
  10. 18 Jun, 2008 1 commit
    • Michael Hanselmann's avatar
      Add more parameters to utils.WriteFile · 71714516
      Michael Hanselmann authored
      - Make closing file optional: Required by ganeti-watcher to keep
        file open after writing it. Changes return value of utils.WriteFile
        if "close" parameter evaluates to True.
      - Pre- and post-write functions: Can be used to lock files. This
        will be used by ganeti-watcher to lock the temporary file before
      Reviewed-by: iustinp
  11. 12 Jun, 2008 2 commits
  12. 09 May, 2008 1 commit
    • Michael Hanselmann's avatar
      Remove utils.CheckDaemonAlive and use “xm info” instead · e3e66f02
      Michael Hanselmann authored
      There are a couple of reasons for doing so:
      - /proc is not OS independent, it's only supported by Linux (there are
        emulations on other systems, but those might differ from the way
        Linux represents data).
      - Checking a daemon's state doesn't necessarily mean it's usable.
        Connecting to the socket using “xm info” is much safer.
      - Reduce code size.
      Reviewed-by: iustinp
  13. 29 Apr, 2008 1 commit
    • Iustin Pop's avatar
      Disable forking in the master daemon · b74159ee
      Iustin Pop authored
      This patch adds a mechanism to disable utils.RunCmd in selected
      programs. This is needed in the master daemon unless we confirm
      threading doesn't pose any problems.
      This makes cluster init fail, but creating new trunk clusters is anyway
      broken at the moment.
      Reviewed-by: ultrotter
  14. 25 Apr, 2008 1 commit
    • Michael Hanselmann's avatar
      Extend utils.WriteFile · 70f4497c
      Michael Hanselmann authored
      Add parameters to not check the path for absoluteness, implement a dry
      run mode and automatically create a backup if requested. This will be
      used by the cfgupgrade utility.
      Reviewed-by: schreiberal
  15. 10 Apr, 2008 1 commit
    • Iustin Pop's avatar
      Move the OS search code into an abstract function · 57c177af
      Iustin Pop authored
      Based on the previous OS search code changes, we can now move the OS
      search code into a generic look-for-file function in utils.py. This
      means that the allocator code can use the same function.
      Reviewed-by: ultrotter
  16. 04 Apr, 2008 2 commits
    • Iustin Pop's avatar
      Allow utils.Daemonize() to not close some fds · 8ff612c2
      Iustin Pop authored
      This patch implements an optional parameter to utils.Daemonize() which
      allows that function to not close some file descriptors.
      This will allow the master daemon to open the listening socket before
      fork - in order to be able to notify errors and return a meaningful exit
      code, and then when we fork we don't close that fd.
      Reviewed-by: imsnah
    • Iustin Pop's avatar
      Move the daemonize function to utils.py · 8f765069
      Iustin Pop authored
      Currently, in ganeti-noded we have the createDaemon function. Since
      we'll need the same in other daemons, we move this function to utils.py
      With the move, a few changes were also done:
        - change the name to Daemonize()
        - add a parameter, logfile, as different daemons will want to log to
          different files
        - remove the try.. except.. around the fork calls, since they were
          only re-raising the OS exception with less data; unless we want to
          actually handle fork error (not just re-raising), these try blocks
          are not useful
        - change the return style at the end of the function
      Reviewed-by: imsnah
  17. 11 Mar, 2008 1 commit
    • Iustin Pop's avatar
      Modify utils.TcpPing to make source address optional · b15d625f
      Iustin Pop authored
      This patch modifies TcpPing and its callers to make the source address
      selection optional. Usually, the kernel will know better what
      source address to use, just in some cases we want to enforce a given
      source address so it makes sense to make this optional.
      Reviewed-by: ultrotter
  18. 05 Mar, 2008 1 commit
  19. 05 Feb, 2008 1 commit
  20. 27 Dec, 2007 1 commit
  21. 19 Dec, 2007 1 commit
    • Iustin Pop's avatar
      Make utils.RunCmd() deal with interleaved stdout/stderr · 9c233417
      Iustin Pop authored
      Currently, RunCmd is written with the assumption that programs will have
      a small stderr output, therefore we read the child's stdout (which can
      be big, so we don't want to block the child) and then the stderr (which
      is small, so it shouldn't block).
      However, with the ‘gnt-cluster verify-disks’ command, we ourselves
      generate heavy stderr, therefore we break the ganeti-watcher which runs
      the verify-disks via utils.RunCmd.
      This patch turns the RunCmd command into an poll-based one, which means
      any kind of interleaved output by a child on stdout/stderr will be
      handled correctly. Of course, since the output is buffered in memory,
      there are other ways to break RunCmd(). But at least this should fix the
      common case.
      Reviewed-by: hansmi
  22. 29 Nov, 2007 2 commits
    • Iustin Pop's avatar
      Replace hardcoded lock dir · 3aecd2c7
      Iustin Pop authored
      This patch replaces the hardcoded ‘/var/lock/’ directory with one based on
      Reviewed-by: imsnah
    • Iustin Pop's avatar
      Make utils.RunCmd log failures when using debug · f362096f
      Iustin Pop authored
      This patch adds logging of command failures to the debug log in case the
      user either started the command (gnt-*) or the node daemon with the
      debug flag.
      Reviewed-by: imsnah
  23. 22 Nov, 2007 1 commit
  24. 20 Nov, 2007 2 commits
  25. 12 Nov, 2007 6 commits
  26. 09 Nov, 2007 1 commit