Added possibility to specify kibana object directly in the model
Change-Id: I773def408620a85f788c8d54a9e86820aba25c28
diff --git a/README.rst b/README.rst
index edfe4bc..97a30e1 100644
--- a/README.rst
+++ b/README.rst
@@ -71,6 +71,27 @@
template: kibana/files/objects/dashboard_logs.json
type: 'dashboard'
+Client directly use a Kibana object that is stored in model:
+
+ .. code-block:: yaml
+
+ kibana:
+ client:
+ enabled: true
+ server:
+ host: elasticsearch.host
+ port: 9200
+ object:
+ logs:
+ enabled: true
+ name: Logs
+ type: 'dashboard'
+ content:
+ title: "Logs"
+ hits: 0
+ description: ""
+ ...
+
Read more
=========
diff --git a/kibana/client/init.sls b/kibana/client/init.sls
index 7d1ba03..7f0f91c 100644
--- a/kibana/client/init.sls
+++ b/kibana/client/init.sls
@@ -13,9 +13,14 @@
{%- for object_name, object in client.get('object', {}).iteritems() %}
kibana_object_{{ object_name }}:
{%- if object.get('enabled', False) %}
+ {%- if object.content is defined %}
+ kibana_object.present:
+ - kibana_content: {{ object.content|json }}
+ {%- else %}
{% import_json object.template as content %}
kibana_object.present:
- kibana_content: {{ content|json }}
+ {%- endif %}
{%- else %}
kibana_object.absent:
{%- endif %}
diff --git a/tests/pillar/kibana_client.sls b/tests/pillar/kibana_client.sls
index 08d7a5f..a4d7cb7 100644
--- a/tests/pillar/kibana_client.sls
+++ b/tests/pillar/kibana_client.sls
@@ -7,3 +7,10 @@
enabled: true
template: kibana/files/objects/dashboard_logs.json
type: dashboard
+ logs-directly:
+ enabled: true
+ type: dashboard
+ content:
+ title: "Logs"
+ hits: 0
+ description: "Test dashboard"