import os
import logging
import re
-import textwrap
import datetime
import json
import smtplib
# Own modules
import webhooks
-from webhooks.common import pp, to_bytes, to_str, to_bool
+from webhooks.common import pp, to_bytes, to_bool
__version__ = webhooks.__version__
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
def do_arg_parser(self):
-
arg_parser = argparse.ArgumentParser(
description=self.description,
add_help=False,
sys.stderr.flush()
os.dup2(se.fileno(), sys.stderr.fileno())
- #sys.stderr.write("Trying to open logfile {!r} ...\n".format(self.logfile))
# we are in a CGI environment
if os.path.isdir(self.log_directory) and os.access(self.log_directory, os.W_OK):
lh_file = logging.FileHandler(
if self.special_chars_re.search(self.name):
msg = "Project {!r}: Received special characters in module name".format(
self.full_name)
+ LOG.error(msg)
+ self.error_data.append(msg)
return False
committers = []
# =============================================================================
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list
-
"""
# Standard modules
-import sys
import os
import logging
-import re
import textwrap
-import datetime
-import json
-import traceback
import copy
import pipes
import subprocess
-import smtplib
-from email.message import EmailMessage
# Third party modules
-import yaml
# Own modules
import webhooks
-from webhooks.common import pp, to_bytes, to_str, to_bool
+from webhooks.common import pp, to_str
from webhooks.base_app import BaseHookApp
return res
-
# -------------------------------------------------------------------------
def evaluate_config(self, config, yaml_file):
'modified': ['lib/webhooks/deploy.py'],
'removed': [],
'timestamp': '2017-01-25T11:20:47+01:00',
- 'url': 'https://git.pixelpark.com/ppadmin/puppetmaster-webhooks/commit/257b9...'
+ 'url': 'https://git.pixelpark.com/ppadmin/puppetmaster-webhooks/commit/257b...'
}
],
'event_name': 'push',
LOG.info("Deploying Hiera working directory ...")
- ns = 'puppet'
pname = 'hiera'
- full_name = ns + '/' + pname
parent_dir = '/www/data/puppet-hiera'
if 'parent_dir' in cfg and cfg['parent_dir']:
parent_dir = cfg['parent_dir']
return self.ensure_workingdir(parent_dir, workdir)
- # -------------------------------------------------------------------------
- def deploy_puppet_modules(self):
-
- LOG.info("Deploying puppet modules working directory ...")
-
- ns = 'puppet'
- pname = cfg['name']
- full_name = ns + '/' + pname
- parent_dir = self.default_parent_dir
- if 'parent_dir' in cfg and cfg['parent_dir']:
- parent_dir = cfg['parent_dir']
-
- if not os.access(parent_dir, os.F_OK):
- msg = "Parent directory {d!r} of project {p!r} does not exists.".format(
- d=parent_dir, p=full_name)
- LOG.error(msg)
- self.error_data.append(msg)
- return True
-
- if not os.path.isdir(parent_dir):
- msg = ("Path for parent directory {d!r} for project {p!r} "
- "is not a directory.").format(d=parent_dir, p=full_name)
- LOG.error(msg)
- self.error_data.append(msg)
- return True
-
- env_branch = 'undefined'
- if self.dev_re.match(self.ref):
- env_branch = 'development'
- elif self.ref == 'master':
- env_branch = 'test'
- full_path_branch = os.path.join(parent_dir, env_branch)
- if not os.access(full_path_branch, os.F_OK):
- msg = "Branch directory {d!r} of project {p!r} does not exists.".format(
- d=full_path_branch, p=full_name)
- LOG.error(msg)
- self.error_data.append(msg)
- return True
-
- modules_dir = os.path.join(full_path_branch, 'modules')
- if not os.access(modules_dir, os.F_OK):
- msg = "Modules directory {d!r} of project {p!r} does not exists.".format(
- d=modules_dir, p=full_name)
- LOG.error(msg)
- self.error_data.append(msg)
- return True
-
- branc2clone = None
- if env_branch =='test':
- branc2clone = 'master'
-
- return self.ensure_workingdir(parent_dir=modules_dir, workdir=pname, branch=branc2clone)
-
# -------------------------------------------------------------------------
def deploy(self, cfg):
import sys
import os
import logging
-import re
import textwrap
-import datetime
import locale
import pipes
import subprocess
import urllib.parse
# Third party modules
-import yaml
# Own modules
import webhooks
-from webhooks.common import pp, to_bytes, to_str, to_bool
+from webhooks.common import pp, to_str, to_bool
from webhooks.base_app import BaseHookApp
try:
self.puppetmaster_api_port = int(ppm_cfg['api_port'])
except Exception as e:
- msg = "Invalid port {p!r} for puppetmaster API in {f!r} found.".format(
- p=ppm_cfg['api_port'], f=yaml_file)
+ msg = "Invalid port {p!r} for puppetmaster API in {f!r} found: {e}".format(
+ p=ppm_cfg['api_port'], f=yaml_file, e=e)
self.error_data.append(msg)
if 'api_path' in ppm_cfg and ppm_cfg['api_path']:
self.puppetmaster_api_path = ppm_cfg['api_path']
self.puppetmaster_ssl_dir, 'certs', 'ca.pem')
path = (
- self.puppetmaster_api_path + '/environment-cache?environment=' +
+ self.puppetmaster_api_path + '/environment-cache?environment=' +
urllib.parse.quote(self.ref))
url = 'https://{h}:{po}{pa}'.format(
h=self.puppetmaster_host, po=self.puppetmaster_api_port, pa=path)