summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuique Llorente <ellorent@redhat.com>2018-07-11 08:52:14 +0200
committerQuique Llorente <ellorent@redhat.com>2018-07-11 08:53:04 +0200
commit2ffded73e99197bb172c915b36fb312e9dfd1712 (patch)
tree2c42d885918074498130ce4b107062fafbe85973
parent2ff186cae74650d660afccdc9f0762e033c6c373 (diff)
Add panel type 'row'HEADmaster
Notes
Notes (review): Code-Review+2: Paul Belanger <pabelanger@redhat.com> Workflow+1: Paul Belanger <pabelanger@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 11 Jul 2018 14:16:37 +0000 Reviewed-on: https://review.openstack.org/581594 Project: openstack-infra/grafyaml Branch: refs/heads/master
-rw-r--r--grafana_dashboards/schema/panel/__init__.py3
-rw-r--r--grafana_dashboards/schema/panel/base.py2
-rw-r--r--grafana_dashboards/schema/panel/row.py28
-rw-r--r--tests/schema/fixtures/dashboard-0033.json36
-rw-r--r--tests/schema/fixtures/dashboard-0033.yaml12
5 files changed, 80 insertions, 1 deletions
diff --git a/grafana_dashboards/schema/panel/__init__.py b/grafana_dashboards/schema/panel/__init__.py
index ab103eb..d9dab40 100644
--- a/grafana_dashboards/schema/panel/__init__.py
+++ b/grafana_dashboards/schema/panel/__init__.py
@@ -17,6 +17,7 @@ import voluptuous as v
17from grafana_dashboards.schema.panel.base import Base 17from grafana_dashboards.schema.panel.base import Base
18from grafana_dashboards.schema.panel.dashlist import Dashlist 18from grafana_dashboards.schema.panel.dashlist import Dashlist
19from grafana_dashboards.schema.panel.graph import Graph 19from grafana_dashboards.schema.panel.graph import Graph
20from grafana_dashboards.schema.panel.row import Row
20from grafana_dashboards.schema.panel.singlestat import Singlestat 21from grafana_dashboards.schema.panel.singlestat import Singlestat
21from grafana_dashboards.schema.panel.text import Text 22from grafana_dashboards.schema.panel.text import Text
22 23
@@ -42,6 +43,8 @@ class Panel(object):
42 schema = Singlestat().get_schema() 43 schema = Singlestat().get_schema()
43 elif panel['type'] == 'text': 44 elif panel['type'] == 'text':
44 schema = Text().get_schema() 45 schema = Text().get_schema()
46 elif panel['type'] == 'row':
47 schema = Row().get_schema()
45 48
46 res.append(schema(panel)) 49 res.append(schema(panel))
47 50
diff --git a/grafana_dashboards/schema/panel/base.py b/grafana_dashboards/schema/panel/base.py
index 79a0483..cfb6c26 100644
--- a/grafana_dashboards/schema/panel/base.py
+++ b/grafana_dashboards/schema/panel/base.py
@@ -41,7 +41,7 @@ class Base(object):
41 v.Required('span', default=12): v.All(int, v.Range(min=0, max=12)), 41 v.Required('span', default=12): v.All(int, v.Range(min=0, max=12)),
42 v.Required('title'): v.All(str, v.Length(min=1)), 42 v.Required('title'): v.All(str, v.Length(min=1)),
43 v.Required('type'): v.Any( 43 v.Required('type'): v.Any(
44 'dashlist', 'graph', 'singlestat', 'text'), 44 'dashlist', 'graph', 'singlestat', 'text', 'row'),
45 v.Optional('id'): int, 45 v.Optional('id'): int,
46 v.Optional('format'): v.Any(self.formats, v.Length(min=1)), 46 v.Optional('format'): v.Any(self.formats, v.Length(min=1)),
47 v.Optional('transparent'): v.All(bool), 47 v.Optional('transparent'): v.All(bool),
diff --git a/grafana_dashboards/schema/panel/row.py b/grafana_dashboards/schema/panel/row.py
new file mode 100644
index 0000000..b48ac56
--- /dev/null
+++ b/grafana_dashboards/schema/panel/row.py
@@ -0,0 +1,28 @@
1# Copyright 2018 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import voluptuous as v
16
17from grafana_dashboards.schema.panel.base import Base
18
19
20class Row(Base):
21
22 def get_schema(self):
23 row = {
24 v.Required('collapsed'): v.All(bool),
25 v.Optional('panels', default=[]): v.All([str])
26 }
27 row.update(self.base)
28 return v.Schema(row)
diff --git a/tests/schema/fixtures/dashboard-0033.json b/tests/schema/fixtures/dashboard-0033.json
new file mode 100644
index 0000000..d061ed1
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0033.json
@@ -0,0 +1,36 @@
1{
2 "dashboard": {
3 "new-dashboard": {
4 "rows": [
5 {
6 "collapse": false,
7 "editable": true,
8 "height": "250px",
9 "panels": [
10 {
11 "collapsed": false,
12 "editable": true,
13 "error": false,
14 "panels": [],
15 "span": 12,
16 "title": "Main",
17 "type": "row"
18 }
19 ],
20 "showTitle": false,
21 "title": "New row"
22 }
23 ],
24 "templating": {
25 "enabled": false,
26 "list": []
27 },
28 "time": {
29 "from": "2018-02-07T08:42:27.000Z",
30 "to": "2018-02-07T13:48:32.000Z"
31 },
32 "timezone": "utc",
33 "title": "New dashboard"
34 }
35 }
36}
diff --git a/tests/schema/fixtures/dashboard-0033.yaml b/tests/schema/fixtures/dashboard-0033.yaml
new file mode 100644
index 0000000..efc4f5d
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0033.yaml
@@ -0,0 +1,12 @@
1dashboard:
2 time:
3 from: "2018-02-07T08:42:27.000Z"
4 to: "2018-02-07T13:48:32.000Z"
5 title: New dashboard
6 rows:
7 - title: New row
8 height: 250px
9 panels:
10 - collapsed: false
11 title: Main
12 type: row