summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2015-03-05 08:51:18 -0500
committerDean Troyer <dtroyer@gmail.com>2015-03-05 16:19:04 +0000
commitd5931d4658b43b5451adc38be5d6b7f257291098 (patch)
tree3c85d580fabba098a92724c3849c0b039d491c9f
parent3b5a20ea037c8e01f5da2f98e9e47082cefad89e (diff)
downloados-client-config-0.6.0.tar.gz
Flesh out api version defaults0.6.0
openstackclient needs a bit richer support for api version defaults. Namely, it knows what defaults it wants to have - but we need to do defaults processing in os-client-config to get sequencing correct. So provide an API call to set new defaults that can be used before config processing. Also, flesh out the dict of known default values with good defaults to match osc behavior, and add the known v1 default of HP to the vendors.py values. Change-Id: I45e2550af58aee616ca168d20a557077beeab007
-rw-r--r--os_client_config/config.py18
-rw-r--r--os_client_config/defaults.py23
-rw-r--r--os_client_config/vendors.py1
3 files changed, 34 insertions, 8 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index 3565fa6..48b99f5 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -23,6 +23,7 @@ except ImportError:
ksc_auth = None
from os_client_config import cloud_config
+from os_client_config import defaults
from os_client_config import exceptions
from os_client_config import vendors
@@ -41,18 +42,23 @@ VENDOR_FILES = [
os.path.join(d, 'clouds-public.yaml') for d in VENDOR_SEARCH_PATH]
+def set_default(key, value):
+ defaults._defaults[key] = value
+
+
def get_boolean(value):
if value.lower() == 'true':
return True
return False
-def _get_os_environ(defaults):
+def _get_os_environ():
+ ret = dict(defaults._defaults)
for (k, v) in os.environ.items():
if k.startswith('OS_'):
newkey = k[3:].lower()
- defaults[newkey] = v
- return defaults
+ ret[newkey] = v
+ return ret
def _auth_update(old_dict, new_dict):
@@ -74,11 +80,7 @@ class OpenStackConfig(object):
self._config_files = config_files or CONFIG_FILES
self._vendor_files = vendor_files or VENDOR_FILES
- defaults = dict(
- auth_type='password',
- compute_api_version='1.1',
- )
- self.defaults = _get_os_environ(defaults)
+ self.defaults = _get_os_environ()
# use a config file if it exists where expected
self.cloud_config = self._load_config_file()
diff --git a/os_client_config/defaults.py b/os_client_config/defaults.py
new file mode 100644
index 0000000..5f70d6e
--- /dev/null
+++ b/os_client_config/defaults.py
@@ -0,0 +1,23 @@
+# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+_defaults = dict(
+ auth_type='password',
+ compute_api_version='2',
+ identity_api_version='2',
+ image_api_version='1',
+ network_api_version='2',
+ object_api_version='1',
+ volume_api_version='1',
+)
diff --git a/os_client_config/vendors.py b/os_client_config/vendors.py
index cab3676..eb08bbd 100644
--- a/os_client_config/vendors.py
+++ b/os_client_config/vendors.py
@@ -20,6 +20,7 @@ CLOUD_DEFAULTS = dict(
),
region_name='region-b.geo-1',
dns_service_type='hpext:dns',
+ image_api_version='1',
),
rackspace=dict(
auth=dict(