]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Bugfixing, adding path to puppet binary in base application class
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 20 Aug 2018 10:33:06 +0000 (12:33 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 20 Aug 2018 10:33:06 +0000 (12:33 +0200)
lib/webhooks/__init__.py
lib/webhooks/base_app.py
lib/webhooks/deploy.py
lib/webhooks/handler.py
lib/webhooks/r10k.py

index f7ee2b66da5aa838c0b0a2debbda21c171e8a315..b65ba7fba4393de4b96732db7c5c8bf1c42ae61e 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/env python3
 # -*- coding: utf-8 -*-
 
-__version__ = '0.8.1'
+__version__ = '0.8.2'
 
 # vim: ts=4 et list
index 6c2925be2c2d7cabbdc3318b1dc6d0cc711c245d..2a3f1b614c7fbf4b1ca670b1ceba9cffc509cca6 100644 (file)
@@ -96,6 +96,7 @@ class BaseHookApp(BaseObject):
 
         self.cmdline_args = None
 
+        self.puppet_bin = None
         self.curl_bin = None
 
         self.error_data = []
@@ -121,6 +122,7 @@ class BaseHookApp(BaseObject):
         else:
             LOG.debug("We are NOT in CGI.")
 
+        self.search_puppet_bin()
         self.search_curl_bin()
 
         return
@@ -243,6 +245,19 @@ class BaseHookApp(BaseObject):
             sys.stderr.write("\nSimulation mode - nothing is really done.\n\n")
             self.simulate = True
 
+    # -------------------------------------------------------------------------
+    def search_puppet_bin(self):
+
+        searcher = BaseHandler(
+            appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+
+        cmd = searcher.get_cmd('puppet')
+        del searcher
+        if not cmd:
+            sys.exit(9)
+        self.puppet_bin = cmd
+        return
+
     # -------------------------------------------------------------------------
     def search_curl_bin(self):
 
index e46a5d9aaa1ba459f5cd10ca38351db7779a61a3..d24bc1e2f0aa2780350147ed7b8a064db26631b6 100644 (file)
@@ -56,18 +56,18 @@ class WebhookDeployApp(BaseHookApp):
         super(WebhookDeployApp, self).__init__(
             appname=appname, verbose=verbose, version=version)
 
-    # -------------------------------------------------------------------------
-    def as_dict(self):
-        """
-        Transforms the elements of the object into a dict
-
-        @return: structure as dict
-        @rtype:  dict
-        """
-
-        res = super(WebhookDeployApp, self).as_dict()
-
-        return res
+#    # -------------------------------------------------------------------------
+#    def as_dict(self, short=True):
+#        """
+#        Transforms the elements of the object into a dict
+#
+#        @return: structure as dict
+#        @rtype:  dict
+#        """
+#
+#        res = super(WebhookDeployApp, self).as_dict()
+#
+#        return res
 
     # -------------------------------------------------------------------------
     def evaluate_config(self, config, yaml_file):
index 8024a6572468d42e650ea75e93d25d560f919ce5..b9046f117d99ca56cf7dde3ff10addcf32c44724 100644 (file)
@@ -249,6 +249,11 @@ class BaseHandler(BaseObject):
         out += ", ".join(fields) + ")>"
         return out
 
+    # -------------------------------------------------------------------------
+    def get_cmd(self, cmd):
+
+        return self.get_command(cmd)
+
     # -------------------------------------------------------------------------
     def get_command(self, cmd, quiet=False):
         """
index 38b64f41f5f0dc2871e0dc67ee6aef78e8669487..873c649429fb45b15c73eabb0d63cc46fefaeb25 100644 (file)
@@ -6,6 +6,7 @@
 @copyright: © 2017 by Frank Brehm, Berlin
 @summary: The module for the r10k_hook application object.
 """
+from __future__ import absolute_import
 
 # Standard modules
 import sys
@@ -25,9 +26,11 @@ import requests
 # Own modules
 import webhooks
 
-from webhooks.common import pp, to_str, to_bool
+from .common import pp, to_str, to_bool
 
-from webhooks.base_app import BaseHookApp
+from .base_app import BaseHookApp
+
+from .handler import BaseHandler
 
 __version__ = webhooks.__version__
 LOG = logging.getLogger(__name__)
@@ -66,7 +69,7 @@ class R10kHookApp(BaseHookApp):
         self.check_cert_files()
 
     # -------------------------------------------------------------------------
-    def as_dict(self):
+    def as_dict(self, short=True):
         """
         Transforms the elements of the object into a dict
 
@@ -81,7 +84,11 @@ class R10kHookApp(BaseHookApp):
     # -------------------------------------------------------------------------
     def search_r10k_bin(self):
 
-        cmd = self.get_cmd('r10k')
+        searcher = BaseHandler(
+            appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+
+        cmd = searcher.get_cmd('r10k')
+        del searcher
         if not cmd:
             sys.exit(9)
         self.r10k_bin = cmd