From 62616f3eaaff708c583919b55093410a0179c940 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Thu, 26 Feb 2015 16:01:50 -0500 Subject: [PATCH] Add behavior to enable ironic noauth mode Added behavior to enable users to utilize the ironic functionality with noauth mode set on the server side. This logic is utilized if the auth_plugin is defined as: None or "None" or ''. Bumped os-client-config requirement because this working requires the pass-through support that got added there in 0.5.0. Change-Id: I3f8a9e0a9952be2d24c6cb655dfed9519134102e --- requirements.txt | 2 +- shade/__init__.py | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 46d428806..95dabd739 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ pbr>=0.5.21,<1.0 -os-client-config>=0.4.0 +os-client-config>=0.5.0 six python-novaclient>=2.21.0 diff --git a/shade/__init__.py b/shade/__init__.py index b854c966d..049f9c895 100644 --- a/shade/__init__.py +++ b/shade/__init__.py @@ -1235,13 +1235,31 @@ class OpenStackCloud(object): class OperatorCloud(OpenStackCloud): + @property + def auth_token(self): + if self.auth_plugin in (None, "None", ''): + return self._auth_token + if not self._auth_token: + self._auth_token = self.keystone_session.get_token() + return self._auth_token + @property def ironic_client(self): if self._ironic_client is None: ironic_logging = logging.getLogger('ironicclient') ironic_logging.addHandler(logging.NullHandler()) token = self.auth_token - endpoint = self.get_endpoint(service_type='baremetal') + if self.auth_plugin in (None, "None", ''): + # TODO: This needs to be improved logic wise, perhaps a list, + # or enhancement of the data stuctures with-in the library + # to allow for things aside password authentication, or no + # authentication if so desired by the user. + # + # Attempt to utilize a pre-stored endpoint in the auth + # dict as the endpoint. + endpoint = self.auth['endpoint'] + else: + endpoint = self.get_endpoint(service_type='baremetal') try: self._ironic_client = ironic_client.Client( '1', endpoint, token=token)