././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.687795 oslo.context-4.1.0/0000775000175000017500000000000000000000000014176 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/.coveragerc0000664000175000017500000000016300000000000016317 0ustar00zuulzuul00000000000000[run] branch = True source = oslo_context omit = oslo_context/tests/* [report] ignore_errors = True precision = 2 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/.mailmap0000664000175000017500000000013100000000000015612 0ustar00zuulzuul00000000000000# Format is: # # ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/.pre-commit-config.yaml0000664000175000017500000000252300000000000020461 0ustar00zuulzuul00000000000000# We from the Oslo project decided to pin repos based on the # commit hash instead of the version tag to prevend arbitrary # code from running in developer's machines. To update to a # newer version, run `pre-commit autoupdate` and then replace # the newer versions with their commit hash. default_language_version: python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: 9136088a246768144165fcc3ecc3d31bb686920a # v3.3.0 hooks: - id: trailing-whitespace # Replaces or checks mixed line ending - id: mixed-line-ending args: ['--fix', 'lf'] exclude: '.*\.(svg)$' # Forbid files which have a UTF-8 byte-order marker - id: check-byte-order-marker # Checks that non-binary executables have a proper shebang - id: check-executables-have-shebangs # Check for files that contain merge conflict strings. - id: check-merge-conflict # Check for debugger imports and py37+ breakpoint() # calls in python source - id: debug-statements - id: check-yaml files: .*\.(yaml|yml)$ - repo: local hooks: - id: flake8 name: flake8 additional_dependencies: - hacking>=3.0.1,<3.1.0 language: python entry: flake8 files: '^.*\.py$' exclude: '^(doc|releasenotes|tools)/.*$' ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/.stestr.conf0000664000175000017500000000006500000000000016450 0ustar00zuulzuul00000000000000[DEFAULT] test_path=./oslo_context/tests top_path=./ ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/.zuul.yaml0000664000175000017500000000034000000000000016134 0ustar00zuulzuul00000000000000- project: templates: - check-requirements - lib-forward-testing-python3 - openstack-python3-yoga-jobs - periodic-stable-jobs - publish-openstack-docs-pti - release-notes-jobs-python3 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037368.0 oslo.context-4.1.0/AUTHORS0000664000175000017500000000503400000000000015250 0ustar00zuulzuul00000000000000Akihiro Motoki Alexander Gorodnev Andreas Jaeger Andrew Bogott Anusree Atsushi SAKAI Ben Nemec ChangBo Guo(gcb) Corey Bryant Cyril Roelandt Daniel Bengtsson Davanum Srinivas (dims) Davanum Srinivas Davanum Srinivas Dina Belova Doug Hellmann Eric Brown Flavio Percoco Flavio Percoco Ghanshyam Mann Hervé Beraud James Carey Jamie Lennox Jason Kölker Jay Pipes Jeremy Stanley Joe Gordon Joshua Harlow Joshua Harlow Juan Antonio Osorio Robles Kenneth Giusti Kirill Bespalov Lance Bragstad Michael Basnight Michael Johnson Moisés Guimarães de Medeiros Monty Taylor Morgan Fainberg OpenStack Release Bot Pierre Riteau Q.hongtao Ronald Bradford Sean Dague Sean McGinnis Stephen Finucane Steve Martinelli Thomas Herve Tony Breeds Tovin Seven Van Hung Pham Victor Sergeyev Victor Stinner Vu Cong Tuan Wei Li ZhijunWei ZhongShengping Zhongyue Luo caoyuan dengzhaosen jacky06 lingyongxu malei melissaml pengyuesheng ricolin wangqi wu.shiming yangyawei yanheven zhangboye ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/CONTRIBUTING.rst0000664000175000017500000000133300000000000016637 0ustar00zuulzuul00000000000000If you would like to contribute to the development of oslo's libraries, first you must take a look to this page: https://specs.openstack.org/openstack/oslo-specs/specs/policy/contributing.html 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 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037368.0 oslo.context-4.1.0/ChangeLog0000664000175000017500000002334100000000000015753 0ustar00zuulzuul00000000000000CHANGES ======= 4.1.0 ----- * Integrate mypy 4.0.0 ----- * Don't test with setuptools local distutils * Remove the deprecated argument tenant from RequestContext 3.4.0 ----- * Add Python3 yoga unit tests * Update master for stable/xena * Fix context from\_dict() for system\_scope 3.3.1 ----- 3.3.0 ----- * setup.cfg: Replace dashes with underscores * Ussuri+ is python3 only and update python to python3 * Fix formatting of release list * Move flake8 as a pre-commit local target * Add Python3 xena unit tests * Update master for stable/wallaby * Remove lower-constraints remnants * Drop use of deprecated collections classes 3.2.0 ----- * Switch to collections.abc.MutableMapping * Dropping lower constraints testing * Use TOX\_CONSTRAINTS\_FILE * Use py3 as the default runtime for tox * Add Python3 wallaby unit tests * Update master for stable/victoria * Adding pre-commit 3.1.1 ----- * Bump bandit version * drop mock from lower-constraints * Fix pygments style 3.1.0 ----- * Remove translation sections from setup.cfg * Fix hacking min version to 3.0.1 * Switch to newer openstackdocstheme and reno versions * Remove the unused coding style modules * Align contributing doc with oslo's policy * Bump default tox env from py37 to py38 * Add py38 package metadata * Add release notes links to doc index * Add Python3 victoria unit tests * Update master for stable/ussuri 3.0.2 ----- * Don't build universal wheel 3.0.1 ----- * Update hacking for Python3 * Filter out auth\_token\_info from logging values * trivial: Cleanup tox.ini * remove outdated header * reword releasenote for py27 support dropping 3.0.0 ----- * Drop python 2.7 support and testing * tox: Trivial cleanup * tox: Trivial cleanup * Bump the openstackdocstheme extension to 1.20 * gitignore: Hide reno cache files * tox: Stop using 'python setup.py test' * Switch to Ussuri jobs * tox: Keeping going with docs * Switch to Ussuri jobs * Update the constraints url * Update master for stable/train 2.23.0 ------ * Add Python 3 Train unit tests * Cap Bandit below 1.6.0 and update Sphinx requirement * Replace git.openstack.org URLs with opendev.org URLs * OpenDev Migration Patch * Dropping the py35 testing * Update master for stable/stein 2.22.1 ------ * add python 3.7 unit test job * Update hacking version * Use template for lower-constraints * Update mailinglist from dev to discuss 2.22.0 ------ * Implement domain-scope for context objects * Clean up .gitignore references to personal tools * Always build universal wheels * add lib-forward-testing-python3 test job * add python 3.6 unit test job * import zuul job settings from project-config * import zuul job settings from project-config * Update reno for stable/rocky * Switch to stestr * Add release notes link to README * fix tox python3 overrides 2.21.0 ------ * Implement system-scope * Remove stale pip-missing-reqs tox test * Trivial: Update pypi url to new url * Switch pep8 job to python 3 * add lower-constraints job * pypy not checked at gate * Updated from global requirements * Update links in README * Add -W for document build * Update reno for stable/queens * Updated from global requirements * Updated from global requirements * Updated from global requirements * Updated from global requirements 2.20.0 ------ * Updated from global requirements * Follow the new PTI for document build * Remove -U from pip install * Avoid tox\_install.sh for constraints support * add bandit to pep8 job * Remove setting of version/release from releasenotes 2.19.3 ------ * Ouput a placeholder instead of the auth\_token 2.19.2 ------ * Make from\_dict extensible 2.19.1 ------ * Output 'project' key in context's to\_dict function * Rename deprecated context params 2.19.0 ------ * Updated from global requirements 2.18.1 ------ * Update the documentation link for doc migration * Revert "Postpone deprecation warnings to Pike" 2.18.0 ------ * Updated from global requirements * Remove use of positional decorator * Update reno for stable/pike * Updated from global requirements 2.17.0 ------ * Fix URLs according to document migration * Cleanup document formatting * rearrange the documentation to fit into the new standard layout 2.16.0 ------ * Switch from oslosphinx to openstackdocstheme * Updated from global requirements 2.15.0 ------ * Optimize the link address * Remove pbr warnerrors in favor of sphinx check * Updated from global requirements 2.14.0 ------ * Provide unified calling interface for global\_id * Add global\_request\_id to context * Updated from global requirements * Updated from global requirements * Updated from global requirements 2.13.0 ------ * Updated from global requirements * [Fix gate]Update test requirement * Updated from global requirements * pbr.version.VersionInfo needs package name (oslo.xyz and not oslo\_xyz) * Postpone deprecation warnings to Pike * Update reno for stable/ocata 2.12.0 ------ * Updated from global requirements * Remove references to Python 3.4 * Add Constraints support * Show team and repo badges on README * Add the service token details to context * Reformat the Context.\_\_init\_\_ arguments * Move existing attributes to \_id suffixed attributes 2.11.0 ------ * Updated from global requirements * Revert "Fix X-User and X-Tenant deprecated headers in from\_environ" * Updated from global requirements * Updated from global requirements * Changed the home-page link 2.10.0 ------ * Enable release notes translation * Updated from global requirements * Provide a way to deprecate policy values * Update reno for stable/newton * Fix typos * Fix X-User and X-Tenant deprecated headers in from\_environ 2.9.0 ----- * Updated from global requirements 2.8.0 ----- * Delete H803 in flake8 ignore list * Fix parameters of assertEqual are misplaced * Manually specify from\_dict parameters 2.7.0 ----- * Add Python 3.5 classifier and venv * Emit deprecation warnings when positional args passed 2.6.0 ----- * Allow deprecated X-Tenant-Name in from\_environ * Handle openstack.request\_id in from\_environ * Add is\_admin\_project to context * Updated from global requirements 2.5.0 ----- * Add reno for releasenotes management * Add oslo.context name attributes matching ids 2.4.0 ----- * Trivial: ignore openstack/common in flake8 exclude list * Strip roles in from\_environ * Allow deprecated headers in from\_environ 2.3.0 ----- * Drop babel as requirement since its not used * Updated from global requirements * Ensure to\_dict() supports unicode 2.2.0 ----- * Standardize an oslo.policy credentials dictionary * Revert "Add common oslo.log format parameters" * Add roles to context 2.1.0 ----- * Agnostic approach to construct context from\_dict * Add common oslo.log format parameters 2.0.0 ----- * Improve Context docs with example syntax * Define method for oslo.log context parameters * Add additional unit tests * Fix request\_id type on Python 3: use text (Unicode) * Updated from global requirements * Provide a helper to load a context from environment 1.0.1 ----- * Revert "Add properties for id attributes" * Add properties for id attributes * Trival: Remove 'MANIFEST.in' 1.0.0 ----- * Updated from global requirements * Remove python 2.6 classifier * Remove python 2.6 and cleanup tox.ini 0.9.0 ----- * Remove reference to undefined attributes 0.8.0 ----- * Fix coverage configuration and execution 0.7.0 ----- * Add shields.io version/downloads links/badges into README.rst * Change ignore-errors to ignore\_errors * Updated from global requirements 0.6.0 ----- * Updated from global requirements * Updated from global requirements * Updated from global requirements 0.5.0 ----- * Updated from global requirements * Updated from global requirements * Add tox target to find missing requirements * Updated from global requirements * Updated from global requirements 0.4.0 ----- * Remove support for Python 3.3 * Do not sync run\_cross\_tests.sh * Updated from global requirements 0.3.0 ----- * Uncap library requirements for liberty * Standardize setup.cfg summary for oslo libs * Update to latest hacking * Updated from global requirements * fix bug tracker link 0.2.0 ----- * ensure we reset contexts when fixture is used * Activate pep8 check that \_ is imported 0.1.0 ----- * Workflow documentation is now in infra-manual * Documentation cleanup * Add ClearRequestContext fixture * Cache the current context for the thread * Add docstring to get\_admin\_context() * Change instance\_uuid to resource\_uuid * Better information in the README * Generate better documentation for the module * Move out of the oslo namespace package * get test to actually run * fix links and requirements to latest versions * Make the unit test run properly - fix import * exported from oslo-incubator by graduate.sh * Add a RequestContext.from\_dict method * Use oslotest instead of common test module * Python 3: enable tests/unit/middleware/test\_request\_id.py * Add model\_query() to db.sqlalchemy.utils module * Adding domain to context and log * Remove vim header * Remove uuidutils imports in oslo modules * Revert "Removes generate\_uuid from uuidutils" * Removes generate\_uuid from uuidutils * Adding instance\_uuid to context and log * Replace using tests.utils with openstack.common.test * Fix bad default for show\_deleted * Enable hacking H404 test * Replaces the standard uuid with common in the context module * Fix Copyright Headers - Rename LLC to Foundation * Fix inconsistency with auth\_tok/auth\_token * Replace direct use of testtools BaseTestCase * Use testtools as test base class * Move get\_context\_from\_function\_and\_args() to context.py * Added dictify() and uuids to the common request context * add context 'tests' * make the skeleton project a template * reog from import merge * Add some more generic middleware, request context, utils, and versioning. Add basic template for server binary * Initial skeleton project ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/HACKING.rst0000664000175000017500000000022200000000000015770 0ustar00zuulzuul00000000000000oslo.context Style Commandments =============================== Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/ ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/LICENSE0000664000175000017500000002363700000000000015216 0ustar00zuulzuul00000000000000 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. ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.687795 oslo.context-4.1.0/PKG-INFO0000664000175000017500000000423000000000000015272 0ustar00zuulzuul00000000000000Metadata-Version: 1.2 Name: oslo.context Version: 4.1.0 Summary: Oslo Context library Home-page: https://docs.openstack.org/oslo.context/latest/ Author: OpenStack Author-email: openstack-discuss@lists.openstack.org License: UNKNOWN Description: ==================== 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://opendev.org/openstack/oslo.context * Bugs: https://bugs.launchpad.net/oslo.context * Release notes: https://docs.openstack.org/releasenotes/oslo.context/ Team and repository tags ======================== .. image:: https://governance.openstack.org/tc/badges/oslo.context.svg :target: https://governance.openstack.org/tc/reference/tags/index.html .. Change things from this point on .. image:: https://img.shields.io/pypi/v/oslo.context.svg :target: https://pypi.org/project/oslo.context/ :alt: Latest Version .. image:: https://img.shields.io/pypi/dm/oslo.context.svg :target: https://pypi.org/project/oslo.context/ :alt: Downloads Platform: UNKNOWN Classifier: Environment :: OpenStack Classifier: Intended Audience :: Information Technology Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: Implementation :: CPython Requires-Python: >=3.6 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/README.rst0000664000175000017500000000202500000000000015664 0ustar00zuulzuul00000000000000==================== 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://opendev.org/openstack/oslo.context * Bugs: https://bugs.launchpad.net/oslo.context * Release notes: https://docs.openstack.org/releasenotes/oslo.context/ Team and repository tags ======================== .. image:: https://governance.openstack.org/tc/badges/oslo.context.svg :target: https://governance.openstack.org/tc/reference/tags/index.html .. Change things from this point on .. image:: https://img.shields.io/pypi/v/oslo.context.svg :target: https://pypi.org/project/oslo.context/ :alt: Latest Version .. image:: https://img.shields.io/pypi/dm/oslo.context.svg :target: https://pypi.org/project/oslo.context/ :alt: Downloads ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.675795 oslo.context-4.1.0/doc/0000775000175000017500000000000000000000000014743 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/requirements.txt0000664000175000017500000000056600000000000020236 0ustar00zuulzuul00000000000000# 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. # These are needed for docs generation openstackdocstheme>=2.2.0 # Apache-2.0 sphinx>=2.0.0,!=2.1.0 # BSD reno>=3.1.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.675795 oslo.context-4.1.0/doc/source/0000775000175000017500000000000000000000000016243 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/conf.py0000664000175000017500000000467600000000000017557 0ustar00zuulzuul00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020 Red Hat, Inc. # # 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', '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 = 'native' # -- 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' # 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 openstackdocs_repo_name = 'openstack/oslo.context' openstackdocs_bug_project = 'oslo.context' openstackdocs_bug_tag = '' ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.675795 oslo.context-4.1.0/doc/source/contributor/0000775000175000017500000000000000000000000020615 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/contributor/index.rst0000664000175000017500000000012400000000000022453 0ustar00zuulzuul00000000000000============== Contributing ============== .. include:: ../../../CONTRIBUTING.rst ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/index.rst0000664000175000017500000000067400000000000020113 0ustar00zuulzuul00000000000000.. include:: ../../README.rst Contents ======== .. toctree:: :maxdepth: 2 install/index user/index contributor/index Code Documentation ================== .. toctree:: :maxdepth: 1 reference/index Release Notes ============= Read also the `oslo.context Release Notes `_. Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.675795 oslo.context-4.1.0/doc/source/install/0000775000175000017500000000000000000000000017711 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/install/index.rst0000664000175000017500000000013600000000000021552 0ustar00zuulzuul00000000000000============ Installation ============ At the command line:: $ pip install oslo.context ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.675795 oslo.context-4.1.0/doc/source/reference/0000775000175000017500000000000000000000000020201 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/reference/context.rst0000664000175000017500000000024700000000000022422 0ustar00zuulzuul00000000000000The :mod:`oslo_context.context` Module ====================================== .. automodule:: oslo_context.context :members: :undoc-members: :show-inheritance: ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/reference/fixture.rst0000664000175000017500000000024700000000000022424 0ustar00zuulzuul00000000000000The :mod:`oslo_context.fixture` Module ====================================== .. automodule:: oslo_context.fixture :members: :undoc-members: :show-inheritance: ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/reference/index.rst0000664000175000017500000000014700000000000022044 0ustar00zuulzuul00000000000000============= API reference ============= .. toctree:: :maxdepth: 1 context.rst fixture.rst ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.675795 oslo.context-4.1.0/doc/source/user/0000775000175000017500000000000000000000000017221 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.679795 oslo.context-4.1.0/doc/source/user/examples/0000775000175000017500000000000000000000000021037 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/user/examples/usage.py0000664000175000017500000000310100000000000022510 0ustar00zuulzuul00000000000000#!/usr/bin/env python3 # # 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) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/user/examples/usage_simple.py0000664000175000017500000000223300000000000024066 0ustar00zuulzuul00000000000000#!/usr/bin/env python3 # # 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") ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/user/examples/usage_user_identity.py0000664000175000017500000000274300000000000025472 0ustar00zuulzuul00000000000000#!/usr/bin/env python3 # # 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/oslo.context/latest/user/index.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") ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/user/examples.rst0000664000175000017500000000132100000000000021566 0ustar00zuulzuul00000000000000========== 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://opendev.org/openstack/oslo.context/src/branch/master/doc/source/user/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: ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/user/history.rst0000664000175000017500000000004000000000000021446 0ustar00zuulzuul00000000000000.. include:: ../../../ChangeLog ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/user/index.rst0000664000175000017500000000033700000000000021065 0ustar00zuulzuul00000000000000================== Using oslo.context ================== .. toctree:: :maxdepth: 2 usage examples .. history contains a lot of sections, toctree with maxdepth 1 is used. .. toctree:: :maxdepth: 1 history ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/doc/source/user/usage.rst0000664000175000017500000001066600000000000021070 0ustar00zuulzuul00000000000000======= 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://opendev.org/openstack/nova/src/branch/master/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 ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.679795 oslo.context-4.1.0/oslo.context.egg-info/0000775000175000017500000000000000000000000020327 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037368.0 oslo.context-4.1.0/oslo.context.egg-info/PKG-INFO0000664000175000017500000000423000000000000021423 0ustar00zuulzuul00000000000000Metadata-Version: 1.2 Name: oslo.context Version: 4.1.0 Summary: Oslo Context library Home-page: https://docs.openstack.org/oslo.context/latest/ Author: OpenStack Author-email: openstack-discuss@lists.openstack.org License: UNKNOWN Description: ==================== 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://opendev.org/openstack/oslo.context * Bugs: https://bugs.launchpad.net/oslo.context * Release notes: https://docs.openstack.org/releasenotes/oslo.context/ Team and repository tags ======================== .. image:: https://governance.openstack.org/tc/badges/oslo.context.svg :target: https://governance.openstack.org/tc/reference/tags/index.html .. Change things from this point on .. image:: https://img.shields.io/pypi/v/oslo.context.svg :target: https://pypi.org/project/oslo.context/ :alt: Latest Version .. image:: https://img.shields.io/pypi/dm/oslo.context.svg :target: https://pypi.org/project/oslo.context/ :alt: Downloads Platform: UNKNOWN Classifier: Environment :: OpenStack Classifier: Intended Audience :: Information Technology Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: Implementation :: CPython Requires-Python: >=3.6 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037368.0 oslo.context-4.1.0/oslo.context.egg-info/SOURCES.txt0000664000175000017500000000360300000000000022215 0ustar00zuulzuul00000000000000.coveragerc .mailmap .pre-commit-config.yaml .stestr.conf .zuul.yaml AUTHORS CONTRIBUTING.rst ChangeLog HACKING.rst LICENSE README.rst requirements.txt setup.cfg setup.py test-requirements.txt tox.ini doc/requirements.txt doc/source/conf.py doc/source/index.rst doc/source/contributor/index.rst doc/source/install/index.rst doc/source/reference/context.rst doc/source/reference/fixture.rst doc/source/reference/index.rst doc/source/user/examples.rst doc/source/user/history.rst doc/source/user/index.rst doc/source/user/usage.rst doc/source/user/examples/usage.py doc/source/user/examples/usage_simple.py doc/source/user/examples/usage_user_identity.py oslo.context.egg-info/PKG-INFO oslo.context.egg-info/SOURCES.txt oslo.context.egg-info/dependency_links.txt oslo.context.egg-info/not-zip-safe oslo.context.egg-info/pbr.json oslo.context.egg-info/requires.txt oslo.context.egg-info/top_level.txt oslo_context/__init__.py oslo_context/context.py oslo_context/fixture.py oslo_context/version.py oslo_context/tests/__init__.py oslo_context/tests/test_context.py oslo_context/tests/test_fixture.py releasenotes/notes/Fix-system-scope-from_dict-29615af90723ba4d.yaml releasenotes/notes/add_reno-3b4ae0789e9c45b4.yaml releasenotes/notes/dont-leak-auth-token-fb7075316cf87b7c.yaml releasenotes/notes/drop-python27-support-b421329839e69d41.yaml releasenotes/notes/remove_deprecated_args_tenant-77724de1422f46d9.yaml releasenotes/source/conf.py releasenotes/source/index.rst releasenotes/source/newton.rst releasenotes/source/ocata.rst releasenotes/source/pike.rst releasenotes/source/queens.rst releasenotes/source/rocky.rst releasenotes/source/stein.rst releasenotes/source/train.rst releasenotes/source/unreleased.rst releasenotes/source/ussuri.rst releasenotes/source/victoria.rst releasenotes/source/wallaby.rst releasenotes/source/xena.rst releasenotes/source/_static/.placeholder releasenotes/source/_templates/.placeholder././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037368.0 oslo.context-4.1.0/oslo.context.egg-info/dependency_links.txt0000664000175000017500000000000100000000000024375 0ustar00zuulzuul00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037368.0 oslo.context-4.1.0/oslo.context.egg-info/not-zip-safe0000664000175000017500000000000100000000000022555 0ustar00zuulzuul00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037368.0 oslo.context-4.1.0/oslo.context.egg-info/pbr.json0000664000175000017500000000005600000000000022006 0ustar00zuulzuul00000000000000{"git_version": "3400cc2", "is_release": true}././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037368.0 oslo.context-4.1.0/oslo.context.egg-info/requires.txt0000664000175000017500000000005000000000000022722 0ustar00zuulzuul00000000000000debtcollector>=1.2.0 pbr!=2.1.0,>=2.0.0 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037368.0 oslo.context-4.1.0/oslo.context.egg-info/top_level.txt0000664000175000017500000000001500000000000023055 0ustar00zuulzuul00000000000000oslo_context ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.679795 oslo.context-4.1.0/oslo_context/0000775000175000017500000000000000000000000016716 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/oslo_context/__init__.py0000664000175000017500000000000000000000000021015 0ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/oslo_context/context.py0000664000175000017500000005105600000000000020763 0ustar00zuulzuul00000000000000# 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.abc import functools import itertools import threading import typing as ty import uuid import warnings import debtcollector from debtcollector import renames _request_store = threading.local() # These arguments will be passed to a new context from the first available # header to support backwards compatibility. _ENVIRON_HEADERS: ty.Dict[str, ty.List[str]] = { 'auth_token': ['HTTP_X_AUTH_TOKEN', 'HTTP_X_STORAGE_TOKEN'], 'user_id': ['HTTP_X_USER_ID', 'HTTP_X_USER'], 'project_id': ['HTTP_X_PROJECT_ID', 'HTTP_X_TENANT_ID', 'HTTP_X_TENANT'], 'domain_id': ['HTTP_X_DOMAIN_ID'], 'system_scope': ['HTTP_OPENSTACK_SYSTEM_SCOPE'], 'user_domain_id': ['HTTP_X_USER_DOMAIN_ID'], 'project_domain_id': ['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() -> str: """Generate a unique request id.""" return 'req-%s' % uuid.uuid4() class _DeprecatedPolicyValues(collections.abc.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: ty.Dict[str, ty.Any]): self._data = data self._deprecated: ty.Dict[str, ty.Any] = {} def __getitem__(self, k: str) -> ty.Any: 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: str, v: ty.Any) -> None: self._deprecated[k] = v def __delitem__(self, k: str) -> None: del self._deprecated[k] def __iter__(self) -> ty.Iterator[ty.Any]: return iter(self._dict) def __len__(self) -> int: return len(self._dict) def __str__(self) -> str: return self._dict.__str__() def __repr__(self) -> str: return self._dict.__repr__() @property def _dict(self) -> ty.Dict[str, ty.Any]: d = self._deprecated.copy() d.update(self._data) return d # TODO(stephenfin): Remove this in the 4.0 release def _moved_msg(new_name: str, old_name: ty.Optional[str]) -> None: 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} debtcollector.deprecate(deprecated_msg, version='2.6', removal_version='3.0', stacklevel=5) def _moved_property( new_name: str, old_name: ty.Optional[str] = None, target: ty.Optional[str] = None, ) -> ty.Any: def getter(self: ty.Any) -> ty.Any: _moved_msg(new_name, old_name) return getattr(self, target or new_name) def setter(self: ty.Any, value: str) -> None: _moved_msg(new_name, old_name) setattr(self, target or new_name, value) def deleter(self: ty.Any) -> None: _moved_msg(new_name, old_name) delattr(self, target or new_name) return property(getter, setter, deleter) _renamed_kwarg = functools.partial(renames.renamed_kwarg, version='2.18', removal_version='3.0', replace=True) 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 = '{user} {project_id} {domain} {user_domain} {p_domain}' # Can be overridden in subclasses to specify extra keys that should be # read when constructing a context using from_dict. FROM_DICT_EXTRA_KEYS: ty.List[str] = [] @_renamed_kwarg('user', 'user_id') @_renamed_kwarg('domain', 'domain_id') @_renamed_kwarg('user_domain', 'user_domain_id') @_renamed_kwarg('project_domain', 'project_domain_id') def __init__( self, auth_token: ty.Optional[str] = None, user_id: ty.Optional[str] = None, project_id: ty.Optional[str] = None, domain_id: ty.Optional[str] = None, user_domain_id: ty.Optional[str] = None, project_domain_id: ty.Optional[str] = None, is_admin: bool = False, read_only: bool = False, show_deleted: bool = False, request_id: ty.Optional[str] = None, resource_uuid: ty.Optional[str] = None, overwrite: bool = True, roles: ty.Optional[ty.List[str]] = None, user_name: ty.Optional[str] = None, project_name: ty.Optional[str] = None, domain_name: ty.Optional[str] = None, user_domain_name: ty.Optional[str] = None, project_domain_name: ty.Optional[str] = None, is_admin_project: bool = True, service_token: ty.Optional[str] = None, service_user_id: ty.Optional[str] = None, service_user_name: ty.Optional[str] = None, service_user_domain_id: ty.Optional[str] = None, service_user_domain_name: ty.Optional[str] = None, service_project_id: ty.Optional[str] = None, service_project_name: ty.Optional[str] = None, service_project_domain_id: ty.Optional[str] = None, service_project_domain_name: ty.Optional[str] = None, service_roles: ty.Optional[ty.List[str]] = None, global_request_id: ty.Optional[str] = None, system_scope: ty.Optional[str] = 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 :param system_scope: The system scope of a token. The value ``all`` represents the entire deployment system. A service ID represents a specific service within the deployment system. :type system_scope: string """ # setting to private variables to avoid triggering subclass properties self._user_id = user_id self._project_id = project_id self._domain_id = domain_id self._user_domain_id = user_domain_id self._project_domain_id = project_domain_id self.auth_token = auth_token self.user_name = user_name self.project_name = project_name self.domain_name = domain_name self.system_scope = system_scope 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 etc point # to the same private variable rather than each other. 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) -> None: """Store the context in the current thread.""" _request_store.context = self def to_policy_values(self) -> _DeprecatedPolicyValues: """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, 'system_scope': self.system_scope, 'domain_id': self.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) -> ty.Dict[str, ty.Any]: """Return a dictionary of context attributes.""" user_idt = self.user_idt_format.format( user=self.user_id or '-', project_id=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, 'project_id': self.project_id, 'system_scope': self.system_scope, 'project': 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) -> ty.Dict[str, ty.Any]: """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()) if self.auth_token: # NOTE(jaosorior): Gotta obfuscate the token since this dict is # meant for logging and we shouldn't leak it. values['auth_token'] = '***' # nosec else: values['auth_token'] = None # NOTE(bnemec: auth_token_info isn't defined in oslo.context, but it's # a common pattern in project context subclasses so we handle it here. # It largely contains things that we don't want logged, like the token # itself (which needs to be removed for security) and the catalog # (which needs to be removed because it bloats the logs terribly). values.pop('auth_token_info', None) return values @property def global_id(self) -> str: """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 @_renamed_kwarg('user', 'user_id') @_renamed_kwarg('domain', 'domain_id') @_renamed_kwarg('user_domain', 'user_domain_id') @_renamed_kwarg('project_domain', 'project_domain_id') def from_dict( cls, values: ty.Dict[str, ty.Any], **kwargs: ty.Any, ) -> 'RequestContext': """Construct a context object from a provided dictionary.""" kwargs.setdefault('auth_token', values.get('auth_token')) kwargs.setdefault('user_id', values.get('user')) kwargs.setdefault('project_id', values.get('project_id')) kwargs.setdefault('domain_id', values.get('domain')) kwargs.setdefault('user_domain_id', values.get('user_domain')) kwargs.setdefault('project_domain_id', 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)) kwargs.setdefault('system_scope', values.get('system_scope')) for key in cls.FROM_DICT_EXTRA_KEYS: kwargs.setdefault(key, values.get(key)) return cls(**kwargs) @classmethod @_renamed_kwarg('user', 'user_id') @_renamed_kwarg('domain', 'domain_id') @_renamed_kwarg('user_domain', 'user_domain_id') @_renamed_kwarg('project_domain', 'project_domain_id') def from_environ( cls, environ: ty.Dict[str, ty.Any], **kwargs: ty.Any, ) -> 'RequestContext': """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: bool = False) -> RequestContext: """Create an administrator context.""" context = RequestContext(None, project_id=None, is_admin=True, show_deleted=show_deleted, overwrite=False) return context def get_context_from_function_and_args( function: ty.Callable, args: ty.List[ty.Any], kwargs: ty.Dict[str, ty.Any], ) -> ty.Optional[RequestContext]: """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: RequestContext) -> bool: """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() -> ty.Optional[RequestContext]: """Return this thread's current context If no context is set, returns None """ return getattr(_request_store, 'context', None) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/oslo_context/fixture.py0000664000175000017500000000276100000000000020764 0ustar00zuulzuul00000000000000# 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) -> None: 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) -> None: """Remove the thread-local context stored in the module.""" try: del context._request_store.context except AttributeError: pass ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.683795 oslo.context-4.1.0/oslo_context/tests/0000775000175000017500000000000000000000000020060 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/oslo_context/tests/__init__.py0000664000175000017500000000000000000000000022157 0ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/oslo_context/tests/test_context.py0000664000175000017500000007355600000000000023175 0ustar00zuulzuul00000000000000# -*- 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 TestContext(context.RequestContext): """A test context with additional members This is representative of how at least some of our consumers use the RequestContext class in their projects. """ FROM_DICT_EXTRA_KEYS = ['auth_token_info'] def __init__(self, auth_token_info=None, **kwargs): super(TestContext, self).__init__(**kwargs) self.auth_token_info = auth_token_info def to_dict(self): d = super(TestContext, self).to_dict() d['auth_token_info'] = self.auth_token_info return d 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", "project_id": "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", "system_scope": "all" } ctx = context.RequestContext.from_dict(dct) self.assertEqual(dct['auth_token'], ctx.auth_token) self.assertEqual(dct['user'], ctx.user_id) self.assertEqual(dct['project_id'], 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) self.assertEqual(dct['system_scope'], ctx.system_scope) 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.project_id) self.assertFalse(ctx.is_admin) self.assertTrue(ctx.read_only) def test_from_dict_extended(self): initial = TestContext(auth_token_info='foo') dct = initial.to_dict() final = TestContext.from_dict(dct) self.assertEqual('foo', final.auth_token_info) self.assertEqual(dct, final.to_dict()) 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) domain_name = uuid.uuid4().hex domain_id = generate_id(domain_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_DOMAIN_ID': domain_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(domain_id, ctx.domain_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.project_id) 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, project_id=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, project_id=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('project_id', 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['project_id']) 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.assertEqual(d['auth_token'], '***') self.assertIn('user', d) self.assertIn('project_id', 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_auth_token_info_removed(self): ctx = TestContext(auth_token_info={'auth_token': 'topsecret'}) d = ctx.get_logging_values() self.assertNotIn('auth_token_info', d) 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 project_id = 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, project_id=project_id, 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, 'system_scope': None, 'domain_id': None, 'project_id': project_id, '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()) # NOTE(lbragstad): This string has special meaning in that the value # ``all`` represents the entire deployment system. system_all = 'all' ctx = context.RequestContext(user=user, user_domain=user_domain, system_scope=system_all, 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, 'system_scope': system_all, 'domain_id': None, 'project_id': None, 'project_domain_id': None, '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()) # context representing a domain-scoped token. domain_id = uuid.uuid4().hex ctx = context.RequestContext(user=user, user_domain=user_domain, domain_id=domain_id, 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, 'system_scope': None, 'domain_id': domain_id, 'project_id': None, 'project_domain_id': None, '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, project_id=project_id, 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, 'system_scope': None, 'domain_id': None, 'project_id': project_id, '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_policy_deprecations(self): user = uuid.uuid4().hex user_domain = uuid.uuid4().hex project_id = 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, project_id=project_id, 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_id = uuid.uuid4().hex project_id = uuid.uuid4().hex domain_id = uuid.uuid4().hex user_domain_id = uuid.uuid4().hex project_domain_id = uuid.uuid4().hex ctx = context.RequestContext(user_id=user_id, project_id=project_id, domain_id=domain_id, user_domain_id=user_domain_id, project_domain_id=project_domain_id) self.assertEqual(0, len(self.warnings)) self.assertEqual(user_id, ctx.user_id) self.assertEqual(project_id, ctx.project_id) self.assertEqual(domain_id, ctx.domain_id) self.assertEqual(user_domain_id, ctx.user_domain_id) self.assertEqual(project_domain_id, ctx.project_domain_id) self.assertEqual(0, len(self.warnings)) self.assertEqual(user_id, ctx.user) self.assertEqual(1, len(self.warnings)) self.assertEqual(domain_id, ctx.domain) self.assertEqual(2, len(self.warnings)) self.assertEqual(user_domain_id, ctx.user_domain) self.assertEqual(3, len(self.warnings)) self.assertEqual(project_domain_id, ctx.project_domain) self.assertEqual(4, len(self.warnings)) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/oslo_context/tests/test_fixture.py0000664000175000017500000000343100000000000023160 0ustar00zuulzuul00000000000000# 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()) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/oslo_context/version.py0000664000175000017500000000126300000000000020757 0ustar00zuulzuul00000000000000# 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') ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.667795 oslo.context-4.1.0/releasenotes/0000775000175000017500000000000000000000000016667 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.683795 oslo.context-4.1.0/releasenotes/notes/0000775000175000017500000000000000000000000020017 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/notes/Fix-system-scope-from_dict-29615af90723ba4d.yaml0000664000175000017500000000012000000000000030152 0ustar00zuulzuul00000000000000--- fixes: - | Fixes context from_dict() to properly handle system_scope. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/notes/add_reno-3b4ae0789e9c45b4.yaml0000664000175000017500000000007100000000000024700 0ustar00zuulzuul00000000000000--- other: - Switch to reno for managing release notes.././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/notes/dont-leak-auth-token-fb7075316cf87b7c.yaml0000664000175000017500000000041200000000000027061 0ustar00zuulzuul00000000000000--- security: - | The ``get_logging_values`` function no longer outputs the auth_token, but instead leaves it as ``***`` instead. As the name suggests, this function is meant for logging, and letting the auth_token there might leak sensitive data. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/notes/drop-python27-support-b421329839e69d41.yaml0000664000175000017500000000017700000000000027063 0ustar00zuulzuul00000000000000--- upgrade: - | Support for Python 2.7 has been dropped. The minimum version of Python now supported is Python 3.6. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/notes/remove_deprecated_args_tenant-77724de1422f46d9.yaml0000664000175000017500000000017300000000000031035 0ustar00zuulzuul00000000000000--- upgrade: - | The ``tenant`` argument of ``RequestContext`` that was deprecated for long time is now removed. ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.687795 oslo.context-4.1.0/releasenotes/source/0000775000175000017500000000000000000000000020167 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.687795 oslo.context-4.1.0/releasenotes/source/_static/0000775000175000017500000000000000000000000021615 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/_static/.placeholder0000664000175000017500000000000000000000000024066 0ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.687795 oslo.context-4.1.0/releasenotes/source/_templates/0000775000175000017500000000000000000000000022324 5ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/_templates/.placeholder0000664000175000017500000000000000000000000024575 0ustar00zuulzuul00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/conf.py0000664000175000017500000002070300000000000021470 0ustar00zuulzuul00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020 Red Hat, Inc. # # 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. copyright = u'2016, oslo.context Developers' # Release notes do not need a version in the title, they span # multiple versions. # The full version, including alpha/beta/rc tags. release = '' # The short X.Y version. version = '' # 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 = 'native' # 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 # " v 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 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 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 --------------------------------------------- # 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 openstackdocs_repo_name = 'openstack/oslo.context' openstackdocs_bug_project = 'oslo.context' openstackdocs_bug_tag = '' ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/index.rst0000664000175000017500000000035200000000000022030 0ustar00zuulzuul00000000000000=========================== oslo.context Release Notes =========================== .. toctree:: :maxdepth: 1 unreleased xena wallaby victoria ussuri train stein rocky queens pike ocata newton ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/newton.rst0000664000175000017500000000021600000000000022232 0ustar00zuulzuul00000000000000============================= Newton Series Release Notes ============================= .. release-notes:: :branch: origin/stable/newton ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/ocata.rst0000664000175000017500000000023000000000000022003 0ustar00zuulzuul00000000000000=================================== Ocata Series Release Notes =================================== .. release-notes:: :branch: origin/stable/ocata ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/pike.rst0000664000175000017500000000021700000000000021651 0ustar00zuulzuul00000000000000=================================== Pike Series Release Notes =================================== .. release-notes:: :branch: stable/pike ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/queens.rst0000664000175000017500000000022300000000000022216 0ustar00zuulzuul00000000000000=================================== Queens Series Release Notes =================================== .. release-notes:: :branch: stable/queens ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/rocky.rst0000664000175000017500000000022100000000000022043 0ustar00zuulzuul00000000000000=================================== Rocky Series Release Notes =================================== .. release-notes:: :branch: stable/rocky ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/stein.rst0000664000175000017500000000022100000000000022036 0ustar00zuulzuul00000000000000=================================== Stein Series Release Notes =================================== .. release-notes:: :branch: stable/stein ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/train.rst0000664000175000017500000000017600000000000022042 0ustar00zuulzuul00000000000000========================== Train Series Release Notes ========================== .. release-notes:: :branch: stable/train ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/unreleased.rst0000664000175000017500000000014400000000000023047 0ustar00zuulzuul00000000000000========================== Unreleased Release Notes ========================== .. release-notes:: ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/ussuri.rst0000664000175000017500000000020200000000000022245 0ustar00zuulzuul00000000000000=========================== Ussuri Series Release Notes =========================== .. release-notes:: :branch: stable/ussuri ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/victoria.rst0000664000175000017500000000021200000000000022534 0ustar00zuulzuul00000000000000============================= Victoria Series Release Notes ============================= .. release-notes:: :branch: stable/victoria ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/wallaby.rst0000664000175000017500000000020600000000000022352 0ustar00zuulzuul00000000000000============================ Wallaby Series Release Notes ============================ .. release-notes:: :branch: stable/wallaby ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/releasenotes/source/xena.rst0000664000175000017500000000017200000000000021654 0ustar00zuulzuul00000000000000========================= Xena Series Release Notes ========================= .. release-notes:: :branch: stable/xena ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/requirements.txt0000664000175000017500000000042600000000000017464 0ustar00zuulzuul00000000000000# 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 ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1645037368.691795 oslo.context-4.1.0/setup.cfg0000664000175000017500000000204000000000000016013 0ustar00zuulzuul00000000000000[metadata] name = oslo.context summary = Oslo Context library description_file = README.rst author = OpenStack author_email = openstack-discuss@lists.openstack.org home_page = https://docs.openstack.org/oslo.context/latest/ python_requires = >=3.6 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 :: 3 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3 :: Only Programming Language :: Python :: Implementation :: CPython [files] packages = oslo_context [mypy] show_column_numbers = true show_error_context = true ignore_missing_imports = true check_untyped_defs = true warn_unused_ignores = true disallow_untyped_defs = true [mypy-oslo_context.tests.*] ignore_errors = true [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/setup.py0000664000175000017500000000170100000000000015707 0ustar00zuulzuul00000000000000# 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. 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) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/test-requirements.txt0000664000175000017500000000073500000000000020444 0ustar00zuulzuul00000000000000# 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. hacking>=3.0.1,<3.1.0 # Apache-2.0 mypy>=0.761 # MIT fixtures>=3.0.0 # Apache-2.0/BSD oslotest>=3.2.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 stestr>=2.0.0 # Apache-2.0 # Bandit security code scanner bandit>=1.6.0,<1.7.0 # Apache-2.0 pre-commit>=2.6.0 # MIT ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1645037328.0 oslo.context-4.1.0/tox.ini0000664000175000017500000000356000000000000015515 0ustar00zuulzuul00000000000000[tox] minversion = 3.2.0 envlist = py3,pep8 ignore_basepython_conflict = true [testenv] basepython = python3 # TODO(damani): Drop distutils override once logging improves in setuptools # https://github.com/pypa/setuptools/issues/3038 setenv = SETUPTOOLS_USE_DISTUTILS=stdlib deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/test-requirements.txt commands = stestr run --slowest {posargs} [testenv:mypy] description = Run type checks. envdir = {toxworkdir}/shared commands = python -m mypy {posargs:.} [testenv:pep8] envdir = {toxworkdir}/shared commands = pre-commit run -a # Run security linter bandit -r oslo_context -x tests -n5 [testenv:venv] envdir = {toxworkdir}/shared commands = {posargs} [testenv:docs] deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/doc/requirements.txt whitelist_externals = rm commands = rm -fr doc/build sphinx-build -W --keep-going -b html doc/source doc/build/html [testenv:cover] # TODO(damani): Drop distutils override once logging improves in setuptools # https://github.com/pypa/setuptools/issues/3038 envdir = {toxworkdir}/shared setenv = SETUPTOOLS_USE_DISTUTILS=stdlib PYTHON=coverage run --source oslo_context --parallel-mode commands = stestr run {posargs} coverage combine coverage html -d cover coverage xml -o cover/coverage.xml [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:releasenotes] envdir = {toxworkdir}/docs whitelist_externals = rm deps = {[testenv:docs]deps} commands = rm -rf releasenotes/build sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html