Tools for working in the OpenStack Oslo community.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

oslo_tool_config.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #
  2. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  3. # not use this file except in compliance with the License. You may obtain
  4. # a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software
  9. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  10. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  11. # License for the specific language governing permissions and limitations
  12. # under the License.
  13. """Utilities functions for working with oslo.config from the tool scripts.
  14. """
  15. import os
  16. from oslo_config import cfg
  17. DEFAULT_CONFIG_FILES = [
  18. './oslo.conf',
  19. os.path.expanduser('~/.oslo.conf'),
  20. ]
  21. def get_config_parser():
  22. conf = cfg.ConfigOpts()
  23. conf.register_cli_opt(
  24. cfg.StrOpt(
  25. 'repo_root',
  26. default='.',
  27. help='directory containing the git repositories',
  28. )
  29. )
  30. return conf
  31. def parse_arguments(conf):
  32. # Look for a few configuration files, and load the ones we find.
  33. default_config_files = [
  34. f
  35. for f in DEFAULT_CONFIG_FILES
  36. if os.path.exists(f)
  37. ]
  38. return conf(
  39. project='oslo',
  40. default_config_files=default_config_files,
  41. )