r=to_addresses, e=pp(self.error_data),
s=self.smtp_server, p=self.smtp_port))
+ if self.simulate:
+ LOG.info("Simulation mode, don't sending mail.")
+ return
+
server = smtplib.SMTP(self.smtp_server, self.smtp_port)
if 'REQUEST_METHOD' not in os.environ:
if self.verbose > 2:
'user_name': 'Frank Brehm'}
"""
- if self.full_name == 'puppet/hiera':
- cfg = copy.copy(self.projects['hiera'])
- return self.deploy_hiera(cfg)
-
for project_key in self.projects.keys():
- if project_key == 'hiera' or project_key == 'puppet_modules':
+ if project_key == 'puppet_modules':
continue
cfg = copy.copy(self.projects[project_key])
if 'namespace' not in cfg:
return True
- # -------------------------------------------------------------------------
- def deploy_hiera(self, cfg):
-
- LOG.info("Deploying Hiera working directory ...")
-
- pname = 'hiera'
- parent_dir = '/www/data/puppet-hiera'
- if self.verbose > 2:
- LOG.debug("Got config structure for hiera:\n{}".format(pp(cfg)))
- if 'parent_dir' in cfg and cfg['parent_dir']:
- parent_dir = cfg['parent_dir']
- workdir = pname
- if 'workdir' in cfg and cfg['workdir']:
- workdir = cfg['workdir']
-
- full_path = os.path.join(parent_dir, workdir)
-
- LOG.info("Deploying working directory {!r} for Hiera ...".format(full_path))
-
- if not os.access(parent_dir, os.F_OK):
- msg = "Parent directory {!r} for Hiera does not exists.".format(parent_dir)
- LOG.error(msg)
- self.error_data.append(msg)
- return True
-
- if not os.path.isdir(parent_dir):
- msg = "Path of parent directory {!r} for Hiera is not a directory.".format(parent_dir)
- LOG.error(msg)
- self.error_data.append(msg)
- return True
-
- return self.ensure_workingdir(parent_dir, workdir)
-
# -------------------------------------------------------------------------
def deploy(self, cfg):
cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
LOG.info("Executing: {}".format(cmd_str))
+ if self.simulate:
+ LOG.info("Simulation mode, don't executing.")
+ return
+
git = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdoutdata, stderrdata) = git.communicate()
ret_val = git.wait()
else:
LOG.info(msg)
self.print_out(msg)
+
finally:
os.chdir(cur_dir)