Adds configuration framework and utils
* Adds configuration framework and autogeneration, * Defines utils and adds a method to get neutronclient instance based on configuration to connect to remote Neutron. Signed-off-by: Thomas Morin <thomas.morin@orange.com> Submitted on behalf of a third-party: Orange Change-Id: I9c0db184400af036cbe231e52480eb1a81879b7a
This commit is contained in:
parent
9048c0c702
commit
13d7f039ef
|
@ -52,6 +52,8 @@ output/*/index.html
|
|||
|
||||
# Sphinx
|
||||
doc/build
|
||||
doc/source/_static/config-samples/*.sample
|
||||
etc/**/*.sample
|
||||
|
||||
# pbr generates these
|
||||
AUTHORS
|
||||
|
|
|
@ -25,6 +25,8 @@ extensions = [
|
|||
'openstackdocstheme',
|
||||
'oslo_policy.sphinxext',
|
||||
'oslo_policy.sphinxpolicygen',
|
||||
'oslo_config.sphinxext',
|
||||
'oslo_config.sphinxconfiggen',
|
||||
]
|
||||
|
||||
# autodoc generation is a bit aggressive and a nuisance when doing heavy
|
||||
|
@ -84,5 +86,24 @@ latex_documents = [
|
|||
|
||||
# -- Options for oslo_policy.sphinxpolicygen ---------------------------------
|
||||
|
||||
_config_generator_config_files = [
|
||||
'neutron-interconnection.conf',
|
||||
]
|
||||
|
||||
def _get_config_generator_config_definition(conf_file):
|
||||
config_file_path = '../../etc/oslo-config-generator/%s' % conf_file
|
||||
# oslo_config.sphinxconfiggen appends '.conf.sample' to the filename,
|
||||
# strip file extentension (.conf or .ini).
|
||||
output_file_path = '_static/config-samples/%s' % conf_file.rsplit('.', 1)[0]
|
||||
return (config_file_path, output_file_path)
|
||||
|
||||
|
||||
config_generator_config_file = [
|
||||
_get_config_generator_config_definition(conf_file)
|
||||
for conf_file in _config_generator_config_files
|
||||
]
|
||||
|
||||
# -- Options for oslo_policy.sphinxpolicygen ---------------------------------
|
||||
|
||||
policy_generator_config_file = '../../etc/oslo-policy-generator/policy.conf'
|
||||
sample_policy_basename = '_static/neutron-interconnection'
|
||||
|
|
|
@ -2,6 +2,34 @@
|
|||
Configuration Guide
|
||||
===================
|
||||
|
||||
This section provides a list of all possible options for each
|
||||
configuration file.
|
||||
These are generated from code and reflect the current state of code
|
||||
in the neutron-interconnection repository.
|
||||
|
||||
Configuration Reference
|
||||
-----------------------
|
||||
|
||||
neutron-interconnection uses the following configuration files for its
|
||||
various services.
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
*
|
||||
|
||||
Sample Configuration Files
|
||||
--------------------------
|
||||
|
||||
The following are sample configuration files for all neutron-interconnection.
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
samples/*
|
||||
|
||||
Policy
|
||||
------
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
============================
|
||||
neutron-interconnection.conf
|
||||
============================
|
||||
|
||||
To use neutron-interconnection, you need to configure remote Keystone credentials
|
||||
(username, password and project) of ``neutron-interconnection`` service specific
|
||||
user in ``[remote_keystone_auth]`` group of the neutron server.
|
||||
|
||||
.. show-options::
|
||||
:config-file: etc/oslo-config-generator/neutron-interconnection.conf
|
|
@ -0,0 +1,9 @@
|
|||
===================================
|
||||
Sample neutron-interconnection.conf
|
||||
===================================
|
||||
|
||||
This sample configuration can also be viewed in `the raw format
|
||||
<../../_static/config-samples/neutron-interconnection.conf.sample>`_.
|
||||
|
||||
.. literalinclude::
|
||||
../../_static/config-samples/neutron-interconnection.conf.sample
|
|
@ -0,0 +1,13 @@
|
|||
To generate the sample neutron-interconnection configuration files and
|
||||
the sample policy file, run the following commands respectively
|
||||
from the top level of the neutron-interconnection directory:
|
||||
|
||||
tox -e genconfig
|
||||
tox -e genpolicy
|
||||
|
||||
If a 'tox' environment is unavailable, then you can run
|
||||
the following commands respectively
|
||||
instead to generate the configuration files:
|
||||
|
||||
oslo-config-generator --config-file etc/oslo-config-generator/neutron-interconnection.conf
|
||||
oslopolicy-sample-generator --config-file=etc/oslo-policy-generator/policy.conf
|
|
@ -0,0 +1,5 @@
|
|||
[DEFAULT]
|
||||
output_file = etc/neutron-interconnection.conf.sample
|
||||
wrap_width = 79
|
||||
|
||||
namespace = neutron-interconnection.remote_keystone_auth
|
|
@ -0,0 +1,34 @@
|
|||
# Copyright 2018 OpenStack Foundation
|
||||
#
|
||||
# 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 oslo_i18n
|
||||
|
||||
DOMAIN = "neutron-interconnection"
|
||||
|
||||
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
|
||||
|
||||
# The primary translation function using the well-known name "_"
|
||||
_ = _translators.primary
|
||||
|
||||
# The contextual translation function using the name "_C"
|
||||
# requires oslo.i18n >=2.1.0
|
||||
_C = _translators.contextual_form
|
||||
|
||||
# The plural translation function using the name "_P"
|
||||
# requires oslo.i18n >=2.1.0
|
||||
_P = _translators.plural_form
|
||||
|
||||
|
||||
def get_available_languages():
|
||||
return oslo_i18n.get_available_languages(DOMAIN)
|
|
@ -0,0 +1,22 @@
|
|||
# Copyright (c) 2018 Orange.
|
||||
# All 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.
|
||||
|
||||
from neutron_interconnection.services.common import config as inter_config
|
||||
|
||||
|
||||
def list_remote_keystone_auth_opts():
|
||||
return [
|
||||
('remote_keystone_auth', inter_config.remote_keystone_auth_opts),
|
||||
]
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright (c) 2018 Orange.
|
||||
# All 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron_interconnection._i18n import _
|
||||
|
||||
remote_keystone_auth_opts = [
|
||||
cfg.StrOpt('username',
|
||||
help=_('Remote Keystone authentication username')),
|
||||
cfg.StrOpt('password', secret=True,
|
||||
help=_('Remote Keystone authentication password')),
|
||||
cfg.StrOpt('project',
|
||||
help=_('Remote Keystone authentication project')),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(remote_keystone_auth_opts, "remote_keystone_auth")
|
|
@ -0,0 +1,43 @@
|
|||
# Copyright (c) 2018 Orange.
|
||||
# All 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from keystoneauth1.identity import v3
|
||||
from keystoneauth1 import session
|
||||
|
||||
from neutronclient.v2_0 import client as neutronclient
|
||||
|
||||
cfg.CONF.import_group('remote_keystone_auth',
|
||||
'neutron_interconnection.services.common.config')
|
||||
|
||||
|
||||
def get_neutron_client(keystone_endpoint, region):
|
||||
# Use keystone session because Neutron is not yet fully integrated with
|
||||
# Keystone v3 API
|
||||
auth = v3.Password(
|
||||
username=cfg.CONF.remote_keystone_auth.username,
|
||||
password=cfg.CONF.remote_keystone_auth.password,
|
||||
project_name=cfg.CONF.remote_keystone_auth.project,
|
||||
auth_url=keystone_endpoint,
|
||||
user_domain_id="default",
|
||||
project_domain_id="default"
|
||||
)
|
||||
sess = session.Session(auth=auth)
|
||||
|
||||
return neutronclient.Client(
|
||||
session=sess,
|
||||
region_name=region
|
||||
)
|
|
@ -30,6 +30,8 @@ neutron.policies =
|
|||
neutron-interconnection = neutron_interconnection.policies:list_rules
|
||||
neutron.db.alembic_migrations=
|
||||
neutron-interconnection = neutron_interconnection.db.migration:alembic_migrations
|
||||
oslo.config.opts =
|
||||
neutron-interconnection.remote_keystone_auth = neutron_interconnection.opts:list_remote_keystone_auth_opts
|
||||
|
||||
[compile_catalog]
|
||||
directory = neutron_interconnection/locale
|
||||
|
|
4
tox.ini
4
tox.ini
|
@ -23,6 +23,7 @@ deps =
|
|||
commands =
|
||||
flake8 {posargs}
|
||||
neutron-db-manage --subproject neutron-interconnection --database-connection sqlite:// check_migration
|
||||
{[testenv:genconfig]commands}
|
||||
{[testenv:genpolicy]commands}
|
||||
|
||||
[testenv:venv]
|
||||
|
@ -50,6 +51,9 @@ commands =
|
|||
[testenv:debug]
|
||||
commands = oslo_debug_helper {posargs}
|
||||
|
||||
[testenv:genconfig]
|
||||
commands = oslo-config-generator --config-file etc/oslo-config-generator/neutron-interconnection.conf
|
||||
|
||||
[testenv:genpolicy]
|
||||
commands = oslopolicy-sample-generator --config-file=etc/oslo-policy-generator/policy.conf
|
||||
|
||||
|
|
Loading…
Reference in New Issue