7fa3136470
1) UCP -> Airship 2) readthedocs.org -> readthedocs.io (there is redirect) 3) http -> https 4) attcomdev -> airshipit (repo on quay.io) 5) att-comdev -> openstack/airship-* (repo on github/openstack git) 6) many URLs have been verified and adjusted to be current 7) no need for 'en/latest/' path in URL of the RTD 8) added more info to some setup.cfg and setup.py files 9) ucp-integration docs are now in airship-in-a-bottle 10) various other minor fixes Change-Id: I4b8cc6ddf491e35d600a83f5f82d7717108e31dd
67 lines
2.6 KiB
Python
67 lines
2.6 KiB
Python
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
import configparser
|
|
import logging
|
|
|
|
from keystoneauth1.identity import v3 as keystone_v3
|
|
from keystoneauth1 import session as keystone_session
|
|
|
|
from deckhand.client import client as deckhand_client
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class DeckhandClientFactory(object):
|
|
"""Factory for DeckhandClient to encapsulate commonly reused setup"""
|
|
|
|
def __init__(self,
|
|
shipyard_conf,
|
|
*args, **kwargs):
|
|
"""Deckhand Client Factory
|
|
|
|
Creates a client factory to retrieve clients
|
|
:param shipyard_conf: Location of shipyard.conf
|
|
"""
|
|
self.config = configparser.ConfigParser()
|
|
self.config.read(shipyard_conf)
|
|
|
|
def get_client(self):
|
|
"""Retrieve a deckhand client"""
|
|
|
|
"""
|
|
Notes:
|
|
TODO(bryan-strassner): If/when the airflow plugin modules move to using
|
|
oslo config, consider using the example here:
|
|
https://github.com/openstack/airship-deckhand/blob/cef3b52a104e620e88a24caf70ed2bb1297c268f/deckhand/barbican/client_wrapper.py#L53
|
|
which will load the attributes from the config more flexibly.
|
|
Keystoneauth1 also provides for a simpler solution with:
|
|
https://docs.openstack.org/keystoneauth/latest/api/keystoneauth1.loading.html
|
|
if oslo config is used.
|
|
"""
|
|
keystone_auth = {}
|
|
# Construct Session Argument
|
|
for attr in ('auth_url', 'password', 'project_domain_name',
|
|
'project_name', 'username', 'user_domain_name'):
|
|
keystone_auth[attr] = self.config.get('keystone_authtoken', attr)
|
|
|
|
# Set up keystone session
|
|
auth = keystone_v3.Password(**keystone_auth)
|
|
sess = keystone_session.Session(auth=auth)
|
|
|
|
LOG.info("Setting up Deckhand client with parameters")
|
|
for attr in keystone_auth:
|
|
if attr != 'password':
|
|
LOG.debug('%s = %s', attr, keystone_auth[attr])
|
|
return deckhand_client.Client(session=sess, endpoint_type='internal')
|