--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+release/
+__pycache__
+.tox
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+---
+
+extends: default
+rules:
+ line-length: disable
+yaml-files:
+ - '*.yaml'
+ - '*.yml'
+ - '.yamllint'
+ignore: |
+ reactive/
+ .tox
+ release/
--- /dev/null
+<!-- Copyright 2021 Canonical Ltd.
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may
+not use this file except in compliance with the License. You may obtain
+a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations
+under the License.
+
+For those usages not covered by the Apache License, Version 2.0 please
+contact: legal@canonical.com
+
+To get in touch with the maintainers, please contact:
+osm-charmers@lists.launchpad.net -->
+
+# Overview
+
+Grafana for Juju CAAS
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+options:
+ advertised-hostname:
+ description: Grafana Hostname
+ type: string
+ default: "grafana-k8s"
+ advertised-port:
+ description: Grafana Port
+ type: int
+ default: 3000
+ image:
+ type: string
+ description: OCI image
+ default: rocks.canonical.com:443/grafana/grafana:latest
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="244px"
+ height="95px" viewBox="0 0 244 95" enable-background="new 0 0 244 95" xml:space="preserve">
+<g id="Layer_2">
+</g>
+<g id="Layer_1">
+ <g id="Layer_3">
+ <g>
+ <g>
+ <path fill="#666766" d="M50.9,63.3v18.9c-4.3,5.7-11,9.2-18.1,9.2c-12.3,0-22.3-10-22.3-22.4c0-12.3,10-22.3,22.3-22.3
+ c6.1,0,11.7,2.4,15.8,6.6l-4,3.5c-3.1-3.1-7.4-4.8-11.9-4.8c-9.4,0-17,7.6-17,17c0,9.5,7.6,17.1,17,17.1c5,0,9.5-2.1,12.8-5.8
+ V68.6H33.1v-5.3H50.9z"/>
+ <path fill="#666766" d="M63.6,66.1c1.7-1.9,6.8-3.4,10-3.4l-1.3,5.2c-4.8,0-8.8,3.7-8.8,8.3v14.6h-5.2V63.3h5.2V66.1z"/>
+ <path fill="#666766" d="M99.1,63.3h5.2v27.5h-5.2v-3.2c-2.6,2.2-5.8,3.8-9.2,3.8c-3.8,0-7.4-1.4-10.2-4.1
+ c-2.7-2.8-4.2-6.4-4.2-10.2s1.5-7.4,4.2-10.2c2.8-2.7,6.4-4.1,10.2-4.1c3.4,0,6.7,1.6,9.2,3.8V63.3z M99.1,77.1
+ c0-5.1-4.1-9.3-9.2-9.3s-9.2,4.2-9.2,9.3c0,5.1,4.1,9.3,9.2,9.3S99.1,82.2,99.1,77.1z"/>
+ <path fill="#666766" d="M129,46.8l-1.3,4.9h-4.6c-2.2,0-4.1,2-4.1,4.2v7.4h8.5v4.9H119v22.6h-5.2V68.2h-4.1v-4.9h4.1v-7.6
+ c0-5,4.1-9,9.1-9H129z"/>
+ <path fill="#666766" d="M153.9,63.3h5.2v27.5h-5.2v-3.2c-2.6,2.2-5.8,3.8-9.2,3.8c-3.8,0-7.4-1.4-10.2-4.1
+ c-2.7-2.8-4.2-6.4-4.2-10.2s1.5-7.4,4.2-10.2c2.8-2.7,6.4-4.1,10.2-4.1c3.4,0,6.7,1.6,9.2,3.8V63.3z M153.9,77.1
+ c0-5.1-4.1-9.3-9.2-9.3s-9.2,4.2-9.2,9.3c0,5.1,4.1,9.3,9.2,9.3S153.9,82.2,153.9,77.1z"/>
+ <path fill="#666766" d="M192.9,76v14.8h-5.2V76c0-4.5-3.6-8.2-8.1-8.2c-4.4,0-8.1,3.7-8.1,8.2v14.8h-5.2V63.3h5.2V66
+ c2.3-1.8,5.2-3.2,8.1-3.2c3.5,0,6.9,1.3,9.4,3.8C191.5,69.1,192.9,72.4,192.9,76z"/>
+ <path fill="#666766" d="M221.2,63.3h5.2v27.5h-5.2v-3.2c-2.6,2.2-5.8,3.8-9.2,3.8c-3.8,0-7.4-1.4-10.2-4.1
+ c-2.7-2.8-4.2-6.4-4.2-10.2s1.5-7.4,4.2-10.2c2.8-2.7,6.4-4.1,10.2-4.1c3.4,0,6.7,1.6,9.2,3.8V63.3z M221.2,77.1
+ c0-5.1-4.1-9.3-9.2-9.3s-9.2,4.2-9.2,9.3c0,5.1,4.1,9.3,9.2,9.3S221.2,82.2,221.2,77.1z"/>
+ </g>
+ </g>
+ </g>
+ <g id="XMLID_1_">
+ <g>
+ <g>
+ <linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="122.2529" y1="92.5215" x2="122.2529" y2="2.3985">
+ <stop offset="0" style="stop-color:#F5EB21"/>
+ <stop offset="0.3608" style="stop-color:#F0AE26"/>
+ <stop offset="1" style="stop-color:#EE2A24"/>
+ </linearGradient>
+ <path fill="url(#SVGID_1_)" d="M226.4,52.3c12.3,6.8,20.2,18.6,14.1,30.2c-4.1,7.8-9.4,11.3-7.6,9.4c3.8-4.1,9.3-11.2,6.8-19.8
+ c-1.3-4.8-4.6-11.1-14.9-16.9c-44-24.5-75.2-21.2-75.2-21.2c-6.3,0.8-5.9,10,0.8,25.1c0,0-8.2-3.2-13.7,0.4
+ c5.1-10.5,3.5-29.2-5.9-24.7c-17.9,8.6-24,0.8-31.7-0.9c-5.1-1.1-8.3,8.8-7.4,16.5c0.7,6.1,5.1,9,3.7,8.6
+ c-7.6-2.4-13.7,0.5-13.7,0.5c-1.3,0.4,7.2-18.2,1.8-25.1c-6.5-8.2-51.3-1-35.9,6.7l2.6,1.6l5,3.8c0.6,0.4,1.1,0.9,1.5,1.4
+ l1.1,1.2c0.6,1.1,2.1,2.1,1.8,4.2c-0.5,3.1-0.6-0.7-3.5-0.8c-1,0-1.5,0.6-3.1,0.9c-1.3,0.2,3.4-1.9-0.4-4.8
+ C41,40.1,35.1,39.7,27,41.1c-7.9,1.4-21.8,8.5-18.1,16.1C9.3,58.1,7,55,4.8,58c-0.6,0.9-1.5,1.5-2,2.4c-0.2,0.5-0.9,0.3-0.9-0.2
+ C2.5,55.2,3.7,47.7,5.8,45c3.2-4.1,6-5.2,6-5.2s1.3-0.8,3.2-1c3.2-0.2,5.5,0.8,5.2-0.4c-0.4-1.5-2.2-4-3-5
+ c-0.8-1.1,2.1,1.3,5.2,2.5c3.1,1.2,4.6,1.4,4.2,0.5c-1.4-3.5-6.3-6.2-5-5.9c1.9,0.4,6,4,7,4.5c1,0.5,2.2-0.5,1.9-1
+ c-1.8-3.5-4.4-5.9-6.2-8.2c-1.8-2.3-2.1-3-0.8-2.3c1.3,0.7,5,4.4,6.7,6.3c1.7,1.9,5.4,3.3,4.5,1.8c-0.9-1.5-3.2-4.4-2.3-4.4
+ c0.9,0,4.3,3.2,5.4,3.2c1.1,0-9.7-12-8.6-12.4c1.1-0.4,9.1,8.9,10.4,10.1c1.3,1.1,3.1,1,3.8-0.2c1-1.7,0.9-2.7,0.3-4.6
+ c-0.6-2-3.4-6.7-2.7-6.6c0.6,0.1,8,9.6,9.4,10.2c1.5,0.6,2.5,0.2,2.4-0.5c-0.1-0.7-1.2-3-0.6-2.7c0.7,0.2,4.2,4,4.6,3.1
+ c0.4-0.9-0.2-1.8-1.8-4.7c-1.7-3.2-2.9-4.7-3.6-6.2c-1.4-2.9,10,9.8,11.5,11.1c1.4,1.2,0.4-2.3-0.1-4.4
+ c-1.2-5.8-4.5-13.1-3.2-12.6c1.3,0.5,9.1,17.9,12.1,13.6c3.7-5.1-6.6-36.7,3.5-11.2c3,7.5,4.8,13.1,7.2,11.3
+ c3.4-2.5,1.9-15,1.8-15.8c0.3,0.9,4.7,15.4,10.7,13.6c9.3-2.9,16.8-9.5,71.4,6.9C172.4,29.9,194.5,34.7,226.4,52.3z"/>
+ </g>
+ </g>
+ <g>
+ <g>
+ <linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="122.2529" y1="2.4034" x2="122.2529" y2="92.4146">
+ <stop offset="0" style="stop-color:#EE2A24"/>
+ <stop offset="5.747605e-02" style="stop-color:#ED4E24"/>
+ <stop offset="0.2818" style="stop-color:#F0A426"/>
+ <stop offset="0.4362" style="stop-color:#F3D624"/>
+ <stop offset="0.5074" style="stop-color:#F5EB21"/>
+ </linearGradient>
+ <path fill="url(#SVGID_2_)" d="M226.4,52.3c12.3,6.8,20.2,18.6,14.1,30.2c-4.1,7.8-9.4,11.3-7.6,9.4c3.8-4.1,9.3-11.2,6.8-19.8
+ c-1.3-4.8-4.6-11.1-14.9-16.9c-44-24.5-75.2-21.2-75.2-21.2c-6.3,0.8-5.9,10,0.8,25.1c0,0-8.2-3.2-13.7,0.4
+ c5.1-10.5,3.5-29.2-5.9-24.7c-17.9,8.6-24,0.8-31.7-0.9c-5.1-1.1-8.3,8.8-7.4,16.5c0.7,6.1,5.1,9,3.7,8.6
+ c-7.6-2.4-13.7,0.5-13.7,0.5c-1.3,0.4,7.2-18.2,1.8-25.1c-6.5-8.2-51.3-1-35.9,6.7l2.6,1.6l5,3.8c0.6,0.4,1.1,0.9,1.5,1.4
+ l1.1,1.2c0.6,1.1,2.1,2.1,1.8,4.2c-0.5,3.1-0.6-0.7-3.5-0.8c-1,0-1.5,0.6-3.1,0.9c-1.3,0.2,3.4-1.9-0.4-4.8
+ C41,40.1,35.1,39.7,27,41.1c-7.9,1.4-21.8,8.5-18.1,16.1C9.3,58.1,7,55,4.8,58c-0.6,0.9-1.5,1.5-2,2.4c-0.2,0.5-0.9,0.3-0.9-0.2
+ C2.5,55.2,3.7,47.7,5.8,45c3.2-4.1,6-5.2,6-5.2s1.3-0.8,3.2-1c3.2-0.2,5.5,0.8,5.2-0.4c-0.4-1.5-2.2-4-3-5
+ c-0.8-1.1,2.1,1.3,5.2,2.5c3.1,1.2,4.6,1.4,4.2,0.5c-1.4-3.5-6.3-6.2-5-5.9c1.9,0.4,6,4,7,4.5c1,0.5,2.2-0.5,1.9-1
+ c-1.8-3.5-4.4-5.9-6.2-8.2c-1.8-2.3-2.1-3-0.8-2.3c1.3,0.7,5,4.4,6.7,6.3c1.7,1.9,5.4,3.3,4.5,1.8c-0.9-1.5-3.2-4.4-2.3-4.4
+ c0.9,0,4.3,3.2,5.4,3.2c1.1,0-9.7-12-8.6-12.4c1.1-0.4,9.1,8.9,10.4,10.1c1.3,1.1,3.1,1,3.8-0.2c1-1.7,0.9-2.7,0.3-4.6
+ c-0.6-2-3.4-6.7-2.7-6.6c0.6,0.1,8,9.6,9.4,10.2c1.5,0.6,2.5,0.2,2.4-0.5c-0.1-0.7-1.2-3-0.6-2.7c0.7,0.2,4.2,4,4.6,3.1
+ c0.4-0.9-0.2-1.8-1.8-4.7c-1.7-3.2-2.9-4.7-3.6-6.2c-1.4-2.9,10,9.8,11.5,11.1c1.4,1.2,0.4-2.3-0.1-4.4
+ c-1.2-5.8-4.5-13.1-3.2-12.6c1.3,0.5,9.1,17.9,12.1,13.6c3.7-5.1-6.6-36.7,3.5-11.2c3,7.5,4.8,13.1,7.2,11.3
+ c3.4-2.5,1.9-15,1.8-15.8c0.3,0.9,4.7,15.4,10.7,13.6c9.3-2.9,16.8-9.5,71.4,6.9C172.4,29.9,194.5,34.7,226.4,52.3z"/>
+ </g>
+ </g>
+ </g>
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8.9,45.8c0,0,0.6,0,1.4-0.2c0.7-0.2,1.6-0.9,2.1-1.4c0.5-0.5,1.2-1.8,1.2-1.8
+ s-2.2,0-3,1C9.8,44.3,9.3,45.1,8.9,45.8L8.9,45.8z"/>
+</g>
+</svg>
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+includes:
+ - "layer:caas-base"
+ - 'layer:status'
+ - 'layer:leadership'
+ - "layer:osm-common"
+ - "interface:prometheus"
+
+repo: https://code.launchpad.net/osm-k8s-bundle
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+name: "grafana-k8s"
+summary: "Grafana charm for Kubernetes"
+maintainers:
+ - "SolutionsQA <solutionsqa@lists.canonical.com>"
+description: |
+ A CAAS charm to deploy grafana
+tags:
+ - "application"
+series:
+ - "kubernetes"
+requires:
+ prometheus:
+ interface: prometheus
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+from charms.layer.caas_base import pod_spec_set
+from charms.reactive import endpoint_from_flag
+from charms.reactive import when, when_not, hook
+from charms.reactive.flags import set_flag, clear_flag
+from charmhelpers.core.hookenv import (
+ log,
+ metadata,
+ config,
+)
+from charms import layer
+from charmhelpers.core import hookenv
+import traceback
+
+
+@hook("upgrade-charm")
+@when("leadership.is_leader")
+def upgrade():
+ clear_flag("grafana-k8s.configured")
+
+
+@when("config.changed")
+@when("leadership.is_leader")
+def restart():
+ clear_flag("grafana-k8s.configured")
+
+
+@when_not("endpoint.prometheus.available")
+@when("leadership.is_leader")
+def waiting_for_prometheus_interface():
+ layer.status.waiting("Waiting for prometheus interface")
+
+
+@when("endpoint.prometheus.available")
+@when_not("grafana-k8s.configured")
+@when("leadership.is_leader")
+def configure():
+ layer.status.maintenance("Configuring grafana container")
+ try:
+ prometheus = endpoint_from_flag("endpoint.prometheus.available")
+ prometheus_url = prometheus.targets()[0]["targets"][0]
+
+ if prometheus_url:
+ spec = make_pod_spec(prometheus_url)
+ log("set pod spec:\n{}".format(spec))
+ pod_spec_set(spec)
+ set_flag("grafana-k8s.configured")
+ layer.status.active("ready")
+
+ except Exception as e:
+ layer.status.blocked("k8s spec failed to deploy: {}".format(e))
+ log(traceback.format_exc(), level=hookenv.ERROR)
+
+
+@when("grafana-k8s.configured")
+def set_grafana_active():
+ layer.status.active("ready")
+
+
+@when("endpoint.prometheus.available")
+@when_not("leadership.is_leader")
+def non_leaders_active():
+ layer.status.active("ready")
+
+
+def make_pod_spec(prometheus_url):
+ """Make pod specification for Kubernetes
+
+ Returns:
+ pod_spec: Pod specification for Kubernetes
+ """
+ with open("reactive/spec_template.yaml") as spec_file:
+ pod_spec_template = spec_file.read()
+
+ md = metadata()
+ cfg = config()
+
+ data = {
+ "name": md.get("name"),
+ "docker_image": cfg.get("image"),
+ "prometheus_url": prometheus_url,
+ }
+ data.update(cfg)
+ return pod_spec_template % data
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+version: 2
+containers:
+ - name: %(name)s
+ image: %(docker_image)s
+ ports:
+ - containerPort: %(advertised-port)s
+ protocol: TCP
+ files:
+ - name: dashboards
+ mountPath: /etc/grafana/provisioning/dashboards/
+ files:
+ dashboards-osm.yml: |
+ apiVersion: 1
+ providers:
+ - name: 'osm'
+ orgId: 1
+ folder: ''
+ type: file
+ options:
+ path: /etc/grafana/provisioning/dashboards/
+ - name: datasources
+ mountPath: /etc/grafana/provisioning/datasources/
+ files:
+ datasource-prometheus.yml: |
+ datasources:
+ - access: proxy
+ editable: true
+ is_default: true
+ name: osm_prometheus
+ org_id: 1
+ type: prometheus
+ url: http://%(prometheus_url)s
+ version: 1
+ kubernetes:
+ readinessProbe:
+ httpGet:
+ path: /api/health
+ port: %(advertised-port)s
+ initialDelaySeconds: 10
+ periodSeconds: 10
+ timeoutSeconds: 5
+ successThreshold: 1
+ failureThreshold: 3
+ livenessProbe:
+ httpGet:
+ path: /api/health
+ port: %(advertised-port)s
+ initialDelaySeconds: 60
+ timeoutSeconds: 30
+ failureThreshold: 10
\ No newline at end of file
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+git+https://github.com/davigar15/zaza.git#egg=zaza
--- /dev/null
+#!/usr/bin/python3
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+import unittest
+import zaza.model as model
+import requests as http
+import time
+
+
+def get_grafana_uri():
+ ip = model.get_status().applications["grafana-k8s"]["public-address"]
+ port = 3000
+ return "http://{}:{}".format(ip, port)
+
+
+class BasicDeployment(unittest.TestCase):
+ def setUp(self):
+ ready = False
+ num_retries = 0
+ while not ready and num_retries < 5:
+ if (
+ model.get_status().applications["grafana-k8s"]["status"]["status"]
+ == "active"
+ ):
+ ready = True
+ else:
+ num_retries += 1
+ time.sleep(5)
+
+ def test_get_grafana_uri(self):
+ get_grafana_uri()
+
+ def test_grafana_get_home(self):
+ grafana_uri = get_grafana_uri()
+ body = http.get("{}/api/dashboards/home".format(grafana_uri))
+ self.assertEqual(body.status_code, 401) # TODO: Get API Token
+
+ def test_grafana_get_tags(self):
+ grafana_uri = get_grafana_uri()
+ body = http.get("{}/api/dashboards/tags".format(grafana_uri))
+ self.assertEqual(body.status_code, 401) # TODO: Get API Token
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+bundle: kubernetes
+applications:
+ prometheus-k8s:
+ charm: 'cs:~charmed-osm/prometheus-k8s'
+ channel: 'edge'
+ scale: 2
+ options:
+ default-target: "mon-k8s:8000"
+ series: kubernetes
+ storage:
+ database: 50M
+ grafana-k8s:
+ charm: '../../release'
+ scale: 2
+relations:
+ - - 'grafana-k8s:prometheus'
+ - 'prometheus-k8s:prometheus'
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+bundle: kubernetes
+applications:
+ prometheus-k8s:
+ charm: 'cs:~charmed-osm/prometheus-k8s'
+ channel: 'edge'
+ scale: 1
+ options:
+ default-target: "mon-k8s:8000"
+ series: kubernetes
+ storage:
+ database: 50M
+ grafana-k8s:
+ charm: '../../release'
+ scale: 1
+relations:
+ - - 'grafana-k8s:prometheus'
+ - 'prometheus-k8s:prometheus'
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+gate_bundles:
+ - grafana
+ - grafana-ha
+smoke_bundles:
+ - grafana
+tests:
+ - tests.basic_deployment.BasicDeployment
--- /dev/null
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+[tox]
+envlist = pep8
+skipsdist = True
+
+[testenv]
+setenv = VIRTUAL_ENV={envdir}
+ PYTHONHASHSEED=0
+whitelist_externals = juju
+passenv = HOME TERM CS_API_* OS_* AMULET_*
+deps = -r{toxinidir}/test-requirements.txt
+install_command =
+ pip install {opts} {packages}
+
+[testenv:build]
+basepython = python3
+passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
+setenv = CHARM_LAYERS_DIR = /tmp
+whitelist_externals = git
+ charm
+ rm
+ mv
+commands =
+ rm -rf /tmp/canonical-osm /tmp/osm-common
+ rm -rf release/
+ git clone https://git.launchpad.net/charm-osm-common /tmp/osm-common
+ charm build . --build-dir /tmp
+ mv /tmp/grafana-k8s/ release/
+
+[testenv:black]
+basepython = python3
+deps =
+ black
+ yamllint
+ flake8
+commands =
+ black --check --diff .
+ yamllint .
+ flake8 reactive/ --max-line-length=88
+ flake8 tests/ --max-line-length=88
+
+[testenv:pep8]
+basepython = python3
+deps=charm-tools
+commands = charm-proof
+
+[testenv:func-noop]
+basepython = python3
+commands =
+ true
+
+[testenv:func]
+basepython = python3
+commands = functest-run-suite
+
+
+[testenv:func-smoke]
+basepython = python3
+commands = functest-run-suite --keep-model --smoke
+
+[testenv:venv]
+commands = {posargs}