Add new upgrade check
This patch adds upgrade check which will test if fwaas v1 service plugin is still enabled in configuration and will then return error as this plugin is now removed already. Depends-On: https://review.openstack.org/637204 Change-Id: Idcb60128295fd26da5adb348b59f51a1c2c227a6
This commit is contained in:
parent
cc2e0a3f00
commit
4a8687e3f3
|
@ -0,0 +1,40 @@
|
|||
# Copyright 2019 Red Hat Inc.
|
||||
#
|
||||
# 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 neutron_lib.utils import upgrade_checks as base_checks
|
||||
from oslo_config import cfg
|
||||
from oslo_upgradecheck import upgradecheck
|
||||
|
||||
from neutron_fwaas._i18n import _
|
||||
|
||||
|
||||
class Checks(base_checks.BaseChecks):
|
||||
|
||||
def get_checks(self):
|
||||
return [
|
||||
(_("Check FWaaS v1"), self.fwaas_v1_check)
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def fwaas_v1_check(checker):
|
||||
fwaas_v1_names = [
|
||||
'firewall',
|
||||
'neutron_fwaas.services.firewall.fwaas_plugin:FirewallPlugin']
|
||||
for name in fwaas_v1_names:
|
||||
if name in cfg.CONF.service_plugins:
|
||||
return upgradecheck.Result(
|
||||
upgradecheck.Code.FAILURE,
|
||||
_("FWaaS v1 is removed. "
|
||||
"FWaaS v2 should be used instead."))
|
||||
return upgradecheck.Result(upgradecheck.Code.SUCCESS)
|
|
@ -0,0 +1,46 @@
|
|||
# Copyright 2019 Red Hat Inc.
|
||||
#
|
||||
# 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 mock
|
||||
from oslo_config import cfg
|
||||
from oslo_upgradecheck.upgradecheck import Code
|
||||
|
||||
from neutron_fwaas.cmd.upgrade_checks import checks
|
||||
from neutron_fwaas.tests import base
|
||||
|
||||
|
||||
class TestChecks(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestChecks, self).setUp()
|
||||
self.checks = checks.Checks()
|
||||
|
||||
def test_get_checks_list(self):
|
||||
self.assertIsInstance(self.checks.get_checks(), list)
|
||||
|
||||
def test_fwaas_v1_check_sucess(self):
|
||||
cfg.CONF.set_override('service_plugins', ['l3', 'qos'])
|
||||
check_result = checks.Checks.fwaas_v1_check(mock.Mock())
|
||||
self.assertEqual(Code.SUCCESS, check_result.code)
|
||||
|
||||
def test_fwaas_v1_check_warning(self):
|
||||
plugins_to_check = [
|
||||
['l3', 'firewall', 'qos'],
|
||||
['l3',
|
||||
'neutron_fwaas.services.firewall.fwaas_plugin:FirewallPlugin',
|
||||
'qos']]
|
||||
for plugins in plugins_to_check:
|
||||
cfg.CONF.set_override('service_plugins', plugins)
|
||||
check_result = checks.Checks.fwaas_v1_check(mock.Mock())
|
||||
self.assertEqual(Code.FAILURE, check_result.code)
|
|
@ -62,6 +62,8 @@ neutron.services.logapi.drivers =
|
|||
fwaas_v2_log = neutron_fwaas.services.logapi.agents.drivers.iptables.log:IptablesLoggingDriver
|
||||
console_scripts =
|
||||
neutron-fwaas-migrate-v1-to-v2 = neutron_fwaas.cmd.v1_to_v2_db_migration:main
|
||||
neutron.status.upgrade.checks =
|
||||
neutron_fwaas = neutron_fwaas.cmd.upgrade_checks.checks:Checks
|
||||
|
||||
[extract_messages]
|
||||
keywords = _ gettext ngettext l_ lazy_gettext
|
||||
|
|
Loading…
Reference in New Issue