Files
designate/designate/cmd/status.py
T
Ghanshyam Mann 1c0bd99c08 [goal] Deprecate the JSON formatted policy file
As per the community goal of migrating the policy file
the format from JSON to YAML[1], we need to do two things:

1. Change the default value of '[oslo_policy] policy_file''
config option from 'policy.json' to 'policy.yaml' with
upgrade checks.

2. Deprecate the JSON formatted policy file on the project side
via warning in doc and releasenotes.

Also replace policy.json to policy.yaml ref from doc.

[1]https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html

Change-Id: I81e7ee3243af11ebb3589f530533731b87178a96
2021-03-08 19:13:17 -06:00

62 lines
2.4 KiB
Python

# Copyright 2018 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 oslo_upgradecheck import common_checks
from oslo_upgradecheck import upgradecheck
from sqlalchemy import MetaData, Table, select, func
import designate.conf
from designate.i18n import _
from designate.sqlalchemy import session
# This import is not used, but is needed to register the storage:sqlalchemy
# group.
import designate.storage.impl_sqlalchemy # noqa
from designate import utils
class Checks(upgradecheck.UpgradeCommands):
def _duplicate_service_status(self):
engine = session.get_engine('storage:sqlalchemy')
metadata = MetaData(bind=engine)
status = Table('service_statuses', metadata, autoload=True)
service_select = (select([func.count()])
.select_from(status)
.group_by('service_name', 'hostname')
)
service_counts = engine.execute(service_select).fetchall()
duplicated_services = [i for i in service_counts if i[0] > 1]
if duplicated_services:
return upgradecheck.Result(upgradecheck.Code.FAILURE,
_('Duplicated services found in '
'service_statuses table.'))
return upgradecheck.Result(upgradecheck.Code.SUCCESS)
_upgrade_checks = ((_('Duplicate service status'),
_duplicate_service_status),
(_('Policy File JSON to YAML Migration'),
(common_checks.check_policy_json,
{'conf': designate.conf.CONF})),
)
def main():
config_files = utils.find_config('designate.conf')
checker = Checks()
return upgradecheck.main(
conf=designate.conf.CONF,
project='designate',
upgrade_command=checker,
default_config_files=config_files,
)