def trigger_plugin_update(self, include_host_ids, exclude_host_ids, plugin_names):
"""
Cause the plugins on the hosts passed to send an update irrespective of whether any
changes have occurred.
:param include_host_ids: List of host ids to include in the trigger update.
:param exclude_host_ids: List of host ids to exclude from the include list (makes for usage easy)
:param plugin_names: list of plugins to trigger update on - empty list means all.
:return: command id that caused updates to be sent.
"""
host_ids = [host.id for host in ManagedHost.objects.all()] if include_host_ids is None else include_host_ids
host_ids = host_ids if exclude_host_ids is None else list(set(host_ids) - set(exclude_host_ids))
if host_ids:
with self._lock:
jobs = [TriggerPluginUpdatesJob(host_ids=json.dumps(host_ids),
plugin_names_json=json.dumps(plugin_names))]
with transaction.commit_on_success():
command = Command.objects.create(message="%s triggering updates from agents" % ManagedHost.objects.get(id=exclude_host_ids[0]).fqdn)
self.CommandPlan.add_jobs(jobs, command)
self.progress.advance()
return command.id
else:
return None
job_scheduler.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录