diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-21 14:35:04 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-21 14:35:04 -0400 |
commit | 38f99b402d3118e2c26ff42d72ddf9b666adac13 (patch) | |
tree | 705d18bed66337192816325facb1733280291ff5 /src/lib/Bcfg2/Client/Client.py | |
parent | a3f2a731bbef5d9c2033eed23432aa7792d47989 (diff) | |
parent | 71d7285c405bd639f1f9f2642ea8fb567b97caec (diff) | |
download | bcfg2-38f99b402d3118e2c26ff42d72ddf9b666adac13.tar.gz bcfg2-38f99b402d3118e2c26ff42d72ddf9b666adac13.tar.bz2 bcfg2-38f99b402d3118e2c26ff42d72ddf9b666adac13.zip |
Merge branch '1.3.2' into maint
Conflicts:
src/lib/Bcfg2/Client/Tools/__init__.py
src/sbin/bcfg2-test
testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/Test__init.py
testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIXUsers.py
testsuite/Testsrc/test_code_checks.py
Diffstat (limited to 'src/lib/Bcfg2/Client/Client.py')
-rw-r--r-- | src/lib/Bcfg2/Client/Client.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/lib/Bcfg2/Client/Client.py b/src/lib/Bcfg2/Client/Client.py index 45e0b64e6..88f3bd6ef 100644 --- a/src/lib/Bcfg2/Client/Client.py +++ b/src/lib/Bcfg2/Client/Client.py @@ -14,9 +14,9 @@ import Bcfg2.Options import Bcfg2.Client.XML import Bcfg2.Client.Frame import Bcfg2.Client.Tools +from Bcfg2.Utils import locked, Executor from Bcfg2.Compat import xmlrpclib from Bcfg2.version import __version__ -from subprocess import Popen, PIPE class Client(object): @@ -41,6 +41,9 @@ class Client(object): to_file=self.setup['logging']) self.logger = logging.getLogger('bcfg2') self.logger.debug(self.setup) + + self.cmd = Executor(self.setup['command_timeout']) + if self.setup['bundle_quick']: if not self.setup['bundle'] and not self.setup['skipbundle']: self.logger.error("-Q option requires -b or -B") @@ -94,16 +97,14 @@ class Client(object): stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | stat.S_IWUSR) # 0755 - proc = Popen(scriptname, stdin=PIPE, stdout=PIPE, stderr=PIPE) - ret.text, err = proc.communicate() - rv = proc.wait() - if err: + rv = self.cmd.run(scriptname, timeout=self.setup['timeout']) + if rv.stderr: self.logger.warning("Probe %s has error output: %s" % - (name, err)) - if rv: + (name, rv.stderr)) + if not rv.success: self._probe_failure(name, "Return value %s" % rv) self.logger.info("Probe %s has result:" % name) - self.logger.info(ret.text) + self.logger.info(rv.stdout) finally: os.unlink(scriptname) except SystemExit: @@ -288,11 +289,7 @@ class Client(object): #check lock here try: lockfile = open(self.setup['lockfile'], 'w') - try: - fcntl.lockf(lockfile.fileno(), - fcntl.LOCK_EX | fcntl.LOCK_NB) - except IOError: - # otherwise exit and give a warning to the user + if locked(lockfile.fileno()): self.fatal_error("Another instance of Bcfg2 is running. " "If you want to bypass the check, run " "with the %s option" % @@ -301,7 +298,8 @@ class Client(object): raise except: lockfile = None - self.logger.error("Failed to open lockfile") + self.logger.error("Failed to open lockfile %s: %s" % + (self.setup['lockfile'], sys.exc_info()[1])) # execute the configuration self.tools.Execute() |