Retire Packaging Deb project repos
This commit is part of a series to retire the Packaging Deb project. Step 2 is to remove all content from the project repos, replacing it with a README notification where to find ongoing work, and how to recover the repo if needed at some future point (as in https://docs.openstack.org/infra/manual/drivers.html#retiring-a-project). Change-Id: I1b9b16c0f2560591b5eb24fce468462feff1906a
This commit is contained in:
parent
e86ee74a72
commit
76db854099
@ -1,8 +0,0 @@
|
||||
[run]
|
||||
branch = True
|
||||
source = oslo_context
|
||||
omit = oslo_context/tests/*
|
||||
|
||||
[report]
|
||||
ignore_errors = True
|
||||
precision = 2
|
55
.gitignore
vendored
55
.gitignore
vendored
@ -1,55 +0,0 @@
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Packages
|
||||
*.egg*
|
||||
*.egg-info
|
||||
dist
|
||||
build
|
||||
eggs
|
||||
parts
|
||||
bin
|
||||
var
|
||||
sdist
|
||||
develop-eggs
|
||||
.installed.cfg
|
||||
lib
|
||||
lib64
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
cover
|
||||
.tox
|
||||
nosetests.xml
|
||||
.testrepository
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Mr Developer
|
||||
.mr.developer.cfg
|
||||
.project
|
||||
.pydevproject
|
||||
|
||||
# Complexity
|
||||
output/*.html
|
||||
output/*/index.html
|
||||
|
||||
# Sphinx
|
||||
doc/build
|
||||
|
||||
# pbr generates these
|
||||
AUTHORS
|
||||
ChangeLog
|
||||
|
||||
# Editors
|
||||
*~
|
||||
.*.swp
|
||||
|
||||
# reno build
|
||||
releasenotes/build
|
@ -1,4 +0,0 @@
|
||||
[gerrit]
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=openstack/oslo.context.git
|
3
.mailmap
3
.mailmap
@ -1,3 +0,0 @@
|
||||
# Format is:
|
||||
# <preferred e-mail> <other e-mail 1>
|
||||
# <preferred e-mail> <other e-mail 2>
|
@ -1,7 +0,0 @@
|
||||
[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ ./oslo_context $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
@ -1,13 +0,0 @@
|
||||
If you would like to contribute to the development of OpenStack,
|
||||
you must follow the steps in this page:
|
||||
https://docs.openstack.org/infra/manual/developers.html
|
||||
|
||||
Once those steps have been completed, changes to OpenStack
|
||||
should be submitted for review via the Gerrit tool, following
|
||||
the workflow documented at:
|
||||
https://docs.openstack.org/infra/manual/developers.html#development-workflow
|
||||
|
||||
Pull requests submitted through GitHub will be ignored.
|
||||
|
||||
Bugs should be filed on Launchpad, not GitHub:
|
||||
https://bugs.launchpad.net/oslo.context
|
@ -1,4 +0,0 @@
|
||||
oslo.context Style Commandments
|
||||
===============================
|
||||
|
||||
Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/
|
176
LICENSE
176
LICENSE
@ -1,176 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
14
README
Normal file
14
README
Normal file
@ -0,0 +1,14 @@
|
||||
This project is no longer maintained.
|
||||
|
||||
The contents of this repository are still available in the Git
|
||||
source code management system. To see the contents of this
|
||||
repository before it reached its end of life, please check out the
|
||||
previous commit with "git checkout HEAD^1".
|
||||
|
||||
For ongoing work on maintaining OpenStack packages in the Debian
|
||||
distribution, please see the Debian OpenStack packaging team at
|
||||
https://wiki.debian.org/OpenStack/.
|
||||
|
||||
For any further questions, please email
|
||||
openstack-dev@lists.openstack.org or join #openstack-dev on
|
||||
Freenode.
|
28
README.rst
28
README.rst
@ -1,28 +0,0 @@
|
||||
====================
|
||||
Oslo Context Library
|
||||
====================
|
||||
|
||||
The Oslo context library has helpers to maintain useful information
|
||||
about a request context. The request context is usually populated in
|
||||
the WSGI pipeline and used by various modules such as logging.
|
||||
|
||||
* License: Apache License, Version 2.0
|
||||
* Documentation: https://docs.openstack.org/oslo.context/latest/
|
||||
* Source: https://git.openstack.org/cgit/openstack/oslo.context
|
||||
* Bugs: https://bugs.launchpad.net/oslo.context
|
||||
|
||||
Team and repository tags
|
||||
========================
|
||||
|
||||
.. image:: https://governance.openstack.org/badges/oslo.context.svg
|
||||
:target: https://governance.openstack.org/reference/tags/index.html
|
||||
|
||||
.. Change things from this point on
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/oslo.context.svg
|
||||
:target: https://pypi.python.org/pypi/oslo.context/
|
||||
:alt: Latest Version
|
||||
|
||||
.. image:: https://img.shields.io/pypi/dm/oslo.context.svg
|
||||
:target: https://pypi.python.org/pypi/oslo.context/
|
||||
:alt: Downloads
|
@ -1,85 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# 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 os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath('../..'))
|
||||
# -- General configuration ----------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
#'sphinx.ext.intersphinx',
|
||||
'openstackdocstheme',
|
||||
]
|
||||
|
||||
# autodoc generation is a bit aggressive and a nuisance when doing heavy
|
||||
# text edit cycles.
|
||||
# execute "export SPHINX_DEBUG=1" in your terminal to disable
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'oslo.context'
|
||||
copyright = u'2016, OpenStack Foundation'
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
add_module_names = True
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# -- Options for HTML output --------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. Major themes that come with
|
||||
# Sphinx are currently 'default' and 'sphinxdoc'.
|
||||
# html_theme_path = ["."]
|
||||
# html_static_path = ['static']
|
||||
html_theme = 'openstackdocs'
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
html_last_updated_fmt = '%Y-%m-%d %H:%M'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = '%sdoc' % project
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass
|
||||
# [howto/manual]).
|
||||
latex_documents = [
|
||||
('index',
|
||||
'%s.tex' % project,
|
||||
u'%s Documentation' % project,
|
||||
u'OpenStack Foundation', 'manual'),
|
||||
]
|
||||
|
||||
# openstackdocstheme options
|
||||
repository_name = 'openstack/oslo.context'
|
||||
bug_project = 'oslo.context'
|
||||
bug_tag = ''
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
#intersphinx_mapping = {'http://docs.python.org/': None}
|
@ -1,5 +0,0 @@
|
||||
==============
|
||||
Contributing
|
||||
==============
|
||||
|
||||
.. include:: ../../../CONTRIBUTING.rst
|
@ -1,26 +0,0 @@
|
||||
.. include:: ../../README.rst
|
||||
|
||||
Contents
|
||||
========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
install/index
|
||||
user/index
|
||||
contributor/index
|
||||
|
||||
Code Documentation
|
||||
==================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
reference/index
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
@ -1,7 +0,0 @@
|
||||
============
|
||||
Installation
|
||||
============
|
||||
|
||||
At the command line::
|
||||
|
||||
$ pip install oslo.context
|
@ -1,7 +0,0 @@
|
||||
The :mod:`oslo_context.context` Module
|
||||
======================================
|
||||
|
||||
.. automodule:: oslo_context.context
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
@ -1,7 +0,0 @@
|
||||
The :mod:`oslo_context.fixture` Module
|
||||
======================================
|
||||
|
||||
.. automodule:: oslo_context.fixture
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
@ -1,9 +0,0 @@
|
||||
=============
|
||||
API reference
|
||||
=============
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
context.rst
|
||||
fixture.rst
|
@ -1,37 +0,0 @@
|
||||
==========
|
||||
Examples
|
||||
==========
|
||||
|
||||
.. _examples:
|
||||
|
||||
These files can be found in the doc/source/examples directory of
|
||||
the git source of this project. They can also be found at the
|
||||
`online git repository`_ of this project.
|
||||
|
||||
.. _online git repository: https://git.openstack.org/cgit/openstack/oslo.context/tree/doc/source/examples
|
||||
|
||||
|
||||
.. _example_usage_simple.py:
|
||||
|
||||
usage_simple.py
|
||||
---------------
|
||||
|
||||
.. highlight:: python
|
||||
.. literalinclude:: examples/usage_simple.py
|
||||
:linenos:
|
||||
|
||||
.. _example_usage.py:
|
||||
|
||||
usage.py
|
||||
--------
|
||||
|
||||
.. literalinclude:: examples/usage.py
|
||||
:linenos:
|
||||
|
||||
.. _example_usage_user_identity.py:
|
||||
|
||||
usage_user_identity.py
|
||||
----------------------
|
||||
|
||||
.. literalinclude:: examples/usage_user_identity.py
|
||||
:linenos:
|
@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2015 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.
|
||||
|
||||
"""A representative usage example of Oslo Context
|
||||
|
||||
This example requires the following modules to be installed.
|
||||
|
||||
$ pip install oslo.context oslo.log
|
||||
|
||||
More information can be found at:
|
||||
|
||||
https://docs.openstack.org/oslo.context/latest/user/usage.html
|
||||
"""
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_context import context
|
||||
from oslo_log import log as logging
|
||||
|
||||
CONF = cfg.CONF
|
||||
DOMAIN = "demo"
|
||||
|
||||
logging.register_options(CONF)
|
||||
logging.setup(CONF, DOMAIN)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
LOG.info("Message without context")
|
||||
# ids in Openstack are 32 characters long
|
||||
# For readability a shorter id value is used
|
||||
context.RequestContext(user='6ce90b4d',
|
||||
tenant='d6134462',
|
||||
project_domain='a6b9360e')
|
||||
LOG.info("Message with context")
|
||||
|
||||
context = context.RequestContext(user='ace90b4d',
|
||||
tenant='b6134462',
|
||||
project_domain='c6b9360e')
|
||||
LOG.info("Message with passed context", context=context)
|
@ -1,42 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2015 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.
|
||||
|
||||
"""A simple usage example of Oslo Context
|
||||
|
||||
This example requires the following modules to be installed.
|
||||
|
||||
$ pip install oslo.context oslo.log
|
||||
|
||||
More information can be found at:
|
||||
|
||||
https://docs.openstack.org/oslo.context/latest/user/usage.html
|
||||
"""
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_context import context
|
||||
from oslo_log import log as logging
|
||||
|
||||
CONF = cfg.CONF
|
||||
DOMAIN = "demo"
|
||||
|
||||
logging.register_options(CONF)
|
||||
logging.setup(CONF, DOMAIN)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
LOG.info("Message without context")
|
||||
context.RequestContext()
|
||||
LOG.info("Message with context")
|
@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2015 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.
|
||||
|
||||
"""A usage example of Oslo Context with user_identity
|
||||
|
||||
This example requires the following modules to be installed.
|
||||
|
||||
$ pip install oslo.context oslo.log
|
||||
|
||||
More information can be found at:
|
||||
|
||||
https://docs.openstack.org/developer/oslo.context/usage.html
|
||||
"""
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_context import context
|
||||
from oslo_log import log as logging
|
||||
|
||||
CONF = cfg.CONF
|
||||
DOMAIN = "demo"
|
||||
|
||||
logging.register_options(CONF)
|
||||
CONF.logging_user_identity_format = "%(user)s/%(tenant)s@%(project_domain)s"
|
||||
logging.setup(CONF, DOMAIN)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
LOG.info("Message without context")
|
||||
# ids in Openstack are 32 characters long
|
||||
# For readability a shorter id value is used
|
||||
context.RequestContext(request_id='req-abc',
|
||||
user='6ce90b4d',
|
||||
tenant='d6134462',
|
||||
project_domain='a6b9360e')
|
||||
LOG.info("Message with context")
|
@ -1 +0,0 @@
|
||||
.. include:: ../../../ChangeLog
|
@ -1,15 +0,0 @@
|
||||
==================
|
||||
Using oslo.context
|
||||
==================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
usage
|
||||
examples
|
||||
|
||||
.. history contains a lot of sections, toctree with maxdepth 1 is used.
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
history
|
@ -1,127 +0,0 @@
|
||||
=======
|
||||
Usage
|
||||
=======
|
||||
|
||||
oslo.context is used in conjunction with `oslo.log`_ to provide context
|
||||
aware log records when specifying a :class:`~oslo_context.context.RequestContext`
|
||||
object.
|
||||
|
||||
This code example demonstrates two INFO log records with varying output
|
||||
format due to the use of RequestContext.
|
||||
|
||||
.. _oslo.log: https://docs.openstack.org/oslo.log/latest/
|
||||
|
||||
.. highlight:: python
|
||||
.. literalinclude:: examples/usage_simple.py
|
||||
:linenos:
|
||||
:lines: 28-42
|
||||
:emphasize-lines: 2,14
|
||||
|
||||
Source: :ref:`example_usage_simple.py`
|
||||
|
||||
**Example Logging Output:**
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
2016-01-20 21:56:29.283 8428 INFO __main__ [-] Message without context
|
||||
2016-01-20 21:56:29.284 8428 INFO __main__ [req-929d23e9-f50e-46ae-a8a7-02bc8c3fd2c8 - - - - -] Message with context
|
||||
|
||||
The format of these log records are defined by the
|
||||
`logging_default_format_string`_ and `logging_context_format_string`_
|
||||
configuration options respectively. The `logging_user_identity_format`_ option
|
||||
also provides further context aware definition flexibility.
|
||||
|
||||
.. _logging_default_format_string: https://docs.openstack.org/oslo.log/latest/configuration/index.html#DEFAULT.logging_default_format_string
|
||||
.. _logging_context_format_string: https://docs.openstack.org/oslo.log/latest/configuration/index.html#DEFAULT.logging_context_format_string
|
||||
.. _logging_user_identity_format: https://docs.openstack.org/oslo.log/latest/configuration/index.html#DEFAULT.logging_user_identity_format
|
||||
|
||||
-----------------
|
||||
Context Variables
|
||||
-----------------
|
||||
|
||||
The oslo.context variables used in the **logging_context_format_string** and
|
||||
**logging_user_identity_format** configuration options include:
|
||||
|
||||
* global_request_id - A request id
|
||||
(e.g. req-9f2c484a-b504-4fd9-b44c-4357544cca50) which may have been
|
||||
sent in from another service to indicate this is part of a chain of requests.
|
||||
* request_id - A request id (e.g. req-9f2c484a-b504-4fd9-b44c-4357544cca50)
|
||||
* user - A user id (e.g. e5bc7033e6b7473c9fe8ee1bd4df79a3)
|
||||
* tenant - A tenant/project id (e.g. 79e338475db84f7c91ee4e86b79b34c1)
|
||||
* domain - A domain id
|
||||
* user_domain - A user domain id
|
||||
* project_domain - A project domain id
|
||||
|
||||
|
||||
This code example demonstrates defining a context with specific attributes
|
||||
that are presented in the output log record.
|
||||
|
||||
.. literalinclude:: examples/usage.py
|
||||
:linenos:
|
||||
:lines: 28-46
|
||||
:emphasize-lines: 2,16-18
|
||||
|
||||
Source: :ref:`example_usage.py`
|
||||
|
||||
**Example Logging Output:**
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
2016-01-21 17:30:50.263 12201 INFO __main__ [-] Message without context
|
||||
2016-01-21 17:30:50.264 12201 INFO __main__ [req-e591e881-36c3-4627-a5d8-54df200168ef 6ce90b4d d6134462 - - a6b9360e] Message with context
|
||||
|
||||
A context object can also be passed as an argument to any logging level
|
||||
message.
|
||||
|
||||
.. literalinclude:: examples/usage.py
|
||||
:linenos:
|
||||
:lines: 48-51
|
||||
:emphasize-lines: 4
|
||||
|
||||
**Example Logging Output:**
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
2016-01-21 22:43:55.621 17295 INFO __main__ [req-ac2d4a3a-ff3c-4c2b-97a0-2b76b33d9e72 ace90b4d b6134462 - - c6b9360e] Message with passed context
|
||||
|
||||
.. note::
|
||||
|
||||
To maintain consistent log messages for operators across multiple
|
||||
OpenStack projects it is highly recommended that
|
||||
**logging_default_format_string** and **logging_context_format_string** are
|
||||
not modified from oslo.log default values.
|
||||
|
||||
|
||||
--------------------------
|
||||
Project Specific Variables
|
||||
--------------------------
|
||||
|
||||
Individual projects can also subclass :class:`~oslo_context.context.RequestContext`
|
||||
to provide additional attributes that can be using with oslo.log. The Nova
|
||||
`RequestContext`_ class for example provides additional variables including
|
||||
user_name and project_name.
|
||||
|
||||
.. _RequestContext: https://git.openstack.org/cgit/openstack/nova/tree/nova/context.py
|
||||
|
||||
This can for example enable the defining of **logging_user_identity_format =
|
||||
%(user_name)s %(project_name)s** which would produce a log record
|
||||
containing a context portion using names instead of ids such as
|
||||
**[req-e4b9a194-a9b1-4829-b7d0-35226fc101fc admin demo]**
|
||||
|
||||
This following code example shows how a modified **logging_user_identity_format**
|
||||
configuration alters the context portion of the log record.
|
||||
|
||||
.. literalinclude:: examples/usage_user_identity.py
|
||||
:linenos:
|
||||
:lines: 28-48
|
||||
:emphasize-lines: 9
|
||||
|
||||
Source: :ref:`example_usage_user_identity.py`
|
||||
|
||||
|
||||
**Example Logging Output:**
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
2016-01-21 20:56:43.964 14816 INFO __main__ [-] Message without context
|
||||
2016-01-21 20:56:43.965 14816 INFO __main__ [req-abc 6ce90b4d/d6134462@a6b9360e] Message with context
|
@ -1,466 +0,0 @@
|
||||
# Copyright 2011 OpenStack Foundation.
|
||||
# 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.
|
||||
|
||||
"""
|
||||
Base class for holding contextual information of a request
|
||||
|
||||
This class has several uses:
|
||||
|
||||
* Used for storing security information in a web request.
|
||||
* Used for passing contextual details to oslo.log.
|
||||
|
||||
Projects should subclass this class if they wish to enhance the request
|
||||
context or provide additional information in their specific WSGI pipeline
|
||||
or logging context.
|
||||
"""
|
||||
|
||||
import collections
|
||||
import itertools
|
||||
import threading
|
||||
import uuid
|
||||
import warnings
|
||||
|
||||
import debtcollector
|
||||
from positional import positional
|
||||
|
||||
_request_store = threading.local()
|
||||
|
||||
# These arguments will be passed to a new context from the first available
|
||||
# header to support backwards compatibility.
|
||||
_ENVIRON_HEADERS = {
|
||||
'auth_token': ['HTTP_X_AUTH_TOKEN',
|
||||
'HTTP_X_STORAGE_TOKEN'],
|
||||
'user': ['HTTP_X_USER_ID',
|
||||
'HTTP_X_USER'],
|
||||
'tenant': ['HTTP_X_PROJECT_ID',
|
||||
'HTTP_X_TENANT_ID',
|
||||
'HTTP_X_TENANT'],
|
||||
'user_domain': ['HTTP_X_USER_DOMAIN_ID'],
|
||||
'project_domain': ['HTTP_X_PROJECT_DOMAIN_ID'],
|
||||
'user_name': ['HTTP_X_USER_NAME'],
|
||||
'project_name': ['HTTP_X_PROJECT_NAME',
|
||||
'HTTP_X_TENANT_NAME'],
|
||||
'user_domain_name': ['HTTP_X_USER_DOMAIN_NAME'],
|
||||
'project_domain_name': ['HTTP_X_PROJECT_DOMAIN_NAME'],
|
||||
'request_id': ['openstack.request_id'],
|
||||
'global_request_id': ['openstack.global_request_id'],
|
||||
|
||||
|
||||
'service_token': ['HTTP_X_SERVICE_TOKEN'],
|
||||
'service_user_id': ['HTTP_X_SERVICE_USER_ID'],
|
||||
'service_user_name': ['HTTP_X_SERVICE_USER_NAME'],
|
||||
'service_user_domain_id': ['HTTP_X_SERVICE_USER_DOMAIN_ID'],
|
||||
'service_user_domain_name': ['HTTP_X_SERVICE_USER_DOMAIN_NAME'],
|
||||
'service_project_id': ['HTTP_X_SERVICE_PROJECT_ID'],
|
||||
'service_project_name': ['HTTP_X_SERVICE_PROJECT_NAME'],
|
||||
'service_project_domain_id': ['HTTP_X_SERVICE_PROJECT_DOMAIN_ID'],
|
||||
'service_project_domain_name': ['HTTP_X_SERVICE_PROJECT_DOMAIN_NAME'],
|
||||
}
|
||||
|
||||
|
||||
def generate_request_id():
|
||||
"""Generate a unique request id."""
|
||||
return 'req-%s' % uuid.uuid4()
|
||||
|
||||
|
||||
class _DeprecatedPolicyValues(collections.MutableMapping):
|
||||
"""A Dictionary that manages current and deprecated policy values.
|
||||
|
||||
Anything added to this dictionary after initial creation is considered a
|
||||
deprecated key that we are trying to move services away from. Accessing
|
||||
these values as oslo.policy will do will trigger a DeprecationWarning.
|
||||
"""
|
||||
|
||||
def __init__(self, data):
|
||||
self._data = data
|
||||
self._deprecated = {}
|
||||
|
||||
def __getitem__(self, k):
|
||||
try:
|
||||
return self._data[k]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
val = self._deprecated[k]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
warnings.warn('Policy enforcement is depending on the value of '
|
||||
'%s. This key is deprecated. Please update your '
|
||||
'policy file to use the standard policy values.' % k,
|
||||
DeprecationWarning)
|
||||
return val
|
||||
|
||||
raise KeyError(k)
|
||||
|
||||
def __setitem__(self, k, v):
|
||||
self._deprecated[k] = v
|
||||
|
||||
def __delitem__(self, k):
|
||||
del self._deprecated[k]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._dict)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._dict)
|
||||
|
||||
def __str__(self):
|
||||
return self._dict.__str__()
|
||||
|
||||
def __repr__(self):
|
||||
return self._dict.__repr__()
|
||||
|
||||
@property
|
||||
def _dict(self):
|
||||
d = self._deprecated.copy()
|
||||
d.update(self._data)
|
||||
return d
|
||||
|
||||
|
||||
# FIXME(dims): Skip deprecation warnings until Pike (Version 2.14)
|
||||
_log_deprecation_warnings = False
|
||||
|
||||
|
||||
def _moved_msg(new_name, old_name):
|
||||
if old_name:
|
||||
deprecated_msg = "Property '%(old_name)s' has moved to '%(new_name)s'"
|
||||
deprecated_msg = deprecated_msg % {'old_name': old_name,
|
||||
'new_name': new_name}
|
||||
|
||||
# FIXME(dims): Skip deprecation warnings until Pike (Version 2.14)
|
||||
if _log_deprecation_warnings:
|
||||
debtcollector.deprecate(deprecated_msg,
|
||||
version='2.6',
|
||||
removal_version='3.0',
|
||||
stacklevel=5)
|
||||
|
||||
|
||||
def _moved_property(new_name, old_name=None, target=None):
|
||||
|
||||
if not target:
|
||||
target = new_name
|
||||
|
||||
def getter(self):
|
||||
_moved_msg(new_name, old_name)
|
||||
return getattr(self, target)
|
||||
|
||||
def setter(self, value):
|
||||
_moved_msg(new_name, old_name)
|
||||
setattr(self, target, value)
|
||||
|
||||
def deleter(self):
|
||||
_moved_msg(new_name, old_name)
|
||||
delattr(self, target)
|
||||
|
||||
return property(getter, setter, deleter)
|
||||
|
||||
|
||||
class RequestContext(object):
|
||||
|
||||
"""Helper class to represent useful information about a request context.
|
||||
|
||||
Stores information about the security context under which the user
|
||||
accesses the system, as well as additional request information.
|
||||
"""
|
||||
|
||||
user_idt_format = u'{user} {tenant} {domain} {user_domain} {p_domain}'
|
||||
|
||||
@positional(enforcement=positional.WARN)
|
||||
def __init__(self,
|
||||
auth_token=None,
|
||||
user=None,
|
||||
tenant=None,
|
||||
domain=None,
|
||||
user_domain=None,
|
||||
project_domain=None,
|
||||
is_admin=False,
|
||||
read_only=False,
|
||||
show_deleted=False,
|
||||
request_id=None,
|
||||
resource_uuid=None,
|
||||
overwrite=True,
|
||||
roles=None,
|
||||
user_name=None,
|
||||
project_name=None,
|
||||
domain_name=None,
|
||||
user_domain_name=None,
|
||||
project_domain_name=None,
|
||||
is_admin_project=True,
|
||||
service_token=None,
|
||||
service_user_id=None,
|
||||
service_user_name=None,
|
||||
service_user_domain_id=None,
|
||||
service_user_domain_name=None,
|
||||
service_project_id=None,
|
||||
service_project_name=None,
|
||||
service_project_domain_id=None,
|
||||
service_project_domain_name=None,
|
||||
service_roles=None,
|
||||
global_request_id=None):
|
||||
"""Initialize the RequestContext
|
||||
|
||||
:param overwrite: Set to False to ensure that the greenthread local
|
||||
copy of the index is not overwritten.
|
||||
:param is_admin_project: Whether the specified project is specified in
|
||||
the token as the admin project. Defaults to
|
||||
True for backwards compatibility.
|
||||
:type is_admin_project: bool
|
||||
"""
|
||||
# setting to private variables to avoid triggering subclass properties
|
||||
self._user_id = user
|
||||
self._project_id = tenant
|
||||
self._domain_id = domain
|
||||
self._user_domain_id = user_domain
|
||||
self._project_domain_id = project_domain
|
||||
|
||||
self.auth_token = auth_token
|
||||
self.user_name = user_name
|
||||
self.project_name = project_name
|
||||
self.domain_name = domain_name
|
||||
self.user_domain_name = user_domain_name
|
||||
self.project_domain_name = project_domain_name
|
||||
self.is_admin = is_admin
|
||||
self.is_admin_project = is_admin_project
|
||||
self.read_only = read_only
|
||||
self.show_deleted = show_deleted
|
||||
self.resource_uuid = resource_uuid
|
||||
self.roles = roles or []
|
||||
|
||||
self.service_token = service_token
|
||||
self.service_user_id = service_user_id
|
||||
self.service_user_name = service_user_name
|
||||
self.service_user_domain_id = service_user_domain_id
|
||||
self.service_user_domain_name = service_user_domain_name
|
||||
self.service_project_id = service_project_id
|
||||
self.service_project_name = service_project_name
|
||||
self.service_project_domain_id = service_project_domain_id
|
||||
self.service_project_domain_name = service_project_domain_name
|
||||
self.service_roles = service_roles or []
|
||||
|
||||
if not request_id:
|
||||
request_id = generate_request_id()
|
||||
self.request_id = request_id
|
||||
self.global_request_id = global_request_id
|
||||
if overwrite or not get_current():
|
||||
self.update_store()
|
||||
|
||||
# NOTE(jamielennox): To prevent circular lookups on subclasses that might
|
||||
# point user to user_id we make user/user_id tenant/project_id etc point
|
||||
# to the same private variable rather than each other.
|
||||
tenant = _moved_property('project_id', 'tenant', target='_project_id')
|
||||
user = _moved_property('user_id', 'user', target='_user_id')
|
||||
domain = _moved_property('domain_id', 'domain', target='_domain_id')
|
||||
user_domain = _moved_property('user_domain_id',
|
||||
'user_domain',
|
||||
target='_user_domain_id')
|
||||
project_domain = _moved_property('project_domain_id',
|
||||
'project_domain',
|
||||
target='_project_domain_id')
|
||||
|
||||
user_id = _moved_property('_user_id')
|
||||
project_id = _moved_property('_project_id')
|
||||
domain_id = _moved_property('_domain_id')
|
||||
user_domain_id = _moved_property('_user_domain_id')
|
||||
project_domain_id = _moved_property('_project_domain_id')
|
||||
|
||||
def update_store(self):
|
||||
"""Store the context in the current thread."""
|
||||
_request_store.context = self
|
||||
|
||||
def to_policy_values(self):
|
||||
"""A dictionary of context attributes to enforce policy with.
|
||||
|
||||
oslo.policy enforcement requires a dictionary of attributes
|
||||
representing the current logged in user on which it applies policy
|
||||
enforcement. This dictionary defines a standard list of attributes that
|
||||
should be available for enforcement across services.
|
||||
|
||||
It is expected that services will often have to override this method
|
||||
with either deprecated values or additional attributes used by that
|
||||
service specific policy.
|
||||
"""
|
||||
# NOTE(jamielennox): We need a way to allow projects to provide old
|
||||
# deprecated policy values that trigger a warning when used in favour
|
||||
# of our standard ones. This object acts like a dict but only values
|
||||
# from oslo.policy don't show a warning.
|
||||
return _DeprecatedPolicyValues({
|
||||
'user_id': self.user_id,
|
||||
'user_domain_id': self.user_domain_id,
|
||||
'project_id': self.project_id,
|
||||
'project_domain_id': self.project_domain_id,
|
||||
'roles': self.roles,
|
||||
'is_admin_project': self.is_admin_project,
|
||||
'service_user_id': self.service_user_id,
|
||||
'service_user_domain_id': self.service_user_domain_id,
|
||||
'service_project_id': self.service_project_id,
|
||||
'service_project_domain_id': self.service_project_domain_id,
|
||||
'service_roles': self.service_roles})
|
||||
|
||||
def to_dict(self):
|
||||
"""Return a dictionary of context attributes."""
|
||||
user_idt = self.user_idt_format.format(
|
||||
user=self.user_id or '-',
|
||||
tenant=self.project_id or '-',
|
||||
domain=self.domain_id or '-',
|
||||
user_domain=self.user_domain_id or '-',
|
||||
p_domain=self.project_domain_id or '-')
|
||||
|
||||
return {'user': self.user_id,
|
||||
'tenant': self.project_id,
|
||||
'domain': self.domain_id,
|
||||
'user_domain': self.user_domain_id,
|
||||
'project_domain': self.project_domain_id,
|
||||
'is_admin': self.is_admin,
|
||||
'read_only': self.read_only,
|
||||
'show_deleted': self.show_deleted,
|
||||
'auth_token': self.auth_token,
|
||||
'request_id': self.request_id,
|
||||
'global_request_id': self.global_request_id,
|
||||
'resource_uuid': self.resource_uuid,
|
||||
'roles': self.roles,
|
||||
'user_identity': user_idt,
|
||||
'is_admin_project': self.is_admin_project}
|
||||
|
||||
def get_logging_values(self):
|
||||
"""Return a dictionary of logging specific context attributes."""
|
||||
values = {'user_name': self.user_name,
|
||||
'project_name': self.project_name,
|
||||
'domain_name': self.domain_name,
|
||||
'user_domain_name': self.user_domain_name,
|
||||
'project_domain_name': self.project_domain_name}
|
||||
values.update(self.to_dict())
|
||||
return values
|
||||
|
||||
@property
|
||||
def global_id(self):
|
||||
"""Return a sensible value for global_id to pass on.
|
||||
|
||||
When we want to make a call with to another service, it's
|
||||
important that we try to use global_request_id if available,
|
||||
and fall back to the locally generated request_id if not.
|
||||
"""
|
||||
return self.global_request_id or self.request_id
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, values, **kwargs):
|
||||
"""Construct a context object from a provided dictionary."""
|
||||
kwargs.setdefault('auth_token', values.get('auth_token'))
|
||||
kwargs.setdefault('user', values.get('user'))
|
||||
kwargs.setdefault('tenant', values.get('tenant'))
|
||||
kwargs.setdefault('domain', values.get('domain'))
|
||||
kwargs.setdefault('user_domain', values.get('user_domain'))
|
||||
kwargs.setdefault('project_domain', values.get('project_domain'))
|
||||
kwargs.setdefault('is_admin', values.get('is_admin', False))
|
||||
kwargs.setdefault('read_only', values.get('read_only', False))
|
||||
kwargs.setdefault('show_deleted', values.get('show_deleted', False))
|
||||
kwargs.setdefault('request_id', values.get('request_id'))
|
||||
kwargs.setdefault('global_request_id', values.get('global_request_id'))
|
||||
kwargs.setdefault('resource_uuid', values.get('resource_uuid'))
|
||||
kwargs.setdefault('roles', values.get('roles'))
|
||||
kwargs.setdefault('user_name', values.get('user_name'))
|
||||
kwargs.setdefault('project_name', values.get('project_name'))
|
||||
kwargs.setdefault('domain_name', values.get('domain_name'))
|
||||
kwargs.setdefault('user_domain_name', values.get('user_domain_name'))
|
||||
kwargs.setdefault('project_domain_name',
|
||||
values.get('project_domain_name'))
|
||||
kwargs.setdefault('is_admin_project',
|
||||
values.get('is_admin_project', True))
|
||||
return cls(**kwargs)
|
||||
|
||||
@classmethod
|
||||
def from_environ(cls, environ, **kwargs):
|
||||
"""Load a context object from a request environment.
|
||||
|
||||
If keyword arguments are provided then they override the values in the
|
||||
request environment.
|
||||
|
||||
:param environ: The environment dictionary associated with a request.
|
||||
:type environ: dict
|
||||
"""
|
||||
# Load a new context object from the environment variables set by
|
||||
# auth_token middleware. See:
|
||||
# https://docs.openstack.org/keystonemiddleware/latest/api/keystonemiddleware.auth_token.html#what-auth-token-adds-to-the-request-for-use-by-the-openstack-service
|
||||
|
||||
# add kwarg if not specified by user from a list of possible headers
|
||||
for k, v_list in _ENVIRON_HEADERS.items():
|
||||
if k in kwargs:
|
||||
continue
|
||||
|
||||
for v in v_list:
|
||||
if v in environ:
|
||||
kwargs[k] = environ[v]
|
||||
break
|
||||
|
||||
if 'roles' not in kwargs:
|
||||
roles = environ.get('HTTP_X_ROLES', environ.get('HTTP_X_ROLE'))
|
||||
roles = [r.strip() for r in roles.split(',')] if roles else []
|
||||
kwargs['roles'] = roles
|
||||
|
||||
if 'service_roles' not in kwargs:
|
||||
roles = environ.get('HTTP_X_SERVICE_ROLES')
|
||||
roles = [r.strip() for r in roles.split(',')] if roles else []
|
||||
kwargs['service_roles'] = roles
|
||||
|
||||
if 'is_admin_project' not in kwargs:
|
||||
# NOTE(jamielennox): we default is_admin_project to true because if
|
||||
# nothing is provided we have to assume it is the admin project to
|
||||
# make old policy continue to work.
|
||||
is_admin_proj_str = environ.get('HTTP_X_IS_ADMIN_PROJECT', 'true')
|
||||
kwargs['is_admin_project'] = is_admin_proj_str.lower() == 'true'
|
||||
|
||||
return cls(**kwargs)
|
||||
|
||||
|
||||
def get_admin_context(show_deleted=False):
|
||||
"""Create an administrator context."""
|
||||
context = RequestContext(None,
|
||||
tenant=None,
|
||||
is_admin=True,
|
||||
show_deleted=show_deleted,
|
||||
overwrite=False)
|
||||
return context
|
||||
|
||||
|
||||
def get_context_from_function_and_args(function, args, kwargs):
|
||||
"""Find an arg of type RequestContext and return it.
|
||||
|
||||
This is useful in a couple of decorators where we don't
|
||||
know much about the function we're wrapping.
|
||||
"""
|
||||
|
||||
for arg in itertools.chain(kwargs.values(), args):
|
||||
if isinstance(arg, RequestContext):
|
||||
return arg
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def is_user_context(context):
|
||||
"""Indicates if the request context is a normal user."""
|
||||
if not context or not isinstance(context, RequestContext):
|
||||
return False
|
||||
if context.is_admin:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def get_current():
|
||||
"""Return this thread's current context
|
||||
|
||||
If no context is set, returns None
|
||||
"""
|
||||
return getattr(_request_store, 'context', None)
|
@ -1,40 +0,0 @@
|
||||
# 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 fixtures
|
||||
|
||||
from oslo_context import context
|
||||
|
||||
|
||||
class ClearRequestContext(fixtures.Fixture):
|
||||
"""Clears any cached RequestContext
|
||||
|
||||
This resets RequestContext at the beginning and end of tests that
|
||||
use this fixture to ensure that we have a clean slate for running
|
||||
tests, and that we leave a clean slate for other tests that might
|
||||
run later in the same process.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(ClearRequestContext, self).setUp()
|
||||
# we need to clear both when we start, and when we finish,
|
||||
# because there might be other tests running that don't handle
|
||||
# this correctly.
|
||||
self._remove_cached_context()
|
||||
self.addCleanup(self._remove_cached_context)
|
||||
|
||||
def _remove_cached_context(self):
|
||||
"""Remove the thread-local context stored in the module."""
|
||||
try:
|
||||
del context._request_store.context
|
||||
except AttributeError:
|
||||
pass
|
@ -1,636 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# Copyright 2011 OpenStack Foundation.
|
||||
# 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.
|
||||
|
||||
import fixtures
|
||||
import hashlib
|
||||
import uuid
|
||||
import warnings
|
||||
|
||||
from oslotest import base as test_base
|
||||
|
||||
from oslo_context import context
|
||||
from oslo_context import fixture
|
||||
|
||||
|
||||
def generate_id(name):
|
||||
return hashlib.md5(name.encode('utf-8')).hexdigest()
|
||||
|
||||
|
||||
class WarningsFixture(fixtures.Fixture):
|
||||
|
||||
def __init__(self, action="always", category=DeprecationWarning):
|
||||
super(WarningsFixture, self).__init__()
|
||||
self.action = action
|
||||
self.category = category
|
||||
|
||||
def setUp(self):
|
||||
super(WarningsFixture, self).setUp()
|
||||
self._w = warnings.catch_warnings(record=True)
|
||||
self.log = self._w.__enter__()
|
||||
self.addCleanup(self._w.__exit__)
|
||||
warnings.simplefilter(self.action, self.category)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.log)
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self.log[item]
|
||||
|
||||
|
||||
class Object(object):
|
||||
pass
|
||||
|
||||
|
||||
class ContextTest(test_base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ContextTest, self).setUp()
|
||||
self.warnings = self.useFixture(WarningsFixture())
|
||||
self.useFixture(fixture.ClearRequestContext())
|
||||
|
||||
def test_context(self):
|
||||
ctx = context.RequestContext()
|
||||
self.assertTrue(ctx)
|
||||
|
||||
def test_store_when_no_overwrite(self):
|
||||
# If no context exists we store one even if overwrite is false
|
||||
# (since we are not overwriting anything).
|
||||
ctx = context.RequestContext(overwrite=False)
|
||||
self.assertIs(context.get_current(), ctx)
|
||||
|
||||
def test_no_overwrite(self):
|
||||
# If there is already a context in the cache a new one will
|
||||
# not overwrite it if overwrite=False.
|
||||
ctx1 = context.RequestContext(overwrite=True)
|
||||
context.RequestContext(overwrite=False)
|
||||
self.assertIs(context.get_current(), ctx1)
|
||||
|
||||
def test_admin_no_overwrite(self):
|
||||
# If there is already a context in the cache creating an admin
|
||||
# context will not overwrite it.
|
||||
ctx1 = context.RequestContext(overwrite=True)
|
||||
context.get_admin_context()
|
||||
self.assertIs(context.get_current(), ctx1)
|
||||
self.assertFalse(ctx1.is_admin)
|
||||
|
||||
def test_store_current(self):
|
||||
# By default a new context is stored.
|
||||
ctx = context.RequestContext()
|
||||
self.assertIs(context.get_current(), ctx)
|
||||
|
||||
def test_no_context(self):
|
||||
self.assertIsNone(context.get_current())
|
||||
|
||||
def test_admin_context_show_deleted_flag_default(self):
|
||||
ctx = context.get_admin_context()
|
||||
self.assertIsInstance(ctx, context.RequestContext)
|
||||
self.assertTrue(ctx.is_admin)
|
||||
self.assertFalse(ctx.show_deleted)
|
||||
self.assertIsNone(ctx.project_id)
|
||||
|
||||
def test_admin_context_show_deleted_flag_set(self):
|
||||
ctx = context.get_admin_context(show_deleted=True)
|
||||
self.assertTrue(ctx.is_admin)
|
||||
self.assertTrue(ctx.show_deleted)
|
||||
|
||||
def test_from_dict(self):
|
||||
dct = {
|
||||
"auth_token": "token1",
|
||||
"user": "user1",
|
||||
"user_name": "user1_name",
|
||||
"tenant": "tenant1",
|
||||
"project_name": "tenant1_name",
|
||||
"domain": "domain1",
|
||||
"domain_name": "domain1_name",
|
||||
"user_domain": "user_domain1",
|
||||
"user_domain_name": "user_domain1_name",
|
||||
"project_domain": "project_domain1",
|
||||
"project_domain_name": "project_domain1_name",
|
||||
"is_admin": True,
|
||||
"read_only": True,
|
||||
"show_deleted": True,
|
||||
"request_id": "request1",
|
||||
"global_request_id": "req-uuid",
|
||||
"resource_uuid": "instance1",
|
||||
"extra_data": "foo"
|
||||
}
|
||||
ctx = context.RequestContext.from_dict(dct)
|
||||
self.assertEqual(dct['auth_token'], ctx.auth_token)
|
||||
self.assertEqual(dct['user'], ctx.user_id)
|
||||
self.assertEqual(dct['tenant'], ctx.project_id)
|
||||
self.assertEqual(dct['domain'], ctx.domain_id)
|
||||
self.assertEqual(dct['user_domain'], ctx.user_domain_id)
|
||||
self.assertEqual(dct['project_domain'], ctx.project_domain_id)
|
||||
self.assertTrue(ctx.is_admin)
|
||||
self.assertTrue(ctx.read_only)
|
||||
self.assertTrue(ctx.show_deleted)
|
||||
self.assertEqual(dct['request_id'], ctx.request_id)
|
||||
self.assertEqual(dct['global_request_id'], ctx.global_request_id)
|
||||
self.assertEqual(dct['resource_uuid'], ctx.resource_uuid)
|
||||
self.assertEqual(dct['user_name'], ctx.user_name)
|
||||
self.assertEqual(dct['project_name'], ctx.project_name)
|
||||
self.assertEqual(dct['domain_name'], ctx.domain_name)
|
||||
self.assertEqual(dct['user_domain_name'], ctx.user_domain_name)
|
||||
self.assertEqual(dct['project_domain_name'], ctx.project_domain_name)
|
||||
|
||||
def test_from_dict_unknown_keys(self):
|
||||
dct = {
|
||||
"auth_token": "token1",
|
||||
"user": "user1",
|
||||
"read_only": True,
|
||||
"roles": "role1,role2,role3", # future review provides this
|
||||
"color": "red",
|
||||
"unknown": ""
|
||||
}
|
||||
ctx = context.RequestContext.from_dict(dct)
|
||||
self.assertEqual("token1", ctx.auth_token)
|
||||
self.assertEqual("user1", ctx.user_id)
|
||||
self.assertIsNone(ctx.project_id)
|
||||
self.assertFalse(ctx.is_admin)
|
||||
self.assertTrue(ctx.read_only)
|
||||
self.assertRaises(KeyError, lambda: ctx.__dict__['color'])
|
||||
|
||||
def test_from_dict_overrides(self):
|
||||
dct = {
|
||||
"auth_token": "token1",
|
||||
"user": "user1",
|
||||
"read_only": True,
|
||||
"roles": "role1,role2,role3",
|
||||
"color": "red",
|
||||
"unknown": ""
|
||||
}
|
||||
ctx = context.RequestContext.from_dict(dct,
|
||||
user="user2",
|
||||
project_name="project1")
|
||||
self.assertEqual("token1", ctx.auth_token)
|
||||
self.assertEqual("user2", ctx.user)
|
||||
self.assertEqual("project1", ctx.project_name)
|
||||
self.assertIsNone(ctx.tenant)
|
||||
self.assertFalse(ctx.is_admin)
|
||||
self.assertTrue(ctx.read_only)
|
||||
|
||||
def test_is_user_context(self):
|
||||
self.assertFalse(context.is_user_context(None))
|
||||
ctx = context.RequestContext(is_admin=True)
|
||||
self.assertFalse(context.is_user_context(ctx))
|
||||
ctx = context.RequestContext(is_admin=False)
|
||||
self.assertTrue(context.is_user_context(ctx))
|
||||
self.assertFalse(context.is_user_context("non context object"))
|
||||
|
||||
def test_from_environ_variables(self):
|
||||
auth_token = uuid.uuid4().hex
|
||||
user_name = uuid.uuid4().hex
|
||||
user_id = generate_id(user_name)
|
||||
project_name = uuid.uuid4().hex
|
||||
project_id = generate_id(project_name)
|
||||
user_domain_name = uuid.uuid4().hex
|
||||
user_domain_id = generate_id(user_domain_name)
|
||||
project_domain_name = uuid.uuid4().hex
|
||||
project_domain_id = generate_id(project_domain_name)
|
||||
roles = [uuid.uuid4().hex, uuid.uuid4().hex, uuid.uuid4().hex]
|
||||
request_id = uuid.uuid4().hex
|
||||
global_request_id = uuid.uuid4().hex
|
||||
service_token = uuid.uuid4().hex
|
||||
service_user_id = uuid.uuid4().hex
|
||||
service_user_name = uuid.uuid4().hex
|
||||
service_user_domain_id = uuid.uuid4().hex
|
||||
service_user_domain_name = uuid.uuid4().hex
|
||||
service_project_id = uuid.uuid4().hex
|
||||
service_project_name = uuid.uuid4().hex
|
||||
service_project_domain_id = uuid.uuid4().hex
|
||||
service_project_domain_name = uuid.uuid4().hex
|
||||
service_roles = [uuid.uuid4().hex, uuid.uuid4().hex, uuid.uuid4().hex]
|
||||
|
||||
environ = {
|
||||
'HTTP_X_AUTH_TOKEN': auth_token,
|
||||
'HTTP_X_USER_ID': user_id,
|
||||
'HTTP_X_PROJECT_ID': project_id,
|
||||
'HTTP_X_USER_DOMAIN_ID': user_domain_id,
|
||||
'HTTP_X_PROJECT_DOMAIN_ID': project_domain_id,
|
||||
'HTTP_X_ROLES': ','.join(roles),
|
||||
'HTTP_X_USER_NAME': user_name,
|
||||
'HTTP_X_PROJECT_NAME': project_name,
|
||||
'HTTP_X_USER_DOMAIN_NAME': user_domain_name,
|
||||
'HTTP_X_PROJECT_DOMAIN_NAME': project_domain_name,
|
||||
'HTTP_X_SERVICE_TOKEN': service_token,
|
||||
'HTTP_X_SERVICE_USER_ID': service_user_id,
|
||||
'HTTP_X_SERVICE_USER_NAME': service_user_name,
|
||||
'HTTP_X_SERVICE_USER_DOMAIN_ID': service_user_domain_id,
|
||||
'HTTP_X_SERVICE_USER_DOMAIN_NAME': service_user_domain_name,
|
||||
'HTTP_X_SERVICE_PROJECT_ID': service_project_id,
|
||||
'HTTP_X_SERVICE_PROJECT_NAME': service_project_name,
|
||||
'HTTP_X_SERVICE_PROJECT_DOMAIN_ID': service_project_domain_id,
|
||||
'HTTP_X_SERVICE_PROJECT_DOMAIN_NAME': service_project_domain_name,
|
||||
'HTTP_X_SERVICE_ROLES': ','.join(service_roles),
|
||||
'openstack.request_id': request_id,
|
||||
'openstack.global_request_id': global_request_id,
|
||||
}
|
||||
|
||||
ctx = context.RequestContext.from_environ(environ)
|
||||
|
||||
self.assertEqual(auth_token, ctx.auth_token)
|
||||
self.assertEqual(user_id, ctx.user_id)
|
||||
self.assertEqual(user_name, ctx.user_name)
|
||||
self.assertEqual(project_id, ctx.project_id)
|
||||
self.assertEqual(project_name, ctx.project_name)
|
||||
self.assertEqual(user_domain_id, ctx.user_domain_id)
|
||||
self.assertEqual(user_domain_name, ctx.user_domain_name)
|
||||
self.assertEqual(project_domain_id, ctx.project_domain_id)
|
||||
self.assertEqual(project_domain_name, ctx.project_domain_name)
|
||||
self.assertEqual(roles, ctx.roles)
|
||||
self.assertEqual(request_id, ctx.request_id)
|
||||
self.assertEqual(global_request_id, ctx.global_request_id)
|
||||
self.assertEqual(service_token, ctx.service_token)
|
||||
self.assertEqual(service_user_id, ctx.service_user_id)
|
||||
self.assertEqual(service_user_name, ctx.service_user_name)
|
||||
self.assertEqual(service_user_domain_id, ctx.service_user_domain_id)
|
||||
self.assertEqual(service_user_domain_name,
|
||||
ctx.service_user_domain_name)
|
||||
self.assertEqual(service_project_id, ctx.service_project_id)
|
||||
self.assertEqual(service_project_name, ctx.service_project_name)
|
||||
self.assertEqual(service_project_domain_id,
|
||||
ctx.service_project_domain_id)
|
||||
self.assertEqual(service_project_domain_name,
|
||||
ctx.service_project_domain_name)
|
||||
self.assertEqual(service_roles, ctx.service_roles)
|
||||
|
||||
def test_from_environ_no_roles(self):
|
||||
ctx = context.RequestContext.from_environ(environ={})
|
||||
self.assertEqual([], ctx.roles)
|
||||
|
||||
ctx = context.RequestContext.from_environ(environ={'HTTP_X_ROLES': ''})
|
||||
self.assertEqual([], ctx.roles)
|
||||
|
||||
def test_from_environ_deprecated_variables(self):
|
||||
value = uuid.uuid4().hex
|
||||
|
||||
environ = {'HTTP_X_USER': value}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual(value, ctx.user)
|
||||
|
||||
environ = {'HTTP_X_TENANT_ID': value}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual(value, ctx.project_id)
|
||||
|
||||
environ = {'HTTP_X_STORAGE_TOKEN': value}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual(value, ctx.auth_token)
|
||||
|
||||
environ = {'HTTP_X_TENANT': value}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual(value, ctx.tenant)
|
||||
|
||||
environ = {'HTTP_X_ROLE': value}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual([value], ctx.roles)
|
||||
|
||||
environ = {'HTTP_X_TENANT_NAME': value}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual(value, ctx.project_name)
|
||||
|
||||
def test_from_environ_deprecated_precendence(self):
|
||||
old = uuid.uuid4().hex
|
||||
new = uuid.uuid4().hex
|
||||
override = uuid.uuid4().hex
|
||||
|
||||
environ = {'HTTP_X_USER': old,
|
||||
'HTTP_X_USER_ID': new}
|
||||
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual(new, ctx.user)
|
||||
|
||||
ctx = context.RequestContext.from_environ(environ=environ,
|
||||
user=override)
|
||||
self.assertEqual(override, ctx.user)
|
||||
|
||||
environ = {'HTTP_X_TENANT': old,
|
||||
'HTTP_X_PROJECT_ID': new}
|
||||
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual(new, ctx.project_id)
|
||||
|
||||
ctx = context.RequestContext.from_environ(environ=environ,
|
||||
tenant=override)
|
||||
self.assertEqual(override, ctx.project_id)
|
||||
|
||||
environ = {'HTTP_X_TENANT_NAME': old,
|
||||
'HTTP_X_PROJECT_NAME': new}
|
||||
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual(new, ctx.project_name)
|
||||
|
||||
def test_from_environ_strip_roles(self):
|
||||
environ = {'HTTP_X_ROLES': ' abc\t,\ndef\n,ghi\n\n',
|
||||
'HTTP_X_SERVICE_ROLES': ' jkl\t,\nmno\n,pqr\n\n'}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertEqual(['abc', 'def', 'ghi'], ctx.roles)
|
||||
self.assertEqual(['jkl', 'mno', 'pqr'], ctx.service_roles)
|
||||
|
||||
def test_environ_admin_project(self):
|
||||
environ = {}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertIs(True, ctx.is_admin_project)
|
||||
self.assertIs(True, ctx.to_policy_values()['is_admin_project'])
|
||||
|
||||
environ = {'HTTP_X_IS_ADMIN_PROJECT': 'True'}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertIs(True, ctx.is_admin_project)
|
||||
self.assertIs(True, ctx.to_policy_values()['is_admin_project'])
|
||||
|
||||
environ = {'HTTP_X_IS_ADMIN_PROJECT': 'False'}
|
||||
ctx = context.RequestContext.from_environ(environ=environ)
|
||||
self.assertIs(False, ctx.is_admin_project)
|
||||
self.assertIs(False, ctx.to_policy_values()['is_admin_project'])
|
||||
|
||||
def test_from_function_and_args(self):
|
||||
ctx = context.RequestContext(user="user1")
|
||||
arg = []
|
||||
kw = dict(c=ctx, s="s")
|
||||
fn = context.get_context_from_function_and_args
|
||||
ctx1 = context.get_context_from_function_and_args(fn, arg, kw)
|
||||
self.assertIs(ctx1, ctx)
|
||||
|
||||
def test_not_in_from_function_and_args(self):
|
||||
arg = []
|
||||
kw = dict()
|
||||
fn = context.get_context_from_function_and_args
|
||||
ctx1 = context.get_context_from_function_and_args(fn, arg, kw)
|
||||
self.assertIsNone(ctx1)
|
||||
|
||||
def test_values(self):
|
||||
auth_token = "token1"
|
||||
# test unicode support
|
||||
user_name = u"John Gāo"
|
||||
user_id = generate_id(user_name)
|
||||
project_name = 'tenant1'
|
||||
project_id = generate_id(project_name)
|
||||
domain_name = 'domain1'
|
||||
domain_id = generate_id(domain_name)
|
||||
user_domain_name = 'user_domain1'
|
||||
user_domain_id = generate_id(user_domain_name)
|
||||
project_domain_name = 'project_domain1'
|
||||
project_domain_id = generate_id(project_domain_name)
|
||||
is_admin = True
|
||||
read_only = True
|
||||
show_deleted = True
|
||||
request_id = "id1"
|
||||
global_request_id = "req-id1"
|
||||
resource_uuid = "uuid1"
|
||||
|
||||
ctx = context.RequestContext(auth_token=auth_token,
|
||||
user=user_id,
|
||||
user_name=user_name,
|
||||
tenant=project_id,
|
||||
project_name=project_name,
|
||||
domain=domain_id,
|
||||
domain_name=domain_name,
|
||||
user_domain=user_domain_id,
|
||||
user_domain_name=user_domain_name,
|
||||
project_domain=project_domain_id,
|
||||
project_domain_name=project_domain_name,
|
||||
is_admin=is_admin,
|
||||
read_only=read_only,
|
||||
show_deleted=show_deleted,
|
||||
request_id=request_id,
|
||||
global_request_id=global_request_id,
|
||||
resource_uuid=resource_uuid)
|
||||
self.assertEqual(auth_token, ctx.auth_token)
|
||||
self.assertEqual(user_id, ctx.user_id)
|
||||
self.assertEqual(user_name, ctx.user_name)
|
||||
self.assertEqual(project_id, ctx.project_id)
|
||||
self.assertEqual(project_name, ctx.project_name)
|
||||
self.assertEqual(domain_id, ctx.domain_id)
|
||||
self.assertEqual(domain_name, ctx.domain_name)
|
||||
self.assertEqual(user_domain_id, ctx.user_domain_id)
|
||||
self.assertEqual(user_domain_name, ctx.user_domain_name)
|
||||
self.assertEqual(project_domain_id, ctx.project_domain_id)
|
||||
self.assertEqual(project_domain_name, ctx.project_domain_name)
|
||||
self.assertEqual(is_admin, ctx.is_admin)
|
||||
self.assertEqual(read_only, ctx.read_only)
|
||||
self.assertEqual(show_deleted, ctx.show_deleted)
|
||||
self.assertEqual(request_id, ctx.request_id)
|
||||
self.assertEqual(resource_uuid, ctx.resource_uuid)
|
||||
|
||||
d = ctx.to_dict()
|
||||
self.assertIn('auth_token', d)
|
||||
self.assertIn('user', d)
|
||||
self.assertIn('tenant', d)
|
||||
self.assertIn('domain', d)
|
||||
self.assertIn('user_domain', d)
|
||||
self.assertIn('project_domain', d)
|
||||
self.assertIn('is_admin', d)
|
||||
self.assertIn('read_only', d)
|
||||
self.assertIn('show_deleted', d)
|
||||
self.assertIn('request_id', d)
|
||||
self.assertIn('resource_uuid', d)
|
||||
self.assertIn('user_identity', d)
|
||||
self.assertIn('roles', d)
|
||||
self.assertNotIn('user_name', d)
|
||||
self.assertNotIn('project_name', d)
|
||||
self.assertNotIn('domain_name', d)
|
||||
self.assertNotIn('user_domain_name', d)
|
||||
self.assertNotIn('project_domain_name', d)
|
||||
|
||||
self.assertEqual(auth_token, d['auth_token'])
|
||||
self.assertEqual(project_id, d['tenant'])
|
||||
self.assertEqual(domain_id, d['domain'])
|
||||
self.assertEqual(user_domain_id, d['user_domain'])
|
||||
self.assertEqual(project_domain_id, d['project_domain'])
|
||||
self.assertEqual(is_admin, d['is_admin'])
|
||||
self.assertEqual(read_only, d['read_only'])
|
||||
self.assertEqual(show_deleted, d['show_deleted'])
|
||||
self.assertEqual(request_id, d['request_id'])
|
||||
self.assertEqual(resource_uuid, d['resource_uuid'])
|
||||
user_identity = "%s %s %s %s %s" % (user_id, project_id, domain_id,
|
||||
user_domain_id, project_domain_id)
|
||||
self.assertEqual(user_identity, d['user_identity'])
|
||||
self.assertEqual([], d['roles'])
|
||||
|
||||
d = ctx.get_logging_values()
|
||||
self.assertIn('auth_token', d)
|
||||
self.assertIn('user', d)
|
||||
self.assertIn('tenant', d)
|
||||
self.assertIn('domain', d)
|
||||
self.assertIn('user_domain', d)
|
||||
self.assertIn('project_domain', d)
|
||||
self.assertIn('is_admin', d)
|
||||
self.assertIn('read_only', d)
|
||||
self.assertIn('show_deleted', d)
|
||||
self.assertIn('request_id', d)
|
||||
self.assertIn('global_request_id', d)
|
||||
self.assertIn('resource_uuid', d)
|
||||
self.assertIn('user_identity', d)
|
||||
self.assertIn('roles', d)
|
||||
self.assertIn('user_name', d)
|
||||
self.assertIn('project_name', d)
|
||||
self.assertIn('domain_name', d)
|
||||
self.assertIn('user_domain_name', d)
|
||||
self.assertIn('project_domain_name', d)
|
||||
|
||||
self.assertEqual(user_name, d['user_name'])
|
||||
self.assertEqual(project_name, d['project_name'])
|
||||
self.assertEqual(domain_name, d['domain_name'])
|
||||
self.assertEqual(user_domain_name, d['user_domain_name'])
|
||||
self.assertEqual(project_domain_name, d['project_domain_name'])
|
||||
|
||||
def test_dict_empty_user_identity(self):
|
||||
ctx = context.RequestContext()
|
||||
d = ctx.to_dict()
|
||||
self.assertEqual("- - - - -", d['user_identity'])
|
||||
|
||||
def test_generate_request_id(self):
|
||||
id = context.generate_request_id()
|
||||
self.assertEqual("req-", id[:4])
|
||||
|
||||
def test_generate_request_id_unique(self):
|
||||
id1 = context.generate_request_id()
|
||||
id2 = context.generate_request_id()
|
||||
self.assertNotEqual(id1, id2)
|
||||
|
||||
def test_no_global_id_by_default(self):
|
||||
ctx = context.RequestContext()
|
||||
self.assertIsNone(ctx.global_request_id)
|
||||
d = ctx.to_dict()
|
||||
self.assertIsNone(d['global_request_id'])
|
||||
|
||||
def test_policy_dict(self):
|
||||
user = uuid.uuid4().hex
|
||||
user_domain = uuid.uuid4().hex
|
||||
tenant = uuid.uuid4().hex
|
||||
project_domain = uuid.uuid4().hex
|
||||
roles = [uuid.uuid4().hex, uuid.uuid4().hex, uuid.uuid4().hex]
|
||||
service_user_id = uuid.uuid4().hex
|
||||
service_project_id = uuid.uuid4().hex
|
||||
service_roles = [uuid.uuid4().hex, uuid.uuid4().hex, uuid.uuid4().hex]
|
||||
|
||||
# default is_admin_project is True
|
||||
ctx = context.RequestContext(user=user,
|
||||
user_domain=user_domain,
|
||||
tenant=tenant,
|
||||
project_domain=project_domain,
|
||||
roles=roles,
|
||||
service_user_id=service_user_id,
|
||||
service_project_id=service_project_id,
|
||||
service_roles=service_roles)
|
||||
|
||||
self.assertEqual({'user_id': user,
|
||||
'user_domain_id': user_domain,
|
||||
'project_id': tenant,
|
||||
'project_domain_id': project_domain,
|
||||
'roles': roles,
|
||||
'is_admin_project': True,
|
||||
'service_user_id': service_user_id,
|
||||
'service_user_domain_id': None,
|
||||
'service_project_id': service_project_id,
|
||||
'service_project_domain_id': None,
|
||||
'service_roles': service_roles},
|
||||
ctx.to_policy_values())
|
||||
|
||||
ctx = context.RequestContext(user=user,
|
||||
user_domain=user_domain,
|
||||
tenant=tenant,
|
||||
project_domain=project_domain,
|
||||
roles=roles,
|
||||
is_admin_project=False,
|
||||
service_user_id=service_user_id,
|
||||
service_project_id=service_project_id,
|
||||
service_roles=service_roles)
|
||||
|
||||
self.assertEqual({'user_id': user,
|
||||
'user_domain_id': user_domain,
|
||||
'project_id': tenant,
|
||||
'project_domain_id': project_domain,
|
||||
'roles': roles,
|
||||
'is_admin_project': False,
|
||||
'service_user_id': service_user_id,
|
||||
'service_user_domain_id': None,
|
||||
'service_project_id': service_project_id,
|
||||
'service_project_domain_id': None,
|
||||
'service_roles': service_roles},
|
||||
ctx.to_policy_values())
|
||||
|
||||
def test_positional_args(self):
|
||||
context.RequestContext('abc', 'def')
|
||||
|
||||
self.assertEqual(1, len(self.warnings.log))
|
||||
self.assertIn('__init__ takes at most 1 positional',
|
||||
str(self.warnings.log[0].message))
|
||||
|
||||
def test_policy_deprecations(self):
|
||||
user = uuid.uuid4().hex
|
||||
user_domain = uuid.uuid4().hex
|
||||
tenant = uuid.uuid4().hex
|
||||
project_domain = uuid.uuid4().hex
|
||||
roles = [uuid.uuid4().hex, uuid.uuid4().hex, uuid.uuid4().hex]
|
||||
|
||||
ctx = context.RequestContext(user=user,
|
||||
user_domain=user_domain,
|
||||
tenant=tenant,
|
||||
project_domain=project_domain,
|
||||
roles=roles)
|
||||
|
||||
policy = ctx.to_policy_values()
|
||||
key = uuid.uuid4().hex
|
||||
val = uuid.uuid4().hex
|
||||
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always")
|
||||
|
||||
# no warning triggered by adding key to dict
|
||||
policy[key] = val
|
||||
self.assertEqual(0, len(w))
|
||||
|
||||
# warning triggered by fetching key from dict
|
||||
self.assertIs(val, policy[key])
|
||||
self.assertEqual(1, len(w))
|
||||
self.assertIn(key, str(w[0].message))
|
||||
|
||||
def test_deprecated_args(self):
|
||||
user = uuid.uuid4().hex
|
||||
tenant = uuid.uuid4().hex
|
||||
domain = uuid.uuid4().hex
|
||||
user_domain = uuid.uuid4().hex
|
||||
project_domain = uuid.uuid4().hex
|
||||
|
||||
ctx = context.RequestContext(user=user,
|
||||
tenant=tenant,
|
||||
domain=domain,
|
||||
user_domain=user_domain,
|
||||
project_domain=project_domain)
|
||||
|
||||
self.assertEqual(0, len(self.warnings))
|
||||
self.assertEqual(user, ctx.user_id)
|
||||
self.assertEqual(tenant, ctx.project_id)
|
||||
self.assertEqual(domain, ctx.domain_id)
|
||||
self.assertEqual(user_domain, ctx.user_domain_id)
|
||||
self.assertEqual(project_domain, ctx.project_domain_id)
|
||||
|
||||
self.assertEqual(0, len(self.warnings))
|
||||
self.assertEqual(user, ctx.user)
|
||||
if context._log_deprecation_warnings:
|
||||
self.assertEqual(1, len(self.warnings))
|
||||
self.assertEqual(tenant, ctx.tenant)
|
||||
if context._log_deprecation_warnings:
|
||||
self.assertEqual(2, len(self.warnings))
|
||||
self.assertEqual(domain, ctx.domain)
|
||||
if context._log_deprecation_warnings:
|
||||
self.assertEqual(3, len(self.warnings))
|
||||
self.assertEqual(user_domain, ctx.user_domain)
|
||||
if context._log_deprecation_warnings:
|
||||
self.assertEqual(4, len(self.warnings))
|
||||
self.assertEqual(project_domain, ctx.project_domain)
|
||||
if context._log_deprecation_warnings:
|
||||
self.assertEqual(5, len(self.warnings))
|
@ -1,46 +0,0 @@
|
||||
# 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 oslotest import base as test_base
|
||||
|
||||
from oslo_context import context
|
||||
from oslo_context import fixture
|
||||
|
||||
|
||||
class ClearRequestContextTest(test_base.BaseTestCase):
|
||||
|
||||
# def setUp(self):
|
||||
# super(ContextTest, self).setUp()
|
||||
# self.useFixture(fixture.ClearRequestContext())
|
||||
|
||||
def test_store_current(self):
|
||||
# By default a new context is stored.
|
||||
ctx = context.RequestContext()
|
||||
self.assertIs(context.get_current(), ctx)
|
||||
fixture.ClearRequestContext()._remove_cached_context()
|
||||
self.assertIsNone(context.get_current())
|
||||
|
||||
def test_store_current_resets_correctly(self):
|
||||
# By default a new context is stored.
|
||||
ctx = context.RequestContext()
|
||||
|
||||
# the use of the fixture should put us in a reset state, not
|
||||
# doing so is a bug because when this fixture is consumed by
|
||||
# other test suites there is no guaruntee that all tests use
|
||||
# this fixture.
|
||||
self.useFixture(fixture.ClearRequestContext())
|
||||
self.assertIsNone(context.get_current())
|
||||
|
||||
ctx = context.RequestContext()
|
||||
self.assertIs(context.get_current(), ctx)
|
||||
fixture.ClearRequestContext()._remove_cached_context()
|
||||
self.assertIsNone(context.get_current())
|
@ -1,18 +0,0 @@
|
||||
# Copyright 2016 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 pbr.version
|
||||
|
||||
version_info = pbr.version.VersionInfo('oslo.context')
|
@ -1,3 +0,0 @@
|
||||
---
|
||||
other:
|
||||
- Switch to reno for managing release notes.
|
@ -1,282 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# 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.
|
||||
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'openstackdocstheme',
|
||||
'reno.sphinxext',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'oslo.context Release Notes'
|
||||
copyright = u'2016, oslo.context Developers'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
from oslo_context.version import version_info as oslo_context_version
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = oslo_context_version.version_string_with_vcs()
|
||||
# The short X.Y version.
|
||||
version = oslo_context_version.canonical_version_string()
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
# language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
# today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
# modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
# keep_warnings = False
|
||||
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'openstackdocs'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
# html_extra_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
html_last_updated_fmt = '%Y-%m-%d %H:%M'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'oslo.contextReleaseNotesDoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
# 'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'oslo.contextReleaseNotes.tex',
|
||||
u'oslo.context Release Notes Documentation',
|
||||
u'oslo.context Developers', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'oslo.contextReleaseNotes',
|
||||
u'oslo.context Release Notes Documentation',
|
||||
[u'oslo.context Developers'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'oslo.contextReleaseNotes',
|
||||
u'oslo.context Release Notes Documentation',
|
||||
u'oslo.context Developers', 'oslo.contextReleaseNotes',
|
||||
'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
# texinfo_no_detailmenu = False
|
||||
|
||||
# -- Options for Internationalization output ------------------------------
|
||||
locale_dirs = ['locale/']
|
||||
|
||||
# openstackdocstheme options
|
||||
repository_name = 'openstack/oslo.context'
|
||||
bug_project = 'oslo.context'
|
||||
bug_tag = ''
|
@ -1,10 +0,0 @@
|
||||
===========================
|
||||
oslo.context Release Notes
|
||||
===========================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
unreleased
|
||||
ocata
|
||||
newton
|
@ -1,6 +0,0 @@
|
||||
=============================
|
||||
Newton Series Release Notes
|
||||
=============================
|
||||
|
||||
.. release-notes::
|
||||
:branch: origin/stable/newton
|
@ -1,6 +0,0 @@
|
||||
===================================
|
||||
Ocata Series Release Notes
|
||||
===================================
|
||||
|
||||
.. release-notes::
|
||||
:branch: origin/stable/ocata
|
@ -1,5 +0,0 @@
|
||||
==========================
|
||||
Unreleased Release Notes
|
||||
==========================
|
||||
|
||||
.. release-notes::
|
@ -1,8 +0,0 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
|
||||
debtcollector>=1.2.0 # Apache-2.0
|
||||
positional>=1.1.1 # Apache-2.0
|
49
setup.cfg
49
setup.cfg
@ -1,49 +0,0 @@
|
||||
[metadata]
|
||||
name = oslo.context
|
||||
summary = Oslo Context library
|
||||
description-file =
|
||||
README.rst
|
||||
author = OpenStack
|
||||
author-email = openstack-dev@lists.openstack.org
|
||||
home-page = https://docs.openstack.org/oslo.context/latest/
|
||||
classifier =
|
||||
Environment :: OpenStack
|
||||
Intended Audience :: Information Technology
|
||||
Intended Audience :: System Administrators
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2
|
||||
Programming Language :: Python :: 2.7
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.5
|
||||
|
||||
[files]
|
||||
packages =
|
||||
oslo_context
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
build-dir = doc/build
|
||||
all_files = 1
|
||||
warning-is-error = 1
|
||||
|
||||
[upload_sphinx]
|
||||
upload-dir = doc/build/html
|
||||
|
||||
[compile_catalog]
|
||||
directory = oslo_context/locale
|
||||
domain = oslo_context
|
||||
|
||||
[update_catalog]
|
||||
domain = oslo_context
|
||||
output_dir = oslo_context/locale
|
||||
input_file = oslo_context/locale/oslo_context.pot
|
||||
|
||||
[extract_messages]
|
||||
keywords = _ gettext ngettext l_ lazy_gettext
|
||||
mapping_file = babel.cfg
|
||||
output_file = oslo_context/locale/oslo_context.pot
|
||||
|
||||
[wheel]
|
||||
universal = true
|
29
setup.py
29
setup.py
@ -1,29 +0,0 @@
|
||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
|
||||
import setuptools
|
||||
|
||||
# In python < 2.7.4, a lazy loading of package `pbr` will break
|
||||
# setuptools if some other modules registered functions in `atexit`.
|
||||
# solution from: http://bugs.python.org/issue15881#msg170215
|
||||
try:
|
||||
import multiprocessing # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['pbr>=2.0.0'],
|
||||
pbr=True)
|
@ -1,13 +0,0 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
||||
oslotest>=1.10.0 # Apache-2.0
|
||||
coverage!=4.4,>=4.0 # Apache-2.0
|
||||
|
||||
# These are needed for docs generation
|
||||
openstackdocstheme>=1.11.0 # Apache-2.0
|
||||
sphinx>=1.6.2 # BSD
|
||||
reno!=2.3.1,>=1.8.0 # Apache-2.0
|
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Client constraint file contains this client version pin that is in conflict
|
||||
# with installing the client from source. We should remove the version pin in
|
||||
# the constraints file before applying it for from-source installation.
|
||||
|
||||
CONSTRAINTS_FILE="$1"
|
||||
shift 1
|
||||
|
||||
set -e
|
||||
|
||||
# NOTE(tonyb): Place this in the tox enviroment's log dir so it will get
|
||||
# published to logs.openstack.org for easy debugging.
|
||||
localfile="$VIRTUAL_ENV/log/upper-constraints.txt"
|
||||
|
||||
if [[ "$CONSTRAINTS_FILE" != http* ]]; then
|
||||
CONSTRAINTS_FILE="file://$CONSTRAINTS_FILE"
|
||||
fi
|
||||
# NOTE(tonyb): need to add curl to bindep.txt if the project supports bindep
|
||||
curl "$CONSTRAINTS_FILE" --insecure --progress-bar --output "$localfile"
|
||||
|
||||
pip install -c"$localfile" openstack-requirements
|
||||
|
||||
# This is the main purpose of the script: Allow local installation of
|
||||
# the current repo. It is listed in constraints file and thus any
|
||||
# install will be constrained and we need to unconstrain it.
|
||||
edit-constraints "$localfile" -- "$CLIENT_NAME"
|
||||
|
||||
pip install -c"$localfile" -U "$@"
|
||||
exit $?
|
45
tox.ini
45
tox.ini
@ -1,45 +0,0 @@
|
||||
[tox]
|
||||
minversion = 2.0
|
||||
envlist = py35,py27,pypy,pep8
|
||||
|
||||
[testenv]
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
BRANCH_NAME=master
|
||||
CLIENT_NAME=oslo.context
|
||||
install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = python setup.py testr --slowest --testr-args='{posargs}'
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:docs]
|
||||
commands = python setup.py build_sphinx
|
||||
|
||||
[testenv:cover]
|
||||
commands = python setup.py test --coverage --coverage-package-name=oslo_context --testr-args='{posargs}'
|
||||
|
||||
[flake8]
|
||||
# E123, E125 skipped as they are invalid PEP-8.
|
||||
|
||||
show-source = True
|
||||
ignore = E123,E125
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||
|
||||
[hacking]
|
||||
import_exceptions =
|
||||
|
||||
[testenv:pip-missing-reqs]
|
||||
# do not install test-requirements as that will pollute the virtualenv for
|
||||
# determining missing packages
|
||||
# this also means that pip-missing-reqs must be installed separately, outside
|
||||
# of the requirements.txt files
|
||||
deps = pip_missing_reqs
|
||||
commands = pip-missing-reqs -d --ignore-module=oslo_context* --ignore-file=oslo_context/tests/* --ignore-file=tests/ oslo_context
|
||||
|
||||
[testenv:releasenotes]
|
||||
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
Loading…
x
Reference in New Issue
Block a user