]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Changin lib/webhooks/r10k.py to use method call() from base handler class
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 20 Aug 2018 13:11:25 +0000 (15:11 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 20 Aug 2018 13:11:25 +0000 (15:11 +0200)
lib/webhooks/__init__.py
lib/webhooks/base_app.py
lib/webhooks/handler.py
lib/webhooks/r10k.py

index b65ba7fba4393de4b96732db7c5c8bf1c42ae61e..77e89e32f0ae8ce127ad2a1e6845593faba85337 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/env python3
 # -*- coding: utf-8 -*-
 
-__version__ = '0.8.2'
+__version__ = '0.8.3'
 
 # vim: ts=4 et list
index 7c8cc2bb1a932defea9b6125f6378cedf6ff37d6..6e1c5411461b27c1c350d8268fd50f2461741706 100644 (file)
@@ -128,7 +128,8 @@ class BaseHookApp(BaseObject):
         self.search_curl_bin()
 
         self.handler = BaseHandler(
-            appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+            appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
+            simulate=self.simulate)
 
         return
 
index b9046f117d99ca56cf7dde3ff10addcf32c44724..8ec2cbdf326ac4c30b2fd64d1be97bfd0a181c7d 100644 (file)
@@ -363,6 +363,7 @@ class BaseHandler(BaseObject):
         if sudo is None:
             sudo = self.sudo
         if sudo:
+            cmd_list.insert(0, '-n')
             cmd_list.insert(0, self.sudo_cmd)
 
         if simulate is None:
index 8f3d48689d221bdd6ad01c4c63e193a39399e3c8..ded2df568eacde0abcc85cd81767b2b798b9a264 100644 (file)
@@ -270,29 +270,12 @@ class R10kHookApp(BaseHookApp):
             elif self.verbose > 1:
                 r10k_loglevel = 'debug'
 
-        cmd = []
-        if self.do_sudo:
-            cmd = ['sudo', '-n']
-
-        cmd += [
+        cmd = [
             self.r10k_bin, 'deploy', 'environment',
             self.ref, '--puppetfile', '--verbose', r10k_loglevel
         ]
 
-        cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
-        if self.verbose > 2:
-            LOG.debug("Cmd: {}".format(pp(cmd)))
-        LOG.info("Executing: {}".format(cmd_str))
-
-        if self.simulate:
-            LOG.warn("Simulation mode, don't executing {!r}.".format(self.r10k_bin))
-            time.sleep(3)
-            return res
-
-        LOG.debug("Really executing ...")
-        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-        (stdoutdata, stderrdata) = proc.communicate()
-        ret_val = proc.wait()
+        (ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo)
 
         LOG.debug("Return value: {}".format(ret_val))
         if stdoutdata: