diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-05-13 16:34:00 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-05-13 16:34:00 +0000 |
commit | fa941945bed1a52995638a257b45a56a4937914c (patch) | |
tree | cfdbe806a0701bd6ae7857e2d1c9e14db5fe5699 | |
parent | 7c03b4a8984bc8a703edff35abf7e8ea6f8a3589 (diff) | |
parent | 4b40133e2199e11ccd5dc48c2ad60ac06d056d0a (diff) | |
download | os-client-config-fa941945bed1a52995638a257b45a56a4937914c.tar.gz |
Merge "Use appdirs for platform-independent locations"1.0.0
-rw-r--r-- | README.rst | 22 | ||||
-rw-r--r-- | os_client_config/config.py | 29 | ||||
-rw-r--r-- | requirements.txt | 1 |
3 files changed, 42 insertions, 10 deletions
@@ -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' diff --git a/os_client_config/config.py b/os_client_config/config.py index 5b64395..88e4b4c 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -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') + # NOTE(dtroyer): This turns out to be not the best idea so let's move # overriding defaults to a kwarg to OpenStackConfig.__init__() diff --git a/requirements.txt b/requirements.txt index 498c5c3..894a70a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 |