summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst22
-rw-r--r--os_client_config/config.py29
-rw-r--r--requirements.txt1
3 files changed, 42 insertions, 10 deletions
diff --git a/README.rst b/README.rst
index 2c27153..4389b68 100644
--- a/README.rst
+++ b/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'
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