diff --git a/src/layer.yaml b/src/layer.yaml new file mode 100644 index 0000000..7f86054 --- /dev/null +++ b/src/layer.yaml @@ -0,0 +1,17 @@ +includes: + - layer:openstack + - interface:dashboard-plugin +options: + basic: + use_venv: True + include_system_packages: False +repo: https://github.com/openstack/charm-magnum-dashboard +config: + deletes: + - debug + - verbose + - use-internal-endpoints + - use-syslog + - ssl_ca + - ssl_cert + - ssl_key diff --git a/src/lib/charm/openstack/magnum_dashboard.py b/src/lib/charm/openstack/magnum_dashboard.py new file mode 100644 index 0000000..fde35b7 --- /dev/null +++ b/src/lib/charm/openstack/magnum_dashboard.py @@ -0,0 +1,35 @@ +# 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. +import os + +import charms_openstack.adapters +import charms_openstack.charm + + +class MagnumDashboardCharm(charms_openstack.charm.OpenStackCharm): + release = 'rocky' + name = 'octavia-dashboard' + packages = ['python3-magnum-ui'] + python_version = 3 + adapters_class = charms_openstack.adapters.OpenStackRelationAdapters + required_relations = ['dashboard'] + + def enable_ui_plugin(self): + source = '/etc/openstack-dashboard/enabled' + destination = '/usr/lib/python3/dist-packages/openstack_dashboard/local/enabled' + for filename in os.listdir(source): + if "container_infra" in filename: + src = os.path.join(source, filename) + dst = os.path.join(destination, filename) + os.symlink(src, dst) diff --git a/src/metadata.yaml b/src/metadata.yaml new file mode 100644 index 0000000..54d65ba --- /dev/null +++ b/src/metadata.yaml @@ -0,0 +1,16 @@ +name: magnum-dashboard +summary: Openstack Magnum Dashboard +maintainer: Marius Oprin +description: | + This is the dashboard for the OpenStack COE service, Magnum. +tags: +- openstack +series: +- bionic +- focal +- groovy +subordinate: true +requires: + dashboard: + interface: dashboard-plugin + scope: container diff --git a/src/reactive/magnum_dashboard.py b/src/reactive/magnum_dashboard.py new file mode 100644 index 0000000..7762ad8 --- /dev/null +++ b/src/reactive/magnum_dashboard.py @@ -0,0 +1,41 @@ +# Copyright 2018 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. + +import charms.reactive as reactive + +import charms_openstack.bus +import charms_openstack.charm as charm + +charms_openstack.bus.discover() + +# Use the charms.openstack defaults for common states and hooks +charm.use_defaults( + 'charm.installed', + 'config.changed', + 'update-status', + 'upgrade-charm') + + +@reactive.when('dashboard.available') +def dashboard_available(): + """Relation to OpenStack Dashboard principal charm complete. + """ + with charm.provide_charm_instance() as magnum_dashboard_charm: + dashboard_relation = reactive.endpoint_from_flag('dashboard.available') + dashboard_relation.publish_plugin_info( + "", None, + conflicting_packages=magnum_dashboard_charm.purge_packages, + install_packages=magnum_dashboard_charm.packages) + magnum_dashboard_charm.enable_ui_plugin() + magnum_dashboard_charm.assess_status()