Merge "Allow user to specify token as env var"
This commit is contained in:
commit
aeb0c198b1
|
@ -12,6 +12,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
import abc
|
import abc
|
||||||
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from keystoneauth1.exceptions.auth import AuthorizationFailure
|
from keystoneauth1.exceptions.auth import AuthorizationFailure
|
||||||
|
@ -135,9 +136,15 @@ class BaseClient(metaclass=abc.ABCMeta):
|
||||||
raise ClientError(str(e))
|
raise ClientError(str(e))
|
||||||
|
|
||||||
def get_token(self):
|
def get_token(self):
|
||||||
|
"""Returns the simple token string for a token
|
||||||
|
|
||||||
|
Attempt to read token from environment variable, if present use it.
|
||||||
|
If not, return the token obtained from Keystone.
|
||||||
"""
|
"""
|
||||||
Returns the simple token string for a token acquired from keystone
|
token = os.environ.get('OS_AUTH_TOKEN')
|
||||||
"""
|
if token:
|
||||||
|
return token
|
||||||
|
else:
|
||||||
return self._get_ks_session().get_auth_headers().get('X-Auth-Token')
|
return self._get_ks_session().get_auth_headers().get('X-Auth-Token')
|
||||||
|
|
||||||
def _get_ks_session(self):
|
def _get_ks_session(self):
|
||||||
|
|
Loading…
Reference in New Issue