Flesh out api version defaults
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
This commit is contained in:
parent
3b5a20ea03
commit
d5931d4658
@ -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()
|
||||
|
23
os_client_config/defaults.py
Normal file
23
os_client_config/defaults.py
Normal file
@ -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',
|
||||
)
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user