summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@linux.vnet.ibm.com>2016-01-06 11:54:48 -0800
committerJames E. Blair <jeblair@linux.vnet.ibm.com>2016-01-06 11:54:48 -0800
commit17e53a824dfc6ce421f8dd11687e3602ddf11264 (patch)
treeb9aca18b77893405bee5b0ebacfb7708074236a4
parentff88ef29e2bcd1ea2fa0790395ee8e7ecddc9daa (diff)
Add support for Y axis formats0.0.5
The list of valid formats is taken from: https://github.com/grafana/grafana/blob/master/public/app/core/utils/kbn.js (grep "value:" in that file). Change-Id: Ibe7317847beba3db3205d759fbf6492e005b128f
Notes
Notes (review): Code-Review+1: Anita Kuno <anteaya@anteaya.info> Code-Review+2: Paul Belanger <pabelanger@redhat.com> Workflow+1: Paul Belanger <pabelanger@redhat.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 07 Jan 2016 16:13:45 +0000 Reviewed-on: https://review.openstack.org/264331 Project: openstack-infra/grafyaml Branch: refs/heads/master
-rw-r--r--grafana_dashboards/schema/panel/graph.py65
-rw-r--r--tests/schema/fixtures/dashboard-0010.json44
-rw-r--r--tests/schema/fixtures/dashboard-0010.yaml15
3 files changed, 124 insertions, 0 deletions
diff --git a/grafana_dashboards/schema/panel/graph.py b/grafana_dashboards/schema/panel/graph.py
index 4d18bb4..c24f235 100644
--- a/grafana_dashboards/schema/panel/graph.py
+++ b/grafana_dashboards/schema/panel/graph.py
@@ -1,3 +1,5 @@
1# -*- coding: utf-8 -*-
2
1# Copyright 2015 Red Hat, Inc. 3# Copyright 2015 Red Hat, Inc.
2# 4#
3# Licensed under the Apache License, Version 2.0 (the "License"); 5# Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +22,68 @@ from grafana_dashboards.schema.panel.base import Base
20class Graph(Base): 22class Graph(Base):
21 23
22 def get_schema(self): 24 def get_schema(self):
25 y_format = v.Any(
26 u'none',
27 u'short',
28 u'percent',
29 u'percentunit',
30 u'humidity',
31 u'ppm',
32 u'dB',
33 u'currencyUSD',
34 u'currencyGBP',
35 u'currencyEUR',
36 u'currencyJPY',
37 u'hertz',
38 u'ns',
39 u'µs',
40 u'ms',
41 u's',
42 u'm',
43 u'h',
44 u'd',
45 u'bits',
46 u'bytes',
47 u'kbytes',
48 u'mbytes',
49 u'gbytes',
50 u'pps',
51 u'bps',
52 u'Bps',
53 u'ops',
54 u'rps',
55 u'wps',
56 u'iops',
57 u'lengthmm',
58 u'lengthm',
59 u'lengthkm',
60 u'lengthmi',
61 u'velocityms',
62 u'velocitykmh',
63 u'velocitymph',
64 u'velocityknot',
65 u'mlitre',
66 u'litre',
67 u'm3',
68 u'watt',
69 u'kwatt',
70 u'watth',
71 u'kwatth',
72 u'joule',
73 u'ev',
74 u'amp',
75 u'volt',
76 u'celsius',
77 u'farenheit',
78 u'kelvin',
79 u'pressurembar',
80 u'pressurehpa',
81 u'pressurehg',
82 u'pressurepsi',
83 )
84
85 y_formats = [y_format]
86
23 graph = { 87 graph = {
24 v.Required('bars', default=False): v.All(bool), 88 v.Required('bars', default=False): v.All(bool),
25 v.Required('fill', default=1): v.All(int), 89 v.Required('fill', default=1): v.All(int),
@@ -35,6 +99,7 @@ class Graph(Base):
35 v.Required('y-axis', default=True): v.All(bool), 99 v.Required('y-axis', default=True): v.All(bool),
36 v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)), 100 v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)),
37 v.Optional('rightYAxisLabel'): v.All(str, v.Length(min=1)), 101 v.Optional('rightYAxisLabel'): v.All(str, v.Length(min=1)),
102 v.Optional('y_formats'): v.All(y_formats, v.Length(min=2, max=2)),
38 } 103 }
39 graph.update(self.base) 104 graph.update(self.base)
40 return v.Schema(graph) 105 return v.Schema(graph)
diff --git a/tests/schema/fixtures/dashboard-0010.json b/tests/schema/fixtures/dashboard-0010.json
new file mode 100644
index 0000000..8944003
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0010.json
@@ -0,0 +1,44 @@
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 "editable": true,
13 "error": false,
14 "fill": 1,
15 "leftYAxisLabel": "left label",
16 "lines": true,
17 "linewidth": 2,
18 "percentage": false,
19 "pointradius": 5,
20 "points": false,
21 "rightYAxisLabel": "right label",
22 "span": 12,
23 "stack": false,
24 "steppedLine": false,
25 "targets": [],
26 "title": "no title (click here)",
27 "type": "graph",
28 "x-axis": true,
29 "y-axis": true,
30 "y_formats": [
31 "hertz",
32 "\u00b5s"
33 ]
34 }
35 ],
36 "showTitle": false,
37 "title": "New row"
38 }
39 ],
40 "timezone": "utc",
41 "title": "New dashboard"
42 }
43 }
44}
diff --git a/tests/schema/fixtures/dashboard-0010.yaml b/tests/schema/fixtures/dashboard-0010.yaml
new file mode 100644
index 0000000..4f767d7
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0010.yaml
@@ -0,0 +1,15 @@
1# -*- coding: utf-8 -*-
2
3dashboard:
4 title: New dashboard
5 rows:
6 - title: New row
7 height: 250px
8 panels:
9 - title: no title (click here)
10 type: graph
11 leftYAxisLabel: left label
12 rightYAxisLabel: right label
13 y_formats:
14 - hertz
15 - µs