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:
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
|
default service type as a prefix. For instance, to set a special service_type
|
||||||
for trove (because you're using Rackspace) set:
|
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'
|
database_service_type: 'rax:database'
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import appdirs
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -27,27 +28,35 @@ from os_client_config import defaults
|
|||||||
from os_client_config import exceptions
|
from os_client_config import exceptions
|
||||||
from os_client_config import vendors
|
from os_client_config import vendors
|
||||||
|
|
||||||
CONFIG_HOME = os.path.join(os.path.expanduser(
|
APPDIRS = appdirs.AppDirs('openstack', 'OpenStack', multipath='/etc')
|
||||||
os.environ.get('XDG_CONFIG_HOME', os.path.join('~', '.config'))),
|
CONFIG_HOME = APPDIRS.user_config_dir
|
||||||
'openstack')
|
CACHE_PATH = APPDIRS.user_cache_dir
|
||||||
CONFIG_SEARCH_PATH = [os.getcwd(), CONFIG_HOME, '/etc/openstack']
|
|
||||||
|
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')
|
YAML_SUFFIXES = ('.yaml', '.yml')
|
||||||
CONFIG_FILES = [
|
CONFIG_FILES = [
|
||||||
os.path.join(d, 'clouds' + s)
|
os.path.join(d, 'clouds' + s)
|
||||||
for d in CONFIG_SEARCH_PATH
|
for d in CONFIG_SEARCH_PATH
|
||||||
for s in YAML_SUFFIXES
|
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 = [
|
VENDOR_FILES = [
|
||||||
os.path.join(d, 'clouds-public' + s)
|
os.path.join(d, 'clouds-public' + s)
|
||||||
for d in VENDOR_SEARCH_PATH
|
for d in CONFIG_SEARCH_PATH
|
||||||
for s in YAML_SUFFIXES
|
for s in YAML_SUFFIXES
|
||||||
]
|
]
|
||||||
|
|
||||||
|
BOOL_KEYS = ('insecure', 'cache')
|
||||||
|
|
||||||
|
|
||||||
def set_default(key, value):
|
def set_default(key, value):
|
||||||
defaults._defaults[key] = value
|
defaults._defaults[key] = value
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
# of appearance. Changing the order has an impact on the overall integration
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
PyYAML>=3.1.0
|
PyYAML>=3.1.0
|
||||||
|
appdirs>=1.3.0
|
||||||
|
|||||||
Reference in New Issue
Block a user