keystone/keystone/cmd/manage.py
Lance Bragstad 254100128d Allow for more robust config checking with keystone-manage
Keystone was logging a warning saying "no configuration file was
found" when one was clearly passed to keystone-manage. This was
due to the fact that keystone-manage was really just checking for
default configuration file values. This means that users passing
a specific configuration file location to keystone-manage would
see a warning that wasn't necessarily true since keystone-manage
passes sys.argv to oslo.config, which resolves the argument
properly.

This change enhances the check to make sure keystone-manage isn't
dealing with a configuration file passed in from an end-user before
emitting the warning.

This change also cleans up some of the interactions between
keystone.cmd.manage and keystone.cmd.cli to make the variables
more clear about their purpose.

Change-Id: I6d58d9c499c447ef1cfd6edd4aeb1176130fb6ad
Closes-Bug: 1782704
2018-08-07 14:24:12 +00:00

42 lines
1.5 KiB
Python

#!/usr/bin/env python
# Copyright 2013 OpenStack Foundation
#
# 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 sys
from keystone.cmd import cli
# If ../../keystone/__init__.py exists, add ../../ to Python search path, so
# that it will override what happens to be installed in
# /usr/(local/)lib/python...
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(__file__),
os.pardir,
os.pardir,
os.pardir))
if os.path.exists(os.path.join(possible_topdir,
'keystone',
'__init__.py')):
sys.path.insert(0, possible_topdir)
# entry point.
def main():
developer_config = os.path.join(possible_topdir, 'etc', 'keystone.conf')
if not os.path.exists(developer_config):
developer_config = None
cli.main(argv=sys.argv, developer_config_file=developer_config)