Use appdirs for platform-independent locations
Cache, data and config files live rooted in different places across different OS's. Use appdirs to find where. Depends-On: Ic939dea11b7476ec504d2bf65854a0781b1bfb39 Change-Id: I7338ae1d0442e0c5cc1ec4ae4d619fac319a4a28
This commit is contained in:
parent
9b9e3d0d32
commit
4b40133e21
22
README.rst
22
README.rst
@ -50,6 +50,28 @@ Service specific settings, like the nova service type, are set with the
|
||||
default service type as a prefix. For instance, to set a special service_type
|
||||
for trove (because you're using Rackspace) set:
|
||||
|
||||
Site Specific File Locations
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In addition to `~/.config/openstack` and `/etc/openstack` - some platforms
|
||||
have other locations they like to put things. `os-client-config` will also
|
||||
look in an OS specific config dir
|
||||
|
||||
* `USER_CONFIG_DIR`
|
||||
* `SITE_CONFIG_DIR`
|
||||
|
||||
`USER_CONFIG_DIR` is different on Linux, OSX and Windows.
|
||||
|
||||
* Linux: `~/.config/openstack`
|
||||
* OSX: `~/Library/Application Support/openstack`
|
||||
* Windows: `C:\\Users\\USERNAME\\AppData\\Local\\OpenStack\\openstack`
|
||||
|
||||
`SITE_CONFIG_DIR` is different on Linux, OSX and Windows.
|
||||
|
||||
* Linux: `/etc/openstack`
|
||||
* OSX: `/Library/Application Support/openstack`
|
||||
* Windows: `C:\\ProgramData\\OpenStack\\openstack`
|
||||
|
||||
::
|
||||
|
||||
database_service_type: 'rax:database'
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import os
|
||||
|
||||
import appdirs
|
||||
import yaml
|
||||
|
||||
try:
|
||||
@ -27,27 +28,35 @@ from os_client_config import defaults
|
||||
from os_client_config import exceptions
|
||||
from os_client_config import vendors
|
||||
|
||||
CONFIG_HOME = os.path.join(os.path.expanduser(
|
||||
os.environ.get('XDG_CONFIG_HOME', os.path.join('~', '.config'))),
|
||||
'openstack')
|
||||
CONFIG_SEARCH_PATH = [os.getcwd(), CONFIG_HOME, '/etc/openstack']
|
||||
APPDIRS = appdirs.AppDirs('openstack', 'OpenStack', multipath='/etc')
|
||||
CONFIG_HOME = APPDIRS.user_config_dir
|
||||
CACHE_PATH = APPDIRS.user_cache_dir
|
||||
|
||||
UNIX_CONFIG_HOME = os.path.join(
|
||||
os.path.expanduser(os.path.join('~', '.config')), 'openstack')
|
||||
UNIX_SITE_CONFIG_HOME = '/etc/openstack'
|
||||
|
||||
SITE_CONFIG_HOME = APPDIRS.site_config_dir
|
||||
|
||||
CONFIG_SEARCH_PATH = [
|
||||
os.getcwd(),
|
||||
CONFIG_HOME, UNIX_CONFIG_HOME,
|
||||
SITE_CONFIG_HOME, UNIX_SITE_CONFIG_HOME
|
||||
]
|
||||
YAML_SUFFIXES = ('.yaml', '.yml')
|
||||
CONFIG_FILES = [
|
||||
os.path.join(d, 'clouds' + s)
|
||||
for d in CONFIG_SEARCH_PATH
|
||||
for s in YAML_SUFFIXES
|
||||
]
|
||||
CACHE_PATH = os.path.join(os.path.expanduser(
|
||||
os.environ.get('XDG_CACHE_PATH', os.path.join('~', '.cache'))),
|
||||
'openstack')
|
||||
BOOL_KEYS = ('insecure', 'cache')
|
||||
VENDOR_SEARCH_PATH = [os.getcwd(), CONFIG_HOME, '/etc/openstack']
|
||||
VENDOR_FILES = [
|
||||
os.path.join(d, 'clouds-public' + s)
|
||||
for d in VENDOR_SEARCH_PATH
|
||||
for d in CONFIG_SEARCH_PATH
|
||||
for s in YAML_SUFFIXES
|
||||
]
|
||||
|
||||
BOOL_KEYS = ('insecure', 'cache')
|
||||
|
||||
|
||||
def set_default(key, value):
|
||||
defaults._defaults[key] = value
|
||||
|
@ -2,3 +2,4 @@
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
PyYAML>=3.1.0
|
||||
appdirs>=1.3.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user