Purge neutron-lbaas dashboard on install
Remove unnecessary config publish. Remove unused build time policy generation. Change-Id: I7616c7aaec8bdd60160e6bc7481ea41b5a71cd3c
This commit is contained in:
parent
18aeee9a65
commit
4d66c30ef4
|
@ -5,5 +5,3 @@
|
|||
# Build requirements
|
||||
charm-tools>=2.4.4
|
||||
simplejson
|
||||
oslo.policy
|
||||
octavia
|
||||
|
|
|
@ -15,11 +15,26 @@
|
|||
import charms_openstack.adapters
|
||||
import charms_openstack.charm
|
||||
|
||||
import charmhelpers.fetch as ch_fetch
|
||||
|
||||
|
||||
class OctaviaDashboardCharm(charms_openstack.charm.OpenStackCharm):
|
||||
release = 'rocky'
|
||||
name = 'octavia-dashboard'
|
||||
packages = ['python3-octavia-dashboard']
|
||||
purge_packages = ['python3-neutron-lbaas-dashboard']
|
||||
python_version = 3
|
||||
adapters_class = charms_openstack.adapters.OpenStackRelationAdapters
|
||||
required_relations = ['dashboard']
|
||||
|
||||
def install(self):
|
||||
# NOTE(fnordahl) purge_packages is only honoured by charms.openstack
|
||||
# on OpenStack upgrade, not first install.
|
||||
installed_purge_packages = list(
|
||||
set(self.purge_packages) -
|
||||
set(ch_fetch.filter_installed_packages(self.purge_packages))
|
||||
)
|
||||
if installed_purge_packages:
|
||||
ch_fetch.apt_purge(packages=installed_purge_packages,
|
||||
fatal=True)
|
||||
super().install()
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import charmhelpers.core as ch_core
|
||||
|
||||
import charms.reactive as reactive
|
||||
|
||||
import charms_openstack.bus
|
||||
|
@ -32,8 +30,6 @@ charm.use_defaults(
|
|||
def dashboard_available():
|
||||
"""Relation to OpenStack Dashboard principal charm complete.
|
||||
"""
|
||||
dashboard = reactive.endpoint_from_flag('dashboard.available')
|
||||
ch_core.hookenv.log('DEBUG: dashboard_available "{}" "{}" "{}"'
|
||||
.format(dashboard.release, dashboard.bin_path,
|
||||
dashboard.openstack_dir))
|
||||
dashboard.publish_plugin_info({'setting-one-key': 'value-one'}, 'priority')
|
||||
# config and restart is handled by package install, just update our status
|
||||
with charm.provide_charm_instance() as octavia_dashboard_charm:
|
||||
octavia_dashboard_charm.assess_status()
|
||||
|
|
1
tox.ini
1
tox.ini
|
@ -21,7 +21,6 @@ deps =
|
|||
[testenv:build]
|
||||
basepython = python3
|
||||
commands =
|
||||
oslopolicy-policy-generator --namespace octavia --output-file src/templates/octavia_policy.yaml
|
||||
charm-build --log-level DEBUG -o {toxinidir}/build src {posargs}
|
||||
|
||||
[testenv:py35]
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# Copyright 2016 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.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
import charms_openstack.test_utils as test_utils
|
||||
|
||||
import charm.openstack.octavia_dashboard as octavia_dashboard
|
||||
|
||||
|
||||
class TestOctaviaDashboardHandlers(test_utils.PatchHelper):
|
||||
|
||||
def test_install(self):
|
||||
# we do not care about the internals of the function we are overriding
|
||||
# and expanding so mock out the call to super()
|
||||
self.patch_object(octavia_dashboard, 'ch_fetch')
|
||||
self.patch('builtins.super', 'super')
|
||||
c = octavia_dashboard.OctaviaDashboardCharm()
|
||||
c.install()
|
||||
self.ch_fetch.filter_installed_packages.return_value = []
|
||||
self.ch_fetch.filter_installed_packages.assert_called_with(
|
||||
c.purge_packages)
|
||||
self.ch_fetch.apt_purge.assert_called_with(
|
||||
fatal=True,
|
||||
packages=c.purge_packages)
|
||||
self.super.assert_called()
|
|
@ -42,11 +42,15 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
|
|||
|
||||
class TestOctaviaDashboardHandlers(test_utils.PatchHelper):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.octavia_dashboard_charm = mock.MagicMock()
|
||||
self.patch_object(handlers.charm, 'provide_charm_instance',
|
||||
new=mock.MagicMock())
|
||||
self.provide_charm_instance().__enter__.return_value = \
|
||||
self.octavia_dashboard_charm
|
||||
self.provide_charm_instance().__exit__.return_value = None
|
||||
|
||||
def test_dashboard_available(self):
|
||||
self.patch_object(handlers.reactive, 'endpoint_from_flag')
|
||||
dashboard = mock.MagicMock()
|
||||
self.endpoint_from_flag.return_value = dashboard
|
||||
handlers.dashboard_available()
|
||||
self.endpoint_from_flag.assert_called_once_with('dashboard.available')
|
||||
dashboard.publish_plugin_info.assert_called_once_with(
|
||||
{'setting-one-key': 'value-one'}, 'priority')
|
||||
self.octavia_dashboard_charm.assess_status.assert_called_once_with()
|
||||
|
|
Loading…
Reference in New Issue