[icinga-checkins] icinga.org: icinga-web/master: * Added additional filter fields for the xml template

git at icinga.org git at icinga.org
Tue Oct 20 16:19:19 CEST 2009


Module: icinga-web
Branch: master
Commit: 40f8495abeac62254cd6bc6b3cb62d8d8e3809c4
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=40f8495abeac62254cd6bc6b3cb62d8d8e3809c4

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Oct 20 12:08:03 2009 +0200

* Added additional filter fields for the xml template
* Altered the xml templates for hostgroup and servicegroup fields
* Searchtargets for host- and servicegroups

---

 .../templates/System/ObjectSearchSuccess.php       |   12 ++++++++++
 .../icinga/template/IcingaTemplateWorker.class.php |   22 +++++++++++++++++++-
 res/xml/icinga-host-template.xml                   |    5 ++++
 res/xml/icinga-service-template.xml                |    6 ++++-
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/app/modules/Cronks/templates/System/ObjectSearchSuccess.php b/app/modules/Cronks/templates/System/ObjectSearchSuccess.php
index 548c632..62cd8c5 100644
--- a/app/modules/Cronks/templates/System/ObjectSearchSuccess.php
+++ b/app/modules/Cronks/templates/System/ObjectSearchSuccess.php
@@ -335,6 +335,18 @@
 						params['template'] = 'icinga-service-template';
 					break;
 					
+					case 'hostgroup':
+						filter['f[hostgroup_object_id-value]'] = re.data.object_id;
+						filter['f[hostgroup_object_id-operator]'] = 50;
+						params['template'] = 'icinga-host-template';
+					break;
+					
+					case 'servicegroup':
+						filter['f[servicegroup_object_id-value]'] = re.data.object_id;
+						filter['f[servicegroup_object_id-operator]'] = 50;
+						params['template'] = 'icinga-service-template';
+					break;
+					
 					default:
 						Ext.Msg.alert('Search', 'This type is not ready implemented yet!');
 						return;
diff --git a/app/modules/Web/lib/icinga/template/IcingaTemplateWorker.class.php b/app/modules/Web/lib/icinga/template/IcingaTemplateWorker.class.php
index f1e6dc4..e4d6c3b 100644
--- a/app/modules/Web/lib/icinga/template/IcingaTemplateWorker.class.php
+++ b/app/modules/Web/lib/icinga/template/IcingaTemplateWorker.class.php
@@ -337,6 +337,22 @@ class IcingaTemplateWorker {
 		return array_keys($fields);
 	}
 	
+	private function getAdditionalFilterFields() {
+		static $fields = null;
+		
+		if ($fields === null) {
+			$ds = $this->getTemplate()->getSection('datasource');
+			if ($ds['additional_filter_fields'] && is_array($ds['additional_filter_fields'])) {
+				$fields = $ds['additional_filter_fields'];
+			}
+			else {
+				$fields = array ();
+			}
+		}
+		
+		return $fields;
+	}
+	
 	/**
 	 * Add a condition by a defined xml field
 	 * @param string $field
@@ -352,7 +368,11 @@ class IcingaTemplateWorker {
 		$database = $this->getTemplate()->getFieldByName($field, 'datasource');
 		$new_field = null;
 		
-		if ($filter->getParameter('field', null)) {
+		$ff = $this->getAdditionalFilterFields();
+		if (array_key_exists($field, $ff) == true) {
+			$new_field = $ff[$field];
+		}
+		elseif ($filter->getParameter('field', null)) {
 			$new_field = $filter->getParameter('field');
 		} 
 		else {
diff --git a/res/xml/icinga-host-template.xml b/res/xml/icinga-host-template.xml
index 06dbd28..24ca5fa 100644
--- a/res/xml/icinga-host-template.xml
+++ b/res/xml/icinga-host-template.xml
@@ -53,6 +53,11 @@
        	<parameter name="additional_fields">
        		<parameter name="max_attempt">HOST_MAX_CHECK_ATTEMPTS</parameter>
        	</parameter>
+       	
+       	<parameter name="additional_filter_fields">
+       		<parameter name="hostgroup_object_id">HOSTGROUP_OBJECT_ID</parameter>
+       		<parameter name="hostgroup_name">HOSTGROUP_NAME</parameter>
+       	</parameter>
     </datasource>
     
     <!-- 
diff --git a/res/xml/icinga-service-template.xml b/res/xml/icinga-service-template.xml
index 9e6d2a8..d1affa5 100644
--- a/res/xml/icinga-service-template.xml
+++ b/res/xml/icinga-service-template.xml
@@ -53,7 +53,11 @@
        	<parameter name="additional_fields">
        		<parameter name="service_max_attempt">SERVICE_MAX_CHECK_ATTEMPTS</parameter>
        	</parameter>
-         
+       	
+       	<parameter name="additional_filter_fields">
+       		<parameter name="servicegroup_object_id">SERVICEGROUP_OBJECT_ID</parameter>
+       		<parameter name="servicegroup_name">SERVICEGROUP_NAME</parameter>
+       	</parameter>
     </datasource>
     
     <!-- 





More information about the icinga-checkins mailing list