diff options
-rw-r--r-- | doc/source/vendor-support.rst | 5 | ||||
-rw-r--r-- | os_client_config/config.py | 82 | ||||
-rw-r--r-- | os_client_config/defaults.json | 2 | ||||
-rw-r--r-- | os_client_config/vendor-schema.json | 11 | ||||
-rw-r--r-- | os_client_config/vendors/citycloud.json | 3 |
5 files changed, 68 insertions, 35 deletions
diff --git a/doc/source/vendor-support.rst b/doc/source/vendor-support.rst index f97c9f6..1053b3d 100644 --- a/doc/source/vendor-support.rst +++ b/doc/source/vendor-support.rst @@ -62,9 +62,12 @@ https://identity1.citycloud.com:5000/v3/ ============== ================ Region Name Human Name ============== ================ +Buf1 Buffalo, NY +Fra1 Frankfurt, DE +Kna1 Karlskrona, SE +La1 Los Angeles, CA Lon1 London, UK Sto2 Stockholm, SE -Kna1 Karlskrona, SE ============== ================ * Identity API Version is 3 diff --git a/os_client_config/config.py b/os_client_config/config.py index 0f19dd1..d1b3144 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -468,6 +468,17 @@ class OpenStackConfig(object): else: profile_data = vendors.get_profile(profile_name) if profile_data: + status = profile_data.pop('status', 'active') + message = profile_data.pop('message', '') + if status == 'deprecated': + warnings.warn( + "{profile_name} is deprecated: {message}".format( + profile_name=profile_name, message=message)) + elif status == 'shutdown': + raise exceptions.OpenStackConfigException( + "{profile_name} references a cloud that no longer" + " exists: {message}".format( + profile_name=profile_name, message=message)) _auth_update(cloud, profile_data) else: # Can't find the requested vendor config, go about business @@ -475,14 +486,6 @@ class OpenStackConfig(object): " the cloud '{1}'".format(profile_name, name)) - def _fix_backwards_madness(self, cloud): - cloud = self._fix_backwards_auth_plugin(cloud) - cloud = self._fix_backwards_project(cloud) - cloud = self._fix_backwards_interface(cloud) - cloud = self._fix_backwards_networks(cloud) - cloud = self._handle_domain_id(cloud) - return cloud - def _project_scoped(self, cloud): return ('project_id' in cloud or 'project_name' in cloud or 'project_id' in cloud['auth'] @@ -812,7 +815,7 @@ class OpenStackConfig(object): def auth_config_hook(self, config): """Allow examination of config values before loading auth plugin - OpenStackClient will override this to perform additional chacks + OpenStackClient will override this to perform additional checks on auth_type. """ return config @@ -911,6 +914,41 @@ class OpenStackConfig(object): return config + def magic_fixes(self, config): + """Perform the set of magic argument fixups""" + + # Infer token plugin if a token was given + if (('auth' in config and 'token' in config['auth']) or + ('auth_token' in config and config['auth_token']) or + ('token' in config and config['token'])): + config.setdefault('token', config.pop('auth_token', None)) + + # These backwards compat values are only set via argparse. If it's + # there, it's because it was passed in explicitly, and should win + config = self._fix_backwards_api_timeout(config) + if 'endpoint_type' in config: + config['interface'] = config.pop('endpoint_type') + + config = self._fix_backwards_auth_plugin(config) + config = self._fix_backwards_project(config) + config = self._fix_backwards_interface(config) + config = self._fix_backwards_networks(config) + config = self._handle_domain_id(config) + + for key in BOOL_KEYS: + if key in config: + if type(config[key]) is not bool: + config[key] = get_boolean(config[key]) + + # TODO(mordred): Special casing auth_url here. We should + # come back to this betterer later so that it's + # more generalized + if 'auth' in config and 'auth_url' in config['auth']: + config['auth']['auth_url'] = config['auth']['auth_url'].format( + **config) + + return config + def get_one_cloud(self, cloud=None, validate=True, argparse=None, **kwargs): """Retrieve a single cloud configuration and merge additional options @@ -961,31 +999,7 @@ class OpenStackConfig(object): else: config[key] = val - # Infer token plugin if a token was given - if (('auth' in config and 'token' in config['auth']) or - ('auth_token' in config and config['auth_token']) or - ('token' in config and config['token'])): - config.setdefault('token', config.pop('auth_token', None)) - - # These backwards compat values are only set via argparse. If it's - # there, it's because it was passed in explicitly, and should win - config = self._fix_backwards_api_timeout(config) - if 'endpoint_type' in config: - config['interface'] = config.pop('endpoint_type') - - config = self._fix_backwards_madness(config) - - for key in BOOL_KEYS: - if key in config: - if type(config[key]) is not bool: - config[key] = get_boolean(config[key]) - - # TODO(mordred): Special casing auth_url here. We should - # come back to this betterer later so that it's - # more generalized - if 'auth' in config and 'auth_url' in config['auth']: - config['auth']['auth_url'] = config['auth']['auth_url'].format( - **config) + config = self.magic_fixes(config) # NOTE(dtroyer): OSC needs a hook into the auth args before the # plugin is loaded in order to maintain backward- diff --git a/os_client_config/defaults.json b/os_client_config/defaults.json index f501862..ba8bf39 100644 --- a/os_client_config/defaults.json +++ b/os_client_config/defaults.json @@ -13,10 +13,12 @@ "image_api_version": "2", "image_format": "qcow2", "key_manager_api_version": "v1", + "message": "", "metering_api_version": "2", "network_api_version": "2", "object_store_api_version": "1", "orchestration_api_version": "1", "secgroup_source": "neutron", + "status": "active", "volume_api_version": "2" } diff --git a/os_client_config/vendor-schema.json b/os_client_config/vendor-schema.json index 6c57ba4..6a6f456 100644 --- a/os_client_config/vendor-schema.json +++ b/os_client_config/vendor-schema.json @@ -55,12 +55,23 @@ "default": "public", "enum": [ "public", "internal", "admin" ] }, + "message": { + "name": "Status message", + "description": "Optional message with information related to status", + "type": "string" + }, "secgroup_source": { "name": "Security Group Source", "description": "Which service provides security groups", "enum": [ "neutron", "nova", "None" ], "default": "neutron" }, + "status": { + "name": "Vendor status", + "description": "Status of the vendor's cloud", + "enum": [ "active", "deprecated", "shutdown"], + "default": "active" + }, "compute_service_name": { "name": "Compute API Service Name", "description": "Compute API Service Name", diff --git a/os_client_config/vendors/citycloud.json b/os_client_config/vendors/citycloud.json index 64cadce..097ddfd 100644 --- a/os_client_config/vendors/citycloud.json +++ b/os_client_config/vendors/citycloud.json @@ -5,6 +5,9 @@ "auth_url": "https://identity1.citycloud.com:5000/v3/" }, "regions": [ + "Buf1", + "La1", + "Fra1", "Lon1", "Sto2", "Kna1" |