From a0b9c2e1bdd8acb8d5c0cba89e67adcb30649a1c Mon Sep 17 00:00:00 2001 From: Jose Idar Date: Wed, 27 Apr 2016 15:26:15 -0500 Subject: [PATCH] Adding BlockStorage alt user config Change-Id: I6906b4f4962a0da34744deff60bf2d583a44ff07 --- cloudcafe/auth/config.py | 1 + cloudcafe/blockstorage/composites.py | 17 ++++++++++++++--- cloudcafe/blockstorage/config.py | 5 +++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/cloudcafe/auth/config.py b/cloudcafe/auth/config.py index 21848834..e448cee8 100644 --- a/cloudcafe/auth/config.py +++ b/cloudcafe/auth/config.py @@ -37,6 +37,7 @@ class UserAuthConfig(ConfigSectionInterface): """ return self.get("strategy") + class UserConfig(ConfigSectionInterface): SECTION_NAME = 'user' diff --git a/cloudcafe/blockstorage/composites.py b/cloudcafe/blockstorage/composites.py index 79136494..8b5ad273 100644 --- a/cloudcafe/blockstorage/composites.py +++ b/cloudcafe/blockstorage/composites.py @@ -1,7 +1,8 @@ import warnings from cloudcafe.auth.provider import MemoizedAuthServiceComposite -from cloudcafe.blockstorage.config import BlockStorageConfig +from cloudcafe.blockstorage.config import \ + BlockStorageConfig, BlockstorageAltUserConfig from cloudcafe.blockstorage.volumes_api.common.config import VolumesAPIConfig from cloudcafe.blockstorage.volumes_api.v1.config import \ @@ -38,10 +39,20 @@ class _BaseVolumesComposite(object): _behaviors = None _auth = _BlockstorageAuthComposite + @classmethod + def spawn_alt_user_composite(cls): + """This will return a new composite of the same version and + configuration as the composite this method is being called from, + except with the blockstorage_alt_user config info used in place of the + default user config. + """ + alt_config = BlockstorageAltUserConfig() + return cls(auth_composite=cls._auth(user_config=alt_config)) + def __init__(self, auth_composite=None): self.auth = auth_composite or self._auth() self.config = self._config() - self.service_endpoint = self.auth.public_url + self.service_endpoint = self.auth.public_url if self.auth.config.service_endpoint_override is not None: self.service_endpoint = "{url}/{tenant_id}".format( url=self.auth.config.service_endpoint_override, @@ -78,7 +89,7 @@ class VolumesV2Composite(_BaseVolumesComposite): class VolumesAutoComposite(object): - def __new__(cls, auth_composite=None): + def __new__(cls, auth_composite=None, version_under_test=None): config = VolumesAPIConfig() if config.version_under_test == "1": return VolumesV1Composite(auth_composite=auth_composite) diff --git a/cloudcafe/blockstorage/config.py b/cloudcafe/blockstorage/config.py index 09c4ce8e..bd5afe66 100644 --- a/cloudcafe/blockstorage/config.py +++ b/cloudcafe/blockstorage/config.py @@ -14,9 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. """ +from cloudcafe.auth.config import UserAuthConfig as _UserAuthConfig from cloudcafe.common.models.configuration import ConfigSectionInterface +class BlockstorageAltUserConfig(_UserAuthConfig): + SECTION_NAME = 'blockstorage_alt_user' + + class BlockStorageConfig(ConfigSectionInterface): SECTION_NAME = 'blockstorage'