1. 11 Nov, 2008 1 commit
    • Iustin Pop's avatar
      Implement working directory for utils.RunCmd · 8797df43
      Iustin Pop authored
      In order to replace usage of the shell just for 'cd %s; ...' we need to
      be able to specify the working directory for childs.
      
      The patch also changes the default working directory (when not
      specified) to "/", as opposed to the current dir; since the daemos run
      with cwd=/ anyway, this should not change things.
      
      Reviewed-by: imsnah
      8797df43
  2. 27 Oct, 2008 1 commit
  3. 24 Oct, 2008 1 commit
    • Iustin Pop's avatar
      Modify utils.RunCmd to write output to file · 36117c2b
      Iustin Pop authored
      Currently we launch processes via the shell in a few places only to
      redirect standard output and error to a log file ("&> $file"). It is
      better to do such redirection from within RunCmd itself.
      
      This patch splits RunCmd in two parts, the setup and the execution part,
      the latter being implemented in two different functions depending on
      whether we write to a file or not.
      
      We also update the unittests with this new case.
      
      Reviewed-by: imsnah
      36117c2b
  4. 20 Oct, 2008 1 commit
    • Iustin Pop's avatar
      Remove the logger.py module · 82d9caef
      Iustin Pop authored
      Since now we use only one function from the logger module
      (SetupLogging), we move it to utils.py (which is already imported by all
      users of this function), and we remove the module.
      
      Reviewed-by: imsnah
      82d9caef
  5. 12 Oct, 2008 1 commit
    • Iustin Pop's avatar
      Abstract checking own address into a function · caad16e2
      Iustin Pop authored
      Currently, we check if we have a given ip address (i.e. it's alive on
      one of our interfaces) but manually calling TcpPing(source=localhost).
      This works, but having it spread all over the code makes it hard to
      change the implementation.
      
      The patch abstracts this into a separate utils.OwnIpAddress(addr)
      function. We add a rpc call for it, which we use instead of the
      (single-use of) call_node_tcp_ping. We leave node_tcp_ping in, as seems
      useful and eventually it should be removed in a separate patch.
      
      Reviewed-by: imsnah
      caad16e2
  6. 01 Oct, 2008 1 commit
  7. 28 Sep, 2008 1 commit
    • Iustin Pop's avatar
      Move the pseudo-secret generation to utils.py · 33081d90
      Iustin Pop authored
      The bootstrap code needs a pseudo-secret and this is currently generated
      inside the InitGanetiServerSetup function. Since more users will need
      this, move it to utils.py
      
      Reviewed-by: ultrotter
      33081d90
  8. 17 Sep, 2008 1 commit
  9. 05 Sep, 2008 2 commits
  10. 29 Aug, 2008 1 commit
  11. 26 Aug, 2008 1 commit
    • Michael Hanselmann's avatar
      Add simple lock debug output · e67bd559
      Michael Hanselmann authored
      Currently it can only be enabled by modifying utils.py, but we can
      add a command line parameter later if needed.
      
      Reviewed-by: schreiberal
      e67bd559
  12. 14 Aug, 2008 1 commit
    • Guido Trotter's avatar
      RunCmd: add optional environment overriding · 2557ff82
      Guido Trotter authored
      If the user passes an env dict to RunCmd we'll override the environment
      passed to the to-be-executed command with the values in the dict. This
      allows us to pass arbitrary environment values to commands we run.
      
      Reviewed-by: imsnah 
      2557ff82
  13. 13 Aug, 2008 1 commit
  14. 11 Aug, 2008 1 commit
  15. 08 Aug, 2008 1 commit
  16. 31 Jul, 2008 1 commit
    • Michael Hanselmann's avatar
      Add FileLock utility class · a87b4824
      Michael Hanselmann authored
      This class is a wrapper around fcntl.flock and abstracts opening and
      closing the lockfile. It'll used for the job queue.
      
      (The patch also removes a duplicate import of tempfile into the unittest)
      
      Reviewed-by: iustinp
      a87b4824
  17. 30 Jul, 2008 3 commits
    • Iustin Pop's avatar
      Fix a misuse of exc_info in logging.info · 8161a646
      Iustin Pop authored
      This is my fault, sorry.
      
      Reviewed-by: imsnah
      8161a646
    • 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
      38206f3c
    • 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
      53beffbb
  18. 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
      b2a1f511
    • 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
      d9f311d7
  19. 28 Jul, 2008 1 commit
  20. 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
      it.
      
      Reviewed-by: iustinp
      
      b330ac0b
    • 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
      
      fee80e90
  21. 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
      de499029
  22. 10 Jul, 2008 2 commits
  23. 09 Jul, 2008 2 commits
  24. 01 Jul, 2008 1 commit
  25. 23 Jun, 2008 1 commit
  26. 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
        renaming.
      
      Reviewed-by: iustinp
      71714516
  27. 12 Jun, 2008 2 commits
  28. 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
      e3e66f02
  29. 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
      b74159ee
  30. 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
      70f4497c
  31. 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
      57c177af
  32. 04 Apr, 2008 1 commit
    • 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
      8ff612c2