def set(self, key, val, env=None): """ Changes the value for the setting specified by 'key' to the new value. By default this will change the current environment, but you can change values in other environments by passing the name of that environment as the 'env' parameter. """ if env is None: env = self.environment else: if env not in self._settings: raise exc.EnvironmentNotFound("There is no environment named " "'%s'." % env) dct = self._settings[env] if key not in dct: raise exc.InvalidSetting("The setting '%s' is not defined." % key) dct[key] = val if key == "identity_type": # If setting the identity_type, also change the identity_class. dct["identity_class"] = _import_identity(val) elif key == "region": if not identity: return current = identity.region if current == val: return if "LON" in (current, val): # This is an outlier, as it has a separate auth identity.region = val elif key == "verify_ssl": if not identity: return identity.verify_ssl = val
def _setEnvironment(self, val): if val not in self._settings: raise exc.EnvironmentNotFound("The environment '%s' has not been " "defined." % val) if val != self.environment: self._environment = val clear_credentials() _create_identity()