[icinga-checkins] icinga.org: icingaweb2-module-director/next: IcingaService(v1): render single service apply...
git at icinga.org
git at icinga.org
Mon Nov 7 13:35:10 CET 2016
Module: icingaweb2-module-director
Branch: next
Commit: 068d38fddc2f4b486577f494f53e78242beb5639
URL: https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=068d38fddc2f4b486577f494f53e78242beb5639
Author: Thomas Gelf <thomas at gelf.net>
Date: Mon Nov 7 13:34:20 2016 +0100
IcingaService(v1): render single service apply...
...fully resolved to all matching hosts respecting their rendering zone
---
library/Director/Objects/IcingaService.php | 37 ++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php
index 957aed8..a37080f 100644
--- a/library/Director/Objects/IcingaService.php
+++ b/library/Director/Objects/IcingaService.php
@@ -175,6 +175,43 @@ class IcingaService extends IcingaObject
return $this->renderRelationProperty('host', $this->host_id, 'host_name');
}
+ public function renderToLegacyConfig(IcingaConfig $config)
+ {
+ if ($this->isApplyRule()) {
+ $this->renderLegacyApplyToConfig($config);
+ } else {
+ parent::renderToLegacyConfig($config);
+ }
+ }
+
+ /**
+ * @param IcingaConfig $config
+ */
+ protected function renderLegacyApplyToConfig(IcingaConfig $config)
+ {
+ $conn = $this->getConnection();
+
+ $filter = Filter::fromQueryString($this->get('assign_filter'));
+ $hosts = HostApplyMatches::forFilter($filter, $conn);
+ $this->set('object_type', 'object');
+
+ foreach ($hosts as $hostname) {
+ $file = $this->legacyHostnameServicesFile($hostname, $config);
+ $this->set('host', $hostname);
+ $file->addLegacyObject($this);
+ }
+
+ $this->set('host', null);
+ $this->set('object_type', 'apply');
+ }
+
+ protected function legacyHostnameServicesFile($hostname, IcingaConfig $config)
+ {
+ return $config->configFile(
+ 'director/' . IcingaHost::load($hostname, $this->getConnection())->getRenderingZone($config) . '/service_apply'
+ );
+ }
+
public function toLegacyConfigString()
{
if ($this->get('service_set_id')) {
More information about the icinga-checkins
mailing list