Commit 4da99694 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Move instanciation of zabbix agentd to a dedicated method.

parent 706ccb3a
...@@ -79,35 +79,48 @@ class Recipe(BaseSlapRecipe): ...@@ -79,35 +79,48 @@ class Recipe(BaseSlapRecipe):
self.path_list.append(wrapper) self.path_list.append(wrapper)
return cron_d return cron_d
def _install(self): def installZabbixAgentd(self, ip, port, hostname, server_ip):
self.path_list = [] log_file = os.path.join(self.log_directory, 'zabbix_agentd.log')
self.requirements, self.ws = self.egg.working_set() self.registerLogRotation('zabbix_agentd', [log_file])
# self.cron_d is a directory, where cron jobs can be registered
self.cron_d = self.installCrond() zabbix_agentd_conf = dict(
self.logrotate_d, self.logrotate_backup = self.installLogrotate()
zabbix_log_file = os.path.join(self.log_directory, 'zabbix_agentd.log')
self.registerLogRotation('zabbix_agentd', [zabbix_log_file])
zabbix_agentd = dict(
pid_file=os.path.join(self.run_directory, "zabbix_agentd.pid"), pid_file=os.path.join(self.run_directory, "zabbix_agentd.pid"),
log_file=zabbix_log_file, log_file=log_file,
ip=self.getGlobalIPv6Address(), ip=ip,
server=self.parameter_dict['server'], server=server_ip,
hostname=self.parameter_dict['hostname'], hostname=hostname,
port='10050' port=port)
)
zabbix_agentd_conf = self.createConfigurationFile("zabbix_agentd.conf", zabbix_agentd_path = self.createConfigurationFile(
pkg_resources.resource_string(__name__, "zabbix_agentd.conf",
'template/zabbix_agentd.conf.in') % zabbix_agentd) pkg_resources.resource_string(
self.path_list.append(zabbix_agentd_conf) __name__, 'template/zabbix_agentd.conf.in') % zabbix_agentd_conf)
self.path_list.append(zabbix_agentd_path)
wrapper = zc.buildout.easy_install.scripts([('zabbixagentd', wrapper = zc.buildout.easy_install.scripts([('zabbixagentd',
'slapos.recipe.librecipe.execute', 'execute')], self.ws, sys.executable, 'slapos.recipe.librecipe.execute', 'execute')], self.ws, sys.executable,
self.bin_directory, arguments=[ self.bin_directory, arguments=[
self.options['zabbix_agentd_binary'].strip(), '-c', self.options['zabbix_agentd_binary'].strip(), '-c',
zabbix_agentd_conf])[0] zabbix_agentd_path])[0]
self.path_list.extend(zc.buildout.easy_install.scripts([ self.path_list.extend(zc.buildout.easy_install.scripts([
('zabbixagentd', __name__ + '.svcdaemon', 'svcdaemon')], ('zabbixagentd', __name__ + '.svcdaemon', 'svcdaemon')],
self.ws, sys.executable, self.wrapper_directory, arguments=[dict( self.ws, sys.executable, self.wrapper_directory, arguments=[dict(
real_binary=wrapper, pid_file=zabbix_agentd['pid_file'])])) real_binary=wrapper, pid_file=zabbix_agentd_conf['pid_file'])]))
self.setConnectionDict(dict(ip=zabbix_agentd['ip'],
name=zabbix_agentd['hostname'], port=zabbix_agentd['port'])) return zabbix_agentd_conf
def _install(self):
self.path_list = []
self.requirements, self.ws = self.egg.working_set()
# self.cron_d is a directory, where cron jobs can be registered
self.cron_d = self.installCrond()
self.logrotate_d, self.logrotate_backup = self.installLogrotate()
zabbix_agentd_conf = self.installZabbixAgentd(self.getGlobalIPv6Address(),
10050,
self.parameter_dict['hostname'],
self.parameter_dict['server'])
self.setConnectionDict(dict(ip=zabbix_agentd_conf['ip'],
name=zabbix_agentd_conf['hostname'], port=zabbix_agentd_conf['port']))
return self.path_list return self.path_list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment