summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-04-02 20:02:11 +0000
committerGerrit Code Review <review@openstack.org>2017-04-02 20:02:11 +0000
commitfccc26d53b384a1f15555526550cec15939ee9fb (patch)
treec273edbc2d9bede2fd71be9c225844deeb844695
parent91180e04760175b9970e2c272f100915c7ae173b (diff)
parentf89102bbf967ad59d9bfe5218f446cbce14ef7c9 (diff)
Merge "Add datasource option to more elements"0.0.6
-rw-r--r--grafana_dashboards/schema/panel/graph.py1
-rw-r--r--grafana_dashboards/schema/panel/singlestat.py1
-rw-r--r--grafana_dashboards/schema/template/query.py1
-rw-r--r--tests/schema/fixtures/dashboard-0019.json43
-rw-r--r--tests/schema/fixtures/dashboard-0019.yaml9
-rw-r--r--tests/schema/fixtures/dashboard-0020.json48
-rw-r--r--tests/schema/fixtures/dashboard-0020.yaml9
-rw-r--r--tests/schema/fixtures/dashboard-0021.json57
-rw-r--r--tests/schema/fixtures/dashboard-0021.yaml17
9 files changed, 186 insertions, 0 deletions
diff --git a/grafana_dashboards/schema/panel/graph.py b/grafana_dashboards/schema/panel/graph.py
index f3297b8..ada6f78 100644
--- a/grafana_dashboards/schema/panel/graph.py
+++ b/grafana_dashboards/schema/panel/graph.py
@@ -115,6 +115,7 @@ class Graph(Base):
115 115
116 graph = { 116 graph = {
117 v.Required('bars', default=False): v.All(bool), 117 v.Required('bars', default=False): v.All(bool),
118 v.Optional('datasource'): v.All(str),
118 v.Required('fill', default=1): v.All(int), 119 v.Required('fill', default=1): v.All(int),
119 v.Optional('hideTimeOverride'): v.All(bool), 120 v.Optional('hideTimeOverride'): v.All(bool),
120 v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)), 121 v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)),
diff --git a/grafana_dashboards/schema/panel/singlestat.py b/grafana_dashboards/schema/panel/singlestat.py
index 9b7d6a5..f8b48e4 100644
--- a/grafana_dashboards/schema/panel/singlestat.py
+++ b/grafana_dashboards/schema/panel/singlestat.py
@@ -62,6 +62,7 @@ class Singlestat(Base):
62 v.Match(r'^[1-9]?[0]{1}%$|^1[0-9]?[0]{1}%$|^200%$')), 62 v.Match(r'^[1-9]?[0]{1}%$|^1[0-9]?[0]{1}%$|^200%$')),
63 v.Required('valueName', default='avg'): v.Any( 63 v.Required('valueName', default='avg'): v.Any(
64 'avg', 'current', 'max', 'min', 'total'), 64 'avg', 'current', 'max', 'min', 'total'),
65 v.Optional('datasource'): v.All(str),
65 v.Optional('decimals'): v.All(int, v.Range(min=0, max=12)), 66 v.Optional('decimals'): v.All(int, v.Range(min=0, max=12)),
66 v.Optional('hideTimeOverride'): v.All(bool), 67 v.Optional('hideTimeOverride'): v.All(bool),
67 v.Optional('timeFrom'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')), 68 v.Optional('timeFrom'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')),
diff --git a/grafana_dashboards/schema/template/query.py b/grafana_dashboards/schema/template/query.py
index b0573a0..c55cbc8 100644
--- a/grafana_dashboards/schema/template/query.py
+++ b/grafana_dashboards/schema/template/query.py
@@ -25,6 +25,7 @@ class Query(Base):
25 v.Required('multi', default=False): v.All(bool), 25 v.Required('multi', default=False): v.All(bool),
26 v.Required('query', default=''): v.All(str), 26 v.Required('query', default=''): v.All(str),
27 v.Required('refresh', default=False): v.All(bool), 27 v.Required('refresh', default=False): v.All(bool),
28 v.Optional('datasource'): v.All(str),
28 } 29 }
29 query.update(self.base) 30 query.update(self.base)
30 return v.Schema(query) 31 return v.Schema(query)
diff --git a/tests/schema/fixtures/dashboard-0019.json b/tests/schema/fixtures/dashboard-0019.json
new file mode 100644
index 0000000..da730fe
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0019.json
@@ -0,0 +1,43 @@
1{
2 "dashboard": {
3 "new-dashboard": {
4 "rows": [
5 {
6 "collapse": false,
7 "editable": true,
8 "height": "250px",
9 "panels": [
10 {
11 "bars": false,
12 "datasource": "graphite",
13 "editable": true,
14 "error": false,
15 "fill": 1,
16 "lines": true,
17 "linewidth": 2,
18 "percentage": false,
19 "pointradius": 5,
20 "points": false,
21 "span": 12,
22 "stack": false,
23 "steppedLine": false,
24 "targets": [],
25 "title": "no title (click here)",
26 "type": "graph",
27 "x-axis": true,
28 "y-axis": true
29 }
30 ],
31 "showTitle": false,
32 "title": "New row"
33 }
34 ],
35 "templating": {
36 "enabled": false,
37 "list": []
38 },
39 "timezone": "utc",
40 "title": "New dashboard"
41 }
42 }
43}
diff --git a/tests/schema/fixtures/dashboard-0019.yaml b/tests/schema/fixtures/dashboard-0019.yaml
new file mode 100644
index 0000000..5aa35cd
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0019.yaml
@@ -0,0 +1,9 @@
1dashboard:
2 title: New dashboard
3 rows:
4 - title: New row
5 height: 250px
6 panels:
7 - title: no title (click here)
8 type: graph
9 datasource: graphite
diff --git a/tests/schema/fixtures/dashboard-0020.json b/tests/schema/fixtures/dashboard-0020.json
new file mode 100644
index 0000000..274f044
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0020.json
@@ -0,0 +1,48 @@
1{
2 "dashboard": {
3 "new-dashboard": {
4 "rows": [
5 {
6 "collapse": false,
7 "editable": true,
8 "height": "250px",
9 "panels": [
10 {
11 "colorBackground": false,
12 "colorValue": false,
13 "datasource": "graphite",
14 "editable": true,
15 "error": false,
16 "maxDataPoints": 100,
17 "postfix": "",
18 "postfixFontSize": "50%",
19 "prefix": "",
20 "prefixFontSize": "50%",
21 "span": 12,
22 "sparkline": {
23 "fillColor": "rgba(31, 118, 189, 0.18)",
24 "full": false,
25 "lineColor": "rgb(31, 120, 193)",
26 "show": false
27 },
28 "targets": [],
29 "thresholds": "",
30 "title": "no title (click here)",
31 "type": "singlestat",
32 "valueFontSize": "80%",
33 "valueName": "avg"
34 }
35 ],
36 "showTitle": false,
37 "title": "New row"
38 }
39 ],
40 "templating": {
41 "enabled": false,
42 "list": []
43 },
44 "timezone": "utc",
45 "title": "New dashboard"
46 }
47 }
48}
diff --git a/tests/schema/fixtures/dashboard-0020.yaml b/tests/schema/fixtures/dashboard-0020.yaml
new file mode 100644
index 0000000..c0e635f
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0020.yaml
@@ -0,0 +1,9 @@
1dashboard:
2 title: New dashboard
3 rows:
4 - title: New row
5 height: 250px
6 panels:
7 - title: no title (click here)
8 type: singlestat
9 datasource: graphite
diff --git a/tests/schema/fixtures/dashboard-0021.json b/tests/schema/fixtures/dashboard-0021.json
new file mode 100644
index 0000000..95c375b
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0021.json
@@ -0,0 +1,57 @@
1{
2 "dashboard": {
3 "new-dashboard": {
4 "rows": [
5 {
6 "collapse": false,
7 "editable": true,
8 "height": "250px",
9 "panels": [
10 {
11 "bars": false,
12 "datasource": "graphite",
13 "editable": true,
14 "error": false,
15 "fill": 1,
16 "lines": true,
17 "linewidth": 2,
18 "percentage": false,
19 "pointradius": 5,
20 "points": false,
21 "span": 12,
22 "stack": false,
23 "steppedLine": false,
24 "targets": [
25 {
26 "target": "$hostname.Cpu.cpu_prct_used"
27 }
28 ],
29 "title": "no title (click here)",
30 "type": "graph",
31 "x-axis": true,
32 "y-axis": true
33 }
34 ],
35 "showTitle": false,
36 "title": "New row"
37 }
38 ],
39 "templating": {
40 "enabled": true,
41 "list": [
42 {
43 "datasource": "graphite",
44 "includeAll": false,
45 "multi": false,
46 "name": "hostname",
47 "query": "node*",
48 "refresh": true,
49 "type": "query"
50 }
51 ]
52 },
53 "timezone": "utc",
54 "title": "New dashboard"
55 }
56 }
57}
diff --git a/tests/schema/fixtures/dashboard-0021.yaml b/tests/schema/fixtures/dashboard-0021.yaml
new file mode 100644
index 0000000..8f75a46
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0021.yaml
@@ -0,0 +1,17 @@
1dashboard:
2 templating:
3 - name: hostname
4 type: query
5 datasource: graphite
6 query: node*
7 refresh: true
8 title: New dashboard
9 rows:
10 - title: New row
11 height: 250px
12 panels:
13 - title: no title (click here)
14 type: graph
15 datasource: graphite
16 targets:
17 - target: $hostname.Cpu.cpu_prct_used