Add initial charm code
Co-authored-by: Marius Oprin <moprin@cloudbasesolutions.com>
This commit is contained in:
parent
b0cb9da641
commit
b674530d33
17
src/layer.yaml
Normal file
17
src/layer.yaml
Normal file
@ -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
|
35
src/lib/charm/openstack/magnum_dashboard.py
Normal file
35
src/lib/charm/openstack/magnum_dashboard.py
Normal file
@ -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)
|
16
src/metadata.yaml
Normal file
16
src/metadata.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
name: magnum-dashboard
|
||||
summary: Openstack Magnum Dashboard
|
||||
maintainer: Marius Oprin<moprin@cloudbasesolutions.com>
|
||||
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
|
41
src/reactive/magnum_dashboard.py
Normal file
41
src/reactive/magnum_dashboard.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user