Add Keystone options to registration of config

When registering options, the list_options was not returning the
appropriate options for keystone. This adds those options. Aslo changes
to use a more direct/generic adding of keystone options.

Related to this, a change was required to the service_endpoints module
to generate an auth object used to get a session.

In addition, the zuul gates for py35 were resolving to a non-existent
target. The changes to tox.ini files addresses making it so the unit
test gates are restored to functionality.

This change also uncovered a misconfigured unit test, and corrects that
test.

Change-Id: Ibc1c6c217ac7396390e7a881afbb9ef1c5ab7091
This commit is contained in:
Bryan Strassner 2018-06-05 16:20:10 -05:00
parent a907923d31
commit 7708ecbe64
8 changed files with 59 additions and 12 deletions

2
.gitignore vendored
View File

@ -2,6 +2,8 @@
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
*$py.class *$py.class
**/.pytest_cache/
# C extensions # C extensions
*.so *.so

View File

@ -277,6 +277,26 @@
# Config Section from which to load plugin specific options (string value) # Config Section from which to load plugin specific options (string value)
#auth_section = <None> #auth_section = <None>
#
# From shipyard_api
#
# PEM encoded Certificate Authority to use when verifying HTTPs connections.
# (string value)
#cafile = <None>
# PEM encoded client certificate cert file (string value)
#certfile = <None>
# PEM encoded client certificate key file (string value)
#keyfile = <None>
# Verify HTTPS connections. (boolean value)
#insecure = false
# Timeout value for http requests (integer value)
#timeout = <None>
[logging] [logging]

View File

@ -277,6 +277,26 @@
# Config Section from which to load plugin specific options (string value) # Config Section from which to load plugin specific options (string value)
#auth_section = <None> #auth_section = <None>
#
# From shipyard_api
#
# PEM encoded Certificate Authority to use when verifying HTTPs connections.
# (string value)
#cafile = <None>
# PEM encoded client certificate cert file (string value)
#certfile = <None>
# PEM encoded client certificate key file (string value)
#keyfile = <None>
# Verify HTTPS connections. (boolean value)
#insecure = false
# Timeout value for http requests (integer value)
#timeout = <None>
[logging] [logging]

View File

@ -241,18 +241,17 @@ def register_opts(conf):
help=section.help)) help=section.help))
conf.register_opts(section.options, group=section.name) conf.register_opts(section.options, group=section.name)
conf.register_opts( ks_loading.register_auth_conf_options(conf, group='keystone_authtoken')
ks_loading.get_auth_plugin_conf_options('password'),
group='keystone_authtoken'
)
def list_opts(): def list_opts():
""" List the options identified by this configuration """ List the options identified by this configuration
""" """
return { all_opts = {
section.name: section.options for section in SECTIONS section.name: section.options for section in SECTIONS
} }
all_opts['keystone_authtoken'] = ks_loading.get_session_conf_options()
return all_opts
def parse_args(args=None, usage=None, default_config_files=None): def parse_args(args=None, usage=None, default_config_files=None):

View File

@ -22,6 +22,7 @@ import logging
import falcon import falcon
from keystoneauth1 import exceptions as exc from keystoneauth1 import exceptions as exc
from keystoneauth1 import loading from keystoneauth1 import loading
from keystoneauth1 import session
from oslo_config import cfg from oslo_config import cfg
from shipyard_airflow.errors import AppError from shipyard_airflow.errors import AppError
@ -113,8 +114,8 @@ def get_session():
def _get_ks_session(): def _get_ks_session():
# Establishes a keystone session # Establishes a keystone session
try: try:
return loading.load_session_from_conf_options( auth = loading.load_auth_from_conf_options(CONF, "keystone_authtoken")
CONF, group="keystone_authtoken") return session.Session(auth=auth)
except exc.AuthorizationFailure as aferr: except exc.AuthorizationFailure as aferr:
LOG.error('Could not authorize against keystone: %s', LOG.error('Could not authorize against keystone: %s',
str(aferr)) str(aferr))

View File

@ -139,7 +139,12 @@ class TestActionValidator:
# any exception is a failure # any exception is a failure
assert False assert False
def test_validate_site_missing_rev(self): @mock.patch("shipyard_airflow.control.service_clients.deckhand_client",
return_value=fake_dh_doc_client('clean'), ds_name='defaulted')
@mock.patch("shipyard_airflow.control.validators."
"validate_deployment_strategy._get_node_lookup",
return_value=node_lookup)
def test_validate_site_missing_rev(self, *args):
"""Test the function that runs the validator class with a """Test the function that runs the validator class with a
deployment strategy that has a cycle in the groups deployment strategy that has a cycle in the groups
""" """

View File

@ -1,5 +1,5 @@
[tox] [tox]
envlist = unit, pep8, bandit envlist = py35, pep8, bandit
[testenv] [testenv]
setenv= setenv=
@ -8,7 +8,7 @@ basepython=python3.5
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
[testenv:unit] [testenv:py35]
skipsdist=True skipsdist=True
commands = commands =
pytest \ pytest \

View File

@ -1,6 +1,6 @@
[tox] [tox]
skipsdist=True skipsdist=True
envlist = unit, pep8, bandit envlist = py35, pep8, bandit
[testenv] [testenv]
setenv= setenv=
@ -9,7 +9,7 @@ basepython=python3.5
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
[testenv:unit] [testenv:py35]
commands = commands =
pytest \ pytest \
{posargs} \ {posargs} \