diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index f4ab5c6f..00000000 --- a/.coveragerc +++ /dev/null @@ -1,7 +0,0 @@ -[run] -branch = True -source = openstack -omit = openstack/tests/* - -[report] -ignore_errors = True diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f8b6eb20..00000000 --- a/.gitignore +++ /dev/null @@ -1,54 +0,0 @@ -*.py[cod] -.venv - -# C extensions -*.so - -# Packages -.eggs -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs -.installed.cfg -lib -lib64 - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -cover/* -.tox -nosetests.xml -.testrepository - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# Complexity -output/*.html -output/*/index.html - -# Sphinx -doc/build - -# pbr generates these -AUTHORS -ChangeLog - -# Editors -*~ -.*.swp diff --git a/.gitreview b/.gitreview deleted file mode 100644 index d838a518..00000000 --- a/.gitreview +++ /dev/null @@ -1,4 +0,0 @@ -[gerrit] -host=review.openstack.org -port=29418 -project=openstack/python-openstacksdk.git diff --git a/.mailmap b/.mailmap deleted file mode 100644 index cc92f17b..00000000 --- a/.mailmap +++ /dev/null @@ -1,3 +0,0 @@ -# Format is: -# -# \ No newline at end of file diff --git a/.testr.conf b/.testr.conf deleted file mode 100644 index 499b7a37..00000000 --- a/.testr.conf +++ /dev/null @@ -1,8 +0,0 @@ -[DEFAULT] -test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ - OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ - OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ - ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./openstack/tests/unit} $LISTOPT $IDOPTION -test_id_option=--load-list $IDFILE -test_list_option=--list -group_regex=([^\.]+\.)+ diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst deleted file mode 100644 index 8fee7941..00000000 --- a/CONTRIBUTING.rst +++ /dev/null @@ -1,16 +0,0 @@ -If you would like to contribute to the development of OpenStack, -you must follow the steps in this page: - - http://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: - - http://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/python-openstacksdk \ No newline at end of file diff --git a/HACKING.rst b/HACKING.rst deleted file mode 100644 index e7627c51..00000000 --- a/HACKING.rst +++ /dev/null @@ -1,4 +0,0 @@ -python-openstacksdk Style Commandments -====================================== - -Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 67db8588..00000000 --- a/LICENSE +++ /dev/null @@ -1,175 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 90f8a7ae..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include AUTHORS -include ChangeLog -exclude .gitignore -exclude .gitreview - -global-exclude *.pyc \ No newline at end of file diff --git a/README b/README new file mode 100644 index 00000000..8fcd2b2f --- /dev/null +++ b/README @@ -0,0 +1,14 @@ +This project is no longer maintained. + +The contents of this repository are still available in the Git +source code management system. To see the contents of this +repository before it reached its end of life, please check out the +previous commit with "git checkout HEAD^1". + +For ongoing work on maintaining OpenStack packages in the Debian +distribution, please see the Debian OpenStack packaging team at +https://wiki.debian.org/OpenStack/. + +For any further questions, please email +openstack-dev@lists.openstack.org or join #openstack-dev on +Freenode. diff --git a/README.rst b/README.rst deleted file mode 100644 index a75f448a..00000000 --- a/README.rst +++ /dev/null @@ -1,36 +0,0 @@ -OpenStack Python SDK -==================== - -The ``python-openstacksdk`` is a collection of libraries for building -applications to work with OpenStack clouds. The project aims to provide -a consistent and complete set of interactions with OpenStack's many -services, along with complete documentation, examples, and tools. - -This SDK is under active development, and in the interests of providing -a high-quality interface, the APIs provided in this release may differ -from those provided in future release. - -Usage ------ - -The following example simply connects to an OpenStack cloud and lists -the containers in the Object Store service.:: - - from openstack import connection - conn = connection.Connection(auth_url="http://openstack:5000/v3", - project_name="big_project", - username="SDK_user", - password="Super5ecretPassw0rd") - for container in conn.object_store.containers(): - print(container.name) - -Documentation -------------- - -Documentation is available at -http://developer.openstack.org/sdks/python/openstacksdk/ - -License -------- - -Apache 2.0 diff --git a/babel.cfg b/babel.cfg deleted file mode 100644 index efceab81..00000000 --- a/babel.cfg +++ /dev/null @@ -1 +0,0 @@ -[python: **.py] diff --git a/create_yaml.sh b/create_yaml.sh deleted file mode 100755 index 4443986e..00000000 --- a/create_yaml.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# NOTE(thowe): There are some issues with OCC envvars that force us to do -# this for now. -# -mkdir -p ~/.config/openstack/ -FILE=~/.config/openstack/clouds.yaml -export OS_IDENTITY_API_VERSION=3 # force v3 identity -echo 'clouds:' >$FILE -echo ' test_cloud:' >>$FILE -env | grep OS_ | tr '=' ' ' | while read k v -do - k=$(echo $k | sed -e 's/OS_//') - k=$(echo $k | tr '[A-Z]' '[a-z]') - case "$k" in - region_name|*_api_version) - echo " $k: $v" >>$FILE - esac -done -echo " auth:" >>$FILE -env | grep OS_ | tr '=' ' ' | while read k v -do - k=$(echo $k | sed -e 's/OS_//') - k=$(echo $k | tr '[A-Z]' '[a-z]') - case "$k" in - region_name|*_api_version) - ;; - *) - echo " $k: $v" >>$FILE - esac -done diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index 2cdd0f5c..00000000 --- a/doc/Makefile +++ /dev/null @@ -1,136 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = build - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source - -.PHONY: help clean html pdf dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " pdf to make pdf with rst2pdf" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - -rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -pdf: - $(SPHINXBUILD) -b pdf $(ALLSPHINXOPTS) $(BUILDDIR)/pdf - @echo - @echo "Build finished. The PDFs are in $(BUILDDIR)/pdf." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/NebulaDocs.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/NebulaDocs.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/NebulaDocs" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/NebulaDocs" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - make -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." diff --git a/doc/source/conf.py b/doc/source/conf.py deleted file mode 100644 index 6c4cbcf1..00000000 --- a/doc/source/conf.py +++ /dev/null @@ -1,132 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import sys -import warnings - -import openstackdocstheme - -sys.path.insert(0, os.path.abspath('../..')) -sys.path.insert(0, os.path.abspath('.')) -# -- General configuration ---------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'enforcer' -] - -# When True, this will raise an exception that kills sphinx-build. -enforcer_warnings_as_errors = True - -# 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 - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'python-openstacksdk' -copyright = u'2015, OpenStack Foundation' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# "version" and "release" are used by the "log-a-bug" feature -# -# The short X.Y version. -version = '1.0' -# The full version, including alpha/beta/rc tags. -release = '1.0' - -# A few variables have to be set for the log-a-bug feature. -# giturl: The location of conf.py on Git. Must be set manually. -# gitsha: The SHA checksum of the bug description. Extracted from git log. -# bug_tag: Tag for categorizing the bug. Must be set manually. -# bug_project: Launchpad project to file bugs against. -# These variables are passed to the logabug code via html_context. -giturl = u'http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/doc/source' -git_cmd = "/usr/bin/git log | head -n1 | cut -f2 -d' '" -try: - gitsha = os.popen(git_cmd).read().strip('\n') -except Exception: - warnings.warn("Can not get git sha.") - gitsha = "unknown" - -bug_tag = "docs" -# source tree -pwd = os.getcwd() -# html_context allows us to pass arbitrary values into the html template -html_context = {"pwd": pwd, - "gitsha": gitsha, - "bug_tag": bug_tag, - "giturl": giturl, - "bug_project": "python-openstacksdk"} - -# If true, '()' will be appended to :func: etc. cross-reference text. -add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -add_module_names = True - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -autodoc_member_order = "bysource" - -# Locations to exclude when looking for source files. -exclude_patterns = [] - -# -- 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' - -# Add any paths that contain custom themes here, relative to this directory. -html_theme_path = [openstackdocstheme.get_html_theme_path()] - -# Don't let openstackdocstheme insert TOCs automatically. -theme_include_auto_toc = False - -# 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'), -] - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/3/': None, - 'http://docs.python-requests.org/en/master/': None} - -# Include both the class and __init__ docstrings when describing the class -autoclass_content = "both" diff --git a/doc/source/contributors/clouds.yaml b/doc/source/contributors/clouds.yaml deleted file mode 100644 index 04cd4aaf..00000000 --- a/doc/source/contributors/clouds.yaml +++ /dev/null @@ -1,19 +0,0 @@ -clouds: - test_cloud: - region_name: RegionOne - auth: - auth_url: http://xxx.xxx.xxx.xxx:5000/v2.0/ - username: demo - password: secrete - project_name: demo - example: - image_name: fedora-20.x86_64 - flavor_name: m1.small - network_name: private - rackspace: - cloud: rackspace - auth: - username: joe - password: joes-password - project_name: 123123 - region_name: IAD diff --git a/doc/source/contributors/create/examples/resource/fake.py b/doc/source/contributors/create/examples/resource/fake.py deleted file mode 100644 index e87416f0..00000000 --- a/doc/source/contributors/create/examples/resource/fake.py +++ /dev/null @@ -1,29 +0,0 @@ -# Apache 2 header omitted for brevity - -from openstack.fake import fake_service -from openstack import resource - - -class Fake(resource.Resource): - resource_key = "resource" - resources_key = "resources" - base_path = "/fake" - service = fake_service.FakeService() - id_attribute = "name" - - allow_create = True - allow_retrieve = True - allow_update = True - allow_delete = True - allow_list = True - allow_head = True - - #: The transaction date and time. - timestamp = resource.prop("x-timestamp") - #: The name of this resource. - name = resource.prop("name") - #: The value of the resource. Also available in headers. - value = resource.prop("value", alias="x-resource-value") - #: Is this resource cool? If so, set it to True. - #: This is a multi-line comment about cool stuff. - cool = resource.prop("cool", type=bool) diff --git a/doc/source/contributors/create/examples/resource/fake_service.py b/doc/source/contributors/create/examples/resource/fake_service.py deleted file mode 100644 index 9524b967..00000000 --- a/doc/source/contributors/create/examples/resource/fake_service.py +++ /dev/null @@ -1,13 +0,0 @@ -# Apache 2 header omitted for brevity - -from openstack import service_filter - - -class FakeService(service_filter.ServiceFilter): - """The fake service.""" - - valid_versions = [service_filter.ValidVersion('v2')] - - def __init__(self, version=None): - """Create a fake service.""" - super(FakeService, self).__init__(service_type='fake', version=version) diff --git a/doc/source/contributors/create/resource.rst b/doc/source/contributors/create/resource.rst deleted file mode 100644 index f4552b53..00000000 --- a/doc/source/contributors/create/resource.rst +++ /dev/null @@ -1,191 +0,0 @@ -Creating a New Resource -======================= - -This guide will walk you through how to add resources for a service. - -Naming Conventions ------------------- - -Above all, names across this project conform to Python's naming standards, -as laid out in `PEP 8 `_. - -The relevant details we need to know are as follows: - - * Module names are lower case, and separated by underscores if more than - one word. For example, ``openstack.object_store`` - * Class names are capitalized, with no spacing, and each subsequent word is - capitalized in a name. For example, ``ServerMetadata``. - * Attributes on classes, including methods, are lower case and separated - by underscores. For example, ``allow_list`` or ``get_data``. - -Services -******** - -Services in the OpenStack SDK are named after their program name, not their -code name. For example, the project often known as "Nova" is always called -"compute" within this SDK. - -This guide walks through creating service for an OpenStack program called -"Fake". Following our guidelines, the code for its service would -live under the ``openstack.fake`` namespace. What follows is the creation -of a :class:`~openstack.resource.Resource` class for the "Fake" service. - -Resources -********* - -Resources are named after the server-side resource, which is set in the -``base_path`` attribute of the resource class. This guide creates a -resouce class for the ``/fake`` server resource, so the resource module -is called ``fake.py`` and the class is called ``Fake``. - -An Example ----------- - -``openstack/fake/fake_service.py`` - -.. literalinclude:: examples/resource/fake_service.py - :language: Python - :linenos: - -``openstack/fake/v2/fake.py`` - -.. literalinclude:: examples/resource/fake.py - :language: Python - :linenos: - -``fake.Fake`` Attributes ------------------------- - -Each service's resources inherit from :class:`~openstack.resource.Resource`, -so they can override any of the base attributes to fit the way their -particular resource operates. - -``resource_key`` and ``resources_key`` -************************************** - -These attributes are set based on how your resource responds with data. -The default values for each of these are ``None``, which works fine -when your resource returns a JSON body that can be used directly without a -top-level key, such as ``{"name": "Ernie Banks", ...}"``. - -However, our ``Fake`` resource returns JSON bodies that have the details of -the resource one level deeper, such as -``{"resources": {"name": "Ernie Banks", ...}, {...}}``. It does a similar -thing with single resources, putting them inside a dictionary keyed on -``"resource"``. - -By setting ``Fake.resource_key`` on *line 8*, we tell the ``Resource.create``, -``Resource.get``, and ``Resource.update`` methods that we're either sending -or receiving a resource that is in a dictionary with that key. - -By setting ``Fake.resources_key`` on *line 9*, we tell the ``Resource.list`` -method that we're expecting to receive multiple resources inside a dictionary -with that key. - -``base_path`` -************* - -The ``base_path`` is the URL we're going to use to make requests for this -resource. In this case, *line 10* sets ``base_path = "/fake"``, which also -corresponds to the name of our class, ``Fake``. - -Most resources follow this basic formula. Some cases are more complex, where -the URL to make requests to has to contain some extra data. The volume service -has several resources which make either basic requests or detailed requests, -so they use ``base_path = "/volumes/%s(detailed)"``. Before a request is made, -if ``detailed = True``, they convert it to a string so the URL becomes -``/volumes/detailed``. If it's ``False``, they only send ``/volumes/``. - -``service`` -*********** - -*Line 11* is an instance of the service we're implementing. Each resource -ties itself to the service through this setting, so that the proper URL -can be constructed. - -In ``fake_service.py``, we specify the valid versions as well as what this -service is called in the service catalog. When a request is made for this -resource, the Session now knows how to construct the appropriate URL using -this ``FakeService`` instance. - -``id_attribute`` -**************** - -*Line 12* specifies that this resource uses a different identifier than -the default of ``id``. While IDs are used internally, such as for creating -request URLs to interact with an individual resource, they are exposed for -consistency so users always have one place to find the resource's identity. - -Supported Operations --------------------- - -The base :class:`~openstack.resource.Resource` disallows all types of requests -by default, requiring each resource to specify which requests they support. -On *lines 14-19*, our ``Fake`` resource specifies that it'll work with all -of the operations. - -In order to have the following methods work, you must allow the corresponding -value by setting it to ``True``: - -+----------------------------------------------+----------------+ -| :class:`~openstack.resource.Resource.create` | allow_create | -+----------------------------------------------+----------------+ -| :class:`~openstack.resource.Resource.delete` | allow_delete | -+----------------------------------------------+----------------+ -| :class:`~openstack.resource.Resource.head` | allow_head | -+----------------------------------------------+----------------+ -| :class:`~openstack.resource.Resource.list` | allow_list | -+----------------------------------------------+----------------+ -| :class:`~openstack.resource.Resource.get` | allow_retrieve | -+----------------------------------------------+----------------+ -| :class:`~openstack.resource.Resource.update` | allow_update | -+----------------------------------------------+----------------+ - -An additional attribute to set is ``put_update`` if your service uses ``PUT`` -requests in order to update a resource. By default, ``PATCH`` requests are -used for ``Resource.update``. - -Properties ----------- - -The way resource classes communicate values between the user and the server -are :class:`~openstack.resource.prop` objects. These act similarly to Python's -built-in property objects, but they share only the name - they're not the same. - -Properties are set based on the contents of a response body or headers. -Based on what your resource returns, you should set ``prop``\s to map -those those values to ones on your :class:`~openstack.resource.Resource` -object. - -*Line 22* sets a prop for ``timestamp`` , which will cause the -``Fake.timestamp`` attribute to contain the value returned in an -``X-Timestamp`` header, such as from a ``Fake.head`` request. - -*Line 24* sets a prop for ``name``, which is a value returned in a body, such -as from a ``Fake.get`` request. Note from *line 12* that ``name`` is -specified its ``id`` attribute, so when this resource -is populated from a response, ``Fake.name`` and ``Fake.id`` are the same -value. - -*Line 26* sets a prop which contains an alias. ``Fake.value`` will be set -when a response body contains a ``value``, or when a header contains -``X-Resource-Value``. - -*Line 28* specifies a type to be checked before sending the value in a request. -In this case, we can only set ``Fake.cool`` to either ``True`` or ``False``, -otherwise a TypeError will be raised if the value can't be converted to the -expected type. - -Documentation -------------- - -We use Sphinx's ``autodoc`` feature in order to build API documentation for -each resource we expose. The attributes we override from -:class:`~openstack.resource.Resource` don't need to be documented, but any -:class:`~openstack.resource.prop` attributes must be. All you need to do is -add a comment *above* the line to document, with a colon following the -pound-sign. - -*Lines 21, 23, 25, and 27-28* are comments which will then appear in the API -documentation. As shown in *lines 27 & 28*, these comments can span multiple -lines. diff --git a/doc/source/contributors/index.rst b/doc/source/contributors/index.rst deleted file mode 100644 index 8b246a24..00000000 --- a/doc/source/contributors/index.rst +++ /dev/null @@ -1,87 +0,0 @@ -Contributing to the OpenStack SDK -================================= - -This section of documentation pertains to those who wish to contribute to the -development of this SDK. If you're looking for documentation on how to use -the SDK to build applications, please see the `user <../users>`_ section. - -About the Project ------------------ - -The OpenStack SDK is a OpenStack project aimed at providing a complete -software development kit for the programs which make up the OpenStack -community. It is a set of Python-based libraries, documentation, examples, -and tools released under the Apache 2 license. - -Contacting the Developers -------------------------- - -IRC -*** - -The developers of this project are available in the -`#openstack-sdks `_ -channel on Freenode. This channel includes conversation on SDKs and tools -within the general OpenStack community, including OpenStackClient as well -as occasional talk about SDKs created for languages outside of Python. - -Email -***** - -The `openstack-dev `_ -mailing list fields questions of all types on OpenStack. Using the -``[python-openstacksdk]`` filter to begin your email subject will ensure -that the message gets to SDK developers. - -Development Environment ------------------------ - -The first step towards contributing code and documentation is to setup your -development environment. We use a pretty standard setup, but it is fully -documented in our :doc:`setup ` section. - -.. toctree:: - :maxdepth: 2 - - setup - -Testing -------- - -The project contains three test packages, one for unit tests, one for -functional tests and one for examples tests. The ``openstack.tests.unit`` -package tests the SDK's features in isolation. The ``openstack.tests.functional`` -and ``openstack.tests.examples`` packages test the SDK's features and examples -against an OpenStack cloud. - -.. toctree:: - - testing - -Project Layout --------------- - -The project contains a top-level ``openstack`` package, which houses several -modules that form the foundation upon which each service's API is built on. -Under the ``openstack`` package are packages for each of those services, -such as ``openstack.compute``. - -.. toctree:: - - layout - -Adding Features ---------------- - -Does this SDK not do what you need it to do? Is it missing a service? Are you -a developer on another project who wants to add their service? You're in the -right place. Below are examples of how to add new features to the -OpenStack SDK. - -.. toctree:: - :maxdepth: 2 - - create/resource - -.. TODO(briancurtin): document how to create a proxy -.. TODO(briancurtin): document how to create auth plugins diff --git a/doc/source/contributors/layout.rst b/doc/source/contributors/layout.rst deleted file mode 100644 index c221bc79..00000000 --- a/doc/source/contributors/layout.rst +++ /dev/null @@ -1,101 +0,0 @@ -How the SDK is organized -======================== - -The following diagram shows how the project is laid out. - -.. literalinclude:: layout.txt - -Session -------- - -The :class:`openstack.session.Session` manages an authenticator, -transport, and user profile. It exposes methods corresponding to -HTTP verbs, and injects your authentication token into a request, -determines any service preferences callers may have set, gets the endpoint -from the authenticator, and sends the request out through the transport. - -Resource --------- - -The :class:`openstack.resource.Resource` base class is the building block -of any service implementation. ``Resource`` objects correspond to the -resources each service's REST API works with, so the -:class:`openstack.compute.v2.server.Server` subclass maps to the compute -service's ``https://openstack:1234/v2/servers`` resource. - -The base ``Resource`` contains methods to support the typical -`CRUD `_ -operations supported by REST APIs, and handles the construction of URLs -and calling the appropriate HTTP verb on the given ``Session``. - -Values sent to or returned from the service are implemented as attributes -on the ``Resource`` subclass with type :class:`openstack.resource.prop`. -The ``prop`` is created with the exact name of what the API expects, -and can optionally include a ``type`` to be validated against on requests. -You should choose an attribute name that follows PEP-8, regardless of what -the server-side expects, as this ``prop`` becomes a mapping between the two.:: - - is_public = resource.prop('os-flavor-access:is_public', type=bool) - -There are six additional attributes which the ``Resource`` class checks -before making requests to the REST API. ``allow_create``, ``allow_retreive``, -``allow_update``, ``allow_delete``, ``allow_head``, and ``allow_list`` are set -to ``True`` or ``False``, and are checked before making the corresponding -method call. - -The ``base_path`` attribute should be set to the URL which corresponds to -this resource. Many ``base_path``\s are simple, such as ``"/servers"``. -For ``base_path``\s which are composed of non-static information, Python's -string replacement is used, e.g., ``base_path = "/servers/%(server_id)s/ips"``. - -``resource_key`` and ``resources_key`` are attributes to set when a -``Resource`` returns more than one item in a response, or otherwise -requires a key to obtain the response value. For example, the ``Server`` -class sets ``resource_key = "server"`` as an individual ``Server`` is -stored in a dictionary keyed with the singular noun, -and ``resource_keys = "servers"`` as multiple ``Server``\s are stored in -a dictionary keyed with the plural noun in the response. - -Proxy ------ - -Each service implements a ``Proxy`` class, within the -``openstack//vX/_proxy.py`` module. For example, the v2 compute -service's ``Proxy`` exists in ``openstack/compute/v2/_proxy.py``. - -This ``Proxy`` class manages a :class:`~openstack.sessions.Session` and -provides a higher-level interface for users to work with via a -:class:`~openstack.connection.Connection` instance. Rather than requiring -users to maintain their own session and work with lower-level -:class:`~openstack.resource.Resource` objects, the ``Proxy`` interface -offers a place to make things easier for the caller. - -Each ``Proxy`` class implements methods which act on the underlying -``Resource`` classes which represent the service. For example:: - - def list_flavors(self, **params): - return flavor.Flavor.list(self.session, **params) - -This method is operating on the ``openstack.compute.v2.flavor.Flavor.list`` -method. For the time being, it simply passes on the ``Session`` maintained -by the ``Proxy``, and returns what the underlying ``Resource.list`` method -does. - -The implementations and method signatures of ``Proxy`` methods are currently -under construction, as we figure out the best way to implement them in a -way which will apply nicely across all of the services. - -Connection ----------- - -The :class:`openstack.connection.Connection` class builds atop a ``Session`` -object, and provides a higher level interface constructed of ``Proxy`` -objects from each of the services. - -The ``Connection`` class' primary purpose is to act as a high-level interface -to this SDK, managing the lower level connecton bits and exposing the -``Resource`` objects through their corresponding `Proxy`_ object. - -If you've built proper ``Resource`` objects and implemented methods on the -corresponding ``Proxy`` object, the high-level interface to your service -should now be exposed. diff --git a/doc/source/contributors/layout.txt b/doc/source/contributors/layout.txt deleted file mode 100644 index 2dd7121d..00000000 --- a/doc/source/contributors/layout.txt +++ /dev/null @@ -1,13 +0,0 @@ -openstack/ - connection.py - resource.py - session.py - compute/ - compute_service.py - v2/ - server.py - _proxy.py - tests/ - compute/ - v2/ - test_server.py diff --git a/doc/source/contributors/local.conf b/doc/source/contributors/local.conf deleted file mode 100644 index 79106dea..00000000 --- a/doc/source/contributors/local.conf +++ /dev/null @@ -1,69 +0,0 @@ -[[local|localrc]] -# Configure passwords and the Swift Hash -MYSQL_PASSWORD=DEVSTACK_PASSWORD -RABBIT_PASSWORD=DEVSTACK_PASSWORD -SERVICE_TOKEN=DEVSTACK_PASSWORD -ADMIN_PASSWORD=DEVSTACK_PASSWORD -SERVICE_PASSWORD=DEVSTACK_PASSWORD -SWIFT_HASH=DEVSTACK_PASSWORD - -# Configure the stable OpenStack branches used by DevStack -# For stable branches see -# http://git.openstack.org/cgit/openstack-dev/devstack/refs/ -CINDER_BRANCH=stable/OPENSTACK_VERSION -CEILOMETER_BRANCH=stable/OPENSTACK_VERSION -GLANCE_BRANCH=stable/OPENSTACK_VERSION -HEAT_BRANCH=stable/OPENSTACK_VERSION -HORIZON_BRANCH=stable/OPENSTACK_VERSION -KEYSTONE_BRANCH=stable/OPENSTACK_VERSION -NEUTRON_BRANCH=stable/OPENSTACK_VERSION -NOVA_BRANCH=stable/OPENSTACK_VERSION -SWIFT_BRANCH=stable/OPENSTACK_VERSION -ZAQAR_BRANCH=stable/OPENSTACK_VERSION - -# Enable Swift -enable_service s-proxy -enable_service s-object -enable_service s-container -enable_service s-account - -# Disable Nova Network and enable Neutron -disable_service n-net -enable_service q-svc -enable_service q-agt -enable_service q-dhcp -enable_service q-l3 -enable_service q-meta -enable_service q-metering - -# Enable Ceilometer -enable_service ceilometer-acompute -enable_service ceilometer-acentral -enable_service ceilometer-anotification -enable_service ceilometer-collector -enable_service ceilometer-alarm-evaluator -enable_service ceilometer-alarm-notifier -enable_service ceilometer-api - -# Enable Zaqar -enable_plugin zaqar https://github.com/openstack/zaqar -enable_service zaqar-server - -# Enable Heat -enable_service h-eng -enable_service h-api -enable_service h-api-cfn -enable_service h-api-cw - -# Automatically download and register a VM image that Heat can launch -# For more information on Heat and DevStack see -# https://docs.openstack.org/heat/latest/getting_started/on_devstack.html -IMAGE_URL_SITE="http://download.fedoraproject.org" -IMAGE_URL_PATH="/pub/fedora/linux/releases/25/CloudImages/x86_64/images/" -IMAGE_URL_FILE="Fedora-Cloud-Base-25-1.3.x86_64.qcow2" -IMAGE_URLS+=","$IMAGE_URL_SITE$IMAGE_URL_PATH$IMAGE_URL_FILE - -# Logging -LOGDAYS=1 -LOGFILE=/opt/stack/logs/stack.sh.log -LOGDIR=/opt/stack/logs diff --git a/doc/source/contributors/setup.rst b/doc/source/contributors/setup.rst deleted file mode 100644 index 628b685b..00000000 --- a/doc/source/contributors/setup.rst +++ /dev/null @@ -1,123 +0,0 @@ -Creating a Development Environment -================================== - -Required Tools --------------- - -Python -****** - -As the OpenStack SDK is developed in Python, you will need at least one -version of Python installed. It is strongly preferred that you have at least -one of version 2 and one of version 3 so that your tests are run against both. -Our continuous integration system runs against several versions, so ultimately -we will have the proper test coverage, but having multiple versions locally -results in less time spent in code review when changes unexpectedly break -other versions. - -Python can be downloaded from https://www.python.org/downloads. - -virtualenv -********** - -In order to isolate our development environment from the system-based Python -installation, we use `virtualenv `_. -This allows us to install all of our necessary dependencies without -interfering with anything else, and preventing others from interfering with us. -Virtualenv must be installed on your system in order to use it, and it can be -had from PyPI, via pip, as follows. Note that you may need to run this -as an administrator in some situations.:: - - $ apt-get install python-virtualenv # Debian based platforms - $ yum install python-virtualenv # Red Hat based platforms - $ pip install virtualenv # Mac OS X and other platforms - -You can create a virtualenv in any location. A common usage is to store all -of your virtualenvs in the same place, such as under your home directory. -To create a virtualenv for the default Python, likely a version 2, run -the following:: - - $ virtualenv $HOME/envs/sdk - -To create an environment for a different version, such as Python 3, run -the following:: - - $ virtualenv -p python3.4 $HOME/envs/sdk3 - -When you want to enable your environment so that you can develop inside of it, -you *activate* it. To activate an environment, run the /bin/activate -script inside of it, like the following:: - - $ source $HOME/envs/sdk3/bin/activate - (sdk3)$ - -Once you are activated, you will see the environment name in front of your -command prompt. In order to exit that environment, run the ``deactivate`` -command. - -tox -*** - -We use `tox `_ as our test runner, -which allows us to run the same test commands against multiple versions -of Python. Inside any of the virtualenvs you use for working on the SDK, -run the following to install ``tox`` into it.:: - - (sdk3)$ pip install tox - -Git -*** - -The source of the OpenStack SDK is stored in Git. In order to work with our -source repository, you must have Git installed on your system. If your -system has a package manager, it can likely be had from there. If not, -you can find downloads or the source at http://git-scm.com. - -Getting the Source Code ------------------------ - -.. TODO(briancurtin): We should try and distill the following document - into the minimally necessary parts to include directly in this section. - I've talked to several people who are discouraged by that large of a - document to go through before even getting into the project they want - to work on. I don't want that to happen to us because we have the potential - to be more public facing than a lot of other projects. - -.. note:: Before checking out the code, please read the OpenStack - `Developer's Guide `_ - for details on how to use the continuous integration and code - review systems that we use. - -The canonical Git repository is hosted on openstack.org at -http://git.openstack.org/cgit/openstack/python-openstacksdk/, with a -mirror on GitHub at https://github.com/openstack/python-openstacksdk. -Because of how Git works, you can create a local clone from either of those, -or your own personal fork.:: - - (sdk3)$ git clone https://git.openstack.org/openstack/python-openstacksdk.git - (sdk3)$ cd python-openstacksdk - -Installing Dependencies ------------------------ - -In order to work with the SDK locally, such as in the interactive interpreter -or to run example scripts, you need to install the project's dependencies.:: - - (sdk3)$ pip install -r requirements.txt - -After the downloads and installs are complete, you'll have a fully functional -environment to use the SDK in. - -Building the Documentation --------------------------- - -Our documentation is written in reStructured Text and is built using -Sphinx. A ``docs`` command is available in our ``tox.ini``, allowing you -to build the documentation like you'd run tests. The ``docs`` command is -not evaluated by default.:: - - (sdk3)$ tox -e docs - -That command will cause the documentation, which lives in the ``docs`` folder, -to be built. HTML output is the most commonly referenced, which is located -in ``docs/build/html``. diff --git a/doc/source/contributors/testing.rst b/doc/source/contributors/testing.rst deleted file mode 100644 index 32d7419e..00000000 --- a/doc/source/contributors/testing.rst +++ /dev/null @@ -1,131 +0,0 @@ -Testing -======= - -The tests are run with `tox `_ and -configured in ``tox.ini``. The test results are tracked by -`testr `_ and configured -in ``.testr.conf``. - -Unit Tests ----------- - -Run -*** - -In order to run the entire unit test suite, simply run the ``tox`` command -inside of your source checkout. This will attempt to run every test command -listed inside of ``tox.ini``, which includes Python 2.7, 3.4, PyPy, -and a PEP 8 check. You should run the full test suite on all versions before -submitting changes for review in order to avoid unexpected failures in the -continuous integration system.:: - - (sdk3)$ tox - ... - py34: commands succeeded - py27: commands succeeded - pypy: commands succeeded - pep8: commands succeeded - congratulations :) - -During development, it may be more convenient to run a subset of the tests -to keep test time to a minimum. You can choose to run the tests only on one -version. A step further is to run only the tests you are working on.:: - - (sdk3)$ tox -e py34 # Run run the tests on Python 3.4 - (sdk3)$ tox -e py34 TestContainer # Run only the TestContainer tests on 3.4 - -Functional Tests ----------------- - -The functional tests assume that you have a public or private OpenStack cloud -that you can run the tests against. The tests must be able to be run against -public clouds but first and foremost they must be run against OpenStack. In -practice, this means that the tests should initially be run against a stable -branch of `DevStack `_. - -DevStack -******** - -There are many ways to run and configure DevStack. The link above will show -you how to run DevStack a number of ways. You'll need to choose a method -you're familiar with and can run in your environment. Wherever DevStack is -running, we need to make sure that python-openstacksdk contributors are -using the same configuration. - -This is the ``local.conf`` file we use to configure DevStack. - -.. literalinclude:: local.conf - -Replace ``DEVSTACK_PASSWORD`` with a password of your choice. - -Replace ``OPENSTACK_VERSION`` with a `stable branch `_ -of OpenStack (without the ``stable/`` prefix on the branch name). - -os-client-config -**************** - -To connect the functional tests to an OpenStack cloud we use -`os-client-config `_. -To setup os-client-config create a ``clouds.yaml`` file in the root of your -source checkout. - -This is an example of a minimal configuration for a ``clouds.yaml`` that -connects the functional tests to a DevStack instance. Note that one cloud -under ``clouds`` must be named ``test_cloud``. - -.. literalinclude:: clouds.yaml - :language: yaml - -Replace ``xxx.xxx.xxx.xxx`` with the IP address or FQDN of your DevStack instance. - -You can also create a ``~/.config/openstack/clouds.yaml`` file for your -DevStack cloud environment using the following commands. Replace -``DEVSTACK_SOURCE`` with your DevStack source checkout.:: - - (sdk3)$ source DEVSTACK_SOURCE/accrc/admin/admin - (sdk3)$ ./create_yaml.sh - -Run -*** - -Functional tests are run against both Python 2 and 3. In order to run the -entire functional test suite, run the ``tox -e functional`` and -``tox -e functional3`` command inside of your source checkout. This will -attempt to run every test command under ``/openstack/tests/functional/`` -in the source tree. You should run the full functional test suite before -submitting changes for review in order to avoid unexpected failures in -the continuous integration system.:: - - (sdk3)$ tox -e functional - ... - functional: commands succeeded - congratulations :) - (sdk3)$ tox -e functional3 - ... - functional3: commands succeeded - congratulations :) - -Examples Tests --------------- - -Similar to the functional tests, the examples tests assume that you have a -public or private OpenStack cloud that you can run the tests against. In -practice, this means that the tests should initially be run against a stable -branch of `DevStack `_. -And like the functional tests, the examples tests connect to an OpenStack cloud -using `os-client-config `_. -See the functional tests instructions for information on setting up DevStack and -os-client-config. - -Run -*** - -In order to run the entire examples test suite, simply run the -``tox -e examples`` command inside of your source checkout. This will -attempt to run every test command under ``/openstack/tests/examples/`` -in the source tree.:: - - (sdk3)$ tox -e examples - ... - examples: commands succeeded - congratulations :) diff --git a/doc/source/enforcer.py b/doc/source/enforcer.py deleted file mode 100644 index 8f653b09..00000000 --- a/doc/source/enforcer.py +++ /dev/null @@ -1,137 +0,0 @@ -import importlib -import itertools -import os - -from bs4 import BeautifulSoup -from sphinx import errors - -# NOTE: We do this because I can't find any way to pass "-v" -# into sphinx-build through pbr... -DEBUG = True if os.getenv("ENFORCER_DEBUG") else False - -WRITTEN_METHODS = set() - -# NOTE: This is temporary! These methods currently exist on the base -# Proxy class as public methods, but they're deprecated in favor of -# subclasses actually exposing them if necessary. However, as they're -# public and purposely undocumented, they cause spurious warnings. -# Ignore these methods until they're actually removed from the API, -# and then we can take this special case out. -IGNORED_METHODS = ("wait_for_delete", "wait_for_status") - -class EnforcementError(errors.SphinxError): - """A mismatch between what exists and what's documented""" - category = "Enforcer" - - -def get_proxy_methods(): - """Return a set of public names on all proxies""" - names = ["openstack.bare_metal.v1._proxy", - "openstack.block_store.v2._proxy", - "openstack.cluster.v1._proxy", - "openstack.compute.v2._proxy", - "openstack.database.v1._proxy", - "openstack.identity.v2._proxy", - "openstack.identity.v3._proxy", - "openstack.image.v1._proxy", - "openstack.image.v2._proxy", - "openstack.key_manager.v1._proxy", - "openstack.message.v1._proxy", - "openstack.message.v2._proxy", - "openstack.metric.v1._proxy", - "openstack.network.v2._proxy", - "openstack.object_store.v1._proxy", - "openstack.orchestration.v1._proxy", - "openstack.telemetry.v2._proxy", - "openstack.telemetry.alarm.v2._proxy", - "openstack.workflow.v2._proxy"] - - modules = (importlib.import_module(name) for name in names) - - methods = set() - for module in modules: - # We're not going to use the Proxy for anything other than a `dir` - # so just pass a dummy value so we can create the instance. - instance = module.Proxy("") - # We only document public names - names = [name for name in dir(instance) if not name.startswith("_")] - - # Remove the wait_for_* names temporarily. - for name in IGNORED_METHODS: - names.remove(name) - - good_names = [module.__name__ + ".Proxy." + name for name in names] - methods.update(good_names) - - return methods - - -def page_context(app, pagename, templatename, context, doctree): - """Handle html-page-context-event - - This event is emitted once the builder has the contents to create - an HTML page, but before the template is rendered. This is the point - where we'll know what documentation is going to be written, so - gather all of the method names that are about to be included - so we can check which ones were or were not processed earlier - by autodoc. - """ - if "users/proxies" in pagename: - soup = BeautifulSoup(context["body"], "html.parser") - dts = soup.find_all("dt") - ids = [dt.get("id") for dt in dts] - - written = 0 - for id in ids: - if id is not None and "_proxy.Proxy" in id: - WRITTEN_METHODS.add(id) - written += 1 - - if DEBUG: - app.info("ENFORCER: Wrote %d proxy methods for %s" % ( - written, pagename)) - - -def build_finished(app, exception): - """Handle build-finished event - - This event is emitted once the builder has written all of the output. - At this point we just compare what we know was written to what we know - exists within the modules and share the results. - - When enforcer_warnings_as_errors=True in conf.py, this method - will raise EnforcementError on any failures in order to signal failure. - """ - all_methods = get_proxy_methods() - - app.info("ENFORCER: %d proxy methods exist" % len(all_methods)) - app.info("ENFORCER: %d proxy methods written" % len(WRITTEN_METHODS)) - missing = all_methods - WRITTEN_METHODS - - def is_ignored(name): - for ignored_name in IGNORED_METHODS: - if ignored_name in name: - return True - return False - - # TEMPORARY: Ignore the wait_for names when determining what is missing. - app.info("ENFORCER: Ignoring wait_for_* names...") - missing = set(itertools.ifilterfalse(is_ignored, missing)) - - missing_count = len(missing) - app.info("ENFORCER: Found %d missing proxy methods " - "in the output" % missing_count) - - for name in sorted(missing): - app.warn("ENFORCER: %s was not included in the output" % name) - - if app.config.enforcer_warnings_as_errors and missing_count > 0: - raise EnforcementError( - "There are %d undocumented proxy methods" % missing_count) - - -def setup(app): - app.add_config_value("enforcer_warnings_as_errors", False, "env") - - app.connect("html-page-context", page_context) - app.connect("build-finished", build_finished) diff --git a/doc/source/glossary.rst b/doc/source/glossary.rst deleted file mode 100644 index 3bdbde41..00000000 --- a/doc/source/glossary.rst +++ /dev/null @@ -1,104 +0,0 @@ -:orphan: - -Glossary -======== - -.. glossary:: - :sorted: - - CLI - Command-Line Interface; a textual user interface. - - compute - OpenStack Compute (Nova). - - container - One of the :term:`object-store` resources; a container holds - :term:`objects ` being stored. - - endpoint - A base URL used in a REST request. An `authentication endpoint` is - specifically the URL given to a user to identify a cloud. A service - endpoint is generally obtained from the service catalog. - - host - A physical computer. Contrast with :term:`node` and :term:`server`. - - identity - OpenStack Identity (Keystone). - - image - OpenStack Image (Glance). Also the attribute name of the disk files - stored for use by servers. - - keypair - The attribute name of the SSH public key used in the OpenStack Compute - API for server authentication. - - node - A logical system, may refer to a :term:`server` (virtual machine) or a - :term:`host`. - - Generally used to describe an OS instance where a specific process is - running, e.g. a 'network node' is where the network processes run, - and may be directly on a host or in a server. Contrast with - :term:`host` and :term:`server`. - - object - A generic term which normally refers to the a Python ``object``. - The OpenStack Object Store service (Swift) also uses `object` as the - name of the item being stored within a :term:`container`. - - object-store - OpenStack Object Store (Swift). - - project - The name of the owner of resources in an OpenStack cloud. A `project` - can map to a customer, account or organization in different OpenStack - deployments. Used instead of the deprecated :term:`tenant`. - - region - The attribute name of a partitioning of cloud resources. - - resource - A Python object representing an OpenStack resource inside the SDK code. - Also used to describe the items managed by OpenStack. - - role - A personality that a user assumes when performing a specific set of - operations. A `role` includes a set of rights and privileges that a - user assuming that role inherits. The OpenStack Identity service - includes the set of roles that a user can assume in the - :term:`token` that is issued to that user. - - The individual services determine how the roles are interpreted - and access granted to operations or resources. The OpenStack Identity - service treats a role as an arbitrary name assigned by the cloud - administrator. - - server - A virtual machine or a bare-metal host managed by the OpenStack Compute - service. Contrast with :term:`host` and :term:`node`. - - service - In OpenStack this refers to a service/endpoint in the - :term:`ServiceCatalog `. - It could also be a collection of endpoints for different - :term:`regions `. - A service has a type and a name. - - service catalog - The list of :term:`services ` configured at a given - authentication endpoint available to the authenticated user. - - tenant - Deprecated in favor of :term:`project`. - - token - An arbitrary bit of text that is used to access resources. Some tokens - are `scoped` to determine what resources are accessible with it. A - token may be revoked at any time and is valid for a finite duration. - - volume - OpenStack Volume (Cinder). Also the attribute name of the virtual - disks managed by the OpenStack Volume service. diff --git a/doc/source/history.rst b/doc/source/history.rst deleted file mode 100644 index 69ed4fe6..00000000 --- a/doc/source/history.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../../ChangeLog diff --git a/doc/source/index.rst b/doc/source/index.rst deleted file mode 100644 index e2c2bb52..00000000 --- a/doc/source/index.rst +++ /dev/null @@ -1,34 +0,0 @@ -Welcome to the OpenStack SDK! -============================= - -This documentation is split into two sections: one for -:doc:`users ` looking to build applications which make use of -OpenStack, and another for those looking to -:doc:`contribute ` to this project. - -For Users ---------- - -.. toctree:: - :maxdepth: 2 - - users/index - -For Contributors ----------------- - -.. toctree:: - :maxdepth: 2 - - contributors/index - -General Information -------------------- - -General information about the SDK including a glossary and release history. - -.. toctree:: - :maxdepth: 1 - - Glossary of Terms - Release History diff --git a/doc/source/users/connection.rst b/doc/source/users/connection.rst deleted file mode 100644 index 70301a29..00000000 --- a/doc/source/users/connection.rst +++ /dev/null @@ -1,13 +0,0 @@ -Connection -========== -.. automodule:: openstack.connection - - from_config - ----------- - .. autofunction:: openstack.connection.from_config - -Connection Object ------------------ - -.. autoclass:: openstack.connection.Connection - :members: diff --git a/doc/source/users/examples b/doc/source/users/examples deleted file mode 120000 index d4cb9b9c..00000000 --- a/doc/source/users/examples +++ /dev/null @@ -1 +0,0 @@ -../../../examples/ \ No newline at end of file diff --git a/doc/source/users/guides/bare_metal.rst b/doc/source/users/guides/bare_metal.rst deleted file mode 100644 index 10e96561..00000000 --- a/doc/source/users/guides/bare_metal.rst +++ /dev/null @@ -1,9 +0,0 @@ -Using OpenStack Bare Metal -=========================== - -Before working with the Bare Metal service, you'll need to create a -connection to your OpenStack cloud by following the :doc:`connect` user -guide. This will provide you with the ``conn`` variable used in the examples -below. - -.. TODO(Qiming): Implement this guide diff --git a/doc/source/users/guides/block_store.rst b/doc/source/users/guides/block_store.rst deleted file mode 100644 index bb67a4ee..00000000 --- a/doc/source/users/guides/block_store.rst +++ /dev/null @@ -1,9 +0,0 @@ -Using OpenStack Block Store -=========================== - -Before working with the Block Store service, you'll need to create a -connection to your OpenStack cloud by following the :doc:`connect` user -guide. This will provide you with the ``conn`` variable used in the examples -below. - -.. TODO(thowe): Implement this guide diff --git a/doc/source/users/guides/cluster.rst b/doc/source/users/guides/cluster.rst deleted file mode 100644 index d0a0474b..00000000 --- a/doc/source/users/guides/cluster.rst +++ /dev/null @@ -1,36 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - - -======================= -Using OpenStack Cluster -======================= - -Before working with the Cluster service, you'll need to create a connection -to your OpenStack cloud by following the :doc:`connect` user guide. This will -provide you with the ``conn`` variable used by all examples in this guide. - -The primary abstractions/resources of the Cluster service are: - -.. toctree:: - :maxdepth: 1 - - Profile Type - Profile - Cluster - Node - Policy Type - Policy - Receiver - Action - Event diff --git a/doc/source/users/guides/cluster/action.rst b/doc/source/users/guides/cluster/action.rst deleted file mode 100644 index 1a07479e..00000000 --- a/doc/source/users/guides/cluster/action.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - -==================== -Working with Actions -==================== - -.. TODO(Qiming): Implement this guide diff --git a/doc/source/users/guides/cluster/cluster.rst b/doc/source/users/guides/cluster/cluster.rst deleted file mode 100644 index b4772ef3..00000000 --- a/doc/source/users/guides/cluster/cluster.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - -================= -Managing Clusters -================= - -.. TODO(Qiming): Implement this guide diff --git a/doc/source/users/guides/cluster/event.rst b/doc/source/users/guides/cluster/event.rst deleted file mode 100644 index 185f454c..00000000 --- a/doc/source/users/guides/cluster/event.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - -=================== -Working with Events -=================== - -.. TODO(Qiming): Implement this guide diff --git a/doc/source/users/guides/cluster/node.rst b/doc/source/users/guides/cluster/node.rst deleted file mode 100644 index d4e2f54f..00000000 --- a/doc/source/users/guides/cluster/node.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - -============== -Managing Nodes -============== - -.. TODO(Qiming): Implement this guide diff --git a/doc/source/users/guides/cluster/policy.rst b/doc/source/users/guides/cluster/policy.rst deleted file mode 100644 index c0995840..00000000 --- a/doc/source/users/guides/cluster/policy.rst +++ /dev/null @@ -1,102 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - -================= -Managing Policies -================= - -A **policy type** can be treated as the meta-type of a `Policy` object. A -registry of policy types is built when the Cluster service starts. When -creating a `Policy` object, you will indicate the policy type used in its -`spec` property. - - -List Policies -~~~~~~~~~~~~~ - -To examine the list of policies: - -.. literalinclude:: ../../examples/cluster/policy.py - :pyobject: list_policies - -When listing policies, you can specify the sorting option using the ``sort`` -parameter and you can do pagination using the ``limit`` and ``marker`` -parameters. - -Full example: `manage policy`_ - - -Create Policy -~~~~~~~~~~~~~ - -When creating a policy, you will provide a dictionary with keys and values -according to the policy type referenced. - -.. literalinclude:: ../../examples/cluster/policy.py - :pyobject: create_policy - -Optionally, you can specify a ``metadata`` keyword argument that contains some -key-value pairs to be associated with the policy. - -Full example: `manage policy`_ - - -Find Policy -~~~~~~~~~~~ - -To find a policy based on its name or ID: - -.. literalinclude:: ../../examples/cluster/policy.py - :pyobject: find_policy - -Full example: `manage policy`_ - - -Get Policy -~~~~~~~~~~ - -To get a policy based on its name or ID: - -.. literalinclude:: ../../examples/cluster/policy.py - :pyobject: get_policy - -Full example: `manage policy`_ - - -Update Policy -~~~~~~~~~~~~~ - -After a policy is created, most of its properties are immutable. Still, you -can update a policy's ``name`` and/or ``metadata``. - -.. literalinclude:: ../../examples/cluster/policy.py - :pyobject: update_policy - -The Cluster service doesn't allow updating the ``spec`` of a policy. The only -way to achieve that is to create a new policy. - -Full example: `manage policy`_ - - -Delete Policy -~~~~~~~~~~~~~ - -A policy can be deleted after creation, provided that it is not referenced -by any active clusters or nodes. If you attempt to delete a policy that is -still in use, you will get an error message. - -.. literalinclude:: ../../examples/cluster/policy.py - :pyobject: delete_policy - - -.. _manage policy: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/cluster/policy.py diff --git a/doc/source/users/guides/cluster/policy_type.rst b/doc/source/users/guides/cluster/policy_type.rst deleted file mode 100644 index 346ed783..00000000 --- a/doc/source/users/guides/cluster/policy_type.rst +++ /dev/null @@ -1,45 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - -========================= -Working with Policy Types -========================= - -A **policy** is a template that encodes the information needed for specifying -the rules that are checked/enforced before/after certain actions are performed -on a cluster. The rules are encoded in a property named ``spec``. - - -List Policy Types -~~~~~~~~~~~~~~~~~ - -To examine the known policy types: - -.. literalinclude:: ../../examples/cluster/policy_type.py - :pyobject: list_policy_types - -Full example: `manage policy type`_ - - -Get Policy Type -~~~~~~~~~~~~~~~ - -To retrieve the details about a policy type, you need to provide the name of -it. - -.. literalinclude:: ../../examples/cluster/policy_type.py - :pyobject: get_policy_type - -Full example: `manage policy type`_ - -.. _manage policy type: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/cluster/policy_type.py diff --git a/doc/source/users/guides/cluster/profile.rst b/doc/source/users/guides/cluster/profile.rst deleted file mode 100644 index ad3f5e5b..00000000 --- a/doc/source/users/guides/cluster/profile.rst +++ /dev/null @@ -1,105 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - -================= -Managing Profiles -================= - -A **profile type** can be treated as the meta-type of a `Profile` object. A -registry of profile types is built when the Cluster service starts. When -creating a `Profile` object, you will indicate the profile type used in its -`spec` property. - - -List Profiles -~~~~~~~~~~~~~ - -To examine the list of profiles: - -.. literalinclude:: ../../examples/cluster/profile.py - :pyobject: list_profiles - -When listing profiles, you can specify the sorting option using the ``sort`` -parameter and you can do pagination using the ``limit`` and ``marker`` -parameters. - -Full example: `manage profile`_ - - -Create Profile -~~~~~~~~~~~~~~ - -When creating a profile, you will provide a dictionary with keys and values -specified according to the profile type referenced. - -.. literalinclude:: ../../examples/cluster/profile.py - :pyobject: create_profile - -Optionally, you can specify a ``metadata`` keyword argument that contains some -key-value pairs to be associated with the profile. - -Full example: `manage profile`_ - - -Find Profile -~~~~~~~~~~~~ - -To find a profile based on its name or ID: - -.. literalinclude:: ../../examples/cluster/profile.py - :pyobject: find_profile - -The Cluster service doesn't allow updating the ``spec`` of a profile. The only -way to achieve that is to create a new profile. - -Full example: `manage profile`_ - - -Get Profile -~~~~~~~~~~~~ - -To get a profile based on its name or ID: - -.. literalinclude:: ../../examples/cluster/profile.py - :pyobject: get_profile - -Full example: `manage profile`_ - - -Update Profile -~~~~~~~~~~~~~~ - -After a profile is created, most of its properties are immutable. Still, you -can update a profile's ``name`` and/or ``metadata``. - -.. literalinclude:: ../../examples/cluster/profile.py - :pyobject: update_profile - -The Cluster service doesn't allow updating the ``spec`` of a profile. The only -way to achieve that is to create a new profile. - -Full example: `manage profile`_ - - -Delete Profile -~~~~~~~~~~~~~~ - -A profile can be deleted after creation, provided that it is not referenced -by any active clusters or nodes. If you attempt to delete a profile that is -still in use, you will get an error message. - -.. literalinclude:: ../../examples/cluster/profile.py - :pyobject: delete_profile - - -.. _manage profile: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/cluster/profile.py diff --git a/doc/source/users/guides/cluster/profile_type.rst b/doc/source/users/guides/cluster/profile_type.rst deleted file mode 100644 index 45183bf0..00000000 --- a/doc/source/users/guides/cluster/profile_type.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - -========================== -Working with Profile Types -========================== - -A **profile** is a template used to create and manage nodes, i.e. objects -exposed by other OpenStack services. A profile encodes the information needed -for node creation in a property named ``spec``. - - -List Profile Types -~~~~~~~~~~~~~~~~~~ - -To examine the known profile types: - -.. literalinclude:: ../../examples/cluster/profile_type.py - :pyobject: list_profile_types - -Full example: `manage profile type`_ - - -Get Profile Type -~~~~~~~~~~~~~~~~ - -To get the details about a profile type, you need to provide the name of it. - -.. literalinclude:: ../../examples/cluster/profile_type.py - :pyobject: get_profile_type - -Full example: `manage profile type`_ - -.. _manage profile type: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/cluster/profile_type.py diff --git a/doc/source/users/guides/cluster/receiver.rst b/doc/source/users/guides/cluster/receiver.rst deleted file mode 100644 index a34f67b7..00000000 --- a/doc/source/users/guides/cluster/receiver.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - -================== -Managing Receivers -================== - -.. TODO(Qiming): Implement this guide diff --git a/doc/source/users/guides/compute.rst b/doc/source/users/guides/compute.rst deleted file mode 100644 index cc06fa28..00000000 --- a/doc/source/users/guides/compute.rst +++ /dev/null @@ -1,89 +0,0 @@ -Using OpenStack Compute -======================= - -Before working with the Compute service, you'll need to create a connection -to your OpenStack cloud by following the :doc:`connect` user guide. This will -provide you with the ``conn`` variable used in the examples below. - -.. contents:: Table of Contents - :local: - -The primary resource of the Compute service is the server. - -List Servers ------------- - -A **server** is a virtual machine that provides access to a compute instance -being run by your cloud provider. - -.. literalinclude:: ../examples/compute/list.py - :pyobject: list_servers - -Full example: `compute resource list`_ - -List Images ------------ - -An **image** is the operating system you want to use for your server. - -.. literalinclude:: ../examples/compute/list.py - :pyobject: list_images - -Full example: `compute resource list`_ - -List Flavors ------------- - -A **flavor** is the resource configuration for a server. Each flavor is a -unique combination of disk, memory, vCPUs, and network bandwidth. - -.. literalinclude:: ../examples/compute/list.py - :pyobject: list_flavors - -Full example: `compute resource list`_ - -List Networks -------------- - -A **network** provides connectivity to servers. - -.. literalinclude:: ../examples/network/list.py - :pyobject: list_networks - -Full example: `network resource list`_ - -Create Key Pair ---------------- - -A **key pair** is the public key and private key of -`public–key cryptography`_. They are used to encrypt and decrypt login -information when connecting to your server. - -.. literalinclude:: ../examples/compute/create.py - :pyobject: create_keypair - -Full example: `compute resource create`_ - -Create Server -------------- - -At minimum, a server requires a name, an image, a flavor, and a network on -creation. You can discover the names and IDs of these attributes by listing -them as above and then using the find methods to get the appropriate -resources. - -Ideally you'll also create a server using a keypair so you can login to that -server with the private key. - -Servers take time to boot so we call ``wait_for_server`` to wait -for it to become active. - -.. literalinclude:: ../examples/compute/create.py - :pyobject: create_server - -Full example: `compute resource create`_ - -.. _compute resource list: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/compute/list.py -.. _network resource list: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/network/list.py -.. _compute resource create: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/compute/create.py -.. _public–key cryptography: https://en.wikipedia.org/wiki/Public-key_cryptography \ No newline at end of file diff --git a/doc/source/users/guides/connect.rst b/doc/source/users/guides/connect.rst deleted file mode 100644 index 6c9937d9..00000000 --- a/doc/source/users/guides/connect.rst +++ /dev/null @@ -1,41 +0,0 @@ -Connect -======= - -In order to work with an OpenStack cloud you first need to create a -:class:`~openstack.connection.Connection` to it using your credentials. A -:class:`~openstack.connection.Connection` can be -created in 3 ways, using the class itself, a file, or environment variables. -If this is your first time using the SDK, we recommend simply using the -class itself as illustrated below. - -Create Connection ------------------ - -To create a connection you need a :class:`~openstack.profile.Profile` and a -:class:`~openstack.connection.Connection`. - -.. literalinclude:: ../examples/connect.py - :pyobject: create_connection - -The :class:`~openstack.profile.Profile` sets your preferences for each -service. You will pass it the region of the OpenStack cloud that this -connection will use. - -The :class:`~openstack.connection.Connection` is a context for a connection -to an OpenStack cloud. You will primarily use it to set the -:class:`~openstack.profile.Profile` and authentication information. You can -also set the ``user_agent`` to something that describes your application -(e.g. ``my-web-app/1.3.4``). - -Full example at `connect.py `_ - -.. note:: To enable logging, see the :doc:`logging` user guide. - -Next ----- -Now that you can create a connection, continue with the :ref:`user_guides` -to work with an OpenStack service. - -As an alternative to creating a :class:`~openstack.connection.Connection` -using the class itself, you can connect using a file or environment -variables. See the :doc:`connect_from_config` user guide. diff --git a/doc/source/users/guides/connect_from_config.rst b/doc/source/users/guides/connect_from_config.rst deleted file mode 100644 index ca99426d..00000000 --- a/doc/source/users/guides/connect_from_config.rst +++ /dev/null @@ -1,72 +0,0 @@ -Connect From Config -=================== - -In order to work with an OpenStack cloud you first need to create a -:class:`~openstack.connection.Connection` to it using your credentials. A -:class:`~openstack.connection.Connection` can be -created in 3 ways, using the class itself (see :doc:`connect`), a file, or -environment variables as illustrated below. The SDK uses -`os-client-config `_ -to handle the configuration. - -Create Connection From A File ------------------------------ - -Default Location -**************** - -To create a connection from a file you need a YAML file to contain the -configuration. - -.. literalinclude:: ../../contributors/clouds.yaml - :language: yaml - -To use a configuration file called ``clouds.yaml`` in one of the default -locations: - -* Current Directory -* ~/.config/openstack -* /etc/openstack - -call :py:func:`~openstack.connection.from_config`. The ``from_config`` -function takes three optional arguments: - -* **cloud_name** allows you to specify a cloud from your ``clouds.yaml`` file. -* **cloud_config** allows you to pass in an existing - ``os_client_config.config.OpenStackConfig``` object. -* **options** allows you to specify a namespace object with options to be - added to the cloud config. - -.. literalinclude:: ../examples/connect.py - :pyobject: Opts - -.. literalinclude:: ../examples/connect.py - :pyobject: create_connection_from_config - -.. literalinclude:: ../examples/connect.py - :pyobject: create_connection_from_args - -.. note:: To enable logging, set ``debug=True`` in the ``options`` object. - -User Defined Location -********************* - -To use a configuration file in a user defined location set the -environment variable ``OS_CLIENT_CONFIG_FILE`` to the -absolute path of a file.:: - - export OS_CLIENT_CONFIG_FILE=/path/to/my/config/my-clouds.yaml - -and call :py:func:`~openstack.connection.from_config` with the **cloud_name** -of the cloud configuration to use, . - -.. Create Connection From Environment Variables - -------------------------------------------- - - TODO(etoews): Document when https://bugs.launchpad.net/os-client-config/+bug/1489617 - is fixed. - -Next ----- -Now that you can create a connection, continue with the :ref:`user_guides` -for an OpenStack service. diff --git a/doc/source/users/guides/database.rst b/doc/source/users/guides/database.rst deleted file mode 100644 index 44256b34..00000000 --- a/doc/source/users/guides/database.rst +++ /dev/null @@ -1,8 +0,0 @@ -Using OpenStack Database -======================== - -Before working with the Database service, you'll need to create a connection -to your OpenStack cloud by following the :doc:`connect` user guide. This will -provide you with the ``conn`` variable used in the examples below. - -.. TODO(thowe): Implement this guide diff --git a/doc/source/users/guides/identity.rst b/doc/source/users/guides/identity.rst deleted file mode 100644 index 1cd0c442..00000000 --- a/doc/source/users/guides/identity.rst +++ /dev/null @@ -1,111 +0,0 @@ -Using OpenStack Identity -======================== - -Before working with the Identity service, you'll need to create a connection -to your OpenStack cloud by following the :doc:`connect` user guide. This will -provide you with the ``conn`` variable used in the examples below. - -The OpenStack Identity service is the default identity management system for -OpenStack. The Identity service authentication process confirms the identity -of a user and an incoming request by validating a set of credentials that the -user supplies. Initially, these credentials are a user name and password or a -user name and API key. When the Identity service validates user credentials, -it issues an authentication token that the user provides in subsequent -requests. An authentication token is an alpha-numeric text string that enables -access to OpenStack APIs and resources. A token may be revoked at any time and -is valid for a finite duration. - -List Users ----------- -A **user** is a digital representation of a person, system, or service that -uses OpenStack cloud services. The Identity service validates that incoming -requests are made by the user who claims to be making the call. Users have -a login and can access resources by using assigned tokens. Users can be -directly assigned to a particular project and behave as if they are contained -in that project. - -.. literalinclude:: ../examples/identity/list.py - :pyobject: list_users - -Full example: `identity resource list`_ - -List Credentials ----------------- -**Credentials** are data that confirms the identity of the user. For example, -user name and password, user name and API key, or an authentication token that -the Identity service provides. - -.. literalinclude:: ../examples/identity/list.py - :pyobject: list_credentials - -Full example: `identity resource list`_ - -List Projects -------------- -A **project** is a container that groups or isolates resources or identity -objects. - -.. literalinclude:: ../examples/identity/list.py - :pyobject: list_projects - -Full example: `identity resource list`_ - -List Domains ------------- -A **domain** is an Identity service API v3 entity and represents a collection -of projects and users that defines administrative boundaries for the management -of Identity entities. Users can be granted the administrator role for a domain. -A domain administrator can create projects, users, and groups in a domain and -assign roles to users and groups in a domain. - -.. literalinclude:: ../examples/identity/list.py - :pyobject: list_domains - -Full example: `identity resource list`_ - -List Groups ------------ -A **group** is an Identity service API v3 entity and represents a collection of -users that are owned by a domain. A group role granted to a domain or project -applies to all users in the group. Adding users to, or removing users from, a -group respectively grants, or revokes, their role and authentication to the -associated domain or project. - -.. literalinclude:: ../examples/identity/list.py - :pyobject: list_groups - -Full example: `identity resource list`_ - -List Services -------------- -A **service** is an OpenStack service, such as Compute, Object Storage, or -Image service, that provides one or more endpoints through which users can -access resources and perform operations. - -.. literalinclude:: ../examples/identity/list.py - :pyobject: list_services - -Full example: `identity resource list`_ - -List Endpoints --------------- -An **endpoint** is a network-accessible address, usually a URL, through which -you can access a service. - -.. literalinclude:: ../examples/identity/list.py - :pyobject: list_endpoints - -Full example: `identity resource list`_ - -List Regions ------------- -A **region** is an Identity service API v3 entity and represents a general -division in an OpenStack deployment. You can associate zero or more -sub-regions with a region to make a tree-like structured hierarchy. - -.. literalinclude:: ../examples/identity/list.py - :pyobject: list_regions - -Full example: `identity resource list`_ - -.. _identity resource list: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/identity/list.py diff --git a/doc/source/users/guides/image.rst b/doc/source/users/guides/image.rst deleted file mode 100644 index 6b78a06e..00000000 --- a/doc/source/users/guides/image.rst +++ /dev/null @@ -1,82 +0,0 @@ -Using OpenStack Image -===================== - -Before working with the Image service, you'll need to create a connection -to your OpenStack cloud by following the :doc:`connect` user guide. This will -provide you with the ``conn`` variable used in the examples below. - -The primary resource of the Image service is the image. - -List Images ------------ - -An **image** is a collection of files for a specific operating system -that you use to create or rebuild a server. OpenStack provides -`pre-built images `_. -You can also create custom images, or snapshots, from servers that you have -launched. Images come in different formats and are sometimes called virtual -machine images. - -.. literalinclude:: ../examples/image/list.py - :pyobject: list_images - -Full example: `image resource list`_ - -Create Image ------------- - -Create an image by uploading its data and setting its attributes. - -.. literalinclude:: ../examples/image/create.py - :pyobject: upload_image - -Full example: `image resource create`_ - -.. _download_image-stream-true: - -Downloading an Image with stream=True -------------------------------------- - -As images are often very large pieces of data, storing their entire contents -in the memory of your application can be less than desirable. A more -efficient method may be to iterate over a stream of the response data. - -By choosing to stream the response content, you determine the ``chunk_size`` -that is appropriate for your needs, meaning only that many bytes of data are -read for each iteration of the loop until all data has been consumed. -See :meth:`requests.Response.iter_content` for more information, as well -as Requests' :ref:`body-content-workflow`. - -When you choose to stream an image download, openstacksdk is no longer -able to compute the checksum of the response data for you. This example -shows how you might do that yourself, in a very similar manner to how -the library calculates checksums for non-streamed responses. - -.. literalinclude:: ../examples/image/download.py - :pyobject: download_image_stream - -Downloading an Image with stream=False --------------------------------------- - -If you wish to download an image's contents all at once and to memory, -simply set ``stream=False``, which is the default. - -.. literalinclude:: ../examples/image/download.py - :pyobject: download_image - -Full example: `image resource download`_ - -Delete Image ------------- - -Delete an image. - -.. literalinclude:: ../examples/image/delete.py - :pyobject: delete_image - -Full example: `image resource delete`_ - -.. _image resource create: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/image/create.py -.. _image resource delete: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/image/delete.py -.. _image resource list: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/image/list.py -.. _image resource download: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/image/download.py diff --git a/doc/source/users/guides/key_manager.rst b/doc/source/users/guides/key_manager.rst deleted file mode 100644 index 1efd12b7..00000000 --- a/doc/source/users/guides/key_manager.rst +++ /dev/null @@ -1,56 +0,0 @@ -Using OpenStack Key Manager -=========================== - -Before working with the Key Manager service, you'll need to create a -connection to your OpenStack cloud by following the :doc:`connect` user -guide. This will provide you with the ``conn`` variable used in the examples -below. - -.. contents:: Table of Contents - :local: - -.. note:: Some interactions with the Key Manager service differ from that - of other services in that resources do not have a proper ``id`` parameter, - which is necessary to make some calls. Instead, resources have a separately - named id attribute, e.g., the Secret resource has ``secret_id``. - - The examples below outline when to pass in those id values. - -Create a Secret ---------------- - -The Key Manager service allows you to create new secrets by passing the -attributes of the :class:`~openstack.key_manager.v1.secret.Secret` to the -:meth:`~openstack.key_manager.v1._proxy.Proxy.create_secret` method. - -.. literalinclude:: ../examples/key_manager/create.py - :pyobject: create_secret - -List Secrets ------------- - -Once you have stored some secrets, they are available for you to list -via the :meth:`~openstack.key_manager.v1._proxy.Proxy.secrets` method. -This method returns a generator, which yields each -:class:`~openstack.key_manager.v1.secret.Secret`. - -.. literalinclude:: ../examples/key_manager/list.py - :pyobject: list_secrets - -The :meth:`~openstack.key_manager.v1._proxy.Proxy.secrets` method can -also make more advanced queries to limit the secrets that are returned. - -.. literalinclude:: ../examples/key_manager/list.py - :pyobject: list_secrets_query - -Get Secret Payload ------------------- - -Once you have received a :class:`~openstack.key_manager.v1.secret.Secret`, -you can obtain the payload for it by passing the secret's id value to -the :meth:`~openstack.key_manager.v1._proxy.Proxy.secrets` method. -Use the :data:`~openstack.key_manager.v1.secret.Secret.secret_id` attribute -when making this request. - -.. literalinclude:: ../examples/key_manager/get.py - :pyobject: get_secret_payload diff --git a/doc/source/users/guides/logging.rst b/doc/source/users/guides/logging.rst deleted file mode 100644 index 623916fa..00000000 --- a/doc/source/users/guides/logging.rst +++ /dev/null @@ -1,79 +0,0 @@ -Logging -======= - -Logging can save you time and effort when developing your code or looking -for help. If your code is not behaving how you expect it to, enabling and -configuring logging can quickly give you valuable insight into the root -cause of the issue. If you need help from the OpenStack community, the -logs can help the people there assist you. - -.. note:: By default, no logging is done. - -Enable SDK Logging ------------------- - -To enable logging you use :func:`~openstack.utils.enable_logging`. - -The ``debug`` parameter controls the logging level. Set ``debug=True`` to -log debug and higher messages. Set ``debug=False`` to log warning and higher -messages. - -To log debug and higher messages:: - - import sys - from openstack import utils - - utils.enable_logging(debug=True, stream=sys.stdout) - -The ``path`` parameter controls the location of a log file. If set, this -parameter will send log messages to a file using a :py:class:`~logging.FileHandler`. - -To log messages to a file called ``openstack.log``:: - - from openstack import utils - - utils.enable_logging(debug=True, path='openstack.log') - -The ``stream`` parameter controls the stream where log message are written to. -If set to ``sys.stdout`` or ``sys.stderr``, this parameter will send log -messages to that stream using a :py:class:`~logging.StreamHandler` - -To log messages to the console on ``stdout``:: - - import sys - from openstack import utils - - utils.enable_logging(debug=True, stream=sys.stdout) - -You can combine the ``path`` and ``stream`` parameters to log to both places -simultaneously. - -To log messages to a file called ``openstack.log`` and the console on -``stdout``:: - - import sys - from openstack import utils - - utils.enable_logging(debug=True, path='openstack.log', stream=sys.stdout) - - -Enable requests Logging ------------------------ - -The SDK depends on a small number other libraries. Notably, it uses -`requests `_ for its transport layer. -To get even more information about the request/response cycle, you enable -logging of requests the same as you would any other library. - -To log messages to the console on ``stdout``:: - - import logging - import sys - - logger = logging.getLogger('requests') - formatter = logging.Formatter( - '%(asctime)s %(levelname)s: %(name)s %(message)s') - console = logging.StreamHandler(sys.stdout) - console.setFormatter(formatter) - logger.setLevel(logging.DEBUG) - logger.addHandler(console) diff --git a/doc/source/users/guides/message.rst b/doc/source/users/guides/message.rst deleted file mode 100644 index ac30f883..00000000 --- a/doc/source/users/guides/message.rst +++ /dev/null @@ -1,8 +0,0 @@ -Using OpenStack Message -======================= - -Before working with the Message service, you'll need to create a connection -to your OpenStack cloud by following the :doc:`connect` user guide. This will -provide you with the ``conn`` variable used in the examples below. - -.. TODO(briancurtin): Implement this guide diff --git a/doc/source/users/guides/network.rst b/doc/source/users/guides/network.rst deleted file mode 100644 index ae9a28b6..00000000 --- a/doc/source/users/guides/network.rst +++ /dev/null @@ -1,140 +0,0 @@ -Using OpenStack Network -======================= - -Before working with the Network service, you'll need to create a connection -to your OpenStack cloud by following the :doc:`connect` user guide. This will -provide you with the ``conn`` variable used in the examples below. - -.. contents:: Table of Contents - :local: - -The primary resource of the Network service is the network. - -List Networks -------------- - -A **network** is an isolated `Layer 2 `_ -networking segment. There are two types of networks, project and provider networks. -Project networks are fully isolated and are not shared with other projects. Provider -networks map to existing physical networks in the data center and provide external -network access for servers. Only an OpenStack administrator can create provider -networks. Networks can be connected via routers. - -.. literalinclude:: ../examples/network/list.py - :pyobject: list_networks - -Full example: `network resource list`_ - -List Subnets ------------- - -A **subnet** is a block of IP addresses and associated configuration state. -Subnets are used to allocate IP addresses when new ports are created on a -network. - -.. literalinclude:: ../examples/network/list.py - :pyobject: list_subnets - -Full example: `network resource list`_ - -List Ports ----------- - -A **port** is a connection point for attaching a single device, such as the -`NIC `_ -of a server, to a network. The port also describes the associated network -configuration, such as the `MAC `_ -and IP addresses to be used on that port. - -.. literalinclude:: ../examples/network/list.py - :pyobject: list_ports - -Full example: `network resource list`_ - -List Security Groups --------------------- - -A **security group** acts as a virtual firewall for servers. It is a container -for security group rules which specify the type of network traffic and direction -that is allowed to pass through a port. - -.. literalinclude:: ../examples/network/list.py - :pyobject: list_security_groups - -Full example: `network resource list`_ - -List Routers ------------- - -A **router** is a logical component that forwards data packets between networks. -It also provides `Layer 3 `_ and -`NAT `_ forwarding to -provide external network access for servers on project networks. - -.. literalinclude:: ../examples/network/list.py - :pyobject: list_routers - -Full example: `network resource list`_ - -List Network Agents -------------------- - -A **network agent** is a plugin that handles various tasks used to -implement virtual networks. These agents include neutron-dhcp-agent, -neutron-l3-agent, neutron-metering-agent, and neutron-lbaas-agent, -among others. - -.. literalinclude:: ../examples/network/list.py - :pyobject: list_network_agents - -Full example: `network resource list`_ - -Create Network --------------- - -Create a project network and subnet. This network can be used when creating -a server and allows the server to communicate with others servers on the -same project network. - -.. literalinclude:: ../examples/network/create.py - :pyobject: create_network - -Full example: `network resource create`_ - -Open a Port ------------ - -When creating a security group for a network, you will need to open certain -ports to allow communication via them. For example, you may need to enable -HTTPS access on port 443. - -.. literalinclude:: ../examples/network/security_group_rules.py - :pyobject: open_port - -Full example: `network security group create`_ - -Accept Pings ------------- - -In order to ping a machine on your network within a security group, -you will need to create a rule to allow inbound ICMP packets. - -.. literalinclude:: ../examples/network/security_group_rules.py - :pyobject: allow_ping - -Full example: `network security group create`_ - -Delete Network --------------- - -Delete a project network and its subnets. - -.. literalinclude:: ../examples/network/delete.py - :pyobject: delete_network - -Full example: `network resource delete`_ - -.. _network resource create: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/network/create.py -.. _network resource delete: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/network/delete.py -.. _network resource list: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/network/list.py -.. _network security group create: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/network/security_group_rules.py diff --git a/doc/source/users/guides/object_store.rst b/doc/source/users/guides/object_store.rst deleted file mode 100644 index da8c57e2..00000000 --- a/doc/source/users/guides/object_store.rst +++ /dev/null @@ -1,211 +0,0 @@ -Using OpenStack Object Store -============================ - -Before working with the Object Store service, you'll need to create a -connection to your OpenStack cloud by following the :doc:`connect` user -guide. This will provide you with the ``conn`` variable used in the examples -below. - -.. contents:: Table of Contents - :local: - -The primary resources of the Object Store service are containers and objects. - -Working with Containers ------------------------ - -Listing Containers -****************** - -To list existing containers, use the -:meth:`~openstack.object_store.v1._proxy.Proxy.containers` method. :: - - >>> for cont in conn.object_store.containers(): - ... print cont - ... - openstack.object_store.v1.container.Container: {u'count': 5, - u'bytes': 500, u'name': u'my container'} - openstack.object_store.v1.container.Container: {u'count': 0, - u'bytes': 0, u'name': u'empty container'} - openstack.object_store.v1.container.Container: {u'count': 100, - u'bytes': 1000000, u'name': u'another container'} - -The ``containers`` method returns a generator which yields -:class:`~openstack.object_store.v1.container.Container` objects. It handles -pagination for you, which can be adjusted via the ``limit`` argument. -By default, the ``containers`` method will yield as many containers as the -service will return, and it will continue requesting until it receives -no more. :: - - >>> for cont in conn.object_store.containers(limit=500): - ... print(cont) - ... - <500 Containers> - ... another request transparently made to the Object Store service - <500 more Containers> - ... - -Creating Containers -******************* - -To create a container, use the -:meth:`~openstack.object_store.v1._proxy.Proxy.create_container` method. :: - - >>> cont = conn.object_store.create_container(name="new container") - >>> cont - openstack.object_store.v1.container.Container: {'name': u'new container'} - -Working with Container Metadata -******************************* - -To get the metadata for a container, use the -:meth:`~openstack.object_store.v1._proxy.Proxy.get_container_metadata` method. -This method either takes the name of a container, or a -:class:`~openstack.object_store.v1.container.Container` object, and it returns -a `Container` object with all of its metadata attributes set. :: - - >>> cont = conn.object_store.get_container_metadata("new container") - openstack.object_store.v1.container.Container: {'content-length': '0', - 'x-container-object-count': '0', 'name': u'new container', - 'accept-ranges': 'bytes', - 'x-trans-id': 'tx22c5de63466e4c05bb104-0054740c39', - 'date': 'Tue, 25 Nov 2014 04:57:29 GMT', - 'x-timestamp': '1416889793.23520', 'x-container-read': '.r:mysite.com', - 'x-container-bytes-used': '0', 'content-type': 'text/plain; charset=utf-8'} - -To set the metadata for a container, use the -:meth:`~openstack.object_store.v1._proxy.Proxy.set_container_metadata` method. -This method takes a :class:`~openstack.object_store.v1.container.Container` -object. For example, to grant another user write access to this container, -you can set the -:attr:`~openstack.object_store.v1.container.Container.write_ACL` on a -resource and pass it to `set_container_metadata`. :: - - >>> cont.write_ACL = "big_project:another_user" - >>> conn.object_store.set_container_metadata(cont) - openstack.object_store.v1.container.Container: {'content-length': '0', - 'x-container-object-count': '0', - 'name': u'my new container', 'accept-ranges': 'bytes', - 'x-trans-id': 'txc3ee751f971d41de9e9f4-0054740ec1', - 'date': 'Tue, 25 Nov 2014 05:08:17 GMT', - 'x-timestamp': '1416889793.23520', 'x-container-read': '.r:mysite.com', - 'x-container-bytes-used': '0', 'content-type': 'text/plain; charset=utf-8', - 'x-container-write': 'big_project:another_user'} - -Working with Objects --------------------- - -Objects are held in containers. From an API standpoint, you work with -them using similarly named methods, typically with an additional argument -to specify their container. - -Listing Objects -*************** - -To list the objects that exist in a container, use the -:meth:`~openstack.object_store.v1._proxy.Proxy.objects` method. - -If you have a :class:`~openstack.object_store.v1.container.Container` -object, you can pass it to ``objects``. :: - - >>> print cont.name - pictures - >>> for obj in conn.object_store.objects(cont): - ... print obj - ... - openstack.object_store.v1.container.Object: - {u'hash': u'0522d4ccdf9956badcb15c4087a0c4cb', - u'name': u'pictures/selfie.jpg', u'bytes': 15744, - 'last-modified': u'2014-10-31T06:33:36.618640', - u'last_modified': u'2014-10-31T06:33:36.618640', - u'content_type': u'image/jpeg', 'container': u'pictures', - 'content-type': u'image/jpeg'} - ... - -Similar to the :meth:`~openstack.object_store.v1._proxy.Proxy.containers` -method, ``objects`` returns a generator which yields -:class:`~openstack.object_store.v1.obj.Object` objects stored in the -container. It also handles pagination for you, which you can adjust -with the ``limit`` parameter, otherwise making each request for the maximum -that your Object Store will return. - -If you have the name of a container instead of an object, you can also -pass that to the ``objects`` method. :: - - >>> for obj in conn.object_store.objects("pictures".decode("utf8"), - limit=100): - ... print obj - ... - <100 Objects> - ... another request transparently made to the Object Store service - <100 more Objects> - -Getting Object Data -******************* - -Once you have an :class:`~openstack.object_store.v1.obj.Object`, you get -the data stored inside of it with the -:meth:`~openstack.object_store.v1._proxy.Proxy.get_object_data` method. :: - - >>> print ob.name - message.txt - >>> data = conn.object_store.get_object_data(ob) - >>> print data - Hello, world! - -Additionally, if you want to save the object to disk, the -:meth:`~openstack.object_store.v1._proxy.Proxy.download_object` convenience -method takes an :class:`~openstack.object_store.v1.obj.Object` and a -``path`` to write the contents to. :: - - >>> conn.object_store.download_object(ob, "the_message.txt") - -Uploading Objects -***************** - -Once you have data you'd like to store in the Object Store service, you use -the :meth:`~openstack.object_store.v1._proxy.Proxy.upload_object` method. -This method takes the ``data`` to be stored, along with at least an object -``name`` and the ``container`` it is to be stored in. :: - - >>> hello = conn.object_store.upload_object(container="messages", - name="helloworld.txt", - data="Hello, world!") - >>> print hello - openstack.object_store.v1.container.Object: {'content-length': '0', - 'container': u'messages', 'name': u'helloworld.txt', - 'last-modified': 'Tue, 25 Nov 2014 17:39:29 GMT', - 'etag': '5eb63bbbe01eeed093cb22bb8f5acdc3', - 'x-trans-id': 'tx3035d41b03334aeaaf3dd-005474bed0', - 'date': 'Tue, 25 Nov 2014 17:39:28 GMT', - 'content-type': 'text/html; charset=UTF-8'} - -Working with Object Metadata -**************************** - -Working with metadata on objects is identical to how it's done with -containers. You use the -:meth:`~openstack.object_store.v1._proxy.Proxy.get_object_metadata` and -:meth:`~openstack.object_store.v1._proxy.Proxy.set_object_metadata` methods. - -The metadata attributes to be set can be found on the -:class:`~openstack.object_store.v1.obj.Object` object. :: - - >>> secret.delete_after = 300 - >>> secret = conn.object_store.set_object_metadata(secret) - -We set the :attr:`~openstack.object_store.obj.Object.delete_after` -value to 500 seconds, causing the object to be deleted in 300 seconds, -or five minutes. That attribute corresponds to the ``X-Delete-After`` -header value, which you can see is returned when we retreive the updated -metadata. :: - - >>> conn.object_store.get_object_metadata(ob) - openstack.object_store.v1.container.Object: {'content-length': '11', - 'container': u'Secret Container', - 'name': u'selfdestruct.txt', 'x-delete-after': 300, - 'accept-ranges': 'bytes', 'last-modified': 'Tue, 25 Nov 2014 17:50:45 GMT', - 'etag': '5eb63bbbe01eeed093cb22bb8f5acdc3', - 'x-timestamp': '1416937844.36805', - 'x-trans-id': 'tx5c3fd94adf7c4e1b8f334-005474c17b', - 'date': 'Tue, 25 Nov 2014 17:50:51 GMT', 'content-type': 'text/plain'} diff --git a/doc/source/users/guides/orchestration.rst b/doc/source/users/guides/orchestration.rst deleted file mode 100644 index 64adc4fd..00000000 --- a/doc/source/users/guides/orchestration.rst +++ /dev/null @@ -1,9 +0,0 @@ -Using OpenStack Orchestration -============================= - -Before working with the Orchestration service, you'll need to create a -connection to your OpenStack cloud by following the :doc:`connect` user -guide. This will provide you with the ``conn`` variable used in the examples -below. - -.. TODO(thowe): Implement this guide diff --git a/doc/source/users/guides/telemetry.rst b/doc/source/users/guides/telemetry.rst deleted file mode 100644 index cf7acae0..00000000 --- a/doc/source/users/guides/telemetry.rst +++ /dev/null @@ -1,11 +0,0 @@ -Using OpenStack Telemetry -========================= - -.. caution:: - BETA: This API is a work in progress and is subject to change. - -Before working with the Telemetry service, you'll need to create a connection -to your OpenStack cloud by following the :doc:`connect` user guide. This will -provide you with the ``conn`` variable used in the examples below. - -.. TODO(thowe): Implement this guide diff --git a/doc/source/users/index.rst b/doc/source/users/index.rst deleted file mode 100644 index 2209a451..00000000 --- a/doc/source/users/index.rst +++ /dev/null @@ -1,139 +0,0 @@ -Getting started with the OpenStack SDK -====================================== - -For a listing of terms used throughout the SDK, including the names of -projects and services supported by it, see the :doc:`glossary <../glossary>`. - -Installation ------------- - -The OpenStack SDK is available on -`PyPI `_ under the name -**openstacksdk**. To install it, use ``pip``:: - - $ pip install openstacksdk - -.. _user_guides: - -User Guides ------------ - -These guides walk you through how to make use of the libraries we provide -to work with each OpenStack service. If you're looking for a cookbook -approach, this is where you'll want to begin. - -.. toctree:: - :maxdepth: 1 - - Connect to an OpenStack Cloud - Connect to an OpenStack Cloud Using a Config File - Logging - Bare Metal - Block Store - Cluster - Compute - Database - Identity - Image - Key Manager - Message - Network - Object Store - Orchestration - Telemetry - -API Documentation ------------------ - -Service APIs are exposed through a two-layered approach. The classes -exposed through our *Connection* interface are the place to start if you're -an application developer consuming an OpenStack cloud. The *Resource* -interface is the layer upon which the *Connection* is built, with -*Connection* methods accepting and returning *Resource* objects. - -Connection Interface -******************** - -A *Connection* instance maintains your session, authentication, transport, -and profile, providing you with a set of higher-level interfaces to work -with OpenStack services. - -.. toctree:: - :maxdepth: 1 - - connection - profile - -Once you have a *Connection* instance, the following services may be exposed -to you. Your user profile determine the full set of exposed services, -but listed below are the ones provided by this SDK by default. - -.. toctree:: - :maxdepth: 1 - - Bare Metal - Block Store - Cluster - Compute - Database - Identity v2 - Identity v3 - Image v1 - Image v2 - Key Manager - Load Balancer - Message v1 - Message v2 - Network - Metric - Object Store - Orchestration - Telemetry - Workflow - -Resource Interface -****************** - -The *Resource* layer is a lower-level interface to communicate with OpenStack -services. While the classes exposed by the *Connection* build a convenience -layer on top of this, *Resources* can be used directly. However, the most -common usage of this layer is in receiving an object from a class in the -*Connection* layer, modifying it, and sending it back into the *Connection* -layer, such as to update a resource on the server. - -The following services have exposed *Resource* classes. - -.. toctree:: - :maxdepth: 1 - - Bare Metal - Block Store - Cluster - Compute - Database - Identity - Image - Key Management - Metric - Network - Orchestration - Object Store - Telemetry - Workflow - -Low-Level Classes -***************** - -The following classes are not commonly used by application developers, -but are used to construct applications to talk to OpenStack APIs. Typically -these parts are managed through the `Connection Interface`_, but their use -can be customized. - -.. toctree:: - :maxdepth: 1 - - session - resource - resource2 - service_filter - utils diff --git a/doc/source/users/profile.rst b/doc/source/users/profile.rst deleted file mode 100644 index 195a1848..00000000 --- a/doc/source/users/profile.rst +++ /dev/null @@ -1,9 +0,0 @@ -Profile -======= -.. automodule:: openstack.profile - -Profile Object --------------- - -.. autoclass:: openstack.profile.Profile - :members: diff --git a/doc/source/users/proxies/bare_metal.rst b/doc/source/users/proxies/bare_metal.rst deleted file mode 100644 index 8317b86b..00000000 --- a/doc/source/users/proxies/bare_metal.rst +++ /dev/null @@ -1,76 +0,0 @@ -Bare Metal API -============== - -For details on how to use bare_metal, see :doc:`/users/guides/bare_metal` - -.. automodule:: openstack.bare_metal.v1._proxy - -The BareMetal Class --------------------- - -The bare_metal high-level interface is available through the ``bare_metal`` -member of a :class:`~openstack.connection.Connection` object. -The ``bare_metal`` member will only be added if the service is detected. - -Node Operations -^^^^^^^^^^^^^^^ -.. autoclass:: openstack.bare_metal.v1._proxy.Proxy - - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.create_node - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.update_node - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.delete_node - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.get_node - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.find_node - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.nodes - -Port Operations -^^^^^^^^^^^^^^^ -.. autoclass:: openstack.bare_metal.v1._proxy.Proxy - - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.create_port - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.update_port - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.delete_port - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.get_port - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.find_port - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.ports - -Port Group Operations -^^^^^^^^^^^^^^^^^^^^^ -.. autoclass:: openstack.bare_metal.v1._proxy.Proxy - - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.create_port_group - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.update_port_group - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.delete_port_group - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.get_port_group - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.find_port_group - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.port_groups - -Driver Operations -^^^^^^^^^^^^^^^^^ -.. autoclass:: openstack.bare_metal.v1._proxy.Proxy - - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.drivers - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.get_driver - -Chassis Operations -^^^^^^^^^^^^^^^^^^ -.. autoclass:: openstack.bare_metal.v1._proxy.Proxy - - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.create_chassis - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.update_chassis - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.delete_chassis - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.get_chassis - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.find_chassis - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.chassis - -Deprecated Methods -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.bare_metal.v1._proxy.Proxy - - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.create_portgroup - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.update_portgroup - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.delete_portgroup - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.get_portgroup - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.find_portgroup - .. automethod:: openstack.bare_metal.v1._proxy.Proxy.portgroups diff --git a/doc/source/users/proxies/block_store.rst b/doc/source/users/proxies/block_store.rst deleted file mode 100644 index 92c12cd1..00000000 --- a/doc/source/users/proxies/block_store.rst +++ /dev/null @@ -1,43 +0,0 @@ -Block Store API -=============== - -For details on how to use block_store, see :doc:`/users/guides/block_store` - -.. automodule:: openstack.block_store.v2._proxy - -The BlockStore Class --------------------- - -The block_store high-level interface is available through the ``block_store`` -member of a :class:`~openstack.connection.Connection` object. -The ``block_store`` member will only be added if the service is detected. - -Volume Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.block_store.v2._proxy.Proxy - - .. automethod:: openstack.block_store.v2._proxy.Proxy.create_volume - .. automethod:: openstack.block_store.v2._proxy.Proxy.delete_volume - .. automethod:: openstack.block_store.v2._proxy.Proxy.get_volume - .. automethod:: openstack.block_store.v2._proxy.Proxy.volumes - -Type Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.block_store.v2._proxy.Proxy - - .. automethod:: openstack.block_store.v2._proxy.Proxy.create_type - .. automethod:: openstack.block_store.v2._proxy.Proxy.delete_type - .. automethod:: openstack.block_store.v2._proxy.Proxy.get_type - .. automethod:: openstack.block_store.v2._proxy.Proxy.types - -Snapshot Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.block_store.v2._proxy.Proxy - - .. automethod:: openstack.block_store.v2._proxy.Proxy.create_snapshot - .. automethod:: openstack.block_store.v2._proxy.Proxy.delete_snapshot - .. automethod:: openstack.block_store.v2._proxy.Proxy.get_snapshot - .. automethod:: openstack.block_store.v2._proxy.Proxy.snapshots diff --git a/doc/source/users/proxies/cluster.rst b/doc/source/users/proxies/cluster.rst deleted file mode 100644 index db7eec00..00000000 --- a/doc/source/users/proxies/cluster.rst +++ /dev/null @@ -1,177 +0,0 @@ -Cluster API -=========== - -.. automodule:: openstack.cluster.v1._proxy - -The Cluster Class ------------------ - -The cluster high-level interface is available through the ``cluster`` -member of a :class:`~openstack.connection.Connection` object. The -``cluster`` member will only be added if the service is detected. - - -Build Info Operations -^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_build_info - - -Profile Type Operations -^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.profile_types - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_profile_type - - -Profile Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.create_profile - .. automethod:: openstack.cluster.v1._proxy.Proxy.update_profile - .. automethod:: openstack.cluster.v1._proxy.Proxy.delete_profile - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_profile - .. automethod:: openstack.cluster.v1._proxy.Proxy.find_profile - .. automethod:: openstack.cluster.v1._proxy.Proxy.profiles - - .. automethod:: openstack.cluster.v1._proxy.Proxy.validate_profile - - -Policy Type Operations -^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.policy_types - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_policy_type - - -Policy Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.create_policy - .. automethod:: openstack.cluster.v1._proxy.Proxy.update_policy - .. automethod:: openstack.cluster.v1._proxy.Proxy.delete_policy - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_policy - .. automethod:: openstack.cluster.v1._proxy.Proxy.find_policy - .. automethod:: openstack.cluster.v1._proxy.Proxy.policies - - .. automethod:: openstack.cluster.v1._proxy.Proxy.validate_policy - - -Cluster Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.create_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.update_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.delete_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.find_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.clusters - - .. automethod:: openstack.cluster.v1._proxy.Proxy.check_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.recover_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.resize_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.scale_in_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.scale_out_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.collect_cluster_attrs - .. automethod:: openstack.cluster.v1._proxy.Proxy.perform_operation_on_cluster - - .. automethod:: openstack.cluster.v1._proxy.Proxy.add_nodes_to_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.remove_nodes_from_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.replace_nodes_in_cluster - - .. automethod:: openstack.cluster.v1._proxy.Proxy.attach_policy_to_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.update_cluster_policy - .. automethod:: openstack.cluster.v1._proxy.Proxy.detach_policy_from_cluster - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_cluster_policy - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_policies - - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_add_nodes - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_attach_policy - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_del_nodes - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_detach_policy - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_operation - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_replace_nodes - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_resize - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_scale_in - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_scale_out - .. automethod:: openstack.cluster.v1._proxy.Proxy.cluster_update_policy - - -Node Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.create_node - .. automethod:: openstack.cluster.v1._proxy.Proxy.update_node - .. automethod:: openstack.cluster.v1._proxy.Proxy.delete_node - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_node - .. automethod:: openstack.cluster.v1._proxy.Proxy.find_node - .. automethod:: openstack.cluster.v1._proxy.Proxy.nodes - - .. automethod:: openstack.cluster.v1._proxy.Proxy.check_node - .. automethod:: openstack.cluster.v1._proxy.Proxy.recover_node - .. automethod:: openstack.cluster.v1._proxy.Proxy.perform_operation_on_node - - .. automethod:: openstack.cluster.v1._proxy.Proxy.adopt_node - .. automethod:: openstack.cluster.v1._proxy.Proxy.node_operation - - -Receiver Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.create_receiver - .. automethod:: openstack.cluster.v1._proxy.Proxy.update_receiver - .. automethod:: openstack.cluster.v1._proxy.Proxy.delete_receiver - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_receiver - .. automethod:: openstack.cluster.v1._proxy.Proxy.find_receiver - .. automethod:: openstack.cluster.v1._proxy.Proxy.receivers - - -Action Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_action - .. automethod:: openstack.cluster.v1._proxy.Proxy.actions - - -Event Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.get_event - .. automethod:: openstack.cluster.v1._proxy.Proxy.events - - -Helper Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.wait_for_delete - .. automethod:: openstack.cluster.v1._proxy.Proxy.wait_for_status - - -Service Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.cluster.v1._proxy.Proxy - - .. automethod:: openstack.cluster.v1._proxy.Proxy.services diff --git a/doc/source/users/proxies/compute.rst b/doc/source/users/proxies/compute.rst deleted file mode 100644 index 3d3b3cb1..00000000 --- a/doc/source/users/proxies/compute.rst +++ /dev/null @@ -1,194 +0,0 @@ -Compute API -=========== - -For details on how to use compute, see :doc:`/users/guides/compute` - -.. automodule:: openstack.compute.v2._proxy - -The Compute Class ------------------ - -The compute high-level interface is available through the ``compute`` -member of a :class:`~openstack.connection.Connection` object. The -``compute`` member will only be added if the service is detected. - - -Server Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.create_server - .. automethod:: openstack.compute.v2._proxy.Proxy.update_server - .. automethod:: openstack.compute.v2._proxy.Proxy.delete_server - .. automethod:: openstack.compute.v2._proxy.Proxy.get_server - .. automethod:: openstack.compute.v2._proxy.Proxy.find_server - .. automethod:: openstack.compute.v2._proxy.Proxy.servers - .. automethod:: openstack.compute.v2._proxy.Proxy.get_server_metadata - .. automethod:: openstack.compute.v2._proxy.Proxy.set_server_metadata - .. automethod:: openstack.compute.v2._proxy.Proxy.delete_server_metadata - .. automethod:: openstack.compute.v2._proxy.Proxy.wait_for_server - .. automethod:: openstack.compute.v2._proxy.Proxy.create_server_image - .. automethod:: openstack.compute.v2._proxy.Proxy.backup_server - -Network Actions -*************** - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.add_fixed_ip_to_server - .. automethod:: openstack.compute.v2._proxy.Proxy.remove_fixed_ip_from_server - .. automethod:: openstack.compute.v2._proxy.Proxy.add_floating_ip_to_server - .. automethod:: openstack.compute.v2._proxy.Proxy.remove_floating_ip_from_server - .. automethod:: openstack.compute.v2._proxy.Proxy.add_security_group_to_server - .. automethod:: openstack.compute.v2._proxy.Proxy.remove_security_group_from_server - -Starting, Stopping, etc. -************************ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.start_server - .. automethod:: openstack.compute.v2._proxy.Proxy.stop_server - .. automethod:: openstack.compute.v2._proxy.Proxy.suspend_server - .. automethod:: openstack.compute.v2._proxy.Proxy.resume_server - .. automethod:: openstack.compute.v2._proxy.Proxy.reboot_server - .. automethod:: openstack.compute.v2._proxy.Proxy.shelve_server - .. automethod:: openstack.compute.v2._proxy.Proxy.unshelve_server - .. automethod:: openstack.compute.v2._proxy.Proxy.lock_server - .. automethod:: openstack.compute.v2._proxy.Proxy.unlock_server - .. automethod:: openstack.compute.v2._proxy.Proxy.pause_server - .. automethod:: openstack.compute.v2._proxy.Proxy.unpause_server - .. automethod:: openstack.compute.v2._proxy.Proxy.rescue_server - .. automethod:: openstack.compute.v2._proxy.Proxy.unrescue_server - .. automethod:: openstack.compute.v2._proxy.Proxy.evacuate_server - .. automethod:: openstack.compute.v2._proxy.Proxy.migrate_server - .. automethod:: openstack.compute.v2._proxy.Proxy.get_server_console_output - .. automethod:: openstack.compute.v2._proxy.Proxy.live_migrate_server - -Modifying a Server -****************** - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.resize_server - .. automethod:: openstack.compute.v2._proxy.Proxy.confirm_server_resize - .. automethod:: openstack.compute.v2._proxy.Proxy.revert_server_resize - .. automethod:: openstack.compute.v2._proxy.Proxy.rebuild_server - .. automethod:: openstack.compute.v2._proxy.Proxy.reset_server_state - .. automethod:: openstack.compute.v2._proxy.Proxy.change_server_password - -Image Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.images - .. automethod:: openstack.compute.v2._proxy.Proxy.get_image - .. automethod:: openstack.compute.v2._proxy.Proxy.find_image - .. automethod:: openstack.compute.v2._proxy.Proxy.delete_image - .. automethod:: openstack.compute.v2._proxy.Proxy.get_image_metadata - .. automethod:: openstack.compute.v2._proxy.Proxy.set_image_metadata - .. automethod:: openstack.compute.v2._proxy.Proxy.delete_image_metadata - -Flavor Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.create_flavor - .. automethod:: openstack.compute.v2._proxy.Proxy.delete_flavor - .. automethod:: openstack.compute.v2._proxy.Proxy.get_flavor - .. automethod:: openstack.compute.v2._proxy.Proxy.find_flavor - .. automethod:: openstack.compute.v2._proxy.Proxy.flavors - -Service Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.services - .. automethod:: openstack.compute.v2._proxy.Proxy.enable_service - .. automethod:: openstack.compute.v2._proxy.Proxy.disable_service - .. automethod:: openstack.compute.v2._proxy.Proxy.force_service_down - -Volume Attachment Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.create_volume_attachment - .. automethod:: openstack.compute.v2._proxy.Proxy.update_volume_attachment - .. automethod:: openstack.compute.v2._proxy.Proxy.delete_volume_attachment - .. automethod:: openstack.compute.v2._proxy.Proxy.get_volume_attachment - .. automethod:: openstack.compute.v2._proxy.Proxy.volume_attachments - -Keypair Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.create_keypair - .. automethod:: openstack.compute.v2._proxy.Proxy.delete_keypair - .. automethod:: openstack.compute.v2._proxy.Proxy.get_keypair - .. automethod:: openstack.compute.v2._proxy.Proxy.find_keypair - .. automethod:: openstack.compute.v2._proxy.Proxy.keypairs - -Server IPs -^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.server_ips - -Server Group Operations -^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.create_server_group - .. automethod:: openstack.compute.v2._proxy.Proxy.delete_server_group - .. automethod:: openstack.compute.v2._proxy.Proxy.get_server_group - .. automethod:: openstack.compute.v2._proxy.Proxy.find_server_group - .. automethod:: openstack.compute.v2._proxy.Proxy.server_groups - -Server Interface Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.create_server_interface - .. automethod:: openstack.compute.v2._proxy.Proxy.delete_server_interface - .. automethod:: openstack.compute.v2._proxy.Proxy.get_server_interface - .. automethod:: openstack.compute.v2._proxy.Proxy.server_interfaces - -Availability Zone Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.availability_zones - -Limits Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.get_limits - -Hypervisor Operations -^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.get_hypervisor - .. automethod:: openstack.compute.v2._proxy.Proxy.find_hypervisor - .. automethod:: openstack.compute.v2._proxy.Proxy.hypervisors - -Extension Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.compute.v2._proxy.Proxy - - .. automethod:: openstack.compute.v2._proxy.Proxy.find_extension - .. automethod:: openstack.compute.v2._proxy.Proxy.extensions diff --git a/doc/source/users/proxies/database.rst b/doc/source/users/proxies/database.rst deleted file mode 100644 index 493589b7..00000000 --- a/doc/source/users/proxies/database.rst +++ /dev/null @@ -1,56 +0,0 @@ -Database API -============ - -For details on how to use database, see :doc:`/users/guides/database` - -.. automodule:: openstack.database.v1._proxy - -The Database Class ------------------- - -The database high-level interface is available through the ``database`` -member of a :class:`~openstack.connection.Connection` object. The -``database`` member will only be added if the service is detected. - -Database Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.database.v1._proxy.Proxy - - .. automethod:: openstack.database.v1._proxy.Proxy.create_database - .. automethod:: openstack.database.v1._proxy.Proxy.delete_database - .. automethod:: openstack.database.v1._proxy.Proxy.get_database - .. automethod:: openstack.database.v1._proxy.Proxy.find_database - .. automethod:: openstack.database.v1._proxy.Proxy.databases - -Flavor Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.database.v1._proxy.Proxy - - .. automethod:: openstack.database.v1._proxy.Proxy.get_flavor - .. automethod:: openstack.database.v1._proxy.Proxy.find_flavor - .. automethod:: openstack.database.v1._proxy.Proxy.flavors - -Instance Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.database.v1._proxy.Proxy - - .. automethod:: openstack.database.v1._proxy.Proxy.create_instance - .. automethod:: openstack.database.v1._proxy.Proxy.update_instance - .. automethod:: openstack.database.v1._proxy.Proxy.delete_instance - .. automethod:: openstack.database.v1._proxy.Proxy.get_instance - .. automethod:: openstack.database.v1._proxy.Proxy.find_instance - .. automethod:: openstack.database.v1._proxy.Proxy.instances - -User Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.database.v1._proxy.Proxy - - .. automethod:: openstack.database.v1._proxy.Proxy.create_user - .. automethod:: openstack.database.v1._proxy.Proxy.delete_user - .. automethod:: openstack.database.v1._proxy.Proxy.get_user - .. automethod:: openstack.database.v1._proxy.Proxy.find_user - .. automethod:: openstack.database.v1._proxy.Proxy.users diff --git a/doc/source/users/proxies/identity_v2.rst b/doc/source/users/proxies/identity_v2.rst deleted file mode 100644 index 0cd4b77e..00000000 --- a/doc/source/users/proxies/identity_v2.rst +++ /dev/null @@ -1,57 +0,0 @@ -Identity API v2 -=============== - -For details on how to use identity, see :doc:`/users/guides/identity` - -.. automodule:: openstack.identity.v2._proxy - -The Identity v2 Class ---------------------- - -The identity high-level interface is available through the ``identity`` -member of a :class:`~openstack.connection.Connection` object. The -``identity`` member will only be added if the service is detected. - -Extension Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v2._proxy.Proxy - - .. automethod:: openstack.identity.v2._proxy.Proxy.get_extension - .. automethod:: openstack.identity.v2._proxy.Proxy.extensions - -User Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v2._proxy.Proxy - - .. automethod:: openstack.identity.v2._proxy.Proxy.create_user - .. automethod:: openstack.identity.v2._proxy.Proxy.update_user - .. automethod:: openstack.identity.v2._proxy.Proxy.delete_user - .. automethod:: openstack.identity.v2._proxy.Proxy.get_user - .. automethod:: openstack.identity.v2._proxy.Proxy.find_user - .. automethod:: openstack.identity.v2._proxy.Proxy.users - -Role Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v2._proxy.Proxy - - .. automethod:: openstack.identity.v2._proxy.Proxy.create_role - .. automethod:: openstack.identity.v2._proxy.Proxy.update_role - .. automethod:: openstack.identity.v2._proxy.Proxy.delete_role - .. automethod:: openstack.identity.v2._proxy.Proxy.get_role - .. automethod:: openstack.identity.v2._proxy.Proxy.find_role - .. automethod:: openstack.identity.v2._proxy.Proxy.roles - -Tenant Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v2._proxy.Proxy - - .. automethod:: openstack.identity.v2._proxy.Proxy.create_tenant - .. automethod:: openstack.identity.v2._proxy.Proxy.update_tenant - .. automethod:: openstack.identity.v2._proxy.Proxy.delete_tenant - .. automethod:: openstack.identity.v2._proxy.Proxy.get_tenant - .. automethod:: openstack.identity.v2._proxy.Proxy.find_tenant - .. automethod:: openstack.identity.v2._proxy.Proxy.tenants diff --git a/doc/source/users/proxies/identity_v3.rst b/doc/source/users/proxies/identity_v3.rst deleted file mode 100644 index a5366a01..00000000 --- a/doc/source/users/proxies/identity_v3.rst +++ /dev/null @@ -1,146 +0,0 @@ -Identity API v3 -=============== - -For details on how to use identity, see :doc:`/users/guides/identity` - -.. automodule:: openstack.identity.v3._proxy - -The Identity v3 Class ---------------------- - -The identity high-level interface is available through the ``identity`` -member of a :class:`~openstack.connection.Connection` object. The -``identity`` member will only be added if the service is detected. - -Credential Operations -^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_credential - .. automethod:: openstack.identity.v3._proxy.Proxy.update_credential - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_credential - .. automethod:: openstack.identity.v3._proxy.Proxy.get_credential - .. automethod:: openstack.identity.v3._proxy.Proxy.find_credential - .. automethod:: openstack.identity.v3._proxy.Proxy.credentials - -Domain Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_domain - .. automethod:: openstack.identity.v3._proxy.Proxy.update_domain - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_domain - .. automethod:: openstack.identity.v3._proxy.Proxy.get_domain - .. automethod:: openstack.identity.v3._proxy.Proxy.find_domain - .. automethod:: openstack.identity.v3._proxy.Proxy.domains - -Endpoint Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_endpoint - .. automethod:: openstack.identity.v3._proxy.Proxy.update_endpoint - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_endpoint - .. automethod:: openstack.identity.v3._proxy.Proxy.get_endpoint - .. automethod:: openstack.identity.v3._proxy.Proxy.find_endpoint - .. automethod:: openstack.identity.v3._proxy.Proxy.endpoints - -Group Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_group - .. automethod:: openstack.identity.v3._proxy.Proxy.update_group - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_group - .. automethod:: openstack.identity.v3._proxy.Proxy.get_group - .. automethod:: openstack.identity.v3._proxy.Proxy.find_group - .. automethod:: openstack.identity.v3._proxy.Proxy.groups - -Policy Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_policy - .. automethod:: openstack.identity.v3._proxy.Proxy.update_policy - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_policy - .. automethod:: openstack.identity.v3._proxy.Proxy.get_policy - .. automethod:: openstack.identity.v3._proxy.Proxy.find_policy - .. automethod:: openstack.identity.v3._proxy.Proxy.policies - -Project Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_project - .. automethod:: openstack.identity.v3._proxy.Proxy.update_project - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_project - .. automethod:: openstack.identity.v3._proxy.Proxy.get_project - .. automethod:: openstack.identity.v3._proxy.Proxy.find_project - .. automethod:: openstack.identity.v3._proxy.Proxy.projects - -Region Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_region - .. automethod:: openstack.identity.v3._proxy.Proxy.update_region - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_region - .. automethod:: openstack.identity.v3._proxy.Proxy.get_region - .. automethod:: openstack.identity.v3._proxy.Proxy.find_region - .. automethod:: openstack.identity.v3._proxy.Proxy.regions - -Role Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_role - .. automethod:: openstack.identity.v3._proxy.Proxy.update_role - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_role - .. automethod:: openstack.identity.v3._proxy.Proxy.get_role - .. automethod:: openstack.identity.v3._proxy.Proxy.find_role - .. automethod:: openstack.identity.v3._proxy.Proxy.roles - .. automethod:: openstack.identity.v3._proxy.Proxy.role_assignments - .. automethod:: openstack.identity.v3._proxy.Proxy.role_assignments_filter - -Service Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_service - .. automethod:: openstack.identity.v3._proxy.Proxy.update_service - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_service - .. automethod:: openstack.identity.v3._proxy.Proxy.get_service - .. automethod:: openstack.identity.v3._proxy.Proxy.find_service - .. automethod:: openstack.identity.v3._proxy.Proxy.services - -Trust Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_trust - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_trust - .. automethod:: openstack.identity.v3._proxy.Proxy.get_trust - .. automethod:: openstack.identity.v3._proxy.Proxy.find_trust - .. automethod:: openstack.identity.v3._proxy.Proxy.trusts - -User Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.identity.v3._proxy.Proxy - - .. automethod:: openstack.identity.v3._proxy.Proxy.create_user - .. automethod:: openstack.identity.v3._proxy.Proxy.update_user - .. automethod:: openstack.identity.v3._proxy.Proxy.delete_user - .. automethod:: openstack.identity.v3._proxy.Proxy.get_user - .. automethod:: openstack.identity.v3._proxy.Proxy.find_user - .. automethod:: openstack.identity.v3._proxy.Proxy.users diff --git a/doc/source/users/proxies/image_v1.rst b/doc/source/users/proxies/image_v1.rst deleted file mode 100644 index 185d60eb..00000000 --- a/doc/source/users/proxies/image_v1.rst +++ /dev/null @@ -1,22 +0,0 @@ -Image API v1 -============ - -For details on how to use image, see :doc:`/users/guides/image` - -.. automodule:: openstack.image.v1._proxy - -The Image v1 Class ------------------- - -The image high-level interface is available through the ``image`` member of a -:class:`~openstack.connection.Connection` object. The ``image`` member will -only be added if the service is detected. - -.. autoclass:: openstack.image.v1._proxy.Proxy - - .. automethod:: openstack.image.v1._proxy.Proxy.upload_image - .. automethod:: openstack.image.v1._proxy.Proxy.update_image - .. automethod:: openstack.image.v1._proxy.Proxy.delete_image - .. automethod:: openstack.image.v1._proxy.Proxy.get_image - .. automethod:: openstack.image.v1._proxy.Proxy.find_image - .. automethod:: openstack.image.v1._proxy.Proxy.images diff --git a/doc/source/users/proxies/image_v2.rst b/doc/source/users/proxies/image_v2.rst deleted file mode 100644 index f88d7450..00000000 --- a/doc/source/users/proxies/image_v2.rst +++ /dev/null @@ -1,42 +0,0 @@ -Image API v2 -============ - -For details on how to use image, see :doc:`/users/guides/image` - -.. automodule:: openstack.image.v2._proxy - -The Image v2 Class ------------------- - -The image high-level interface is available through the ``image`` member of a -:class:`~openstack.connection.Connection` object. The ``image`` member will -only be added if the service is detected. - -Image Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.image.v2._proxy.Proxy - - .. automethod:: openstack.image.v2._proxy.Proxy.upload_image - .. automethod:: openstack.image.v2._proxy.Proxy.download_image - .. automethod:: openstack.image.v2._proxy.Proxy.update_image - .. automethod:: openstack.image.v2._proxy.Proxy.delete_image - .. automethod:: openstack.image.v2._proxy.Proxy.get_image - .. automethod:: openstack.image.v2._proxy.Proxy.find_image - .. automethod:: openstack.image.v2._proxy.Proxy.images - .. automethod:: openstack.image.v2._proxy.Proxy.deactivate_image - .. automethod:: openstack.image.v2._proxy.Proxy.reactivate_image - .. automethod:: openstack.image.v2._proxy.Proxy.add_tag - .. automethod:: openstack.image.v2._proxy.Proxy.remove_tag - -Member Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.image.v2._proxy.Proxy - - .. automethod:: openstack.image.v2._proxy.Proxy.add_member - .. automethod:: openstack.image.v2._proxy.Proxy.remove_member - .. automethod:: openstack.image.v2._proxy.Proxy.update_member - .. automethod:: openstack.image.v2._proxy.Proxy.get_member - .. automethod:: openstack.image.v2._proxy.Proxy.find_member - .. automethod:: openstack.image.v2._proxy.Proxy.members diff --git a/doc/source/users/proxies/key_manager.rst b/doc/source/users/proxies/key_manager.rst deleted file mode 100644 index 7d24bb13..00000000 --- a/doc/source/users/proxies/key_manager.rst +++ /dev/null @@ -1,51 +0,0 @@ -KeyManager API -============== - -For details on how to use key_management, see -:doc:`/users/guides/key_manager` - -.. automodule:: openstack.key_manager.v1._proxy - -The KeyManager Class --------------------- - -The key_management high-level interface is available through the -``key_manager`` member of a :class:`~openstack.connection.Connection` -object. The ``key_manager`` member will only be added if the service is -detected. - -Secret Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.key_manager.v1._proxy.Proxy - - .. automethod:: openstack.key_manager.v1._proxy.Proxy.create_secret - .. automethod:: openstack.key_manager.v1._proxy.Proxy.update_secret - .. automethod:: openstack.key_manager.v1._proxy.Proxy.delete_secret - .. automethod:: openstack.key_manager.v1._proxy.Proxy.get_secret - .. automethod:: openstack.key_manager.v1._proxy.Proxy.find_secret - .. automethod:: openstack.key_manager.v1._proxy.Proxy.secrets - -Container Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.key_manager.v1._proxy.Proxy - - .. automethod:: openstack.key_manager.v1._proxy.Proxy.create_container - .. automethod:: openstack.key_manager.v1._proxy.Proxy.update_container - .. automethod:: openstack.key_manager.v1._proxy.Proxy.delete_container - .. automethod:: openstack.key_manager.v1._proxy.Proxy.get_container - .. automethod:: openstack.key_manager.v1._proxy.Proxy.find_container - .. automethod:: openstack.key_manager.v1._proxy.Proxy.containers - -Order Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.key_manager.v1._proxy.Proxy - - .. automethod:: openstack.key_manager.v1._proxy.Proxy.create_order - .. automethod:: openstack.key_manager.v1._proxy.Proxy.update_order - .. automethod:: openstack.key_manager.v1._proxy.Proxy.delete_order - .. automethod:: openstack.key_manager.v1._proxy.Proxy.get_order - .. automethod:: openstack.key_manager.v1._proxy.Proxy.find_order - .. automethod:: openstack.key_manager.v1._proxy.Proxy.orders diff --git a/doc/source/users/proxies/load_balancer_v2.rst b/doc/source/users/proxies/load_balancer_v2.rst deleted file mode 100644 index 220c4f70..00000000 --- a/doc/source/users/proxies/load_balancer_v2.rst +++ /dev/null @@ -1,22 +0,0 @@ -Load Balancer v2 API -==================== - -.. automodule:: openstack.load_balancer.v2._proxy - -The LoadBalancer Class ----------------------- - -The load_balancer high-level interface is available through the -``load_balancer`` member of a :class:`~openstack.connection.Connection` object. -The ``load_balancer`` member will only be added if the service is detected. - -Load Balancer Operations -^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.load_balancer.v2._proxy.Proxy - - .. automethod:: openstack.load_balancer.v2._proxy.Proxy.create_load_balancer - .. automethod:: openstack.load_balancer.v2._proxy.Proxy.get_load_balancer - .. automethod:: openstack.load_balancer.v2._proxy.Proxy.load_balancers - .. automethod:: openstack.load_balancer.v2._proxy.Proxy.delete_load_balancer - .. automethod:: openstack.load_balancer.v2._proxy.Proxy.find_load_balancer diff --git a/doc/source/users/proxies/message_v1.rst b/doc/source/users/proxies/message_v1.rst deleted file mode 100644 index 3803eaf2..00000000 --- a/doc/source/users/proxies/message_v1.rst +++ /dev/null @@ -1,30 +0,0 @@ -Message API v1 -============== - -For details on how to use message, see :doc:`/users/guides/message` - -.. automodule:: openstack.message.v1._proxy - -The Message v1 Class --------------------- - -The message high-level interface is available through the ``message`` member -of a :class:`~openstack.connection.Connection` object. The ``message`` -member will only be added if the service is detected. - -Message Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.message.v1._proxy.Proxy - - .. automethod:: openstack.message.v1._proxy.Proxy.claim_messages - .. automethod:: openstack.message.v1._proxy.Proxy.create_messages - .. automethod:: openstack.message.v1._proxy.Proxy.delete_message - -Queue Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.message.v1._proxy.Proxy - - .. automethod:: openstack.message.v1._proxy.Proxy.create_queue - .. automethod:: openstack.message.v1._proxy.Proxy.delete_queue diff --git a/doc/source/users/proxies/message_v2.rst b/doc/source/users/proxies/message_v2.rst deleted file mode 100644 index 5575663a..00000000 --- a/doc/source/users/proxies/message_v2.rst +++ /dev/null @@ -1,53 +0,0 @@ -Message API v2 -============== - -For details on how to use message, see :doc:`/users/guides/message` - -.. automodule:: openstack.message.v2._proxy - -The Message v2 Class --------------------- - -The message high-level interface is available through the ``message`` member -of a :class:`~openstack.connection.Connection` object. The ``message`` -member will only be added if the service is detected. - -Message Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.message.v2._proxy.Proxy - - .. automethod:: openstack.message.v2._proxy.Proxy.post_message - .. automethod:: openstack.message.v2._proxy.Proxy.delete_message - .. automethod:: openstack.message.v2._proxy.Proxy.get_message - .. automethod:: openstack.message.v2._proxy.Proxy.messages - -Queue Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.message.v2._proxy.Proxy - - .. automethod:: openstack.message.v2._proxy.Proxy.create_queue - .. automethod:: openstack.message.v2._proxy.Proxy.delete_queue - .. automethod:: openstack.message.v2._proxy.Proxy.get_queue - .. automethod:: openstack.message.v2._proxy.Proxy.queues - -Claim Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.message.v2._proxy.Proxy - - .. automethod:: openstack.message.v2._proxy.Proxy.create_claim - .. automethod:: openstack.message.v2._proxy.Proxy.update_claim - .. automethod:: openstack.message.v2._proxy.Proxy.delete_claim - .. automethod:: openstack.message.v2._proxy.Proxy.get_claim - -Subscription Operations -^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.message.v2._proxy.Proxy - - .. automethod:: openstack.message.v2._proxy.Proxy.create_subscription - .. automethod:: openstack.message.v2._proxy.Proxy.delete_subscription - .. automethod:: openstack.message.v2._proxy.Proxy.get_subscription - .. automethod:: openstack.message.v2._proxy.Proxy.subscriptions diff --git a/doc/source/users/proxies/metric.rst b/doc/source/users/proxies/metric.rst deleted file mode 100644 index 3abd98f9..00000000 --- a/doc/source/users/proxies/metric.rst +++ /dev/null @@ -1,18 +0,0 @@ -Metric API -========== - -.. automodule:: openstack.metric.v1._proxy - -The Metric Class ----------------- - -The metric high-level interface is available through the ``metric`` -member of a :class:`~openstack.connection.Connection` object. The -``metric`` member will only be added if the service is detected. - -Capability Operations -^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.metric.v1._proxy.Proxy - - .. automethod:: openstack.metric.v1._proxy.Proxy.capabilities diff --git a/doc/source/users/proxies/network.rst b/doc/source/users/proxies/network.rst deleted file mode 100644 index 290e2010..00000000 --- a/doc/source/users/proxies/network.rst +++ /dev/null @@ -1,367 +0,0 @@ -Network API -=========== - -For details on how to use network, see :doc:`/users/guides/network` - -.. automodule:: openstack.network.v2._proxy - -The Network Class ------------------ - -The network high-level interface is available through the ``network`` -member of a :class:`~openstack.connection.Connection` object. The -``network`` member will only be added if the service is detected. - -Network Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_network - .. automethod:: openstack.network.v2._proxy.Proxy.update_network - .. automethod:: openstack.network.v2._proxy.Proxy.delete_network - .. automethod:: openstack.network.v2._proxy.Proxy.get_network - .. automethod:: openstack.network.v2._proxy.Proxy.find_network - .. automethod:: openstack.network.v2._proxy.Proxy.networks - - .. automethod:: openstack.network.v2._proxy.Proxy.get_network_ip_availability - .. automethod:: openstack.network.v2._proxy.Proxy.find_network_ip_availability - .. automethod:: openstack.network.v2._proxy.Proxy.network_ip_availabilities - - .. automethod:: openstack.network.v2._proxy.Proxy.add_dhcp_agent_to_network - .. automethod:: openstack.network.v2._proxy.Proxy.remove_dhcp_agent_from_network - .. automethod:: openstack.network.v2._proxy.Proxy.dhcp_agent_hosting_networks - -Port Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_port - .. automethod:: openstack.network.v2._proxy.Proxy.update_port - .. automethod:: openstack.network.v2._proxy.Proxy.delete_port - .. automethod:: openstack.network.v2._proxy.Proxy.get_port - .. automethod:: openstack.network.v2._proxy.Proxy.find_port - .. automethod:: openstack.network.v2._proxy.Proxy.ports - - .. automethod:: openstack.network.v2._proxy.Proxy.add_ip_to_port - .. automethod:: openstack.network.v2._proxy.Proxy.remove_ip_from_port - -Router Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_router - .. automethod:: openstack.network.v2._proxy.Proxy.update_router - .. automethod:: openstack.network.v2._proxy.Proxy.delete_router - .. automethod:: openstack.network.v2._proxy.Proxy.get_router - .. automethod:: openstack.network.v2._proxy.Proxy.find_router - .. automethod:: openstack.network.v2._proxy.Proxy.routers - - .. automethod:: openstack.network.v2._proxy.Proxy.add_gateway_to_router - .. automethod:: openstack.network.v2._proxy.Proxy.remove_gateway_from_router - .. automethod:: openstack.network.v2._proxy.Proxy.add_interface_to_router - .. automethod:: openstack.network.v2._proxy.Proxy.remove_interface_from_router - -Floating IP Operations -^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_ip - .. automethod:: openstack.network.v2._proxy.Proxy.update_ip - .. automethod:: openstack.network.v2._proxy.Proxy.delete_ip - .. automethod:: openstack.network.v2._proxy.Proxy.get_ip - .. automethod:: openstack.network.v2._proxy.Proxy.find_ip - .. automethod:: openstack.network.v2._proxy.Proxy.find_available_ip - .. automethod:: openstack.network.v2._proxy.Proxy.ips - -Pool Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_pool - .. automethod:: openstack.network.v2._proxy.Proxy.update_pool - .. automethod:: openstack.network.v2._proxy.Proxy.delete_pool - .. automethod:: openstack.network.v2._proxy.Proxy.get_pool - .. automethod:: openstack.network.v2._proxy.Proxy.find_pool - .. automethod:: openstack.network.v2._proxy.Proxy.pools - - .. automethod:: openstack.network.v2._proxy.Proxy.create_pool_member - .. automethod:: openstack.network.v2._proxy.Proxy.update_pool_member - .. automethod:: openstack.network.v2._proxy.Proxy.delete_pool_member - .. automethod:: openstack.network.v2._proxy.Proxy.get_pool_member - .. automethod:: openstack.network.v2._proxy.Proxy.find_pool_member - .. automethod:: openstack.network.v2._proxy.Proxy.pool_members - -Auto Allocated Topology Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.delete_auto_allocated_topology - .. automethod:: openstack.network.v2._proxy.Proxy.get_auto_allocated_topology - .. automethod:: openstack.network.v2._proxy.Proxy.validate_auto_allocated_topology - -Security Group Operations -^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_security_group - .. automethod:: openstack.network.v2._proxy.Proxy.update_security_group - .. automethod:: openstack.network.v2._proxy.Proxy.delete_security_group - .. automethod:: openstack.network.v2._proxy.Proxy.get_security_group - .. automethod:: openstack.network.v2._proxy.Proxy.get_security_group_rule - .. automethod:: openstack.network.v2._proxy.Proxy.find_security_group - .. automethod:: openstack.network.v2._proxy.Proxy.find_security_group_rule - .. automethod:: openstack.network.v2._proxy.Proxy.security_group_rules - .. automethod:: openstack.network.v2._proxy.Proxy.security_groups - - .. automethod:: openstack.network.v2._proxy.Proxy.security_group_allow_ping - .. automethod:: openstack.network.v2._proxy.Proxy.security_group_open_port - - .. automethod:: openstack.network.v2._proxy.Proxy.create_security_group_rule - .. automethod:: openstack.network.v2._proxy.Proxy.delete_security_group_rule - -Availability Zone Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.availability_zones - -Address Scope Operations -^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_address_scope - .. automethod:: openstack.network.v2._proxy.Proxy.update_address_scope - .. automethod:: openstack.network.v2._proxy.Proxy.delete_address_scope - .. automethod:: openstack.network.v2._proxy.Proxy.get_address_scope - .. automethod:: openstack.network.v2._proxy.Proxy.find_address_scope - .. automethod:: openstack.network.v2._proxy.Proxy.address_scopes - -Quota Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.update_quota - .. automethod:: openstack.network.v2._proxy.Proxy.delete_quota - .. automethod:: openstack.network.v2._proxy.Proxy.get_quota - .. automethod:: openstack.network.v2._proxy.Proxy.get_quota_default - .. automethod:: openstack.network.v2._proxy.Proxy.quotas - -QoS Operations -^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_qos_policy - .. automethod:: openstack.network.v2._proxy.Proxy.update_qos_policy - .. automethod:: openstack.network.v2._proxy.Proxy.delete_qos_policy - .. automethod:: openstack.network.v2._proxy.Proxy.get_qos_policy - .. automethod:: openstack.network.v2._proxy.Proxy.find_qos_policy - .. automethod:: openstack.network.v2._proxy.Proxy.qos_policies - .. automethod:: openstack.network.v2._proxy.Proxy.qos_rule_types - - .. automethod:: openstack.network.v2._proxy.Proxy.create_qos_minimum_bandwidth_rule - .. automethod:: openstack.network.v2._proxy.Proxy.update_qos_minimum_bandwidth_rule - .. automethod:: openstack.network.v2._proxy.Proxy.delete_qos_minimum_bandwidth_rule - .. automethod:: openstack.network.v2._proxy.Proxy.get_qos_minimum_bandwidth_rule - .. automethod:: openstack.network.v2._proxy.Proxy.find_qos_minimum_bandwidth_rule - .. automethod:: openstack.network.v2._proxy.Proxy.qos_minimum_bandwidth_rules - - .. automethod:: openstack.network.v2._proxy.Proxy.create_qos_bandwidth_limit_rule - .. automethod:: openstack.network.v2._proxy.Proxy.update_qos_bandwidth_limit_rule - .. automethod:: openstack.network.v2._proxy.Proxy.delete_qos_bandwidth_limit_rule - .. automethod:: openstack.network.v2._proxy.Proxy.get_qos_bandwidth_limit_rule - .. automethod:: openstack.network.v2._proxy.Proxy.find_qos_bandwidth_limit_rule - .. automethod:: openstack.network.v2._proxy.Proxy.qos_bandwidth_limit_rules - - .. automethod:: openstack.network.v2._proxy.Proxy.create_qos_dscp_marking_rule - .. automethod:: openstack.network.v2._proxy.Proxy.update_qos_dscp_marking_rule - .. automethod:: openstack.network.v2._proxy.Proxy.delete_qos_dscp_marking_rule - .. automethod:: openstack.network.v2._proxy.Proxy.get_qos_dscp_marking_rule - .. automethod:: openstack.network.v2._proxy.Proxy.find_qos_dscp_marking_rule - .. automethod:: openstack.network.v2._proxy.Proxy.qos_dscp_marking_rules - -Agent Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.delete_agent - .. automethod:: openstack.network.v2._proxy.Proxy.update_agent - .. automethod:: openstack.network.v2._proxy.Proxy.get_agent - .. automethod:: openstack.network.v2._proxy.Proxy.agents - .. automethod:: openstack.network.v2._proxy.Proxy.agent_hosted_routers - .. automethod:: openstack.network.v2._proxy.Proxy.routers_hosting_l3_agents - .. automethod:: openstack.network.v2._proxy.Proxy.network_hosting_dhcp_agents - - .. automethod:: openstack.network.v2._proxy.Proxy.add_router_to_agent - .. automethod:: openstack.network.v2._proxy.Proxy.remove_router_from_agent - -RBAC Operations -^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_rbac_policy - .. automethod:: openstack.network.v2._proxy.Proxy.update_rbac_policy - .. automethod:: openstack.network.v2._proxy.Proxy.delete_rbac_policy - .. automethod:: openstack.network.v2._proxy.Proxy.get_rbac_policy - .. automethod:: openstack.network.v2._proxy.Proxy.find_rbac_policy - .. automethod:: openstack.network.v2._proxy.Proxy.rbac_policies - -Listener Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_listener - .. automethod:: openstack.network.v2._proxy.Proxy.update_listener - .. automethod:: openstack.network.v2._proxy.Proxy.delete_listener - .. automethod:: openstack.network.v2._proxy.Proxy.get_listener - .. automethod:: openstack.network.v2._proxy.Proxy.find_listener - .. automethod:: openstack.network.v2._proxy.Proxy.listeners - -Subnet Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_subnet - .. automethod:: openstack.network.v2._proxy.Proxy.update_subnet - .. automethod:: openstack.network.v2._proxy.Proxy.delete_subnet - .. automethod:: openstack.network.v2._proxy.Proxy.get_subnet - .. automethod:: openstack.network.v2._proxy.Proxy.get_subnet_ports - .. automethod:: openstack.network.v2._proxy.Proxy.find_subnet - .. automethod:: openstack.network.v2._proxy.Proxy.subnets - - .. automethod:: openstack.network.v2._proxy.Proxy.create_subnet_pool - .. automethod:: openstack.network.v2._proxy.Proxy.update_subnet_pool - .. automethod:: openstack.network.v2._proxy.Proxy.delete_subnet_pool - .. automethod:: openstack.network.v2._proxy.Proxy.get_subnet_pool - .. automethod:: openstack.network.v2._proxy.Proxy.find_subnet_pool - .. automethod:: openstack.network.v2._proxy.Proxy.subnet_pools - -Load Balancer Operations -^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_load_balancer - .. automethod:: openstack.network.v2._proxy.Proxy.update_load_balancer - .. automethod:: openstack.network.v2._proxy.Proxy.delete_load_balancer - .. automethod:: openstack.network.v2._proxy.Proxy.get_load_balancer - .. automethod:: openstack.network.v2._proxy.Proxy.find_load_balancer - .. automethod:: openstack.network.v2._proxy.Proxy.load_balancers - -Health Monitor Operations -^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_health_monitor - .. automethod:: openstack.network.v2._proxy.Proxy.update_health_monitor - .. automethod:: openstack.network.v2._proxy.Proxy.delete_health_monitor - .. automethod:: openstack.network.v2._proxy.Proxy.get_health_monitor - .. automethod:: openstack.network.v2._proxy.Proxy.find_health_monitor - .. automethod:: openstack.network.v2._proxy.Proxy.health_monitors - -Metering Label Operations -^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_metering_label - .. automethod:: openstack.network.v2._proxy.Proxy.update_metering_label - .. automethod:: openstack.network.v2._proxy.Proxy.delete_metering_label - .. automethod:: openstack.network.v2._proxy.Proxy.get_metering_label - .. automethod:: openstack.network.v2._proxy.Proxy.find_metering_label - .. automethod:: openstack.network.v2._proxy.Proxy.metering_labels - - .. automethod:: openstack.network.v2._proxy.Proxy.create_metering_label_rule - .. automethod:: openstack.network.v2._proxy.Proxy.update_metering_label_rule - .. automethod:: openstack.network.v2._proxy.Proxy.delete_metering_label_rule - .. automethod:: openstack.network.v2._proxy.Proxy.get_metering_label_rule - .. automethod:: openstack.network.v2._proxy.Proxy.find_metering_label_rule - .. automethod:: openstack.network.v2._proxy.Proxy.metering_label_rules - -Segment Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_segment - .. automethod:: openstack.network.v2._proxy.Proxy.update_segment - .. automethod:: openstack.network.v2._proxy.Proxy.delete_segment - .. automethod:: openstack.network.v2._proxy.Proxy.get_segment - .. automethod:: openstack.network.v2._proxy.Proxy.find_segment - .. automethod:: openstack.network.v2._proxy.Proxy.segments - -Flavor Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_flavor - .. automethod:: openstack.network.v2._proxy.Proxy.update_flavor - .. automethod:: openstack.network.v2._proxy.Proxy.delete_flavor - .. automethod:: openstack.network.v2._proxy.Proxy.get_flavor - .. automethod:: openstack.network.v2._proxy.Proxy.find_flavor - .. automethod:: openstack.network.v2._proxy.Proxy.flavors - -Service Profile Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_service_profile - .. automethod:: openstack.network.v2._proxy.Proxy.update_service_profile - .. automethod:: openstack.network.v2._proxy.Proxy.delete_service_profile - .. automethod:: openstack.network.v2._proxy.Proxy.get_service_profile - .. automethod:: openstack.network.v2._proxy.Proxy.find_service_profile - .. automethod:: openstack.network.v2._proxy.Proxy.service_profiles - - .. automethod:: openstack.network.v2._proxy.Proxy.associate_flavor_with_service_profile - .. automethod:: openstack.network.v2._proxy.Proxy.disassociate_flavor_from_service_profile - -Tag Operations -^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.set_tags - -VPN Operations -^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.create_vpn_service - .. automethod:: openstack.network.v2._proxy.Proxy.update_vpn_service - .. automethod:: openstack.network.v2._proxy.Proxy.delete_vpn_service - .. automethod:: openstack.network.v2._proxy.Proxy.get_vpn_service - .. automethod:: openstack.network.v2._proxy.Proxy.find_vpn_service - .. automethod:: openstack.network.v2._proxy.Proxy.vpn_services - -Extension Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.find_extension - .. automethod:: openstack.network.v2._proxy.Proxy.extensions - -Service Provider Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.network.v2._proxy.Proxy - - .. automethod:: openstack.network.v2._proxy.Proxy.service_providers diff --git a/doc/source/users/proxies/object_store.rst b/doc/source/users/proxies/object_store.rst deleted file mode 100644 index db685e4b..00000000 --- a/doc/source/users/proxies/object_store.rst +++ /dev/null @@ -1,50 +0,0 @@ -Object Store API -================ - -For details on how to use this API, see :doc:`/users/guides/object_store` - -.. automodule:: openstack.object_store.v1._proxy - -The Object Store Class ----------------------- - -The Object Store high-level interface is exposed as the ``object_store`` -object on :class:`~openstack.connection.Connection` objects. - -Account Operations -^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.object_store.v1._proxy.Proxy - - .. automethod:: openstack.object_store.v1._proxy.Proxy.get_account_metadata - .. automethod:: openstack.object_store.v1._proxy.Proxy.set_account_metadata - .. automethod:: openstack.object_store.v1._proxy.Proxy.delete_account_metadata - -Container Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.object_store.v1._proxy.Proxy - - .. automethod:: openstack.object_store.v1._proxy.Proxy.create_container - .. automethod:: openstack.object_store.v1._proxy.Proxy.delete_container - .. automethod:: openstack.object_store.v1._proxy.Proxy.containers - - .. automethod:: openstack.object_store.v1._proxy.Proxy.get_container_metadata - .. automethod:: openstack.object_store.v1._proxy.Proxy.set_container_metadata - .. automethod:: openstack.object_store.v1._proxy.Proxy.delete_container_metadata - -Object Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.object_store.v1._proxy.Proxy - - .. automethod:: openstack.object_store.v1._proxy.Proxy.upload_object - .. automethod:: openstack.object_store.v1._proxy.Proxy.download_object - .. automethod:: openstack.object_store.v1._proxy.Proxy.copy_object - .. automethod:: openstack.object_store.v1._proxy.Proxy.delete_object - .. automethod:: openstack.object_store.v1._proxy.Proxy.get_object - .. automethod:: openstack.object_store.v1._proxy.Proxy.objects - - .. automethod:: openstack.object_store.v1._proxy.Proxy.get_object_metadata - .. automethod:: openstack.object_store.v1._proxy.Proxy.set_object_metadata - .. automethod:: openstack.object_store.v1._proxy.Proxy.delete_object_metadata diff --git a/doc/source/users/proxies/orchestration.rst b/doc/source/users/proxies/orchestration.rst deleted file mode 100644 index e663e64e..00000000 --- a/doc/source/users/proxies/orchestration.rst +++ /dev/null @@ -1,53 +0,0 @@ -Orchestration API -================= - -For details on how to use orchestration, see :doc:`/users/guides/orchestration` - -.. automodule:: openstack.orchestration.v1._proxy - -The Orchestration Class ------------------------ - -The orchestration high-level interface is available through the -``orchestration`` member of a :class:`~openstack.connection.Connection` -object. The ``orchestration`` member will only be added if the service -is detected. - -Stack Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.orchestration.v1._proxy.Proxy - - .. automethod:: openstack.orchestration.v1._proxy.Proxy.create_stack - .. automethod:: openstack.orchestration.v1._proxy.Proxy.check_stack - .. automethod:: openstack.orchestration.v1._proxy.Proxy.update_stack - .. automethod:: openstack.orchestration.v1._proxy.Proxy.delete_stack - .. automethod:: openstack.orchestration.v1._proxy.Proxy.find_stack - .. automethod:: openstack.orchestration.v1._proxy.Proxy.get_stack - .. automethod:: openstack.orchestration.v1._proxy.Proxy.get_stack_environment - .. automethod:: openstack.orchestration.v1._proxy.Proxy.get_stack_files - .. automethod:: openstack.orchestration.v1._proxy.Proxy.get_stack_template - .. automethod:: openstack.orchestration.v1._proxy.Proxy.stacks - .. automethod:: openstack.orchestration.v1._proxy.Proxy.validate_template - .. automethod:: openstack.orchestration.v1._proxy.Proxy.resources - -Software Configuration Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.orchestration.v1._proxy.Proxy - - .. automethod:: openstack.orchestration.v1._proxy.Proxy.create_software_config - .. automethod:: openstack.orchestration.v1._proxy.Proxy.delete_software_config - .. automethod:: openstack.orchestration.v1._proxy.Proxy.get_software_config - .. automethod:: openstack.orchestration.v1._proxy.Proxy.software_configs - -Software Deployment Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.orchestration.v1._proxy.Proxy - - .. automethod:: openstack.orchestration.v1._proxy.Proxy.create_software_deployment - .. automethod:: openstack.orchestration.v1._proxy.Proxy.update_software_deployment - .. automethod:: openstack.orchestration.v1._proxy.Proxy.delete_software_deployment - .. automethod:: openstack.orchestration.v1._proxy.Proxy.get_software_deployment - .. automethod:: openstack.orchestration.v1._proxy.Proxy.software_deployments diff --git a/doc/source/users/proxies/telemetry.rst b/doc/source/users/proxies/telemetry.rst deleted file mode 100644 index fc29a13a..00000000 --- a/doc/source/users/proxies/telemetry.rst +++ /dev/null @@ -1,85 +0,0 @@ -Telemetry API -============= - -.. caution:: - BETA: This API is a work in progress and is subject to change. - -For details on how to use telemetry, see :doc:`/users/guides/telemetry` - -.. automodule:: openstack.telemetry.v2._proxy - -The Telemetry Class -------------------- - -The telemetry high-level interface is available through the ``telemetry`` -member of a :class:`~openstack.connection.Connection` object. The -``telemetry`` member will only be added if the service is detected. - -Sample Operations -^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.telemetry.v2._proxy.Proxy - - .. automethod:: openstack.telemetry.v2._proxy.Proxy.find_sample - .. automethod:: openstack.telemetry.v2._proxy.Proxy.samples - -Statistic Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.telemetry.v2._proxy.Proxy - - .. automethod:: openstack.telemetry.v2._proxy.Proxy.find_statistics - .. automethod:: openstack.telemetry.v2._proxy.Proxy.statistics - -Resource Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.telemetry.v2._proxy.Proxy - - .. automethod:: openstack.telemetry.v2._proxy.Proxy.get_resource - .. automethod:: openstack.telemetry.v2._proxy.Proxy.find_resource - .. automethod:: openstack.telemetry.v2._proxy.Proxy.resources - -Meter Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.telemetry.v2._proxy.Proxy - - .. automethod:: openstack.telemetry.v2._proxy.Proxy.find_meter - .. automethod:: openstack.telemetry.v2._proxy.Proxy.meters - -Capability Operations -^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.telemetry.v2._proxy.Proxy - - .. automethod:: openstack.telemetry.v2._proxy.Proxy.find_capability - .. automethod:: openstack.telemetry.v2._proxy.Proxy.capabilities - -The Alarm Class ---------------- - -The alarm high-level interface is available through the ``telemetry.alarm`` -member of a :class:`~openstack.connection.Connection` object. The -``telemetry.alarm`` member will only be added if the service is detected. - -Alarm Operations -^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.telemetry.alarm.v2._proxy.Proxy - - .. automethod:: openstack.telemetry.alarm.v2._proxy.Proxy.create_alarm - .. automethod:: openstack.telemetry.alarm.v2._proxy.Proxy.update_alarm - .. automethod:: openstack.telemetry.alarm.v2._proxy.Proxy.delete_alarm - .. automethod:: openstack.telemetry.alarm.v2._proxy.Proxy.get_alarm - .. automethod:: openstack.telemetry.alarm.v2._proxy.Proxy.find_alarm - .. automethod:: openstack.telemetry.alarm.v2._proxy.Proxy.alarms - - -Alarm Change Operations -^^^^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.telemetry.alarm.v2._proxy.Proxy - - .. automethod:: openstack.telemetry.alarm.v2._proxy.Proxy.find_alarm_change - .. automethod:: openstack.telemetry.alarm.v2._proxy.Proxy.alarm_changes diff --git a/doc/source/users/proxies/workflow.rst b/doc/source/users/proxies/workflow.rst deleted file mode 100644 index 429d6d7a..00000000 --- a/doc/source/users/proxies/workflow.rst +++ /dev/null @@ -1,33 +0,0 @@ -Workflow API -============ - -.. automodule:: openstack.workflow.v2._proxy - -The Workflow Class ------------------- - -The workflow high-level interface is available through the ``workflow`` -member of a :class:`~openstack.connection.Connection` object. -The ``workflow`` member will only be added if the service is detected. - -Workflow Operations -^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.workflow.v2._proxy.Proxy - - .. automethod:: openstack.workflow.v2._proxy.Proxy.create_workflow - .. automethod:: openstack.workflow.v2._proxy.Proxy.delete_workflow - .. automethod:: openstack.workflow.v2._proxy.Proxy.get_workflow - .. automethod:: openstack.workflow.v2._proxy.Proxy.find_workflow - .. automethod:: openstack.workflow.v2._proxy.Proxy.workflows - -Execution Operations -^^^^^^^^^^^^^^^^^^^^ - -.. autoclass:: openstack.workflow.v2._proxy.Proxy - - .. automethod:: openstack.workflow.v2._proxy.Proxy.create_execution - .. automethod:: openstack.workflow.v2._proxy.Proxy.delete_execution - .. automethod:: openstack.workflow.v2._proxy.Proxy.get_execution - .. automethod:: openstack.workflow.v2._proxy.Proxy.find_execution - .. automethod:: openstack.workflow.v2._proxy.Proxy.executions diff --git a/doc/source/users/resource.rst b/doc/source/users/resource.rst deleted file mode 100644 index f40188e1..00000000 --- a/doc/source/users/resource.rst +++ /dev/null @@ -1,39 +0,0 @@ -**NOTE: This module is being phased out in favor of** -:mod:`openstack.resource2`. **Once all services have been moved over to use -resource2, that module will take this `resource` name.** - -Resource -======== -.. automodule:: openstack.resource - -The prop class --------------- - -.. autoclass:: openstack.resource.prop - :members: - -The Resource class ------------------- - -.. autoclass:: openstack.resource.Resource - :members: - :member-order: bysource - -How path_args are used -********************** - -As :class:`Resource`\s often contain compound :data:`Resource.base_path`\s, -meaning the path is constructed from more than just that string, the -various request methods need a way to fill in the missing parts. -That's where ``path_args`` come in. - -For example:: - - class ServerIP(resource.Resource): - base_path = "/servers/%(server_id)s/ips" - -Making a GET request to obtain server IPs requires the ID of the server -to check. This is handled by passing ``{"server_id": "12345"}`` as the -``path_args`` argument when calling :meth:`Resource.get_by_id`. From there, -the method uses Python's string interpolation to fill in the ``server_id`` -piece of the URL, and then makes the request. diff --git a/doc/source/users/resource2.rst b/doc/source/users/resource2.rst deleted file mode 100644 index bc664213..00000000 --- a/doc/source/users/resource2.rst +++ /dev/null @@ -1,26 +0,0 @@ -**Note: This class is in the process of being applied as the new base class -for resources around the OpenStack SDK. Once that has been completed, -this module will be drop the 2 suffix and be the only resource module.** - -Resource -======== -.. automodule:: openstack.resource2 - -Components ----------- - -.. autoclass:: openstack.resource2.Body - :members: - -.. autoclass:: openstack.resource2.Header - :members: - -.. autoclass:: openstack.resource2.URI - :members: - -The Resource class ------------------- - -.. autoclass:: openstack.resource2.Resource - :members: - :member-order: bysource diff --git a/doc/source/users/resources/bare_metal/index.rst b/doc/source/users/resources/bare_metal/index.rst deleted file mode 100644 index 348a6e4f..00000000 --- a/doc/source/users/resources/bare_metal/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -Bare Metal Resources -===================== - -.. toctree:: - :maxdepth: 1 - - v1/driver - v1/chassis - v1/node - v1/port - v1/port_group diff --git a/doc/source/users/resources/bare_metal/v1/chassis.rst b/doc/source/users/resources/bare_metal/v1/chassis.rst deleted file mode 100644 index 30389637..00000000 --- a/doc/source/users/resources/bare_metal/v1/chassis.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.bare_metal.v1.chassis -=============================== - -.. automodule:: openstack.bare_metal.v1.chassis - -The Chassis Class ------------------ - -The ``Chassis`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.bare_metal.v1.chassis.Chassis - :members: diff --git a/doc/source/users/resources/bare_metal/v1/driver.rst b/doc/source/users/resources/bare_metal/v1/driver.rst deleted file mode 100644 index d45379e3..00000000 --- a/doc/source/users/resources/bare_metal/v1/driver.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.bare_metal.v1.driver -============================== - -.. automodule:: openstack.bare_metal.v1.driver - -The Driver Class ----------------- - -The ``Driver`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.bare_metal.v1.driver.Driver - :members: diff --git a/doc/source/users/resources/bare_metal/v1/node.rst b/doc/source/users/resources/bare_metal/v1/node.rst deleted file mode 100644 index 7900c559..00000000 --- a/doc/source/users/resources/bare_metal/v1/node.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.bare_metal.v1.Node -============================ - -.. automodule:: openstack.bare_metal.v1.node - -The Node Class --------------- - -The ``Node`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.bare_metal.v1.node.Node - :members: diff --git a/doc/source/users/resources/bare_metal/v1/port.rst b/doc/source/users/resources/bare_metal/v1/port.rst deleted file mode 100644 index b0ed31b4..00000000 --- a/doc/source/users/resources/bare_metal/v1/port.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.bare_metal.v1.port -============================ - -.. automodule:: openstack.bare_metal.v1.port - -The Port Class --------------- - -The ``Port`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.bare_metal.v1.port.Port - :members: diff --git a/doc/source/users/resources/bare_metal/v1/port_group.rst b/doc/source/users/resources/bare_metal/v1/port_group.rst deleted file mode 100644 index 3feb4e2f..00000000 --- a/doc/source/users/resources/bare_metal/v1/port_group.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.bare_metal.v1.port_group -================================== - -.. automodule:: openstack.bare_metal.v1.port_group - -The PortGroup Class -------------------- - -The ``PortGroup`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.bare_metal.v1.port_group.PortGroup - :members: diff --git a/doc/source/users/resources/block_store/index.rst b/doc/source/users/resources/block_store/index.rst deleted file mode 100644 index ba0be3c1..00000000 --- a/doc/source/users/resources/block_store/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Block Store Resources -===================== - -.. toctree:: - :maxdepth: 1 - - v2/snapshot - v2/type - v2/volume diff --git a/doc/source/users/resources/block_store/v2/snapshot.rst b/doc/source/users/resources/block_store/v2/snapshot.rst deleted file mode 100644 index e742ffcf..00000000 --- a/doc/source/users/resources/block_store/v2/snapshot.rst +++ /dev/null @@ -1,21 +0,0 @@ -openstack.block_store.v2.snapshot -================================= - -.. automodule:: openstack.block_store.v2.snapshot - -The Snapshot Class ------------------- - -The ``Snapshot`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.block_store.v2.snapshot.Snapshot - :members: - -The SnapshotDetail Class ------------------------- - -The ``SnapshotDetail`` class inherits from -:class:`~openstack.block_store.v2.snapshot.Snapshot`. - -.. autoclass:: openstack.block_store.v2.snapshot.SnapshotDetail - :members: diff --git a/doc/source/users/resources/block_store/v2/type.rst b/doc/source/users/resources/block_store/v2/type.rst deleted file mode 100644 index fcab77fe..00000000 --- a/doc/source/users/resources/block_store/v2/type.rst +++ /dev/null @@ -1,13 +0,0 @@ -openstack.block_store.v2.type -============================= - -.. automodule:: openstack.block_store.v2.type - -The Type Class --------------- - -The ``Type`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.block_store.v2.type.Type - :members: - diff --git a/doc/source/users/resources/block_store/v2/volume.rst b/doc/source/users/resources/block_store/v2/volume.rst deleted file mode 100644 index 11545253..00000000 --- a/doc/source/users/resources/block_store/v2/volume.rst +++ /dev/null @@ -1,21 +0,0 @@ -openstack.block_store.v2.volume -=============================== - -.. automodule:: openstack.block_store.v2.volume - -The Volume Class ----------------- - -The ``Volume`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.block_store.v2.volume.Volume - :members: - -The VolumeDetail Class ----------------------- - -The ``VolumeDetail`` class inherits from -:class:`~openstack.block_store.v2.volume.Volume`. - -.. autoclass:: openstack.block_store.v2.volume.VolumeDetail - :members: diff --git a/doc/source/users/resources/cluster/index.rst b/doc/source/users/resources/cluster/index.rst deleted file mode 100644 index 8ec0a432..00000000 --- a/doc/source/users/resources/cluster/index.rst +++ /dev/null @@ -1,17 +0,0 @@ -Cluster Resources -================= - -.. toctree:: - :maxdepth: 1 - - v1/build_info - v1/profile_type - v1/profile - v1/policy_type - v1/policy - v1/cluster - v1/node - v1/cluster_policy - v1/receiver - v1/action - v1/event diff --git a/doc/source/users/resources/cluster/v1/action.rst b/doc/source/users/resources/cluster/v1/action.rst deleted file mode 100644 index f75deb42..00000000 --- a/doc/source/users/resources/cluster/v1/action.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.action -=========================== - -.. automodule:: openstack.cluster.v1.action - -The Action Class ----------------- - -The ``Action`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.action.Action - :members: diff --git a/doc/source/users/resources/cluster/v1/build_info.rst b/doc/source/users/resources/cluster/v1/build_info.rst deleted file mode 100644 index 8534e1f7..00000000 --- a/doc/source/users/resources/cluster/v1/build_info.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.build_info -=============================== - -.. automodule:: openstack.cluster.v1.build_info - -The BuildInfo Class -------------------- - -The ``BuildInfo`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.build_info.BuildInfo - :members: diff --git a/doc/source/users/resources/cluster/v1/cluster.rst b/doc/source/users/resources/cluster/v1/cluster.rst deleted file mode 100644 index a54ce6cf..00000000 --- a/doc/source/users/resources/cluster/v1/cluster.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.Cluster -============================ - -.. automodule:: openstack.cluster.v1.cluster - -The Cluster Class ------------------ - -The ``Cluster`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.cluster.Cluster - :members: diff --git a/doc/source/users/resources/cluster/v1/cluster_policy.rst b/doc/source/users/resources/cluster/v1/cluster_policy.rst deleted file mode 100644 index d3a55d54..00000000 --- a/doc/source/users/resources/cluster/v1/cluster_policy.rst +++ /dev/null @@ -1,13 +0,0 @@ -openstack.cluster.v1.cluster_policy -=================================== - -.. automodule:: openstack.cluster.v1.cluster_policy - -The ClusterPolicy Class ------------------------ - -The ``ClusterPolicy`` class inherits from -:class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.cluster_policy.ClusterPolicy - :members: diff --git a/doc/source/users/resources/cluster/v1/event.rst b/doc/source/users/resources/cluster/v1/event.rst deleted file mode 100644 index 29678062..00000000 --- a/doc/source/users/resources/cluster/v1/event.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.event -========================== - -.. automodule:: openstack.cluster.v1.event - -The Event Class ---------------- - -The ``Event`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.event.Event - :members: diff --git a/doc/source/users/resources/cluster/v1/node.rst b/doc/source/users/resources/cluster/v1/node.rst deleted file mode 100644 index 74f11f35..00000000 --- a/doc/source/users/resources/cluster/v1/node.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.Node -========================= - -.. automodule:: openstack.cluster.v1.node - -The Node Class --------------- - -The ``Node`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.node.Node - :members: diff --git a/doc/source/users/resources/cluster/v1/policy.rst b/doc/source/users/resources/cluster/v1/policy.rst deleted file mode 100644 index 0fe59378..00000000 --- a/doc/source/users/resources/cluster/v1/policy.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.policy -=========================== - -.. automodule:: openstack.cluster.v1.policy - -The Policy Class ----------------- - -The ``Policy`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.policy.Policy - :members: diff --git a/doc/source/users/resources/cluster/v1/policy_type.rst b/doc/source/users/resources/cluster/v1/policy_type.rst deleted file mode 100644 index ee74b310..00000000 --- a/doc/source/users/resources/cluster/v1/policy_type.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.policy_type -================================ - -.. automodule:: openstack.cluster.v1.policy_type - -The PolicyType Class --------------------- - -The ``PolicyType`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.policy_type.PolicyType - :members: diff --git a/doc/source/users/resources/cluster/v1/profile.rst b/doc/source/users/resources/cluster/v1/profile.rst deleted file mode 100644 index bdf782dc..00000000 --- a/doc/source/users/resources/cluster/v1/profile.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.profile -============================ - -.. automodule:: openstack.cluster.v1.profile - -The Profile Class ------------------ - -The ``Profile`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.profile.Profile - :members: diff --git a/doc/source/users/resources/cluster/v1/profile_type.rst b/doc/source/users/resources/cluster/v1/profile_type.rst deleted file mode 100644 index 48c007f0..00000000 --- a/doc/source/users/resources/cluster/v1/profile_type.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.profile_type -================================= - -.. automodule:: openstack.cluster.v1.profile_type - -The ProfileType Class ---------------------- - -The ``ProfileType`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.profile_type.ProfileType - :members: diff --git a/doc/source/users/resources/cluster/v1/receiver.rst b/doc/source/users/resources/cluster/v1/receiver.rst deleted file mode 100644 index 8d757d55..00000000 --- a/doc/source/users/resources/cluster/v1/receiver.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.cluster.v1.receiver -============================= - -.. automodule:: openstack.cluster.v1.receiver - -The Reciever Class ------------------- - -The ``Reciever`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.cluster.v1.receiver.Receiver - :members: diff --git a/doc/source/users/resources/compute/index.rst b/doc/source/users/resources/compute/index.rst deleted file mode 100644 index f597c7d8..00000000 --- a/doc/source/users/resources/compute/index.rst +++ /dev/null @@ -1,14 +0,0 @@ -Compute Resources -================= - -.. toctree:: - :maxdepth: 1 - - v2/extension - v2/flavor - v2/image - v2/keypair - v2/limits - v2/server - v2/server_interface - v2/server_ip diff --git a/doc/source/users/resources/compute/v2/extension.rst b/doc/source/users/resources/compute/v2/extension.rst deleted file mode 100644 index 8d6c6089..00000000 --- a/doc/source/users/resources/compute/v2/extension.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.compute.v2.extension -============================== - -.. automodule:: openstack.compute.v2.extension - -The Extension Class -------------------- - -The ``Extension`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.extension.Extension - :members: diff --git a/doc/source/users/resources/compute/v2/flavor.rst b/doc/source/users/resources/compute/v2/flavor.rst deleted file mode 100644 index 9f62f96f..00000000 --- a/doc/source/users/resources/compute/v2/flavor.rst +++ /dev/null @@ -1,21 +0,0 @@ -openstack.compute.v2.flavor -============================ - -.. automodule:: openstack.compute.v2.flavor - -The Flavor Class ----------------- - -The ``Flavor`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.flavor.Flavor - :members: - -The FlavorDetail Class ----------------------- - -The ``FlavorDetail`` class inherits from -:class:`~openstack.compute.v2.flavor.Flavor`. - -.. autoclass:: openstack.compute.v2.flavor.FlavorDetail - :members: diff --git a/doc/source/users/resources/compute/v2/image.rst b/doc/source/users/resources/compute/v2/image.rst deleted file mode 100644 index d3900653..00000000 --- a/doc/source/users/resources/compute/v2/image.rst +++ /dev/null @@ -1,21 +0,0 @@ -openstack.compute.v2.image -========================== - -.. automodule:: openstack.compute.v2.image - -The Image Class ---------------- - -The ``Image`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.image.Image - :members: - -The ImageDetail Class ---------------------- - -The ``ImageDetail`` class inherits from -:class:`~openstack.compute.v2.image.Image`. - -.. autoclass:: openstack.compute.v2.image.ImageDetail - :members: diff --git a/doc/source/users/resources/compute/v2/keypair.rst b/doc/source/users/resources/compute/v2/keypair.rst deleted file mode 100644 index cd2f3696..00000000 --- a/doc/source/users/resources/compute/v2/keypair.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.compute.v2.keypair -============================ - -.. automodule:: openstack.compute.v2.keypair - -The Keypair Class ------------------ - -The ``Keypair`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.keypair.Keypair - :members: diff --git a/doc/source/users/resources/compute/v2/limits.rst b/doc/source/users/resources/compute/v2/limits.rst deleted file mode 100644 index 090988bb..00000000 --- a/doc/source/users/resources/compute/v2/limits.rst +++ /dev/null @@ -1,28 +0,0 @@ -openstack.compute.v2.limits -=========================== - -.. automodule:: openstack.compute.v2.limits - -The Limits Class ----------------- - -The ``Limits`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.limits.Limits - :members: - -The AbsoluteLimits Class ------------------------- - -The ``AbsoluteLimits`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.limits.AbsoluteLimits - :members: - -The RateLimit Class -------------------- - -The ``RateLimit`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.limits.RateLimit - :members: diff --git a/doc/source/users/resources/compute/v2/server.rst b/doc/source/users/resources/compute/v2/server.rst deleted file mode 100644 index 6f0ddbb7..00000000 --- a/doc/source/users/resources/compute/v2/server.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.compute.v2.server -============================ - -.. automodule:: openstack.compute.v2.server - -The Server Class ----------------- - -The ``Server`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.server.Server - :members: diff --git a/doc/source/users/resources/compute/v2/server_interface.rst b/doc/source/users/resources/compute/v2/server_interface.rst deleted file mode 100644 index e67d9964..00000000 --- a/doc/source/users/resources/compute/v2/server_interface.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.compute.v2.server_interface -===================================== - -.. automodule:: openstack.compute.v2.server_interface - -The ServerInterface Class -------------------------- - -The ``ServerInterface`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.server_interface.ServerInterface - :members: diff --git a/doc/source/users/resources/compute/v2/server_ip.rst b/doc/source/users/resources/compute/v2/server_ip.rst deleted file mode 100644 index cdd63dad..00000000 --- a/doc/source/users/resources/compute/v2/server_ip.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.compute.v2.server_ip -============================== - -.. automodule:: openstack.compute.v2.server_ip - -The ServerIP Class ------------------- - -The ``ServerIP`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.compute.v2.server_ip.ServerIP - :members: diff --git a/doc/source/users/resources/database/index.rst b/doc/source/users/resources/database/index.rst deleted file mode 100644 index 962aa081..00000000 --- a/doc/source/users/resources/database/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -Database Resources -====================== - -.. toctree:: - :maxdepth: 1 - - v1/database - v1/flavor - v1/instance - v1/user diff --git a/doc/source/users/resources/database/v1/database.rst b/doc/source/users/resources/database/v1/database.rst deleted file mode 100644 index 7148f211..00000000 --- a/doc/source/users/resources/database/v1/database.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.database.v1.database -============================== - -.. automodule:: openstack.database.v1.database - -The Database Class ------------------- - -The ``Database`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.database.v1.database.Database - :members: diff --git a/doc/source/users/resources/database/v1/flavor.rst b/doc/source/users/resources/database/v1/flavor.rst deleted file mode 100644 index 2318d803..00000000 --- a/doc/source/users/resources/database/v1/flavor.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.database.v1.flavor -============================ - -.. automodule:: openstack.database.v1.flavor - -The Flavor Class ----------------- - -The ``Flavor`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.database.v1.flavor.Flavor - :members: diff --git a/doc/source/users/resources/database/v1/instance.rst b/doc/source/users/resources/database/v1/instance.rst deleted file mode 100644 index e70be2fa..00000000 --- a/doc/source/users/resources/database/v1/instance.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.database.v1.instance -============================== - -.. automodule:: openstack.database.v1.instance - -The Instance Class ------------------- - -The ``Instance`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.database.v1.instance.Instance - :members: diff --git a/doc/source/users/resources/database/v1/user.rst b/doc/source/users/resources/database/v1/user.rst deleted file mode 100644 index 817f77e8..00000000 --- a/doc/source/users/resources/database/v1/user.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.database.v1.user -========================== - -.. automodule:: openstack.database.v1.user - -The User Class --------------- - -The ``User`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.database.v1.user.User - :members: diff --git a/doc/source/users/resources/identity/index.rst b/doc/source/users/resources/identity/index.rst deleted file mode 100644 index b536e8b7..00000000 --- a/doc/source/users/resources/identity/index.rst +++ /dev/null @@ -1,26 +0,0 @@ -Identity v2 Resources -===================== - -.. toctree:: - :maxdepth: 1 - - v2/extension - v2/role - v2/tenant - v2/user - -Identity v3 Resources -===================== - -.. toctree:: - :maxdepth: 1 - - v3/credential - v3/domain - v3/endpoint - v3/group - v3/policy - v3/project - v3/service - v3/trust - v3/user diff --git a/doc/source/users/resources/identity/v2/extension.rst b/doc/source/users/resources/identity/v2/extension.rst deleted file mode 100644 index 53f5136b..00000000 --- a/doc/source/users/resources/identity/v2/extension.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v2.extension -=============================== - -.. automodule:: openstack.identity.v2.extension - -The Extension Class -------------------- - -The ``Extension`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v2.extension.Extension - :members: diff --git a/doc/source/users/resources/identity/v2/role.rst b/doc/source/users/resources/identity/v2/role.rst deleted file mode 100644 index f818ffc9..00000000 --- a/doc/source/users/resources/identity/v2/role.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v2.role -========================== - -.. automodule:: openstack.identity.v2.role - -The Role Class --------------- - -The ``Role`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v2.role.Role - :members: diff --git a/doc/source/users/resources/identity/v2/tenant.rst b/doc/source/users/resources/identity/v2/tenant.rst deleted file mode 100644 index a7abcc65..00000000 --- a/doc/source/users/resources/identity/v2/tenant.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v2.tenant -============================ - -.. automodule:: openstack.identity.v2.tenant - -The Tenant Class ----------------- - -The ``Tenant`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v2.tenant.Tenant - :members: diff --git a/doc/source/users/resources/identity/v2/user.rst b/doc/source/users/resources/identity/v2/user.rst deleted file mode 100644 index d9fdd37d..00000000 --- a/doc/source/users/resources/identity/v2/user.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v2.user -========================== - -.. automodule:: openstack.identity.v2.user - -The User Class --------------- - -The ``User`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v2.user.User - :members: diff --git a/doc/source/users/resources/identity/v3/credential.rst b/doc/source/users/resources/identity/v3/credential.rst deleted file mode 100644 index dabc9afd..00000000 --- a/doc/source/users/resources/identity/v3/credential.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v3.credential -================================ - -.. automodule:: openstack.identity.v3.credential - -The Credential Class --------------------- - -The ``Credential`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v3.credential.Credential - :members: diff --git a/doc/source/users/resources/identity/v3/domain.rst b/doc/source/users/resources/identity/v3/domain.rst deleted file mode 100644 index bf7d109f..00000000 --- a/doc/source/users/resources/identity/v3/domain.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v3.domain -============================ - -.. automodule:: openstack.identity.v3.domain - -The Domain Class ----------------- - -The ``Domain`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v3.domain.Domain - :members: diff --git a/doc/source/users/resources/identity/v3/endpoint.rst b/doc/source/users/resources/identity/v3/endpoint.rst deleted file mode 100644 index 366113d8..00000000 --- a/doc/source/users/resources/identity/v3/endpoint.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v3.endpoint -============================== - -.. automodule:: openstack.identity.v3.endpoint - -The Endpoint Class ------------------- - -The ``Endpoint`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v3.endpoint.Endpoint - :members: diff --git a/doc/source/users/resources/identity/v3/group.rst b/doc/source/users/resources/identity/v3/group.rst deleted file mode 100644 index fe6c4462..00000000 --- a/doc/source/users/resources/identity/v3/group.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v3.group -=========================== - -.. automodule:: openstack.identity.v3.group - -The Group Class ---------------- - -The ``Group`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v3.group.Group - :members: diff --git a/doc/source/users/resources/identity/v3/policy.rst b/doc/source/users/resources/identity/v3/policy.rst deleted file mode 100644 index 2506b112..00000000 --- a/doc/source/users/resources/identity/v3/policy.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v3.policy -============================ - -.. automodule:: openstack.identity.v3.policy - -The Policy Class ----------------- - -The ``Policy`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v3.policy.Policy - :members: diff --git a/doc/source/users/resources/identity/v3/project.rst b/doc/source/users/resources/identity/v3/project.rst deleted file mode 100644 index db8c8546..00000000 --- a/doc/source/users/resources/identity/v3/project.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v3.project -============================= - -.. automodule:: openstack.identity.v3.project - -The Project Class ------------------ - -The ``Project`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v3.project.Project - :members: diff --git a/doc/source/users/resources/identity/v3/service.rst b/doc/source/users/resources/identity/v3/service.rst deleted file mode 100644 index 02585f5f..00000000 --- a/doc/source/users/resources/identity/v3/service.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v3.service -============================= - -.. automodule:: openstack.identity.v3.service - -The Service Class ------------------ - -The ``Service`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v3.service.Service - :members: diff --git a/doc/source/users/resources/identity/v3/trust.rst b/doc/source/users/resources/identity/v3/trust.rst deleted file mode 100644 index fdb945ee..00000000 --- a/doc/source/users/resources/identity/v3/trust.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v3.trust -=========================== - -.. automodule:: openstack.identity.v3.trust - -The Trust Class ---------------- - -The ``Trust`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v3.trust.Trust - :members: diff --git a/doc/source/users/resources/identity/v3/user.rst b/doc/source/users/resources/identity/v3/user.rst deleted file mode 100644 index 6ba7ae3f..00000000 --- a/doc/source/users/resources/identity/v3/user.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.identity.v3.user -========================== - -.. automodule:: openstack.identity.v3.user - -The User Class --------------- - -The ``User`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.identity.v3.user.User - :members: diff --git a/doc/source/users/resources/image/index.rst b/doc/source/users/resources/image/index.rst deleted file mode 100644 index 2696ab1e..00000000 --- a/doc/source/users/resources/image/index.rst +++ /dev/null @@ -1,16 +0,0 @@ -Image v1 Resources -================== - -.. toctree:: - :maxdepth: 1 - - v1/image - -Image v2 Resources -================== - -.. toctree:: - :maxdepth: 1 - - v2/image - v2/member diff --git a/doc/source/users/resources/image/v1/image.rst b/doc/source/users/resources/image/v1/image.rst deleted file mode 100644 index 7f5dffd8..00000000 --- a/doc/source/users/resources/image/v1/image.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.image.v1.image -======================== - -.. automodule:: openstack.image.v1.image - -The Image Class ---------------- - -The ``Image`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.image.v1.image.Image - :members: diff --git a/doc/source/users/resources/image/v2/image.rst b/doc/source/users/resources/image/v2/image.rst deleted file mode 100644 index 5d51cba1..00000000 --- a/doc/source/users/resources/image/v2/image.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.image.v2.image -======================== - -.. automodule:: openstack.image.v2.image - -The Image Class ---------------- - -The ``Image`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.image.v2.image.Image - :members: diff --git a/doc/source/users/resources/image/v2/member.rst b/doc/source/users/resources/image/v2/member.rst deleted file mode 100644 index 03107fdc..00000000 --- a/doc/source/users/resources/image/v2/member.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.image.v2.member -========================= - -.. automodule:: openstack.image.v2.member - -The Member Class ----------------- - -The ``Member`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.image.v2.member.Member - :members: diff --git a/doc/source/users/resources/key_manager/index.rst b/doc/source/users/resources/key_manager/index.rst deleted file mode 100644 index 76b6659c..00000000 --- a/doc/source/users/resources/key_manager/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -KeyManager Resources -==================== - -.. toctree:: - :maxdepth: 1 - - v1/container - v1/order - v1/secret diff --git a/doc/source/users/resources/key_manager/v1/container.rst b/doc/source/users/resources/key_manager/v1/container.rst deleted file mode 100644 index ef09035d..00000000 --- a/doc/source/users/resources/key_manager/v1/container.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.key_manager.v1.container -===================================== - -.. automodule:: openstack.key_manager.v1.container - -The Container Class -------------------- - -The ``Container`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.key_manager.v1.container.Container - :members: diff --git a/doc/source/users/resources/key_manager/v1/order.rst b/doc/source/users/resources/key_manager/v1/order.rst deleted file mode 100644 index 2f53627b..00000000 --- a/doc/source/users/resources/key_manager/v1/order.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.key_manager.v1.order -============================== - -.. automodule:: openstack.key_manager.v1.order - -The Order Class ---------------- - -The ``Order`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.key_manager.v1.order.Order - :members: diff --git a/doc/source/users/resources/key_manager/v1/secret.rst b/doc/source/users/resources/key_manager/v1/secret.rst deleted file mode 100644 index 8d0a56e7..00000000 --- a/doc/source/users/resources/key_manager/v1/secret.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.key_manager.v1.secret -=============================== - -.. automodule:: openstack.key_manager.v1.secret - -The Secret Class ----------------- - -The ``Secret`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.key_manager.v1.secret.Secret - :members: diff --git a/doc/source/users/resources/metric/index.rst b/doc/source/users/resources/metric/index.rst deleted file mode 100644 index 1bfa667d..00000000 --- a/doc/source/users/resources/metric/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -Metric Resources -================ - -.. toctree:: - :maxdepth: 1 - - v1/archive_policy - v1/capabilities - v1/metric - v1/resource diff --git a/doc/source/users/resources/metric/v1/archive_policy.rst b/doc/source/users/resources/metric/v1/archive_policy.rst deleted file mode 100644 index 903aaa4f..00000000 --- a/doc/source/users/resources/metric/v1/archive_policy.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.metric.v1.archive_policy -================================== - -.. automodule:: openstack.metric.v1.archive_policy - -The ArchivePolicy Class ------------------------ - -The ``ArchivePolicy`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.metric.v1.archive_policy.ArchivePolicy - :members: diff --git a/doc/source/users/resources/metric/v1/capabilities.rst b/doc/source/users/resources/metric/v1/capabilities.rst deleted file mode 100644 index 571d460f..00000000 --- a/doc/source/users/resources/metric/v1/capabilities.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.metric.v1.capabilities -================================ - -.. automodule:: openstack.metric.v1.capabilities - -The Capabilities Class ----------------------- - -The ``Capabilities`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.metric.v1.capabilities.Capabilities - :members: diff --git a/doc/source/users/resources/metric/v1/metric.rst b/doc/source/users/resources/metric/v1/metric.rst deleted file mode 100644 index 4c4feb5b..00000000 --- a/doc/source/users/resources/metric/v1/metric.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.metric.v1.metric -========================== - -.. automodule:: openstack.metric.v1.metric - -The Metric Class ----------------- - -The ``Metric`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.metric.v1.metric.Metric - :members: diff --git a/doc/source/users/resources/metric/v1/resource.rst b/doc/source/users/resources/metric/v1/resource.rst deleted file mode 100644 index 748fb47c..00000000 --- a/doc/source/users/resources/metric/v1/resource.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.metric.v1.resource -============================ - -.. automodule:: openstack.metric.v1.resource - -The Generic Class ------------------ - -The ``Generic`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.metric.v1.resource.Generic - :members: diff --git a/doc/source/users/resources/network/index.rst b/doc/source/users/resources/network/index.rst deleted file mode 100644 index 21da8cf9..00000000 --- a/doc/source/users/resources/network/index.rst +++ /dev/null @@ -1,38 +0,0 @@ -Network Resources -================= - -.. toctree:: - :maxdepth: 1 - - v2/address_scope - v2/agent - v2/auto_allocated_topology - v2/availability_zone - v2/extension - v2/flavor - v2/floating_ip - v2/health_monitor - v2/listener - v2/load_balancer - v2/metering_label - v2/metering_label_rule - v2/network - v2/network_ip_availability - v2/pool - v2/pool_member - v2/port - v2/qos_bandwidth_limit_rule - v2/qos_dscp_marking_rule - v2/qos_minimum_bandwidth_rule - v2/qos_policy - v2/qos_rule_type - v2/quota - v2/rbac_policy - v2/router - v2/security_group - v2/security_group_rule - v2/segment - v2/service_profile - v2/service_provider - v2/subnet - v2/subnet_pool diff --git a/doc/source/users/resources/network/v2/address_scope.rst b/doc/source/users/resources/network/v2/address_scope.rst deleted file mode 100644 index 6b8274ab..00000000 --- a/doc/source/users/resources/network/v2/address_scope.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.address_scope -================================== - -.. automodule:: openstack.network.v2.address_scope - -The AddressScope Class ----------------------- - -The ``AddressScope`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.address_scope.AddressScope - :members: diff --git a/doc/source/users/resources/network/v2/agent.rst b/doc/source/users/resources/network/v2/agent.rst deleted file mode 100644 index 1d99337d..00000000 --- a/doc/source/users/resources/network/v2/agent.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.agent -========================== - -.. automodule:: openstack.network.v2.agent - -The Agent Class ------------------ - -The ``Agent`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.agent.Agent - :members: diff --git a/doc/source/users/resources/network/v2/auto_allocated_topology.rst b/doc/source/users/resources/network/v2/auto_allocated_topology.rst deleted file mode 100644 index f27241c5..00000000 --- a/doc/source/users/resources/network/v2/auto_allocated_topology.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.auto_allocated_topology -============================================ - -.. automodule:: openstack.network.v2.auto_allocated_topology - -The Auto Allocated Topology Class ---------------------------------- - -The ``Auto Allocated Toplogy`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.auto_allocated_topology.AutoAllocatedTopology - :members: diff --git a/doc/source/users/resources/network/v2/availability_zone.rst b/doc/source/users/resources/network/v2/availability_zone.rst deleted file mode 100644 index a33f2b65..00000000 --- a/doc/source/users/resources/network/v2/availability_zone.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.availability_zone -====================================== - -.. automodule:: openstack.network.v2.availability_zone - -The AvailabilityZone Class --------------------------- - -The ``AvailabilityZone`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.availability_zone.AvailabilityZone - :members: diff --git a/doc/source/users/resources/network/v2/extension.rst b/doc/source/users/resources/network/v2/extension.rst deleted file mode 100644 index c5ff15ec..00000000 --- a/doc/source/users/resources/network/v2/extension.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.extension -============================== - -.. automodule:: openstack.network.v2.extension - -The Extension Class -------------------- - -The ``Extension`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.extension.Extension - :members: diff --git a/doc/source/users/resources/network/v2/flavor.rst b/doc/source/users/resources/network/v2/flavor.rst deleted file mode 100644 index 8810a9cc..00000000 --- a/doc/source/users/resources/network/v2/flavor.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.flavor -=========================== - -.. automodule:: openstack.network.v2.flavor - -The Flavor Class ----------------- - -The ``Flavor`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.flavor.Flavor - :members: diff --git a/doc/source/users/resources/network/v2/floating_ip.rst b/doc/source/users/resources/network/v2/floating_ip.rst deleted file mode 100644 index 2badbcec..00000000 --- a/doc/source/users/resources/network/v2/floating_ip.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.floating_ip -================================ - -.. automodule:: openstack.network.v2.floating_ip - -The FloatingIP Class --------------------- - -The ``FloatingIP`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.floating_ip.FloatingIP - :members: diff --git a/doc/source/users/resources/network/v2/health_monitor.rst b/doc/source/users/resources/network/v2/health_monitor.rst deleted file mode 100644 index 63a029cd..00000000 --- a/doc/source/users/resources/network/v2/health_monitor.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.health_monitor -=================================== - -.. automodule:: openstack.network.v2.health_monitor - -The HealthMonitor Class ------------------------ - -The ``HealthMonitor`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.health_monitor.HealthMonitor - :members: diff --git a/doc/source/users/resources/network/v2/listener.rst b/doc/source/users/resources/network/v2/listener.rst deleted file mode 100644 index a9fa4824..00000000 --- a/doc/source/users/resources/network/v2/listener.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.listener -============================= - -.. automodule:: openstack.network.v2.listener - -The Listener Class ------------------- - -The ``Listener`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.listener.Listener - :members: diff --git a/doc/source/users/resources/network/v2/load_balancer.rst b/doc/source/users/resources/network/v2/load_balancer.rst deleted file mode 100644 index 61695820..00000000 --- a/doc/source/users/resources/network/v2/load_balancer.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.load_balancer -================================== - -.. automodule:: openstack.network.v2.load_balancer - -The LoadBalancer Class ----------------------- - -The ``LoadBalancer`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.load_balancer.LoadBalancer - :members: diff --git a/doc/source/users/resources/network/v2/metering_label.rst b/doc/source/users/resources/network/v2/metering_label.rst deleted file mode 100644 index dacb3801..00000000 --- a/doc/source/users/resources/network/v2/metering_label.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.metering_label -=================================== - -.. automodule:: openstack.network.v2.metering_label - -The MeteringLabel Class ------------------------ - -The ``MeteringLabel`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.metering_label.MeteringLabel - :members: diff --git a/doc/source/users/resources/network/v2/metering_label_rule.rst b/doc/source/users/resources/network/v2/metering_label_rule.rst deleted file mode 100644 index 39088493..00000000 --- a/doc/source/users/resources/network/v2/metering_label_rule.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.metering_label_rule -======================================== - -.. automodule:: openstack.network.v2.metering_label_rule - -The MeteringLabelRule Class ---------------------------- - -The ``MeteringLabelRule`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.metering_label_rule.MeteringLabelRule - :members: diff --git a/doc/source/users/resources/network/v2/network.rst b/doc/source/users/resources/network/v2/network.rst deleted file mode 100644 index 8c6f6f27..00000000 --- a/doc/source/users/resources/network/v2/network.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.network -============================ - -.. automodule:: openstack.network.v2.network - -The Network Class ------------------ - -The ``Network`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.network.Network - :members: diff --git a/doc/source/users/resources/network/v2/network_ip_availability.rst b/doc/source/users/resources/network/v2/network_ip_availability.rst deleted file mode 100644 index 3cbbd9f2..00000000 --- a/doc/source/users/resources/network/v2/network_ip_availability.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.network_ip_availability -============================================ - -.. automodule:: openstack.network.v2.network_ip_availability - -The NetworkIPAvailability Class -------------------------------- - -The ``NetworkIPAvailability`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.network_ip_availability.NetworkIPAvailability - :members: diff --git a/doc/source/users/resources/network/v2/pool.rst b/doc/source/users/resources/network/v2/pool.rst deleted file mode 100644 index 6b94a701..00000000 --- a/doc/source/users/resources/network/v2/pool.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.pool -========================= - -.. automodule:: openstack.network.v2.pool - -The Pool Class --------------- - -The ``Pool`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.pool.Pool - :members: diff --git a/doc/source/users/resources/network/v2/pool_member.rst b/doc/source/users/resources/network/v2/pool_member.rst deleted file mode 100644 index ce80a1da..00000000 --- a/doc/source/users/resources/network/v2/pool_member.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.pool_member -================================ - -.. automodule:: openstack.network.v2.pool_member - -The PoolMember Class --------------------- - -The ``PoolMember`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.pool_member.PoolMember - :members: diff --git a/doc/source/users/resources/network/v2/port.rst b/doc/source/users/resources/network/v2/port.rst deleted file mode 100644 index b592d361..00000000 --- a/doc/source/users/resources/network/v2/port.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.port -========================= - -.. automodule:: openstack.network.v2.port - -The Port Class --------------- - -The ``Port`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.port.Port - :members: diff --git a/doc/source/users/resources/network/v2/qos_bandwidth_limit_rule.rst b/doc/source/users/resources/network/v2/qos_bandwidth_limit_rule.rst deleted file mode 100644 index 115a55de..00000000 --- a/doc/source/users/resources/network/v2/qos_bandwidth_limit_rule.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.qos_bandwidth_limit_rule -============================================= - -.. automodule:: openstack.network.v2.qos_bandwidth_limit_rule - -The QoSBandwidthLimitRule Class -------------------------------- - -The ``QoSBandwidthLimitRule`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.qos_bandwidth_limit_rule.QoSBandwidthLimitRule - :members: diff --git a/doc/source/users/resources/network/v2/qos_dscp_marking_rule.rst b/doc/source/users/resources/network/v2/qos_dscp_marking_rule.rst deleted file mode 100644 index 6d2cf9a4..00000000 --- a/doc/source/users/resources/network/v2/qos_dscp_marking_rule.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.qos_dscp_marking_rule -========================================== - -.. automodule:: openstack.network.v2.qos_dscp_marking_rule - -The QoSDSCPMarkingRule Class ----------------------------- - -The ``QoSDSCPMarkingRule`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.qos_dscp_marking_rule.QoSDSCPMarkingRule - :members: diff --git a/doc/source/users/resources/network/v2/qos_minimum_bandwidth_rule.rst b/doc/source/users/resources/network/v2/qos_minimum_bandwidth_rule.rst deleted file mode 100644 index 6ba004b4..00000000 --- a/doc/source/users/resources/network/v2/qos_minimum_bandwidth_rule.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.qos_minimum_bandwidth_rule -=============================================== - -.. automodule:: openstack.network.v2.qos_minimum_bandwidth_rule - -The QoSMinimumBandwidthRule Class ---------------------------------- - -The ``QoSMinimumBandwidthRule`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule - :members: diff --git a/doc/source/users/resources/network/v2/qos_policy.rst b/doc/source/users/resources/network/v2/qos_policy.rst deleted file mode 100644 index edffe5ce..00000000 --- a/doc/source/users/resources/network/v2/qos_policy.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.qos_policy -=============================== - -.. automodule:: openstack.network.v2.qos_policy - -The QoSPolicy Class -------------------- - -The ``QoSPolicy`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.qos_policy.QoSPolicy - :members: diff --git a/doc/source/users/resources/network/v2/qos_rule_type.rst b/doc/source/users/resources/network/v2/qos_rule_type.rst deleted file mode 100644 index 6d5ed5a8..00000000 --- a/doc/source/users/resources/network/v2/qos_rule_type.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.qos_rule_type -================================== - -.. automodule:: openstack.network.v2.qos_rule_type - -The QoSRuleType Class ---------------------- - -The ``QoSRuleType`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.qos_rule_type.QoSRuleType - :members: diff --git a/doc/source/users/resources/network/v2/quota.rst b/doc/source/users/resources/network/v2/quota.rst deleted file mode 100644 index e1507205..00000000 --- a/doc/source/users/resources/network/v2/quota.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.quota -========================== - -.. automodule:: openstack.network.v2.quota - -The Quota Class ---------------- - -The ``Quota`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.quota.Quota - :members: diff --git a/doc/source/users/resources/network/v2/rbac_policy.rst b/doc/source/users/resources/network/v2/rbac_policy.rst deleted file mode 100644 index daf76007..00000000 --- a/doc/source/users/resources/network/v2/rbac_policy.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.rbac_policy -================================ - -.. automodule:: openstack.network.v2.rbac_policy - -The RBACPolicy Class --------------------- - -The ``RBACPolicy`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.rbac_policy.RBACPolicy - :members: \ No newline at end of file diff --git a/doc/source/users/resources/network/v2/router.rst b/doc/source/users/resources/network/v2/router.rst deleted file mode 100644 index 83126d40..00000000 --- a/doc/source/users/resources/network/v2/router.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.router -=========================== - -.. automodule:: openstack.network.v2.router - -The Router Class ----------------- - -The ``Router`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.router.Router - :members: diff --git a/doc/source/users/resources/network/v2/security_group.rst b/doc/source/users/resources/network/v2/security_group.rst deleted file mode 100644 index 5d478843..00000000 --- a/doc/source/users/resources/network/v2/security_group.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.security_group -=================================== - -.. automodule:: openstack.network.v2.security_group - -The SecurityGroup Class ------------------------ - -The ``SecurityGroup`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.security_group.SecurityGroup - :members: diff --git a/doc/source/users/resources/network/v2/security_group_rule.rst b/doc/source/users/resources/network/v2/security_group_rule.rst deleted file mode 100644 index 24572005..00000000 --- a/doc/source/users/resources/network/v2/security_group_rule.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.security_group_rule -======================================== - -.. automodule:: openstack.network.v2.security_group_rule - -The SecurityGroupRule Class ---------------------------- - -The ``SecurityGroupRule`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.security_group_rule.SecurityGroupRule - :members: diff --git a/doc/source/users/resources/network/v2/segment.rst b/doc/source/users/resources/network/v2/segment.rst deleted file mode 100644 index 2e652b8a..00000000 --- a/doc/source/users/resources/network/v2/segment.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.segment -============================ - -.. automodule:: openstack.network.v2.segment - -The Segment Class ------------------ - -The ``Segment`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.segment.Segment - :members: diff --git a/doc/source/users/resources/network/v2/service_profile.rst b/doc/source/users/resources/network/v2/service_profile.rst deleted file mode 100644 index c1c01302..00000000 --- a/doc/source/users/resources/network/v2/service_profile.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.service_profile -==================================== - -.. automodule:: openstack.network.v2.service_profile - -The ServiceProfile Class ------------------------- - -The ``ServiceProfile`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.service_profile.ServiceProfile - :members: diff --git a/doc/source/users/resources/network/v2/service_provider.rst b/doc/source/users/resources/network/v2/service_provider.rst deleted file mode 100644 index e9d66784..00000000 --- a/doc/source/users/resources/network/v2/service_provider.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.service_provider -===================================== - -.. automodule:: openstack.network.v2.service_provider - -The Service Provider Class --------------------------- - -The ``Service Provider`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.service_provider.ServiceProvider - :members: diff --git a/doc/source/users/resources/network/v2/subnet.rst b/doc/source/users/resources/network/v2/subnet.rst deleted file mode 100644 index 16a6d277..00000000 --- a/doc/source/users/resources/network/v2/subnet.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.subnet -=========================== - -.. automodule:: openstack.network.v2.subnet - -The Subnet Class ----------------- - -The ``Subnet`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.subnet.Subnet - :members: diff --git a/doc/source/users/resources/network/v2/subnet_pool.rst b/doc/source/users/resources/network/v2/subnet_pool.rst deleted file mode 100644 index 14bf753f..00000000 --- a/doc/source/users/resources/network/v2/subnet_pool.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.network.v2.subnet_pool -================================ - -.. automodule:: openstack.network.v2.subnet_pool - -The SubnetPool Class --------------------- - -The ``SubnetPool`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.network.v2.subnet_pool.SubnetPool - :members: diff --git a/doc/source/users/resources/object_store/index.rst b/doc/source/users/resources/object_store/index.rst deleted file mode 100644 index e5524e34..00000000 --- a/doc/source/users/resources/object_store/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Object Store Resources -====================== - -.. toctree:: - :maxdepth: 1 - - v1/account - v1/container - v1/obj diff --git a/doc/source/users/resources/object_store/v1/account.rst b/doc/source/users/resources/object_store/v1/account.rst deleted file mode 100644 index 5236faea..00000000 --- a/doc/source/users/resources/object_store/v1/account.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.object_store.v1.account -================================= - -.. automodule:: openstack.object_store.v1.account - -The Account Class ------------------ - -The ``Account`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.object_store.v1.account.Account - :members: diff --git a/doc/source/users/resources/object_store/v1/container.rst b/doc/source/users/resources/object_store/v1/container.rst deleted file mode 100644 index 30491909..00000000 --- a/doc/source/users/resources/object_store/v1/container.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.object_store.v1.container -=================================== - -.. automodule:: openstack.object_store.v1.container - -The Container Class -------------------- - -The ``Container`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.object_store.v1.container.Container - :members: diff --git a/doc/source/users/resources/object_store/v1/obj.rst b/doc/source/users/resources/object_store/v1/obj.rst deleted file mode 100644 index 292cfc04..00000000 --- a/doc/source/users/resources/object_store/v1/obj.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.object_store.v1.obj -============================= - -.. automodule:: openstack.object_store.v1.obj - -The Object Class ----------------- - -The ``Object`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.object_store.v1.obj.Object - :members: diff --git a/doc/source/users/resources/orchestration/index.rst b/doc/source/users/resources/orchestration/index.rst deleted file mode 100644 index 0af426b4..00000000 --- a/doc/source/users/resources/orchestration/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -Orchestration Resources -======================= - -.. toctree:: - :maxdepth: 1 - - v1/stack - v1/resource diff --git a/doc/source/users/resources/orchestration/v1/resource.rst b/doc/source/users/resources/orchestration/v1/resource.rst deleted file mode 100644 index 7eb96a9a..00000000 --- a/doc/source/users/resources/orchestration/v1/resource.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.orchestration.v1.resource -=================================== - -.. automodule:: openstack.orchestration.v1.resource - -The Resource Class ------------------- - -The ``Resource`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.orchestration.v1.resource.Resource - :members: diff --git a/doc/source/users/resources/orchestration/v1/stack.rst b/doc/source/users/resources/orchestration/v1/stack.rst deleted file mode 100644 index 8dda6582..00000000 --- a/doc/source/users/resources/orchestration/v1/stack.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.orchestration.v1.stack -================================ - -.. automodule:: openstack.orchestration.v1.stack - -The Stack Class ---------------- - -The ``Stack`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.orchestration.v1.stack.Stack - :members: diff --git a/doc/source/users/resources/telemetry/index.rst b/doc/source/users/resources/telemetry/index.rst deleted file mode 100644 index b429949d..00000000 --- a/doc/source/users/resources/telemetry/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -Telemetry Resources -=================== - -.. toctree:: - :maxdepth: 1 - - v2/capability - v2/meter - v2/resource - v2/sample - v2/statistics diff --git a/doc/source/users/resources/telemetry/v2/capability.rst b/doc/source/users/resources/telemetry/v2/capability.rst deleted file mode 100644 index c17edd50..00000000 --- a/doc/source/users/resources/telemetry/v2/capability.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.telemetry.v2.capability -================================= - -.. automodule:: openstack.telemetry.v2.capability - -The Capability Class --------------------- - -The ``Capability`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.telemetry.v2.capability.Capability - :members: diff --git a/doc/source/users/resources/telemetry/v2/meter.rst b/doc/source/users/resources/telemetry/v2/meter.rst deleted file mode 100644 index b38bc5b6..00000000 --- a/doc/source/users/resources/telemetry/v2/meter.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.telemetry.v2.meter -============================ - -.. automodule:: openstack.telemetry.v2.meter - -The Meter Class ----------------- - -The ``Meter`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.telemetry.v2.meter.Meter - :members: diff --git a/doc/source/users/resources/telemetry/v2/resource.rst b/doc/source/users/resources/telemetry/v2/resource.rst deleted file mode 100644 index f3b33887..00000000 --- a/doc/source/users/resources/telemetry/v2/resource.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.telemetry.v2.resource -=============================== - -.. automodule:: openstack.telemetry.v2.resource - -The Resource Class ------------------- - -The ``Resource`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.telemetry.v2.resource.Resource - :members: diff --git a/doc/source/users/resources/telemetry/v2/sample.rst b/doc/source/users/resources/telemetry/v2/sample.rst deleted file mode 100644 index f2430df2..00000000 --- a/doc/source/users/resources/telemetry/v2/sample.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.telemetry.v2.sample -============================= - -.. automodule:: openstack.telemetry.v2.sample - -The Sample Class ----------------- - -The ``Sample`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.telemetry.v2.sample.Sample - :members: diff --git a/doc/source/users/resources/telemetry/v2/statistics.rst b/doc/source/users/resources/telemetry/v2/statistics.rst deleted file mode 100644 index 7e1e6b8a..00000000 --- a/doc/source/users/resources/telemetry/v2/statistics.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.telemetry.v2.statistics -================================= - -.. automodule:: openstack.telemetry.v2.statistics - -The Statistics Class --------------------- - -The ``Statistics`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.telemetry.v2.statistics.Statistics - :members: diff --git a/doc/source/users/resources/workflow/index.rst b/doc/source/users/resources/workflow/index.rst deleted file mode 100644 index 30221b15..00000000 --- a/doc/source/users/resources/workflow/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -Object Store Resources -====================== - -.. toctree:: - :maxdepth: 1 - - v2/execution - v2/workflow diff --git a/doc/source/users/resources/workflow/v2/execution.rst b/doc/source/users/resources/workflow/v2/execution.rst deleted file mode 100644 index 62ec283a..00000000 --- a/doc/source/users/resources/workflow/v2/execution.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.workflow.v2.execution -=============================== - -.. automodule:: openstack.workflow.v2.execution - -The Execution Class -------------------- - -The ``Execution`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.workflow.v2.execution.Execution - :members: diff --git a/doc/source/users/resources/workflow/v2/workflow.rst b/doc/source/users/resources/workflow/v2/workflow.rst deleted file mode 100644 index 8f8950e5..00000000 --- a/doc/source/users/resources/workflow/v2/workflow.rst +++ /dev/null @@ -1,12 +0,0 @@ -openstack.workflow.v2.workflow -============================== - -.. automodule:: openstack.workflow.v2.workflow - -The Workflow Class ------------------- - -The ``Workflow`` class inherits from :class:`~openstack.resource.Resource`. - -.. autoclass:: openstack.workflow.v2.workflow.Workflow - :members: diff --git a/doc/source/users/service_filter.rst b/doc/source/users/service_filter.rst deleted file mode 100644 index 60910ce6..00000000 --- a/doc/source/users/service_filter.rst +++ /dev/null @@ -1,10 +0,0 @@ -ServiceFilter -============== -.. automodule:: openstack.service_filter - - -ServiceFilter object --------------------- - -.. autoclass:: openstack.service_filter.ServiceFilter - :members: diff --git a/doc/source/users/session.rst b/doc/source/users/session.rst deleted file mode 100644 index 44ac576b..00000000 --- a/doc/source/users/session.rst +++ /dev/null @@ -1,10 +0,0 @@ -Session -======= - -.. automodule:: openstack.session - -Session Object --------------- - -.. autoclass:: openstack.session.Session - :members: diff --git a/doc/source/users/utils.rst b/doc/source/users/utils.rst deleted file mode 100644 index f69638e3..00000000 --- a/doc/source/users/utils.rst +++ /dev/null @@ -1,4 +0,0 @@ -Utilities -========= -.. automodule:: openstack.utils - :members: enable_logging diff --git a/docs-requirements.txt b/docs-requirements.txt deleted file mode 100644 index 94638119..00000000 --- a/docs-requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ --r requirements.txt --r test-requirements.txt diff --git a/examples/__init__.py b/examples/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/cluster/__init__.py b/examples/cluster/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/cluster/policy.py b/examples/cluster/policy.py deleted file mode 100644 index 0f37820d..00000000 --- a/examples/cluster/policy.py +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Managing policies in the Cluster service. - -For a full guide see -https://developer.openstack.org/sdks/python/openstacksdk/users/guides/cluster.html -""" - - -def list_policies(conn): - print("List Policies:") - - for policy in conn.cluster.policies(): - print(policy.to_dict()) - - for policy in conn.cluster.policies(sort='name:asc'): - print(policy.to_dict()) - - -def create_policy(conn): - print("Create Policy:") - - spec = { - 'policy': 'senlin.policy.deletion', - 'version': 1.0, - 'properties': { - 'criteria': 'oldest_first', - 'destroy_after_deletion': True, - } - } - - policy = conn.cluster.create_policy('dp01', spec) - print(policy.to_dict()) - - -def get_policy(conn): - print("Get Policy:") - - policy = conn.cluster.get_policy('dp01') - print(policy.to_dict()) - - -def find_policy(conn): - print("Find Policy:") - - policy = conn.cluster.find_policy('dp01') - print(policy.to_dict()) - - -def update_policy(conn): - print("Update Policy:") - - policy = conn.cluster.update_policy('dp01', name='dp02') - print(policy.to_dict()) - - -def delete_policy(conn): - print("Delete Policy:") - - conn.cluster.delete_policy('dp01') - - print("Policy deleted.") diff --git a/examples/cluster/policy_type.py b/examples/cluster/policy_type.py deleted file mode 100644 index 447ecf26..00000000 --- a/examples/cluster/policy_type.py +++ /dev/null @@ -1,33 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Managing policy types in the Cluster service. - -For a full guide see -https://developer.openstack.org/sdks/python/openstacksdk/users/guides/cluster.html -""" - - -def list_policy_types(conn): - print("List Policy Types:") - - for pt in conn.cluster.policy_types(): - print(pt.to_dict()) - - -def get_policy_type(conn): - print("Get Policy Type:") - - pt = conn.cluster.get_policy_type('senlin.policy.deletion-1.0') - - print(pt.to_dict()) diff --git a/examples/cluster/profile.py b/examples/cluster/profile.py deleted file mode 100644 index 0fad312c..00000000 --- a/examples/cluster/profile.py +++ /dev/null @@ -1,82 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from examples.connect import FLAVOR_NAME -from examples.connect import IMAGE_NAME -from examples.connect import NETWORK_NAME -from examples.connect import SERVER_NAME - -""" -Managing profiles in the Cluster service. - -For a full guide see -https://developer.openstack.org/sdks/python/openstacksdk/users/guides/cluster.html -""" - - -def list_profiles(conn): - print("List Profiles:") - - for profile in conn.cluster.profiles(): - print(profile.to_dict()) - - for profile in conn.cluster.profiles(sort='name:asc'): - print(profile.to_dict()) - - -def create_profile(conn): - print("Create Profile:") - - spec = { - 'profile': 'os.nova.server', - 'version': 1.0, - 'properties': { - 'name': SERVER_NAME, - 'flavor': FLAVOR_NAME, - 'image': IMAGE_NAME, - 'networks': { - 'network': NETWORK_NAME - } - } - } - - profile = conn.cluster.create_profile('os_server', spec) - print(profile.to_dict()) - - -def get_profile(conn): - print("Get Profile:") - - profile = conn.cluster.get_profile('os_server') - print(profile.to_dict()) - - -def find_profile(conn): - print("Find Profile:") - - profile = conn.cluster.find_profile('os_server') - print(profile.to_dict()) - - -def update_profile(conn): - print("Update Profile:") - - profile = conn.cluster.update_profile('os_server', name='old_server') - print(profile.to_dict()) - - -def delete_profile(conn): - print("Delete Profile:") - - conn.cluster.delete_profile('os_server') - - print("Profile deleted.") diff --git a/examples/cluster/profile_type.py b/examples/cluster/profile_type.py deleted file mode 100644 index 8a3e9955..00000000 --- a/examples/cluster/profile_type.py +++ /dev/null @@ -1,33 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Managing profile types in the Cluster service. - -For a full guide see -https://developer.openstack.org/sdks/python/openstacksdk/users/guides/cluster.html -""" - - -def list_profile_types(conn): - print("List Profile Types:") - - for pt in conn.cluster.profile_types(): - print(pt.to_dict()) - - -def get_profile_type(conn): - print("Get Profile Type:") - - pt = conn.cluster.get_profile_type('os.nova.server-1.0') - - print(pt.to_dict()) diff --git a/examples/compute/__init__.py b/examples/compute/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/compute/create.py b/examples/compute/create.py deleted file mode 100644 index c04d8981..00000000 --- a/examples/compute/create.py +++ /dev/null @@ -1,71 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import errno -import os - -from examples.connect import FLAVOR_NAME -from examples.connect import IMAGE_NAME -from examples.connect import KEYPAIR_NAME -from examples.connect import NETWORK_NAME -from examples.connect import PRIVATE_KEYPAIR_FILE -from examples.connect import SERVER_NAME -from examples.connect import SSH_DIR - -""" -Create resources with the Compute service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def create_keypair(conn): - keypair = conn.compute.find_keypair(KEYPAIR_NAME) - - if not keypair: - print("Create Key Pair:") - - keypair = conn.compute.create_keypair(name=KEYPAIR_NAME) - - print(keypair) - - try: - os.mkdir(SSH_DIR) - except OSError as e: - if e.errno != errno.EEXIST: - raise e - - with open(PRIVATE_KEYPAIR_FILE, 'w') as f: - f.write("%s" % keypair.private_key) - - os.chmod(PRIVATE_KEYPAIR_FILE, 0o400) - - return keypair - - -def create_server(conn): - print("Create Server:") - - image = conn.compute.find_image(IMAGE_NAME) - flavor = conn.compute.find_flavor(FLAVOR_NAME) - network = conn.network.find_network(NETWORK_NAME) - keypair = create_keypair(conn) - - server = conn.compute.create_server( - name=SERVER_NAME, image_id=image.id, flavor_id=flavor.id, - networks=[{"uuid": network.id}], key_name=keypair.name) - - server = conn.compute.wait_for_server(server) - - print("ssh -i {key} root@{ip}".format( - key=PRIVATE_KEYPAIR_FILE, - ip=server.access_ipv4)) diff --git a/examples/compute/delete.py b/examples/compute/delete.py deleted file mode 100644 index ba344314..00000000 --- a/examples/compute/delete.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import errno -import os - -from examples.connect import KEYPAIR_NAME -from examples.connect import PRIVATE_KEYPAIR_FILE -from examples.connect import SERVER_NAME - -""" -Delete resources with the Compute service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def delete_keypair(conn): - print("Delete Key Pair:") - - keypair = conn.compute.find_keypair(KEYPAIR_NAME) - - try: - os.remove(PRIVATE_KEYPAIR_FILE) - except OSError as e: - if e.errno != errno.ENOENT: - raise e - - print(keypair) - - conn.compute.delete_keypair(keypair) - - -def delete_server(conn): - print("Delete Server:") - - server = conn.compute.find_server(SERVER_NAME) - - print(server) - - conn.compute.delete_server(server) diff --git a/examples/compute/find.py b/examples/compute/find.py deleted file mode 100644 index b009df92..00000000 --- a/examples/compute/find.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import examples.connect - -""" -Find a resource from the Compute service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def find_image(conn): - print("Find Image:") - - image = conn.compute.find_image(examples.connect.IMAGE_NAME) - - print(image) - - return image - - -def find_flavor(conn): - print("Find Flavor:") - - flavor = conn.compute.find_flavor(examples.connect.FLAVOR_NAME) - - print(flavor) - - return flavor - - -def find_keypair(conn): - print("Find Keypair:") - - keypair = conn.compute.find_keypair(examples.connect.KEYPAIR_NAME) - - print(keypair) - - return keypair diff --git a/examples/compute/list.py b/examples/compute/list.py deleted file mode 100644 index 0886f881..00000000 --- a/examples/compute/list.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -List resources from the Compute service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def list_servers(conn): - print("List Servers:") - - for server in conn.compute.servers(): - print(server) - - -def list_images(conn): - print("List Images:") - - for image in conn.compute.images(): - print(image) - - -def list_flavors(conn): - print("List Flavors:") - - for flavor in conn.compute.flavors(): - print(flavor) - - -def list_keypairs(conn): - print("List Keypairs:") - - for keypair in conn.compute.keypairs(): - print(keypair) diff --git a/examples/connect.py b/examples/connect.py deleted file mode 100644 index 07216ae1..00000000 --- a/examples/connect.py +++ /dev/null @@ -1,95 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Connect to an OpenStack cloud. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - -import argparse -import os - -import os_client_config - -from openstack import connection -from openstack import profile -from openstack import utils -import sys - -utils.enable_logging(True, stream=sys.stdout) - -#: Defines the OpenStack Client Config (OCC) cloud key in your OCC config -#: file, typically in $HOME/.config/openstack/clouds.yaml. That configuration -#: will determine where the examples will be run and what resource defaults -#: will be used to run the examples. -TEST_CLOUD = os.getenv('OS_TEST_CLOUD', 'devstack-admin') - - -class Opts(object): - def __init__(self, cloud_name='devstack-admin', debug=False): - self.cloud = cloud_name - self.debug = debug - # Use identity v3 API for examples. - self.identity_api_version = '3' - - -def _get_resource_value(resource_key, default): - try: - return cloud.config['example'][resource_key] - except KeyError: - return default - -occ = os_client_config.OpenStackConfig() -cloud = occ.get_one_cloud(TEST_CLOUD) - -SERVER_NAME = 'openstacksdk-example' -IMAGE_NAME = _get_resource_value('image_name', 'cirros-0.3.5-x86_64-disk') -FLAVOR_NAME = _get_resource_value('flavor_name', 'm1.small') -NETWORK_NAME = _get_resource_value('network_name', 'private') -KEYPAIR_NAME = _get_resource_value('keypair_name', 'openstacksdk-example') -SSH_DIR = _get_resource_value( - 'ssh_dir', '{home}/.ssh'.format(home=os.path.expanduser("~"))) -PRIVATE_KEYPAIR_FILE = _get_resource_value( - 'private_keypair_file', '{ssh_dir}/id_rsa.{key}'.format( - ssh_dir=SSH_DIR, key=KEYPAIR_NAME)) - -EXAMPLE_IMAGE_NAME = 'openstacksdk-example-public-image' - - -def create_connection_from_config(): - opts = Opts(cloud_name=TEST_CLOUD) - occ = os_client_config.OpenStackConfig() - cloud = occ.get_one_cloud(opts.cloud) - return connection.from_config(cloud_config=cloud, options=opts) - - -def create_connection_from_args(): - parser = argparse.ArgumentParser() - config = os_client_config.OpenStackConfig() - config.register_argparse_arguments(parser, sys.argv[1:]) - args = parser.parse_args() - return connection.from_config(options=args) - - -def create_connection(auth_url, region, project_name, username, password): - prof = profile.Profile() - prof.set_region(profile.Profile.ALL, region) - - return connection.Connection( - profile=prof, - user_agent='examples', - auth_url=auth_url, - project_name=project_name, - username=username, - password=password - ) diff --git a/examples/identity/__init__.py b/examples/identity/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/identity/list.py b/examples/identity/list.py deleted file mode 100644 index fff73a50..00000000 --- a/examples/identity/list.py +++ /dev/null @@ -1,108 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -List resources from the Identity service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def list_users(conn): - print("List Users:") - - for user in conn.identity.users(): - print(user) - - -def list_credentials(conn): - print("List Credentials:") - - for credential in conn.identity.credentials(): - print(credential) - - -def list_projects(conn): - print("List Projects:") - - for project in conn.identity.projects(): - print(project) - - -def list_domains(conn): - print("List Domains:") - - for domain in conn.identity.domains(): - print(domain) - - -def list_groups(conn): - print("List Groups:") - - for group in conn.identity.groups(): - print(group) - - -def list_services(conn): - print("List Services:") - - for service in conn.identity.services(): - print(service) - - -def list_endpoints(conn): - print("List Endpoints:") - - for endpoint in conn.identity.endpoints(): - print(endpoint) - - -def list_regions(conn): - print("List Regions:") - - for region in conn.identity.regions(): - print(region) - - -def list_roles(conn): - print("List Roles:") - - for role in conn.identity.roles(): - print(role) - - -def list_role_domain_group_assignments(conn): - print("List Roles assignments for a group on domain:") - - for role in conn.identity.role_domain_group_assignments(): - print(role) - - -def list_role_domain_user_assignments(conn): - print("List Roles assignments for a user on domain:") - - for role in conn.identity.role_project_user_assignments(): - print(role) - - -def list_role_project_group_assignments(conn): - print("List Roles assignments for a group on project:") - - for role in conn.identity.role_project_group_assignments(): - print(role) - - -def list_role_project_user_assignments(conn): - print("List Roles assignments for a user on project:") - - for role in conn.identity.role_project_user_assignments(): - print(role) diff --git a/examples/image/__init__.py b/examples/image/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/image/create.py b/examples/image/create.py deleted file mode 100644 index 45b4bc7d..00000000 --- a/examples/image/create.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from examples.connect import EXAMPLE_IMAGE_NAME - -""" -Create resources with the Image service. - -For a full guide see -http://developer.openstack.org/sdks/python/openstacksdk/users/guides/image.html -""" - - -def upload_image(conn): - print("Upload Image:") - - # Load fake image data for the example. - data = 'This is fake image data.' - - # Build the image attributes and upload the image. - image_attrs = { - 'name': EXAMPLE_IMAGE_NAME, - 'data': data, - 'disk_format': 'raw', - 'container_format': 'bare', - 'visibility': 'public', - } - conn.image.upload_image(**image_attrs) diff --git a/examples/image/delete.py b/examples/image/delete.py deleted file mode 100644 index dc656036..00000000 --- a/examples/image/delete.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from examples.connect import EXAMPLE_IMAGE_NAME - -""" -Delete resources with the Image service. - -For a full guide see -http://developer.openstack.org/sdks/python/openstacksdk/users/guides/image.html -""" - - -def delete_image(conn): - print("Delete Image:") - - example_image = conn.image.find_image(EXAMPLE_IMAGE_NAME) - - conn.image.delete_image(example_image, ignore_missing=False) diff --git a/examples/image/download.py b/examples/image/download.py deleted file mode 100644 index 8b68dd6a..00000000 --- a/examples/image/download.py +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import hashlib - -""" -Download an image with the Image service. - -For a full guide see -http://developer.openstack.org/sdks/python/openstacksdk/users/guides/image.html -""" - - -def download_image_stream(conn): - print("Download Image via streaming:") - - # Find the image you would like to download. - image = conn.image.find_image("myimage") - - # As the actual download now takes place outside of the library - # and in your own code, you are now responsible for checking - # the integrity of the data. Create an MD5 has to be computed - # after all of the data has been consumed. - md5 = hashlib.md5() - - with open("myimage.qcow2", "wb") as local_image: - response = conn.image.download_image(image, stream=True) - - # Read only 1024 bytes of memory at a time until - # all of the image data has been consumed. - for chunk in response.iter_content(chunk_size=1024): - - # With each chunk, add it to the hash to be computed. - md5.update(chunk) - - local_image.write(chunk) - - # Now that you've consumed all of the data the response gave you, - # ensure that the checksums of what the server offered and - # what you downloaded are the same. - if response.headers["Content-MD5"] != md5.hexdigest(): - raise Exception("Checksum mismatch in downloaded content") - - -def download_image(conn): - print("Download Image:") - - # Find the image you would like to download. - image = conn.image.find_image("myimage") - - with open("myimage.qcow2", "w") as local_image: - response = conn.image.download_image(image) - - # Response will contain the entire contents of the Image. - local_image.write(response) diff --git a/examples/image/list.py b/examples/image/list.py deleted file mode 100644 index decb6e5d..00000000 --- a/examples/image/list.py +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -List resources from the Image service. - -For a full guide see -http://developer.openstack.org/sdks/python/openstacksdk/users/guides/image.html -""" - - -def list_images(conn): - print("List Images:") - - for image in conn.image.images(): - print(image) diff --git a/examples/key_manager/__init__.py b/examples/key_manager/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/key_manager/create.py b/examples/key_manager/create.py deleted file mode 100644 index c45e7dc2..00000000 --- a/examples/key_manager/create.py +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -List resources from the Key Manager service. -""" - - -def create_secret(conn): - print("Create a secret:") - - conn.key_manager.create_secret(name="My public key", - secret_type="public", - expiration="2020-02-28T23:59:59", - payload="ssh rsa...", - payload_content_type="text/plain") diff --git a/examples/key_manager/get.py b/examples/key_manager/get.py deleted file mode 100644 index 0025dd62..00000000 --- a/examples/key_manager/get.py +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -List resources from the Key Manager service. -""" - -s = None - - -def get_secret_payload(conn): - print("Get a secret's payload:") - - # Assuming you have an object `s` which you perhaps received from - # a conn.key_manager.secrets() call... - secret = conn.key_manager.get_secret(s.secret_id) - print(secret.payload) diff --git a/examples/key_manager/list.py b/examples/key_manager/list.py deleted file mode 100644 index b74e4df7..00000000 --- a/examples/key_manager/list.py +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -List resources from the Key Manager service. -""" - - -def list_secrets(conn): - print("List Secrets:") - - for secret in conn.key_manager.secrets(): - print(secret) - - -def list_secrets_query(conn): - print("List Secrets:") - - for secret in conn.key_manager.secrets( - secret_type="symmetric", - expiration="gte:2020-01-01T00:00:00"): - print(secret) diff --git a/examples/network/__init__.py b/examples/network/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/network/create.py b/examples/network/create.py deleted file mode 100644 index f89387b8..00000000 --- a/examples/network/create.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Create resources with the Network service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def create_network(conn): - print("Create Network:") - - example_network = conn.network.create_network( - name='openstacksdk-example-project-network') - - print(example_network) - - example_subnet = conn.network.create_subnet( - name='openstacksdk-example-project-subnet', - network_id=example_network.id, - ip_version='4', - cidr='10.0.2.0/24', - gateway_ip='10.0.2.1') - - print(example_subnet) diff --git a/examples/network/delete.py b/examples/network/delete.py deleted file mode 100644 index 41e7a3bb..00000000 --- a/examples/network/delete.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Delete resources with the Network service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def delete_network(conn): - print("Delete Network:") - - example_network = conn.network.find_network( - 'openstacksdk-example-project-network') - - for example_subnet in example_network.subnet_ids: - conn.network.delete_subnet(example_subnet, ignore_missing=False) - conn.network.delete_network(example_network, ignore_missing=False) diff --git a/examples/network/find.py b/examples/network/find.py deleted file mode 100644 index 1d9005d1..00000000 --- a/examples/network/find.py +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import examples.connect - -""" -Find a resource from the Network service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def find_network(conn): - print("Find Network:") - - network = conn.network.find_network(examples.connect.NETWORK_NAME) - - print(network) - - return network diff --git a/examples/network/list.py b/examples/network/list.py deleted file mode 100644 index ff85e1c2..00000000 --- a/examples/network/list.py +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -List resources from the Network service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def list_networks(conn): - print("List Networks:") - - for network in conn.network.networks(): - print(network) - - -def list_subnets(conn): - print("List Subnets:") - - for subnet in conn.network.subnets(): - print(subnet) - - -def list_ports(conn): - print("List Ports:") - - for port in conn.network.ports(): - print(port) - - -def list_security_groups(conn): - print("List Security Groups:") - - for port in conn.network.security_groups(): - print(port) - - -def list_routers(conn): - print("List Routers:") - - for router in conn.network.routers(): - print(router) - - -def list_network_agents(conn): - print("List Network Agents:") - - for agent in conn.network.agents(): - print(agent) diff --git a/examples/network/security_group_rules.py b/examples/network/security_group_rules.py deleted file mode 100644 index b2cf42dd..00000000 --- a/examples/network/security_group_rules.py +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Create resources with the Network service. - -For a full guide see TODO(etoews):link to docs on developer.openstack.org -""" - - -def open_port(conn): - print("Open a port:") - - example_sec_group = conn.network.create_security_group( - name='openstacksdk-example-security-group') - - print(example_sec_group) - - example_rule = conn.network.create_security_group_rule( - security_group_id=example_sec_group.id, - direction='ingress', - remote_ip_prefix='0.0.0.0/0', - protocol='HTTPS', - port_range_max='443', - port_range_min='443', - ethertype='IPv4') - - print(example_rule) - - -def allow_ping(conn): - print("Allow pings:") - - example_sec_group = conn.network.create_security_group( - name='openstacksdk-example-security-group2') - - print(example_sec_group) - - example_rule = conn.network.create_security_group_rule( - security_group_id=example_sec_group.id, - direction='ingress', - remote_ip_prefix='0.0.0.0/0', - protocol='icmp', - port_range_max=None, - port_range_min=None, - ethertype='IPv4') - - print(example_rule) diff --git a/openstack/__init__.py b/openstack/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/bare_metal/__init__.py b/openstack/bare_metal/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/bare_metal/bare_metal_service.py b/openstack/bare_metal/bare_metal_service.py deleted file mode 100644 index 71c3bca5..00000000 --- a/openstack/bare_metal/bare_metal_service.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class BareMetalService(service_filter.ServiceFilter): - """The bare metal service.""" - - valid_versions = [service_filter.ValidVersion('v1')] - - def __init__(self, version=None): - """Create a bare metal service.""" - super(BareMetalService, self).__init__(service_type='baremetal', - version=version) diff --git a/openstack/bare_metal/v1/__init__.py b/openstack/bare_metal/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/bare_metal/v1/_proxy.py b/openstack/bare_metal/v1/_proxy.py deleted file mode 100644 index 0c3cccfb..00000000 --- a/openstack/bare_metal/v1/_proxy.py +++ /dev/null @@ -1,619 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.bare_metal.v1 import chassis as _chassis -from openstack.bare_metal.v1 import driver as _driver -from openstack.bare_metal.v1 import node as _node -from openstack.bare_metal.v1 import port as _port -from openstack.bare_metal.v1 import port_group as _portgroup -from openstack import proxy2 -from openstack import utils - - -class Proxy(proxy2.BaseProxy): - - def chassis(self, details=False, **query): - """Retrieve a generator of chassis. - - :param details: A boolean indicating whether the detailed information - for every chassis should be returned. - :param dict query: Optional query parameters to be sent to - restrict the chassis to be returned. Available parameters include: - - * ``fields``: A list containing one or more fields to be returned - in the response. This may lead to some performance gain - because other fields of the resource are not refreshed. - * ``limit``: Requests at most the specified number of items be - returned from the query. - * ``marker``: Specifies the ID of the last-seen chassis. Use the - ``limit`` parameter to make an initial limited request and - use the ID of the last-seen chassis from the response as - the ``marker`` value in a subsequent limited request. - * ``sort_dir``: Sorts the response by the requested sort direction. - A valid value is ``asc`` (ascending) or ``desc`` - (descending). Default is ``asc``. You can specify multiple - pairs of sort key and sort direction query parameters. If - you omit the sort direction in a pair, the API uses the - natural sorting direction of the server attribute that is - provided as the ``sort_key``. - * ``sort_key``: Sorts the response by the this attribute value. - Default is ``id``. You can specify multiple pairs of sort - key and sort direction query parameters. If you omit the - sort direction in a pair, the API uses the natural sorting - direction of the server attribute that is provided as the - ``sort_key``. - - :returns: A generator of chassis instances. - """ - cls = _chassis.ChassisDetail if details else _chassis.Chassis - return self._list(cls, paginated=True, **query) - - def create_chassis(self, **attrs): - """Create a new chassis from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.bare_metal.v1.chassis.Chassis`, it comprised - of the properties on the ``Chassis`` class. - - :returns: The results of chassis creation. - :rtype: :class:`~openstack.bare_metal.v1.chassis.Chassis`. - """ - return self._create(_chassis.Chassis, **attrs) - - def find_chassis(self, name_or_id, ignore_missing=True): - """Find a single chassis. - - :param str name_or_id: The name or ID of a chassis. - :param bool ignore_missing: When set to ``False``, an exception of - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the chassis does not exist. When set to `True``, None will - be returned when attempting to find a nonexistent chassis. - :returns: One :class:`~openstack.bare_metal.v1.chassis.Chassis` object - or None. - """ - return self._find(_chassis.Chassis, name_or_id, - ignore_missing=ignore_missing) - - def get_chassis(self, chassis): - """Get a specific chassis. - - :param chassis: The value can be the name or ID of a chassis or a - :class:`~openstack.bare_metal.v1.chassis.Chassis` instance. - - :returns: One :class:`~openstack.bare_metal.v1.chassis.Chassis` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - chassis matching the name or ID could be found. - """ - return self._get(_chassis.Chassis, chassis) - - def update_chassis(self, chassis, **attrs): - """Update a chassis. - - :param chassis: Either the name or the ID of a chassis, or an instance - of :class:`~openstack.bare_metal.v1.chassis.Chassis`. - :param dict attrs: The attributes to update on the chassis represented - by the ``chassis`` parameter. - - :returns: The updated chassis. - :rtype: :class:`~openstack.bare_metal.v1.chassis.Chassis` - """ - return self._update(_chassis.Chassis, chassis, **attrs) - - def delete_chassis(self, chassis, ignore_missing=True): - """Delete a chassis. - - :param chassis: The value can be either the name or ID of a chassis or - a :class:`~openstack.bare_metal.v1.chassis.Chassis` instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the chassis could not be found. When set to ``True``, no - exception will be raised when attempting to delete a non-existent - chassis. - - :returns: The instance of the chassis which was deleted. - :rtype: :class:`~openstack.bare_metal.v1.chassis.Chassis`. - """ - return self._delete(_chassis.Chassis, chassis, - ignore_missing=ignore_missing) - - def drivers(self): - """Retrieve a generator of drivers. - - :returns: A generator of driver instances. - """ - return self._list(_driver.Driver, paginated=False) - - def get_driver(self, driver): - """Get a specific driver. - - :param driver: The value can be the name of a driver or a - :class:`~openstack.bare_metal.v1.driver.Driver` instance. - - :returns: One :class:`~openstack.bare_metal.v1.driver.Driver` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - driver matching the name could be found. - """ - return self._get(_driver.Driver, driver) - - def nodes(self, details=False, **query): - """Retrieve a generator of nodes. - - :param details: A boolean indicating whether the detailed information - for every node should be returned. - :param dict query: Optional query parameters to be sent to restrict - the nodes returned. Available parameters include: - - * ``associated``: Only return those which are, or are not, - associated with an ``instance_id``. - * ``driver``: Only return those with the specified ``driver``. - * ``fields``: A list containing one or more fields to be returned - in the response. This may lead to some performance gain - because other fields of the resource are not refreshed. - * ``instance_id``: Only return the node with this specific instance - UUID or an empty set if not found. - * ``is_maintenance``: Only return those with ``maintenance`` set to - ``True`` or ``False``. - * ``limit``: Requests at most the specified number of nodes be - returned from the query. - * ``marker``: Specifies the ID of the last-seen node. Use the - ``limit`` parameter to make an initial limited request and - use the ID of the last-seen node from the response as - the ``marker`` value in a subsequent limited request. - * ``provision_state``: Only return those nodes with the specified - ``provision_state``. - * ``sort_dir``: Sorts the response by the requested sort direction. - A valid value is ``asc`` (ascending) or ``desc`` - (descending). Default is ``asc``. You can specify multiple - pairs of sort key and sort direction query parameters. If - you omit the sort direction in a pair, the API uses the - natural sorting direction of the server attribute that is - provided as the ``sort_key``. - * ``sort_key``: Sorts the response by the this attribute value. - Default is ``id``. You can specify multiple pairs of sort - key and sort direction query parameters. If you omit the - sort direction in a pair, the API uses the natural sorting - direction of the server attribute that is provided as the - ``sort_key``. - - :returns: A generator of node instances. - """ - cls = _node.NodeDetail if details else _node.Node - return self._list(cls, paginated=True, **query) - - def create_node(self, **attrs): - """Create a new node from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.bare_metal.v1.node.Node`, it comprised - of the properties on the ``Node`` class. - - :returns: The results of node creation. - :rtype: :class:`~openstack.bare_metal.v1.node.Node`. - """ - return self._create(_node.Node, **attrs) - - def find_node(self, name_or_id, ignore_missing=True): - """Find a single node. - - :param str name_or_id: The name or ID of a node. - :param bool ignore_missing: When set to ``False``, an exception of - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the node does not exist. When set to `True``, None will - be returned when attempting to find a nonexistent node. - :returns: One :class:`~openstack.bare_metal.v1.node.Node` object - or None. - """ - return self._find(_node.Node, name_or_id, - ignore_missing=ignore_missing) - - def get_node(self, node): - """Get a specific node. - - :param node: The value can be the name or ID of a chassis or a - :class:`~openstack.bare_metal.v1.node.Node` instance. - - :returns: One :class:`~openstack.bare_metal.v1.node.Node` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - node matching the name or ID could be found. - """ - return self._get(_node.Node, node) - - def update_node(self, node, **attrs): - """Update a node. - - :param chassis: Either the name or the ID of a node or an instance - of :class:`~openstack.bare_metal.v1.node.Node`. - :param dict attrs: The attributes to update on the node represented - by the ``node`` parameter. - - :returns: The updated node. - :rtype: :class:`~openstack.bare_metal.v1.node.Node` - """ - return self._update(_node.Node, node, **attrs) - - def delete_node(self, node, ignore_missing=True): - """Delete a node. - - :param node: The value can be either the name or ID of a node or - a :class:`~openstack.bare_metal.v1.node.Node` instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the node could not be found. When set to ``True``, no - exception will be raised when attempting to delete a non-existent - node. - - :returns: The instance of the node which was deleted. - :rtype: :class:`~openstack.bare_metal.v1.node.Node`. - """ - return self._delete(_node.Node, node, ignore_missing=ignore_missing) - - def ports(self, details=False, **query): - """Retrieve a generator of ports. - - :param details: A boolean indicating whether the detailed information - for every port should be returned. - :param dict query: Optional query parameters to be sent to restrict - the ports returned. Available parameters include: - - * ``address``: Only return ports with the specified physical - hardware address, typically a MAC address. - * ``driver``: Only return those with the specified ``driver``. - * ``fields``: A list containing one or more fields to be returned - in the response. This may lead to some performance gain - because other fields of the resource are not refreshed. - * ``limit``: Requests at most the specified number of ports be - returned from the query. - * ``marker``: Specifies the ID of the last-seen port. Use the - ``limit`` parameter to make an initial limited request and - use the ID of the last-seen port from the response as - the ``marker`` value in a subsequent limited request. - * ``node``:only return the ones associated with this specific node - (name or UUID), or an empty set if not found. - * ``node_id``:only return the ones associated with this specific - node UUID, or an empty set if not found. - * ``portgroup``: only return the ports associated with this - specific Portgroup (name or UUID), or an empty set if not - found. Added in API microversion 1.24. - * ``sort_dir``: Sorts the response by the requested sort direction. - A valid value is ``asc`` (ascending) or ``desc`` - (descending). Default is ``asc``. You can specify multiple - pairs of sort key and sort direction query parameters. If - you omit the sort direction in a pair, the API uses the - natural sorting direction of the server attribute that is - provided as the ``sort_key``. - * ``sort_key``: Sorts the response by the this attribute value. - Default is ``id``. You can specify multiple pairs of sort - key and sort direction query parameters. If you omit the - sort direction in a pair, the API uses the natural sorting - direction of the server attribute that is provided as the - ``sort_key``. - - :returns: A generator of port instances. - """ - cls = _port.PortDetail if details else _port.Port - return self._list(cls, paginated=True, **query) - - def create_port(self, **attrs): - """Create a new port from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.bare_metal.v1.port.Port`, it comprises of the - properties on the ``Port`` class. - - :returns: The results of port creation. - :rtype: :class:`~openstack.bare_metal.v1.port.Port`. - """ - return self._create(_port.Port, **attrs) - - def find_port(self, name_or_id, ignore_missing=True): - """Find a single port. - - :param str name_or_id: The name or ID of a port. - :param bool ignore_missing: When set to ``False``, an exception of - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the port does not exist. When set to `True``, None will - be returned when attempting to find a nonexistent port. - :returns: One :class:`~openstack.bare_metal.v1.port.Port` object - or None. - """ - return self._find(_port.Port, name_or_id, - ignore_missing=ignore_missing) - - def get_port(self, port, **query): - """Get a specific port. - - :param port: The value can be the name or ID of a chassis or a - :class:`~openstack.bare_metal.v1.port.Port` instance. - :param dict query: Optional query parameters to be sent to restrict - the port properties returned. Available parameters include: - - * ``fields``: A list containing one or more fields to be returned - in the response. This may lead to some performance gain - because other fields of the resource are not refreshed. - - :returns: One :class:`~openstack.bare_metal.v1.port.Port` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - port matching the name or ID could be found. - """ - return self._get(_port.Port, port, **query) - - def update_port(self, port, **attrs): - """Update a port. - - :param chassis: Either the name or the ID of a port or an instance - of :class:`~openstack.bare_metal.v1.port.Port`. - :param dict attrs: The attributes to update on the port represented - by the ``port`` parameter. - - :returns: The updated port. - :rtype: :class:`~openstack.bare_metal.v1.port.Port` - """ - return self._update(_port.Port, port, **attrs) - - def delete_port(self, port, ignore_missing=True): - """Delete a port. - - :param port: The value can be either the name or ID of a port or - a :class:`~openstack.bare_metal.v1.port.Port` instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the port could not be found. When set to ``True``, no - exception will be raised when attempting to delete a non-existent - port. - - :returns: The instance of the port which was deleted. - :rtype: :class:`~openstack.bare_metal.v1.port.Port`. - """ - return self._delete(_port.Port, port, ignore_missing=ignore_missing) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use port_groups instead") - def portgroups(self, details=False, **query): - """Retrieve a generator of port groups. - - :param details: A boolean indicating whether the detailed information - for every portgroup should be returned. - :param dict query: Optional query parameters to be sent to restrict - the portgroups returned. Available parameters include: - - * ``address``: Only return portgroups with the specified physical - hardware address, typically a MAC address. - * ``fields``: A list containing one or more fields to be returned - in the response. This may lead to some performance gain - because other fields of the resource are not refreshed. - * ``limit``: Requests at most the specified number of portgroups - returned from the query. - * ``marker``: Specifies the ID of the last-seen portgroup. Use the - ``limit`` parameter to make an initial limited request and - use the ID of the last-seen portgroup from the response as - the ``marker`` value in a subsequent limited request. - * ``node``:only return the ones associated with this specific node - (name or UUID), or an empty set if not found. - * ``sort_dir``: Sorts the response by the requested sort direction. - A valid value is ``asc`` (ascending) or ``desc`` - (descending). Default is ``asc``. You can specify multiple - pairs of sort key and sort direction query parameters. If - you omit the sort direction in a pair, the API uses the - natural sorting direction of the server attribute that is - provided as the ``sort_key``. - * ``sort_key``: Sorts the response by the this attribute value. - Default is ``id``. You can specify multiple pairs of sort - key and sort direction query parameters. If you omit the - sort direction in a pair, the API uses the natural sorting - direction of the server attribute that is provided as the - ``sort_key``. - - :returns: A generator of portgroup instances. - """ - return self.port_groups(details=details, **query) - - def port_groups(self, details=False, **query): - """Retrieve a generator of port groups. - - :param details: A boolean indicating whether the detailed information - for every port group should be returned. - :param dict query: Optional query parameters to be sent to restrict - the port groups returned. Available parameters include: - - * ``address``: Only return portgroups with the specified physical - hardware address, typically a MAC address. - * ``fields``: A list containing one or more fields to be returned - in the response. This may lead to some performance gain - because other fields of the resource are not refreshed. - * ``limit``: Requests at most the specified number of portgroups - returned from the query. - * ``marker``: Specifies the ID of the last-seen portgroup. Use the - ``limit`` parameter to make an initial limited request and - use the ID of the last-seen portgroup from the response as - the ``marker`` value in a subsequent limited request. - * ``node``:only return the ones associated with this specific node - (name or UUID), or an empty set if not found. - * ``sort_dir``: Sorts the response by the requested sort direction. - A valid value is ``asc`` (ascending) or ``desc`` - (descending). Default is ``asc``. You can specify multiple - pairs of sort key and sort direction query parameters. If - you omit the sort direction in a pair, the API uses the - natural sorting direction of the server attribute that is - provided as the ``sort_key``. - * ``sort_key``: Sorts the response by the this attribute value. - Default is ``id``. You can specify multiple pairs of sort - key and sort direction query parameters. If you omit the - sort direction in a pair, the API uses the natural sorting - direction of the server attribute that is provided as the - ``sort_key``. - - :returns: A generator of port group instances. - """ - cls = _portgroup.PortGroupDetail if details else _portgroup.PortGroup - return self._list(cls, paginated=True, **query) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use create_port_group instead") - def create_portgroup(self, **attrs): - """Create a new port group from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.bare_metal.v1.port_group.PortGroup`, it - comprises of the properties on the ``PortGroup`` class. - - :returns: The results of portgroup creation. - :rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`. - """ - return self.create_port_group(**attrs) - - def create_port_group(self, **attrs): - """Create a new portgroup from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.bare_metal.v1.port_group.PortGroup`, it - comprises of the properties on the ``PortGroup`` class. - - :returns: The results of portgroup creation. - :rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`. - """ - return self._create(_portgroup.PortGroup, **attrs) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use find_port_group instead") - def find_portgroup(self, name_or_id, ignore_missing=True): - """Find a single port group. - - :param str name_or_id: The name or ID of a portgroup. - :param bool ignore_missing: When set to ``False``, an exception of - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the port group does not exist. When set to `True``, None will - be returned when attempting to find a nonexistent port group. - :returns: One :class:`~openstack.bare_metal.v1.port_group.PortGroup` - object or None. - """ - return self.find_port_group(name_or_id, ignore_missing=ignore_missing) - - def find_port_group(self, name_or_id, ignore_missing=True): - """Find a single port group. - - :param str name_or_id: The name or ID of a portgroup. - :param bool ignore_missing: When set to ``False``, an exception of - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the port group does not exist. When set to `True``, None will - be returned when attempting to find a nonexistent port group. - :returns: One :class:`~openstack.bare_metal.v1.port_group.PortGroup` - object or None. - """ - return self._find(_portgroup.PortGroup, name_or_id, - ignore_missing=ignore_missing) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use get_port_group instead") - def get_portgroup(self, portgroup, **query): - """Get a specific port group. - - :param portgroup: The value can be the name or ID of a chassis or a - :class:`~openstack.bare_metal.v1.port_group.PortGroup` instance. - :param dict query: Optional query parameters to be sent to restrict - the portgroup properties returned. Available parameters include: - - * ``fields``: A list containing one or more fields to be returned - in the response. This may lead to some performance gain - because other fields of the resource are not refreshed. - - :returns: One :class:`~openstack.bare_metal.v1.port_group.PortGroup` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - port group matching the name or ID could be found. - """ - return self.get_port_group(portgroup, **query) - - def get_port_group(self, port_group, **query): - """Get a specific port group. - - :param port_group: The value can be the name or ID of a chassis or a - :class:`~openstack.bare_metal.v1.port_group.PortGroup` instance. - :param dict query: Optional query parameters to be sent to restrict - the port group properties returned. Available parameters include: - - * ``fields``: A list containing one or more fields to be returned - in the response. This may lead to some performance gain - because other fields of the resource are not refreshed. - - :returns: One :class:`~openstack.bare_metal.v1.port_group.PortGroup` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - port group matching the name or ID could be found. - """ - return self._get(_portgroup.PortGroup, port_group, **query) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use update_port_group instead") - def update_portgroup(self, portgroup, **attrs): - """Update a port group. - - :param chassis: Either the name or the ID of a port group or - an instance of - :class:`~openstack.bare_metal.v1.port_group.PortGroup`. - :param dict attrs: The attributes to update on the port group - represented by the ``portgroup`` parameter. - - :returns: The updated port group. - :rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup` - """ - return self.update_port_group(portgroup, **attrs) - - def update_port_group(self, port_group, **attrs): - """Update a port group. - - :param chassis: Either the name or the ID of a port group or - an instance of - :class:`~openstack.bare_metal.v1.port_group.PortGroup`. - :param dict attrs: The attributes to update on the port group - represented by the ``port_group`` parameter. - - :returns: The updated port group. - :rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup` - """ - return self._update(_portgroup.PortGroup, port_group, **attrs) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use delete_port_group instead") - def delete_portgroup(self, portgroup, ignore_missing=True): - """Delete a port group. - - :param portgroup: The value can be either the name or ID of a port - group or a - :class:`~openstack.bare_metal.v1.port_group.PortGroup` - instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the port group could not be found. When set to ``True``, no - exception will be raised when attempting to delete a non-existent - port group. - - :returns: The instance of the port group which was deleted. - :rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`. - """ - return self.delete_port_group(portgroup, ignore_missing=ignore_missing) - - def delete_port_group(self, port_group, ignore_missing=True): - """Delete a port group. - - :param port_group: The value can be either the name or ID of - a port group or a - :class:`~openstack.bare_metal.v1.port_group.PortGroup` - instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the port group could not be found. When set to ``True``, no - exception will be raised when attempting to delete a non-existent - port group. - - :returns: The instance of the port group which was deleted. - :rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`. - """ - return self._delete(_portgroup.PortGroup, port_group, - ignore_missing=ignore_missing) diff --git a/openstack/bare_metal/v1/chassis.py b/openstack/bare_metal/v1/chassis.py deleted file mode 100644 index 7440e2f4..00000000 --- a/openstack/bare_metal/v1/chassis.py +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.bare_metal import bare_metal_service -from openstack import resource2 as resource - - -class Chassis(resource.Resource): - - resources_key = 'chassis' - base_path = '/chassis' - service = bare_metal_service.BareMetalService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - _query_mapping = resource.QueryParameters( - 'fields' - ) - - #: Timestamp at which the chassis was created. - created_at = resource.Body('created_at') - #: A descriptive text about the service - description = resource.Body('description') - #: A set of one or more arbitrary metadata key and value pairs. - extra = resource.Body('extra') - #: The UUID for the chassis - id = resource.Body('uuid', alternate_id=True) - #: A list of relative links, including the self and bookmark links. - links = resource.Body('links', type=list) - #: Links to the collection of nodes contained in the chassis - nodes = resource.Body('nodes', type=list) - #: Timestamp at which the chassis was last updated. - updated_at = resource.Body('updated_at') - - -class ChassisDetail(Chassis): - - base_path = '/chassis/detail' - - # capabilities - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_list = True - - #: The UUID for the chassis - id = resource.Body('uuid', alternate_id=True) diff --git a/openstack/bare_metal/v1/driver.py b/openstack/bare_metal/v1/driver.py deleted file mode 100644 index fcf6229b..00000000 --- a/openstack/bare_metal/v1/driver.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.bare_metal import bare_metal_service -from openstack import resource2 as resource - - -class Driver(resource.Resource): - - resources_key = 'drivers' - base_path = '/drivers' - service = bare_metal_service.BareMetalService() - - # capabilities - allow_create = False - allow_get = True - allow_update = False - allow_delete = False - allow_list = True - - # NOTE: Query mapping? - - #: The name of the driver - name = resource.Body('name', alternate_id=True) - #: A list of active hosts that support this driver. - hosts = resource.Body('hosts', type=list) - #: A list of relative links, including the self and bookmark links. - links = resource.Body('links', type=list) - #: A list of links to driver properties. - properties = resource.Body('properties', type=list) diff --git a/openstack/bare_metal/v1/node.py b/openstack/bare_metal/v1/node.py deleted file mode 100644 index 8d920e66..00000000 --- a/openstack/bare_metal/v1/node.py +++ /dev/null @@ -1,135 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.bare_metal import bare_metal_service -from openstack import resource2 as resource - - -class Node(resource.Resource): - - resources_key = 'nodes' - base_path = '/nodes' - service = bare_metal_service.BareMetalService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - _query_mapping = resource.QueryParameters( - 'associated', 'driver', 'fields', 'provision_state', 'resource_class', - instance_id='instance_uuid', - is_maintenance='maintenance', - ) - - # Properties - #: The UUID of the chassis associated wit this node. Can be empty or None. - chassis_id = resource.Body("chassis_uuid") - #: The current clean step. - clean_step = resource.Body("clean_step") - #: Timestamp at which the node was last updated. - created_at = resource.Body("created_at") - #: The name of the driver. - driver = resource.Body("driver") - #: All the metadata required by the driver to manage this node. List of - #: fields varies between drivers, and can be retrieved from the - #: :class:`openstack.bare_metal.v1.driver.Driver` resource. - driver_info = resource.Body("driver_info", type=dict) - #: Internal metadata set and stored by node's driver. This is read-only. - driver_internal_info = resource.Body("driver_internal_info", type=dict) - #: A set of one or more arbitrary metadata key and value pairs. - extra = resource.Body("extra") - #: The UUID of the node resource. - id = resource.Body("uuid", alternate_id=True) - #: Information used to customize the deployed image, e.g. size of root - #: partition, config drive in the form of base64 encoded string and other - #: metadata. - instance_info = resource.Body("instance_info") - #: UUID of the nova instance associated with this node. - instance_id = resource.Body("instance_uuid") - #: Whether console access is enabled on this node. - is_console_enabled = resource.Body("console_enabled", type=bool) - #: Whether node is currently in "maintenance mode". Nodes put into - #: maintenance mode are removed from the available resource pool. - is_maintenance = resource.Body("maintenance", type=bool) - #: Any error from the most recent transaction that started but failed to - #: finish. - last_error = resource.Body("last_error") - #: A list of relative links, including self and bookmark links. - links = resource.Body("links", type=list) - #: user settable description of the reason why the node was placed into - #: maintenance mode. - maintenance_reason = resource.Body("maintenance_reason") - #: Human readable identifier for the node. May be undefined. Certain words - #: are reserved. Added in API microversion 1.5 - name = resource.Body("name") - #: Network interface provider to use when plumbing the network connections - #: for this node. Introduced in API microversion 1.20. - network_interface = resource.Body("network_interface") - #: Links to the collection of ports on this node. - ports = resource.Body("ports", type=list) - #: Links to the collection of portgroups on this node. Available since - #: API microversion 1.24. - port_groups = resource.Body("portgroups", type=list) - #: The current power state. Usually "power on" or "power off", but may be - #: "None" if service is unable to determine the power state. - power_state = resource.Body("power_state") - #: Physical characteristics of the node. Content populated by the service - #: during inspection. - properties = resource.Body("properties", type=dict) - #: The current provisioning state of the node. - provision_state = resource.Body("provision_state") - #: The current RAID configuration of the node. - raid_config = resource.Body("raid_config") - #: The name of an service conductor host which is holding a lock on this - #: node, if a lock is held. - reservation = resource.Body("reservation") - #: A string to be used by external schedulers to identify this node as a - #: unit of a specific type of resource. Added in API microversion 1.21. - resource_class = resource.Body("resource_class") - #: Links to the collection of states. - states = resource.Body("states", type=list) - #: The requested state if a provisioning action has been requested. For - #: example, ``AVAILABLE``, ``DEPLOYING``, ``DEPLOYWAIT``, ``DEPLOYING``, - #: ``ACTIVE`` etc. - target_provision_state = resource.Body("target_provision_state") - #: The requested state during a state transition. - target_power_state = resource.Body("target_power_state") - #: The requested RAID configration of the node which will be applied when - #: the node next transitions through the CLEANING state. - target_raid_config = resource.Body("target_raid_config") - #: Timestamp at which the node was last updated. - updated_at = resource.Body("updated_at") - - -class NodeDetail(Node): - - base_path = '/nodes/detail' - - # capabilities - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_list = True - - _query_mapping = resource.QueryParameters( - 'associated', 'driver', 'fields', 'provision_state', 'resource_class', - instance_id='instance_uuid', - is_maintenance='maintenance', - ) - - #: The UUID of the node resource. - id = resource.Body("uuid", alternate_id=True) diff --git a/openstack/bare_metal/v1/port.py b/openstack/bare_metal/v1/port.py deleted file mode 100644 index 99aa0ffe..00000000 --- a/openstack/bare_metal/v1/port.py +++ /dev/null @@ -1,82 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.bare_metal import bare_metal_service -from openstack import resource2 as resource - - -class Port(resource.Resource): - - resources_key = 'ports' - base_path = '/ports' - service = bare_metal_service.BareMetalService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - _query_mapping = resource.QueryParameters( - 'fields' - ) - - #: The physical hardware address of the network port, typically the - #: hardware MAC address. - address = resource.Body('address') - #: Timestamp at which the port was created. - created_at = resource.Body('created_at') - #: A set of one or more arbitrary metadata key and value pairs. - extra = resource.Body('extra') - #: The UUID of the port - id = resource.Body('uuid', alternate_id=True) - #: Internal metadata set and stored by the port. This field is read-only. - #: Added in API microversion 1.18. - internal_info = resource.Body('internal_info') - #: Whether PXE is enabled on the port. Added in API microversion 1.19. - is_pxe_enabled = resource.Body('pxe_enabled', type=bool) - #: A list of relative links, including the self and bookmark links. - links = resource.Body('links', type=list) - #: The port bindig profile. If specified, must contain ``switch_id`` and - #: ``port_id`` fields. ``switch_info`` field is an optional string field - #: to be used to store vendor specific information. Added in API - #: microversion 1.19. - local_link_connection = resource.Body('local_link_connection') - #: The UUID of node this port belongs to - node_id = resource.Body('node_uuid') - #: The UUID of PortGroup this port belongs to. Added in API microversion - #: 1.23. - port_group_id = resource.Body('portgroup_uuid') - #: Timestamp at which the port was last updated. - updated_at = resource.Body('updated_at') - - -class PortDetail(Port): - - base_path = '/ports/detail' - - # capabilities - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_list = True - - _query_mapping = resource.QueryParameters( - 'address', 'fields', 'node', 'portgroup', - node_id='node_uuid', - ) - - #: The UUID of the port - id = resource.Body('uuid', alternate_id=True) diff --git a/openstack/bare_metal/v1/port_group.py b/openstack/bare_metal/v1/port_group.py deleted file mode 100644 index 7cec820e..00000000 --- a/openstack/bare_metal/v1/port_group.py +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.bare_metal import bare_metal_service -from openstack import resource2 as resource - - -class PortGroup(resource.Resource): - - resources_key = 'portgroups' - base_path = '/portgroups' - service = bare_metal_service.BareMetalService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - _query_mapping = resource.QueryParameters( - 'node', 'address', 'fields', - ) - - #: The physical hardware address of the portgroup, typically the hardware - #: MAC address. Added in API microversion 1.23. - address = resource.Body('address') - #: Timestamp at which the portgroup was created. - created_at = resource.Body('created_at') - #: A set of one or more arbitrary metadata key and value pairs. - extra = resource.Body('extra', type=dict) - #: The name of the portgroup - name = resource.Body('name') - #: The UUID for the portgroup - id = resource.Body('uuid', alternate_id=True) - #: Internal metadaa set and stored by the portgroup. - internal_info = resource.Body('internal_info') - #: Whether ports that are members of this portgroup can be used as - #: standalone ports. Added in API microversion 1.23. - is_standalone_ports_supported = resource.Body('standalone_ports_supported', - type=bool) - #: A list of relative links, including the self and bookmark links. - links = resource.Body('links', type=list) - #: UUID of the node this portgroup belongs to. - node_id = resource.Body('node_uuid') - #: A list of links to the collection of ports belonging to this portgroup. - #: Added in API microversion 1.24. - ports = resource.Body('ports') - #: Timestamp at which the portgroup was last updated. - updated_at = resource.Body('updated_at') - - -class PortGroupDetail(PortGroup): - - base_path = '/portgroups/detail' - - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_list = True - - _query_mapping = resource.QueryParameters( - 'node', 'address', - ) - - #: The UUID for the portgroup - id = resource.Body('uuid', alternate_id=True) diff --git a/openstack/bare_metal/version.py b/openstack/bare_metal/version.py deleted file mode 100644 index f98f3b1f..00000000 --- a/openstack/bare_metal/version.py +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.bare_metal import bare_metal_service -from openstack import resource2 - - -class Version(resource2.Resource): - resource_key = 'version' - resources_key = 'versions' - base_path = '/' - service = bare_metal_service.BareMetalService( - version=bare_metal_service.BareMetalService.UNVERSIONED - ) - - # Capabilities - allow_list = True - - # Attributes - links = resource2.Body('links') - status = resource2.Body('status') - updated = resource2.Body('updated') diff --git a/openstack/block_store/__init__.py b/openstack/block_store/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/block_store/block_store_service.py b/openstack/block_store/block_store_service.py deleted file mode 100644 index fa133a6a..00000000 --- a/openstack/block_store/block_store_service.py +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class BlockStoreService(service_filter.ServiceFilter): - """The block store service.""" - - valid_versions = [service_filter.ValidVersion('v2')] - - def __init__(self, version=None): - """Create a block store service.""" - super(BlockStoreService, self).__init__(service_type='volume', - version=version, - requires_project_id=True) diff --git a/openstack/block_store/v2/__init__.py b/openstack/block_store/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/block_store/v2/_proxy.py b/openstack/block_store/v2/_proxy.py deleted file mode 100644 index 1d82eae3..00000000 --- a/openstack/block_store/v2/_proxy.py +++ /dev/null @@ -1,189 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.block_store.v2 import snapshot as _snapshot -from openstack.block_store.v2 import type as _type -from openstack.block_store.v2 import volume as _volume -from openstack import proxy2 - - -class Proxy(proxy2.BaseProxy): - - def get_snapshot(self, snapshot): - """Get a single snapshot - - :param snapshot: The value can be the ID of a snapshot or a - :class:`~openstack.volume.v2.snapshot.Snapshot` - instance. - - :returns: One :class:`~openstack.volume.v2.snapshot.Snapshot` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_snapshot.Snapshot, snapshot) - - def snapshots(self, details=True, **query): - """Retrieve a generator of snapshots - - :param bool details: When set to ``False`` - :class:`~openstack.block_store.v2.snapshot.Snapshot` - objects will be returned. The default, ``True``, will cause - :class:`~openstack.block_store.v2.snapshot.SnapshotDetail` - objects to be returned. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the snapshots being returned. Available parameters include: - - * name: Name of the snapshot as a string. - * all_tenants: Whether return the snapshots of all tenants. - * volume_id: volume id of a snapshot. - * status: Value of the status of the snapshot so that you can - filter on "available" for example. - - :returns: A generator of snapshot objects. - """ - snapshot = _snapshot.SnapshotDetail if details else _snapshot.Snapshot - return self._list(snapshot, paginated=True, **query) - - def create_snapshot(self, **attrs): - """Create a new snapshot from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.volume.v2.snapshot.Snapshot`, - comprised of the properties on the Snapshot class. - - :returns: The results of snapshot creation - :rtype: :class:`~openstack.volume.v2.snapshot.Snapshot` - """ - return self._create(_snapshot.Snapshot, **attrs) - - def delete_snapshot(self, snapshot, ignore_missing=True): - """Delete a snapshot - - :param snapshot: The value can be either the ID of a snapshot or a - :class:`~openstack.volume.v2.snapshot.Snapshot` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the snapshot does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent snapshot. - - :returns: ``None`` - """ - self._delete(_snapshot.Snapshot, snapshot, - ignore_missing=ignore_missing) - - def get_type(self, type): - """Get a single type - - :param type: The value can be the ID of a type or a - :class:`~openstack.volume.v2.type.Type` instance. - - :returns: One :class:`~openstack.volume.v2.type.Type` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_type.Type, type) - - def types(self): - """Retrieve a generator of volume types - - :returns: A generator of volume type objects. - """ - return self._list(_type.Type, paginated=False) - - def create_type(self, **attrs): - """Create a new type from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.volume.v2.type.Type`, - comprised of the properties on the Type class. - - :returns: The results of type creation - :rtype: :class:`~openstack.volume.v2.type.Type` - """ - return self._create(_type.Type, **attrs) - - def delete_type(self, type, ignore_missing=True): - """Delete a type - - :param type: The value can be either the ID of a type or a - :class:`~openstack.volume.v2.type.Type` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the type does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent type. - - :returns: ``None`` - """ - self._delete(_type.Type, type, ignore_missing=ignore_missing) - - def get_volume(self, volume): - """Get a single volume - - :param volume: The value can be the ID of a volume or a - :class:`~openstack.volume.v2.volume.Volume` instance. - - :returns: One :class:`~openstack.volume.v2.volume.Volume` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_volume.Volume, volume) - - def volumes(self, details=True, **query): - """Retrieve a generator of volumes - - :param bool details: When set to ``False`` - :class:`~openstack.block_store.v2.volume.Volume` objects - will be returned. The default, ``True``, will cause - :class:`~openstack.block_store.v2.volume.VolumeDetail` - objects to be returned. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the volumes being returned. Available parameters include: - - * name: Name of the volume as a string. - * all_tenants: Whether return the volumes of all tenants - * status: Value of the status of the volume so that you can filter - on "available" for example. - - :returns: A generator of volume objects. - """ - volume = _volume.VolumeDetail if details else _volume.Volume - return self._list(volume, paginated=True, **query) - - def create_volume(self, **attrs): - """Create a new volume from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.volume.v2.volume.Volume`, - comprised of the properties on the Volume class. - - :returns: The results of volume creation - :rtype: :class:`~openstack.volume.v2.volume.Volume` - """ - return self._create(_volume.Volume, **attrs) - - def delete_volume(self, volume, ignore_missing=True): - """Delete a volume - - :param volume: The value can be either the ID of a volume or a - :class:`~openstack.volume.v2.volume.Volume` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the volume does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent volume. - - :returns: ``None`` - """ - self._delete(_volume.Volume, volume, ignore_missing=ignore_missing) diff --git a/openstack/block_store/v2/snapshot.py b/openstack/block_store/v2/snapshot.py deleted file mode 100644 index ae2755c2..00000000 --- a/openstack/block_store/v2/snapshot.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.block_store import block_store_service -from openstack import format -from openstack import resource2 - - -class Snapshot(resource2.Resource): - resource_key = "snapshot" - resources_key = "snapshots" - base_path = "/snapshots" - service = block_store_service.BlockStoreService() - - _query_mapping = resource2.QueryParameters('all_tenants', 'name', 'status', - 'volume_id') - - # capabilities - allow_get = True - allow_create = True - allow_delete = True - allow_update = True - allow_list = True - - # Properties - #: A ID representing this snapshot. - id = resource2.Body("id") - #: Name of the snapshot. Default is None. - name = resource2.Body("name") - - #: The current status of this snapshot. Potential values are creating, - #: available, deleting, error, and error_deleting. - status = resource2.Body("status") - #: Description of snapshot. Default is None. - description = resource2.Body("description") - #: The timestamp of this snapshot creation. - created_at = resource2.Body("created_at") - #: Metadata associated with this snapshot. - metadata = resource2.Body("metadata", type=dict) - #: The ID of the volume this snapshot was taken of. - volume_id = resource2.Body("volume_id") - #: The size of the volume, in GBs. - size = resource2.Body("size", type=int) - #: Indicate whether to create snapshot, even if the volume is attached. - #: Default is ``False``. *Type: bool* - is_forced = resource2.Body("force", type=format.BoolStr) - - -class SnapshotDetail(Snapshot): - - base_path = "/snapshots/detail" - - #: The percentage of completeness the snapshot is currently at. - progress = resource2.Body("os-extended-snapshot-attributes:progress") - #: The project ID this snapshot is associated with. - project_id = resource2.Body("os-extended-snapshot-attributes:project_id") diff --git a/openstack/block_store/v2/type.py b/openstack/block_store/v2/type.py deleted file mode 100644 index a39466a5..00000000 --- a/openstack/block_store/v2/type.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.block_store import block_store_service -from openstack import resource2 - - -class Type(resource2.Resource): - resource_key = "volume_type" - resources_key = "volume_types" - base_path = "/types" - service = block_store_service.BlockStoreService() - - # capabilities - allow_get = True - allow_create = True - allow_delete = True - allow_list = True - - # Properties - #: A ID representing this type. - id = resource2.Body("id") - #: Name of the type. - name = resource2.Body("name") - #: A dict of extra specifications. "capabilities" is a usual key. - extra_specs = resource2.Body("extra_specs", type=dict) diff --git a/openstack/block_store/v2/volume.py b/openstack/block_store/v2/volume.py deleted file mode 100644 index a20ddd62..00000000 --- a/openstack/block_store/v2/volume.py +++ /dev/null @@ -1,103 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.block_store import block_store_service -from openstack import format -from openstack import resource2 - - -class Volume(resource2.Resource): - resource_key = "volume" - resources_key = "volumes" - base_path = "/volumes" - service = block_store_service.BlockStoreService() - - _query_mapping = resource2.QueryParameters('all_tenants', 'name', - 'status', 'project_id') - - # capabilities - allow_get = True - allow_create = True - allow_delete = True - allow_update = True - allow_list = True - - # Properties - #: A ID representing this volume. - id = resource2.Body("id") - #: The name of this volume. - name = resource2.Body("name") - #: A list of links associated with this volume. *Type: list* - links = resource2.Body("links", type=list) - - #: The availability zone. - availability_zone = resource2.Body("availability_zone") - #: To create a volume from an existing volume, specify the ID of - #: the existing volume. If specified, the volume is created with - #: same size of the source volume. - source_volume_id = resource2.Body("source_volid") - #: The volume description. - description = resource2.Body("description") - #: To create a volume from an existing snapshot, specify the ID of - #: the existing volume snapshot. If specified, the volume is created - #: in same availability zone and with same size of the snapshot. - snapshot_id = resource2.Body("snapshot_id") - #: The size of the volume, in GBs. *Type: int* - size = resource2.Body("size", type=int) - #: The ID of the image from which you want to create the volume. - #: Required to create a bootable volume. - image_id = resource2.Body("imageRef") - #: The name of the associated volume type. - volume_type = resource2.Body("volume_type") - #: Enables or disables the bootable attribute. You can boot an - #: instance from a bootable volume. *Type: bool* - is_bootable = resource2.Body("bootable", type=format.BoolStr) - #: One or more metadata key and value pairs to associate with the volume. - metadata = resource2.Body("metadata") - - #: One of the following values: creating, available, attaching, in-use - #: deleting, error, error_deleting, backing-up, restoring-backup, - #: error_restoring. For details on these statuses, see the - #: Block Storage API documentation. - status = resource2.Body("status") - #: TODO(briancurtin): This is currently undocumented in the API. - attachments = resource2.Body("attachments") - #: The timestamp of this volume creation. - created_at = resource2.Body("created_at") - - -class VolumeDetail(Volume): - - base_path = "/volumes/detail" - - #: The volume's current back-end. - host = resource2.Body("os-vol-host-attr:host") - #: The project ID associated with current back-end. - project_id = resource2.Body("os-vol-tenant-attr:tenant_id") - #: The status of this volume's migration (None means that a migration - #: is not currently in progress). - migration_status = resource2.Body("os-vol-mig-status-attr:migstat") - #: The volume ID that this volume's name on the back-end is based on. - migration_id = resource2.Body("os-vol-mig-status-attr:name_id") - #: Status of replication on this volume. - replication_status = resource2.Body("replication_status") - #: Extended replication status on this volume. - extended_replication_status = resource2.Body( - "os-volume-replication:extended_status") - #: ID of the consistency group. - consistency_group_id = resource2.Body("consistencygroup_id") - #: Data set by the replication driver - replication_driver_data = resource2.Body( - "os-volume-replication:driver_data") - #: ``True`` if this volume is encrypted, ``False`` if not. - #: *Type: bool* - is_encrypted = resource2.Body("encrypted", type=format.BoolStr) diff --git a/openstack/cluster/__init__.py b/openstack/cluster/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/cluster/cluster_service.py b/openstack/cluster/cluster_service.py deleted file mode 100644 index 7b6eb5d1..00000000 --- a/openstack/cluster/cluster_service.py +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class ClusterService(service_filter.ServiceFilter): - """The cluster service.""" - - valid_versions = [service_filter.ValidVersion('v1')] - UNVERSIONED = None - - def __init__(self, version=None): - """Create a cluster service.""" - super(ClusterService, self).__init__( - service_type='clustering', - version=version - ) diff --git a/openstack/cluster/v1/__init__.py b/openstack/cluster/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/cluster/v1/_proxy.py b/openstack/cluster/v1/_proxy.py deleted file mode 100644 index 7bcff9f7..00000000 --- a/openstack/cluster/v1/_proxy.py +++ /dev/null @@ -1,1138 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster.v1 import action as _action -from openstack.cluster.v1 import build_info -from openstack.cluster.v1 import cluster as _cluster -from openstack.cluster.v1 import cluster_attr as _cluster_attr -from openstack.cluster.v1 import cluster_policy as _cluster_policy -from openstack.cluster.v1 import event as _event -from openstack.cluster.v1 import node as _node -from openstack.cluster.v1 import policy as _policy -from openstack.cluster.v1 import policy_type as _policy_type -from openstack.cluster.v1 import profile as _profile -from openstack.cluster.v1 import profile_type as _profile_type -from openstack.cluster.v1 import receiver as _receiver -from openstack.cluster.v1 import service as _service -from openstack import proxy2 -from openstack import resource2 -from openstack import utils - - -class Proxy(proxy2.BaseProxy): - - def get_build_info(self): - """Get build info for service engine and API - - :returns: A dictionary containing the API and engine revision string. - """ - return self._get(build_info.BuildInfo, requires_id=False) - - def profile_types(self, **query): - """Get a generator of profile types. - - :returns: A generator of objects that are of type - :class:`~openstack.cluster.v1.profile_type.ProfileType` - """ - return self._list(_profile_type.ProfileType, paginated=False, **query) - - def get_profile_type(self, profile_type): - """Get the details about a profile_type. - - :param name: The name of the profile_type to retrieve or an object of - :class:`~openstack.cluster.v1.profile_type.ProfileType`. - - :returns: A :class:`~openstack.cluster.v1.profile_type.ProfileType` - object. - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - profile_type matching the name could be found. - """ - return self._get(_profile_type.ProfileType, profile_type) - - def policy_types(self, **query): - """Get a generator of policy types. - - :returns: A generator of objects that are of type - :class:`~openstack.cluster.v1.policy_type.PolicyType` - """ - return self._list(_policy_type.PolicyType, paginated=False, **query) - - def get_policy_type(self, policy_type): - """Get the details about a policy_type. - - :param policy_type: The name of a poicy_type or an object of - :class:`~openstack.cluster.v1.policy_type.PolicyType`. - - :returns: A :class:`~openstack.cluster.v1.policy_type.PolicyType` - object. - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - policy_type matching the name could be found. - """ - return self._get(_policy_type.PolicyType, policy_type) - - def create_profile(self, **attrs): - """Create a new profile from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.cluster.v1.profile.Profile`, it is comprised - of the properties on the Profile class. - - :returns: The results of profile creation. - :rtype: :class:`~openstack.cluster.v1.profile.Profile`. - """ - return self._create(_profile.Profile, **attrs) - - def delete_profile(self, profile, ignore_missing=True): - """Delete a profile. - - :param profile: The value can be either the name or ID of a profile or - a :class:`~openstack.cluster.v1.profile.Profile` instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised when - the profile could not be found. When set to ``True``, no exception - will be raised when attempting to delete a non-existent profile. - - :returns: ``None`` - """ - self._delete(_profile.Profile, profile, ignore_missing=ignore_missing) - - def find_profile(self, name_or_id, ignore_missing=True): - """Find a single profile. - - :param str name_or_id: The name or ID of a profile. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.cluster.v1.profile.Profile` object - or None - """ - return self._find(_profile.Profile, name_or_id, - ignore_missing=ignore_missing) - - def get_profile(self, profile): - """Get a single profile. - - :param profile: The value can be the name or ID of a profile or a - :class:`~openstack.cluster.v1.profile.Profile` instance. - - :returns: One :class:`~openstack.cluster.v1.profile.Profile` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - profile matching the criteria could be found. - """ - return self._get(_profile.Profile, profile) - - def profiles(self, **query): - """Retrieve a generator of profiles. - - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the profiles to be returned. Available parameters include: - - * name: The name of a profile. - * type: The type name of a profile. - * metadata: A list of key-value pairs that are associated with a - profile. - * sort: A list of sorting keys separated by commas. Each sorting - key can optionally be attached with a sorting direction - modifier which can be ``asc`` or ``desc``. - * limit: Requests a specified size of returned items from the - query. Returns a number of items up to the specified limit - value. - * marker: Specifies the ID of the last-seen item. Use the limit - parameter to make an initial limited request and use the ID of - the last-seen item from the response as the marker parameter - value in a subsequent limited request. - * global_project: A boolean value indicating whether profiles - from all projects will be returned. - - :returns: A generator of profile instances. - """ - return self._list(_profile.Profile, paginated=True, **query) - - def update_profile(self, profile, **attrs): - """Update a profile. - - :param profile: Either the name or the ID of the profile, or an - instance of :class:`~openstack.cluster.v1.profile.Profile`. - :param attrs: The attributes to update on the profile represented by - the ``value`` parameter. - - :returns: The updated profile. - :rtype: :class:`~openstack.cluster.v1.profile.Profile` - """ - return self._update(_profile.Profile, profile, **attrs) - - def validate_profile(self, **attrs): - """Validate a profile spec. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.cluster.v1.profile.ProfileValidate`, it is - comprised of the properties on the Profile class. - - :returns: The results of profile validation. - :rtype: :class:`~openstack.cluster.v1.profile.ProfileValidate`. - """ - return self._create(_profile.ProfileValidate, **attrs) - - def create_cluster(self, **attrs): - """Create a new cluster from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.cluster.v1.cluster.Cluster`, it is comprised - of the properties on the Cluster class. - - :returns: The results of cluster creation. - :rtype: :class:`~openstack.cluster.v1.cluster.Cluster`. - """ - return self._create(_cluster.Cluster, **attrs) - - def delete_cluster(self, cluster, ignore_missing=True): - """Delete a cluster. - - :param cluster: The value can be either the name or ID of a cluster or - a :class:`~openstack.cluster.v1.cluster.Cluster` instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised when - the cluster could not be found. When set to ``True``, no exception - will be raised when attempting to delete a non-existent cluster. - - :returns: The instance of the Cluster which was deleted. - :rtype: :class:`~openstack.cluster.v1.cluster.Cluster`. - """ - return self._delete(_cluster.Cluster, cluster, - ignore_missing=ignore_missing) - - def find_cluster(self, name_or_id, ignore_missing=True): - """Find a single cluster. - - :param str name_or_id: The name or ID of a cluster. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.cluster.v1.cluster.Cluster` object - or None - """ - return self._find(_cluster.Cluster, name_or_id, - ignore_missing=ignore_missing) - - def get_cluster(self, cluster): - """Get a single cluster. - - :param cluster: The value can be the name or ID of a cluster or a - :class:`~openstack.cluster.v1.cluster.Cluster` instance. - - :returns: One :class:`~openstack.cluster.v1.cluster.Cluster` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - cluster matching the criteria could be found. - """ - return self._get(_cluster.Cluster, cluster) - - def clusters(self, **query): - """Retrieve a generator of clusters. - - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the clusters to be returned. Available parameters include: - - * name: The name of a cluster. - * status: The current status of a cluster. - * sort: A list of sorting keys separated by commas. Each sorting - key can optionally be attached with a sorting direction - modifier which can be ``asc`` or ``desc``. - * limit: Requests a specified size of returned items from the - query. Returns a number of items up to the specified limit - value. - * marker: Specifies the ID of the last-seen item. Use the limit - parameter to make an initial limited request and use the ID of - the last-seen item from the response as the marker parameter - value in a subsequent limited request. - * global_project: A boolean value indicating whether clusters - from all projects will be returned. - - :returns: A generator of cluster instances. - """ - return self._list(_cluster.Cluster, paginated=True, **query) - - def update_cluster(self, cluster, **attrs): - """Update a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param attrs: The attributes to update on the cluster represented by - the ``cluster`` parameter. - - :returns: The updated cluster. - :rtype: :class:`~openstack.cluster.v1.cluster.Cluster` - """ - return self._update(_cluster.Cluster, cluster, **attrs) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use add_nodes_to_cluster instead") - def cluster_add_nodes(self, cluster, nodes): - """Add nodes to a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param nodes: List of nodes to be added to the cluster. - :returns: A dict containing the action initiated by this operation. - """ - return self.add_nodes_to_cluster(cluster, nodes) - - def add_nodes_to_cluster(self, cluster, nodes): - """Add nodes to a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param nodes: List of nodes to be added to the cluster. - :returns: A dict containing the action initiated by this operation. - """ - if isinstance(cluster, _cluster.Cluster): - obj = cluster - else: - obj = self._find(_cluster.Cluster, cluster, ignore_missing=False) - return obj.add_nodes(self._session, nodes) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use remove_nodes_from_cluster instead") - def cluster_del_nodes(self, cluster, nodes, **params): - """Remove nodes from a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param nodes: List of nodes to be removed from the cluster. - :param kwargs \*\*params: Optional query parameters to be sent to - restrict the nodes to be returned. Available parameters include: - - * destroy_after_deletion: A boolean value indicating whether the - deleted nodes to be destroyed right away. - :returns: A dict containing the action initiated by this operation. - """ - return self.remove_nodes_from_cluster(cluster, nodes, **params) - - def remove_nodes_from_cluster(self, cluster, nodes, **params): - """Remove nodes from a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param nodes: List of nodes to be removed from the cluster. - :param kwargs \*\*params: Optional query parameters to be sent to - restrict the nodes to be returned. Available parameters include: - - * destroy_after_deletion: A boolean value indicating whether the - deleted nodes to be destroyed right away. - :returns: A dict containing the action initiated by this operation. - """ - if isinstance(cluster, _cluster.Cluster): - obj = cluster - else: - obj = self._find(_cluster.Cluster, cluster, ignore_missing=False) - return obj.del_nodes(self._session, nodes, **params) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use replace_nodes_in_cluster instead") - def cluster_replace_nodes(self, cluster, nodes): - """Replace the nodes in a cluster with specified nodes. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param nodes: List of nodes to be deleted/added to the cluster. - :returns: A dict containing the action initiated by this operation. - """ - return self.replace_nodes_in_cluster(cluster, nodes) - - def replace_nodes_in_cluster(self, cluster, nodes): - """Replace the nodes in a cluster with specified nodes. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param nodes: List of nodes to be deleted/added to the cluster. - :returns: A dict containing the action initiated by this operation. - """ - if isinstance(cluster, _cluster.Cluster): - obj = cluster - else: - obj = self._find(_cluster.Cluster, cluster, ignore_missing=False) - return obj.replace_nodes(self._session, nodes) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use scale_out_cluster instead") - def cluster_scale_out(self, cluster, count=None): - """Inflate the size of a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param count: Optional parameter specifying the number of nodes to - be added. - :returns: A dict containing the action initiated by this operation. - """ - return self.scale_out_cluster(cluster, count) - - def scale_out_cluster(self, cluster, count=None): - """Inflate the size of a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param count: Optional parameter specifying the number of nodes to - be added. - :returns: A dict containing the action initiated by this operation. - """ - if isinstance(cluster, _cluster.Cluster): - obj = cluster - else: - obj = self._find(_cluster.Cluster, cluster, ignore_missing=False) - return obj.scale_out(self._session, count) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use scale_in_cluster instead") - def cluster_scale_in(self, cluster, count=None): - """Shrink the size of a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param count: Optional parameter specifying the number of nodes to - be removed. - :returns: A dict containing the action initiated by this operation. - """ - return self.scale_in_cluster(cluster, count) - - def scale_in_cluster(self, cluster, count=None): - """Shrink the size of a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param count: Optional parameter specifying the number of nodes to - be removed. - :returns: A dict containing the action initiated by this operation. - """ - if isinstance(cluster, _cluster.Cluster): - obj = cluster - else: - obj = self._find(_cluster.Cluster, cluster, ignore_missing=False) - return obj.scale_in(self._session, count) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use resize_cluster instead") - def cluster_resize(self, cluster, **params): - """Resize of cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param dict \*\*params: A dictionary providing the parameters for the - resize action. - :returns: A dict containing the action initiated by this operation. - """ - return self.resize_cluster(cluster, **params) - - def resize_cluster(self, cluster, **params): - """Resize of cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param dict \*\*params: A dictionary providing the parameters for the - resize action. - :returns: A dict containing the action initiated by this operation. - """ - if isinstance(cluster, _cluster.Cluster): - obj = cluster - else: - obj = self._find(_cluster.Cluster, cluster, ignore_missing=False) - return obj.resize(self._session, **params) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use attach_policy_to_cluster instead") - def cluster_attach_policy(self, cluster, policy, **params): - """Attach a policy to a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param policy: Either the name or the ID of a policy. - :param dict \*\*params: A dictionary containing the properties for the - policy to be attached. - :returns: A dict containing the action initiated by this operation. - """ - return self.attach_policy_to_cluster(cluster, policy, **params) - - def attach_policy_to_cluster(self, cluster, policy, **params): - """Attach a policy to a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param policy: Either the name or the ID of a policy. - :param dict \*\*params: A dictionary containing the properties for the - policy to be attached. - :returns: A dict containing the action initiated by this operation. - """ - if isinstance(cluster, _cluster.Cluster): - obj = cluster - else: - obj = self._find(_cluster.Cluster, cluster, ignore_missing=False) - return obj.policy_attach(self._session, policy, **params) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use detach_policy_from_cluster instead") - def cluster_detach_policy(self, cluster, policy): - """Attach a policy to a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param policy: Either the name or the ID of a policy. - :returns: A dict containing the action initiated by this operation. - """ - return self.detach_policy_from_cluster(cluster, policy) - - def detach_policy_from_cluster(self, cluster, policy): - """Detach a policy from a cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param policy: Either the name or the ID of a policy. - :returns: A dict containing the action initiated by this operation. - """ - if isinstance(cluster, _cluster.Cluster): - obj = cluster - else: - obj = self._find(_cluster.Cluster, cluster, ignore_missing=False) - return obj.policy_detach(self._session, policy) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use update_cluster_policy instead") - def cluster_update_policy(self, cluster, policy, **params): - """Change properties of a policy which is bound to the cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param policy: Either the name or the ID of a policy. - :param dict \*\*params: A dictionary containing the new properties for - the policy. - :returns: A dict containing the action initiated by this operation. - """ - return self.update_cluster_policy(cluster, policy, **params) - - def update_cluster_policy(self, cluster, policy, **params): - """Change properties of a policy which is bound to the cluster. - - :param cluster: Either the name or the ID of the cluster, or an - instance of :class:`~openstack.cluster.v1.cluster.Cluster`. - :param policy: Either the name or the ID of a policy. - :param dict \*\*params: A dictionary containing the new properties for - the policy. - :returns: A dict containing the action initiated by this operation. - """ - if isinstance(cluster, _cluster.Cluster): - obj = cluster - else: - obj = self._find(_cluster.Cluster, cluster, ignore_missing=False) - return obj.policy_update(self._session, policy, **params) - - def collect_cluster_attrs(self, cluster, path): - """Collect attribute values across a cluster. - - :param cluster: The value can be either the ID of a cluster or a - :class:`~openstack.cluster.v1.cluster.Cluster` instance. - :param path: A Json path string specifying the attribute to collect. - - :returns: A dictionary containing the list of attribute values. - """ - return self._list(_cluster_attr.ClusterAttr, paginated=False, - cluster_id=cluster, path=path) - - def check_cluster(self, cluster, **params): - """Check a cluster. - - :param cluster: The value can be either the ID of a cluster or a - :class:`~openstack.cluster.v1.cluster.Cluster` instance. - :param dict params: A dictionary providing the parameters for the - check action. - - :returns: A dictionary containing the action ID. - """ - obj = self._get_resource(_cluster.Cluster, cluster) - return obj.check(self._session, **params) - - def recover_cluster(self, cluster, **params): - """recover a cluster. - - :param cluster: The value can be either the ID of a cluster or a - :class:`~openstack.cluster.v1.cluster.Cluster` instance. - :param dict params: A dictionary providing the parameters for the - recover action. - - :returns: A dictionary containing the action ID. - """ - obj = self._get_resource(_cluster.Cluster, cluster) - return obj.recover(self._session, **params) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use perform_operation_on_cluster instead") - def cluster_operation(self, cluster, operation, **params): - """Perform an operation on the specified cluster. - - :param cluster: The value can be either the ID of a cluster or a - :class:`~openstack.cluster.v1.cluster.Cluster` instance. - :param operation: A string specifying the operation to be performed. - :param dict params: A dictionary providing the parameters for the - operation. - - :returns: A dictionary containing the action ID. - """ - return self.perform_operation_on_cluster(cluster, operation, **params) - - def perform_operation_on_cluster(self, cluster, operation, **params): - """Perform an operation on the specified cluster. - - :param cluster: The value can be either the ID of a cluster or a - :class:`~openstack.cluster.v1.cluster.Cluster` instance. - :param operation: A string specifying the operation to be performed. - :param dict params: A dictionary providing the parameters for the - operation. - - :returns: A dictionary containing the action ID. - """ - obj = self._get_resource(_cluster.Cluster, cluster) - return obj.op(self._session, operation, **params) - - def create_node(self, **attrs): - """Create a new node from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.cluster.v1.node.Node`, it is comprised - of the properties on the ``Node`` class. - - :returns: The results of node creation. - :rtype: :class:`~openstack.cluster.v1.node.Node`. - """ - return self._create(_node.Node, **attrs) - - def delete_node(self, node, ignore_missing=True): - """Delete a node. - - :param node: The value can be either the name or ID of a node or a - :class:`~openstack.cluster.v1.node.Node` instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised when - the node could not be found. When set to ``True``, no exception - will be raised when attempting to delete a non-existent node. - - :returns: The instance of the Node which was deleted. - :rtype: :class:`~openstack.cluster.v1.node.Node`. - """ - return self._delete(_node.Node, node, ignore_missing=ignore_missing) - - def find_node(self, name_or_id, ignore_missing=True): - """Find a single node. - - :param str name_or_id: The name or ID of a node. - :returns: One :class:`~openstack.cluster.v1.node.Node` object or None. - """ - return self._find(_node.Node, name_or_id, - ignore_missing=ignore_missing) - - def get_node(self, node, details=False): - """Get a single node. - - :param node: The value can be the name or ID of a node or a - :class:`~openstack.cluster.v1.node.Node` instance. - :param details: An optional argument that indicates whether the - server should return more details when retrieving the node data. - - :returns: One :class:`~openstack.cluster.v1.node.Node` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - node matching the name or ID could be found. - """ - # NOTE: When retrieving node with details (using NodeDetail resource), - # the `node_id` is treated as part of the base_path thus a URI - # property rather than a resource ID as assumed by the _get() method - # in base proxy. - if details: - return self._get(_node.NodeDetail, requires_id=False, node_id=node) - return self._get(_node.Node, node) - - def nodes(self, **query): - """Retrieve a generator of nodes. - - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the nodes to be returned. Available parameters include: - - * cluster_id: A string including the name or ID of a cluster to - which the resulted node(s) is a member. - * name: The name of a node. - * status: The current status of a node. - * sort: A list of sorting keys separated by commas. Each sorting - key can optionally be attached with a sorting direction - modifier which can be ``asc`` or ``desc``. - * limit: Requests at most the specified number of items be - returned from the query. - * marker: Specifies the ID of the last-seen node. Use the limit - parameter to make an initial limited request and use the ID of - the last-seen node from the response as the marker parameter - value in a subsequent limited request. - * global_project: A boolean value indicating whether nodes - from all projects will be returned. - - :returns: A generator of node instances. - """ - return self._list(_node.Node, paginated=True, **query) - - def update_node(self, node, **attrs): - """Update a node. - - :param node: Either the name or the ID of the node, or an instance - of :class:`~openstack.cluster.v1.node.Node`. - :param attrs: The attributes to update on the node represented by - the ``node`` parameter. - - :returns: The updated node. - :rtype: :class:`~openstack.cluster.v1.node.Node` - """ - return self._update(_node.Node, node, **attrs) - - def check_node(self, node, **params): - """Check the health of the specified node. - - :param node: The value can be either the ID of a node or a - :class:`~openstack.cluster.v1.node.Node` instance. - :param dict params: A dictionary providing the parametes to the check - action. - - :returns: A dictionary containing the action ID. - """ - obj = self._get_resource(_node.Node, node) - return obj.check(self._session, **params) - - def recover_node(self, node, **params): - """Recover the specified node into healthy status. - - :param node: The value can be either the ID of a node or a - :class:`~openstack.cluster.v1.node.Node` instance. - :param dict params: A dict supplying parameters to the recover action. - - :returns: A dictionary containing the action ID. - """ - obj = self._get_resource(_node.Node, node) - return obj.recover(self._session, **params) - - def adopt_node(self, preview=False, **attrs): - """Adopting an existing resource as a node. - - :param preview: A boolean indicating whether this is a "preview" - operation which means only the profile to be used is returned - rather than creating a node object using that profile. - :param dict attrs: Keyword parameters for node adoption. Valid - parameters include: - - * type: (Required) A string containing the profile type and - version to be used for node adoption. For example, - ``os.nova.sever-1.0``. - * identity: (Required) A string including the name or ID of an - OpenStack resource to be adopted as a Senlin node. - * name: (Optional) The name of of node to be created. Omitting - this parameter will have the node named automatically. - * snapshot: (Optional) A boolean indicating whether a snapshot - of the target resource should be created if possible. Default - is False. - * metadata: (Optional) A dictionary of arbitrary key-value pairs - to be associated with the adopted node. - * overrides: (Optional) A dictionary of key-value pairs to be used - to override attributes derived from the target resource. - - :returns: The result of node adoption. If `preview` is set to False - (default), returns a :class:`~openstack.cluster.v1.node.Node` - object, otherwise a Dict is returned containing the profile to - be used for the new node. - """ - node = self._get_resource(_node.Node, None) - return node.adopt(self._session, preview=preview, **attrs) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="Use perform_operation_on_node instead") - def node_operation(self, node, operation, **params): - """Perform an operation on the specified node. - - :param cluster: The value can be either the ID of a node or a - :class:`~openstack.cluster.v1.node.Node` instance. - :param operation: A string specifying the operation to be performed. - :param dict params: A dictionary providing the parameters for the - operation. - - :returns: A dictionary containing the action ID. - """ - return self.perform_operation_on_node(node, operation, **params) - - def perform_operation_on_node(self, node, operation, **params): - """Perform an operation on the specified node. - - :param cluster: The value can be either the ID of a node or a - :class:`~openstack.cluster.v1.node.Node` instance. - :param operation: A string specifying the operation to be performed. - :param dict params: A dictionary providing the parameters for the - operation. - - :returns: A dictionary containing the action ID. - """ - obj = self._get_resource(_node.Node, node) - return obj.op(self._session, operation, **params) - - def create_policy(self, **attrs): - """Create a new policy from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.cluster.v1.policy.Policy`, it is comprised - of the properties on the ``Policy`` class. - - :returns: The results of policy creation. - :rtype: :class:`~openstack.cluster.v1.policy.Policy`. - """ - return self._create(_policy.Policy, **attrs) - - def delete_policy(self, policy, ignore_missing=True): - """Delete a policy. - - :param policy: The value can be either the name or ID of a policy or a - :class:`~openstack.cluster.v1.policy.Policy` instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised when - the policy could not be found. When set to ``True``, no exception - will be raised when attempting to delete a non-existent policy. - - :returns: ``None`` - """ - self._delete(_policy.Policy, policy, ignore_missing=ignore_missing) - - def find_policy(self, name_or_id, ignore_missing=True): - """Find a single policy. - - :param str name_or_id: The name or ID of a policy. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the specified policy does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent policy. - :returns: A policy object or None. - :rtype: :class:`~openstack.cluster.v1.policy.Policy` - """ - return self._find(_policy.Policy, name_or_id, - ignore_missing=ignore_missing) - - def get_policy(self, policy): - """Get a single policy. - - :param policy: The value can be the name or ID of a policy or a - :class:`~openstack.cluster.v1.policy.Policy` instance. - - :returns: A policy object. - :rtype: :class:`~openstack.cluster.v1.policy.Policy` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - policy matching the criteria could be found. - """ - return self._get(_policy.Policy, policy) - - def policies(self, **query): - """Retrieve a generator of policies. - - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the policies to be returned. Available parameters include: - - * name: The name of a policy. - * type: The type name of a policy. - * sort: A list of sorting keys separated by commas. Each sorting - key can optionally be attached with a sorting direction - modifier which can be ``asc`` or ``desc``. - * limit: Requests a specified size of returned items from the - query. Returns a number of items up to the specified limit - value. - * marker: Specifies the ID of the last-seen item. Use the limit - parameter to make an initial limited request and use the ID of - the last-seen item from the response as the marker parameter - value in a subsequent limited request. - * global_project: A boolean value indicating whether policies from - all projects will be returned. - - :returns: A generator of policy instances. - """ - return self._list(_policy.Policy, paginated=True, **query) - - def update_policy(self, policy, **attrs): - """Update a policy. - - :param policy: Either the name or the ID of a policy, or an instance - of :class:`~openstack.cluster.v1.policy.Policy`. - :param attrs: The attributes to update on the policy represented by - the ``value`` parameter. - - :returns: The updated policy. - :rtype: :class:`~openstack.cluster.v1.policy.Policy` - """ - return self._update(_policy.Policy, policy, **attrs) - - def validate_policy(self, **attrs): - """Validate a policy spec. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.cluster.v1.policy.PolicyValidate`, it is - comprised of the properties on the Policy class. - - :returns: The results of Policy validation. - :rtype: :class:`~openstack.cluster.v1.policy.PolicyValidate`. - """ - return self._create(_policy.PolicyValidate, **attrs) - - def cluster_policies(self, cluster, **query): - """Retrieve a generator of cluster-policy bindings. - - :param cluster: The value can be the name or ID of a cluster or a - :class:`~openstack.cluster.v1.cluster.Cluster` instance. - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the policies to be returned. Available parameters include: - - * enabled: A boolean value indicating whether the policy is - enabled on the cluster. - :returns: A generator of cluster-policy binding instances. - """ - cluster_id = resource2.Resource._get_id(cluster) - return self._list(_cluster_policy.ClusterPolicy, paginated=False, - cluster_id=cluster_id, **query) - - def get_cluster_policy(self, cluster_policy, cluster): - """Get a cluster-policy binding. - - :param cluster_policy: - The value can be the name or ID of a policy or a - :class:`~openstack.cluster.v1.policy.Policy` instance. - :param cluster: The value can be the name or ID of a cluster or a - :class:`~openstack.cluster.v1.cluster.Cluster` instance. - - :returns: a cluster-policy binding object. - :rtype: :class:`~openstack.cluster.v1.cluster_policy.CLusterPolicy` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - cluster-policy binding matching the criteria could be found. - """ - return self._get(_cluster_policy.ClusterPolicy, cluster_policy, - cluster_id=cluster) - - def create_receiver(self, **attrs): - """Create a new receiver from attributes. - - :param dict attrs: Keyword arguments that will be used to create a - :class:`~openstack.cluster.v1.receiver.Receiver`, it is comprised - of the properties on the Receiver class. - - :returns: The results of receiver creation. - :rtype: :class:`~openstack.cluster.v1.receiver.Receiver`. - """ - return self._create(_receiver.Receiver, **attrs) - - def update_receiver(self, receiver, **attrs): - """Update a receiver. - - :param receiver: The value can be either the name or ID of a receiver - or a :class:`~openstack.cluster.v1.receiver.Receiver` instance. - :param attrs: The attributes to update on the receiver parameter. - Valid attribute names include ``name``, ``action`` and ``params``. - :returns: The updated receiver. - :rtype: :class:`~openstack.cluster.v1.receiver.Receiver` - """ - return self._update(_receiver.Receiver, receiver, **attrs) - - def delete_receiver(self, receiver, ignore_missing=True): - """Delete a receiver. - - :param receiver: The value can be either the name or ID of a receiver - or a :class:`~openstack.cluster.v1.receiver.Receiver` instance. - :param bool ignore_missing: When set to ``False``, an exception - :class:`~openstack.exceptions.ResourceNotFound` will be raised when - the receiver could not be found. When set to ``True``, no exception - will be raised when attempting to delete a non-existent receiver. - - :returns: ``None`` - """ - self._delete(_receiver.Receiver, receiver, - ignore_missing=ignore_missing) - - def find_receiver(self, name_or_id, ignore_missing=True): - """Find a single receiver. - - :param str name_or_id: The name or ID of a receiver. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the specified receiver does not exist. When - set to ``True``, None will be returned when attempting to - find a nonexistent receiver. - :returns: A receiver object or None. - :rtype: :class:`~openstack.cluster.v1.receiver.Receiver` - """ - return self._find(_receiver.Receiver, name_or_id, - ignore_missing=ignore_missing) - - def get_receiver(self, receiver): - """Get a single receiver. - - :param receiver: The value can be the name or ID of a receiver or a - :class:`~openstack.cluster.v1.receiver.Receiver` instance. - - :returns: A receiver object. - :rtype: :class:`~openstack.cluster.v1.receiver.Receiver` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - receiver matching the criteria could be found. - """ - return self._get(_receiver.Receiver, receiver) - - def receivers(self, **query): - """Retrieve a generator of receivers. - - :param kwargs \*\*query: Optional query parameters for restricting the - receivers to be returned. Available parameters include: - - * name: The name of a receiver object. - * type: The type of receiver objects. - * cluster_id: The ID of the associated cluster. - * action: The name of the associated action. - * sort: A list of sorting keys separated by commas. Each sorting - key can optionally be attached with a sorting direction - modifier which can be ``asc`` or ``desc``. - * global_project: A boolean value indicating whether receivers - * from all projects will be returned. - - :returns: A generator of receiver instances. - """ - return self._list(_receiver.Receiver, paginated=True, **query) - - def get_action(self, action): - """Get a single action. - - :param action: The value can be the name or ID of an action or a - :class:`~openstack.cluster.v1.action.Action` instance. - - :returns: an action object. - :rtype: :class:`~openstack.cluster.v1.action.Action` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - action matching the criteria could be found. - """ - return self._get(_action.Action, action) - - def actions(self, **query): - """Retrieve a generator of actions. - - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the actions to be returned. Available parameters include: - - * name: name of action for query. - * target: ID of the target object for which the actions should be - returned. - * action: built-in action types for query. - * sort: A list of sorting keys separated by commas. Each sorting - key can optionally be attached with a sorting direction - modifier which can be ``asc`` or ``desc``. - * limit: Requests a specified size of returned items from the - query. Returns a number of items up to the specified limit - value. - * marker: Specifies the ID of the last-seen item. Use the limit - parameter to make an initial limited request and use the ID of - the last-seen item from the response as the marker parameter - value in a subsequent limited request. - - :returns: A generator of action instances. - """ - return self._list(_action.Action, paginated=True, **query) - - def get_event(self, event): - """Get a single event. - - :param event: The value can be the name or ID of an event or a - :class:`~openstack.cluster.v1.event.Event` instance. - - :returns: an event object. - :rtype: :class:`~openstack.cluster.v1.event.Event` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - event matching the criteria could be found. - """ - return self._get(_event.Event, event) - - def events(self, **query): - """Retrieve a generator of events. - - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the events to be returned. Available parameters include: - - * obj_name: name string of the object associated with an event. - * obj_type: type string of the object related to an event. The - value can be ``cluster``, ``node``, ``policy`` etc. - * obj_id: ID of the object associated with an event. - * cluster_id: ID of the cluster associated with the event, if any. - * action: name of the action associated with an event. - * sort: A list of sorting keys separated by commas. Each sorting - key can optionally be attached with a sorting direction - modifier which can be ``asc`` or ``desc``. - * limit: Requests a specified size of returned items from the - query. Returns a number of items up to the specified limit - value. - * marker: Specifies the ID of the last-seen item. Use the limit - parameter to make an initial limited request and use the ID of - the last-seen item from the response as the marker parameter - value in a subsequent limited request. - * global_project: A boolean specifying whether events from all - projects should be returned. This option is subject to access - control checking. - - :returns: A generator of event instances. - """ - return self._list(_event.Event, paginated=True, **query) - - def wait_for_status(self, resource, status, failures=[], interval=2, - wait=120): - """Wait for a resource to be in a particular status. - - :param resource: The resource to wait on to reach the specified status. - The resource must have a ``status`` attribute. - :type resource: A :class:`~openstack.resource2.Resource` object. - :param status: Desired status. - :param failures: Statuses that would be interpreted as failures. - :type failures: :py:class:`list` - :param interval: Number of seconds to wait before to consecutive - checks. Default to 2. - :param wait: Maximum number of seconds to wait before the change. - Default to 120. - :returns: The resource is returned on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` if transition - to the desired status failed to occur in specified seconds. - :raises: :class:`~openstack.exceptions.ResourceFailure` if the resource - has transited to one of the failure statuses. - :raises: :class:`~AttributeError` if the resource does not have a - ``status`` attribute. - """ - return resource2.wait_for_status(self._session, resource, status, - failures, interval, wait) - - def wait_for_delete(self, resource, interval=2, wait=120): - """Wait for a resource to be deleted. - - :param resource: The resource to wait on to be deleted. - :type resource: A :class:`~openstack.resource2.Resource` object. - :param interval: Number of seconds to wait before to consecutive - checks. Default to 2. - :param wait: Maximum number of seconds to wait before the change. - Default to 120. - :returns: The resource is returned on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` if transition - to delete failed to occur in the specified seconds. - """ - return resource2.wait_for_delete(self._session, resource, interval, - wait) - - def services(self, **query): - """Get a generator of services. - - :returns: A generator of objects that are of type - :class:`~openstack.cluster.v1.service.Service` - """ - return self._list(_service.Service, paginated=False, **query) diff --git a/openstack/cluster/v1/action.py b/openstack/cluster/v1/action.py deleted file mode 100644 index a7db8aa9..00000000 --- a/openstack/cluster/v1/action.py +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class Action(resource.Resource): - resource_key = 'action' - resources_key = 'actions' - base_path = '/actions' - service = cluster_service.ClusterService() - - # Capabilities - allow_list = True - allow_get = True - - _query_mapping = resource.QueryParameters( - 'name', 'action', 'status', 'sort', 'global_project', - target_id='target') - - # Properties - #: Name of the action. - name = resource.Body('name') - #: ID of the target object, which can be a cluster or a node. - target_id = resource.Body('target') - #: Built-in type name of action. - action = resource.Body('action') - #: A string representation of the reason why the action was created. - cause = resource.Body('cause') - #: The owning engine that is currently running the action. - owner_id = resource.Body('owner') - #: The ID of the user who created this action. - user_id = resource.Body('user') - #: The ID of the project this profile belongs to. - project_id = resource.Body('project') - #: The domain ID of the action. - domain_id = resource.Body('domain') - #: Interval in seconds between two consecutive executions. - interval = resource.Body('interval') - #: The time the action was started. - start_at = resource.Body('start_time') - #: The time the action completed execution. - end_at = resource.Body('end_time') - #: The timeout in seconds. - timeout = resource.Body('timeout') - #: Current status of the action. - status = resource.Body('status') - #: A string describing the reason that brought the action to its current - # status. - status_reason = resource.Body('status_reason') - #: A dictionary containing the inputs to the action. - inputs = resource.Body('inputs', type=dict) - #: A dictionary containing the outputs to the action. - outputs = resource.Body('outputs', type=dict) - #: A list of actions that must finish before this action starts execution. - depends_on = resource.Body('depends_on', type=list) - #: A list of actions that can start only after this action has finished. - depended_by = resource.Body('depended_by', type=list) - #: Timestamp when the action is created. - created_at = resource.Body('created_at') - #: Timestamp when the action was last updated. - updated_at = resource.Body('updated_at') diff --git a/openstack/cluster/v1/build_info.py b/openstack/cluster/v1/build_info.py deleted file mode 100644 index 78ac642a..00000000 --- a/openstack/cluster/v1/build_info.py +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class BuildInfo(resource.Resource): - base_path = '/build-info' - resource_key = 'build_info' - service = cluster_service.ClusterService() - - # Capabilities - allow_get = True - - # Properties - #: String representation of the API build version - api = resource.Body('api') - #: String representation of the engine build version - engine = resource.Body('engine') diff --git a/openstack/cluster/v1/cluster.py b/openstack/cluster/v1/cluster.py deleted file mode 100644 index a1d44ac7..00000000 --- a/openstack/cluster/v1/cluster.py +++ /dev/null @@ -1,183 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource -from openstack import utils - - -class Cluster(resource.Resource): - resource_key = 'cluster' - resources_key = 'clusters' - base_path = '/clusters' - service = cluster_service.ClusterService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - _query_mapping = resource.QueryParameters( - 'name', 'status', 'sort', 'global_project') - - # Properties - #: The name of the cluster. - name = resource.Body('name') - #: The ID of the profile used by this cluster. - profile_id = resource.Body('profile_id') - #: The ID of the user who created this cluster, thus the owner of it. - user_id = resource.Body('user') - #: The ID of the project this cluster belongs to. - project_id = resource.Body('project') - #: The domain ID of the cluster owner. - domain_id = resource.Body('domain') - #: Timestamp of when the cluster was initialized. - #: *Type: datetime object parsed from ISO 8601 formatted string* - init_at = resource.Body('init_at') - #: Timestamp of when the cluster was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.Body('created_at') - #: Timestamp of when the cluster was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.Body('updated_at') - #: Lower bound (inclusive) for the size of the cluster. - min_size = resource.Body('min_size', type=int) - #: Upper bound (inclusive) for the size of the cluster. A value of - #: -1 indicates that there is no upper limit of cluster size. - max_size = resource.Body('max_size', type=int) - #: Desired capacity for the cluster. A cluster would be created at the - #: scale specified by this value. - desired_capacity = resource.Body('desired_capacity', type=int) - #: Default timeout (in seconds) for cluster operations. - timeout = resource.Body('timeout') - #: A string representation of the cluster status. - status = resource.Body('status') - #: A string describing the reason why the cluster in current status. - status_reason = resource.Body('status_reason') - #: A dictionary configuration for cluster. - config = resource.Body('config', type=dict) - #: A collection of key-value pairs that are attached to the cluster. - metadata = resource.Body('metadata', type=dict) - #: A dictionary with some runtime data associated with the cluster. - data = resource.Body('data', type=dict) - #: A list IDs of nodes that are members of the cluster. - node_ids = resource.Body('nodes') - #: Name of the profile used by the cluster. - profile_name = resource.Body('profile_name') - #: Specify whether the cluster update should only pertain to the profile. - is_profile_only = resource.Body('profile_only', type=bool) - #: A dictionary with dependency information of the cluster - dependents = resource.Body('dependents', type=dict) - - def action(self, session, body): - url = utils.urljoin(self.base_path, self._get_id(self), 'actions') - resp = session.post(url, endpoint_filter=self.service, json=body) - return resp.json() - - def add_nodes(self, session, nodes): - body = { - 'add_nodes': { - 'nodes': nodes, - } - } - return self.action(session, body) - - def del_nodes(self, session, nodes, **params): - data = {'nodes': nodes} - data.update(params) - body = { - 'del_nodes': data - } - return self.action(session, body) - - def replace_nodes(self, session, nodes): - body = { - 'replace_nodes': { - 'nodes': nodes, - } - } - return self.action(session, body) - - def scale_out(self, session, count=None): - body = { - 'scale_out': { - 'count': count, - } - } - return self.action(session, body) - - def scale_in(self, session, count=None): - body = { - 'scale_in': { - 'count': count, - } - } - return self.action(session, body) - - def resize(self, session, **params): - body = { - 'resize': params - } - return self.action(session, body) - - def policy_attach(self, session, policy_id, **params): - data = {'policy_id': policy_id} - data.update(params) - body = { - 'policy_attach': data - } - return self.action(session, body) - - def policy_detach(self, session, policy_id): - body = { - 'policy_detach': { - 'policy_id': policy_id, - } - } - return self.action(session, body) - - def policy_update(self, session, policy_id, **params): - data = {'policy_id': policy_id} - data.update(params) - body = { - 'policy_update': data - } - return self.action(session, body) - - def check(self, session, **params): - body = { - 'check': params - } - return self.action(session, body) - - def recover(self, session, **params): - body = { - 'recover': params - } - return self.action(session, body) - - def op(self, session, operation, **params): - """Perform an operation on the cluster. - - :param session: A session object used for sending request. - :param operation: A string representing the operation to be performed. - :param dict params: An optional dict providing the parameters for the - operation. - :returns: A dictionary containing the action ID. - """ - url = utils.urljoin(self.base_path, self.id, 'ops') - resp = session.post(url, endpoint_filter=self.service, - json={operation: params}) - return resp.json() diff --git a/openstack/cluster/v1/cluster_attr.py b/openstack/cluster/v1/cluster_attr.py deleted file mode 100644 index 1755b100..00000000 --- a/openstack/cluster/v1/cluster_attr.py +++ /dev/null @@ -1,33 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class ClusterAttr(resource.Resource): - resources_key = 'cluster_attributes' - base_path = '/clusters/%(cluster_id)s/attrs/%(path)s' - service = cluster_service.ClusterService() - - # capabilities - allow_list = True - - # Properties - #: The identity of the cluster - cluster_id = resource.URI('cluster_id') - #: The json path string for attribute retrieval - path = resource.URI('path') - #: The id of the node that carries the attribute value. - node_id = resource.Body('id') - #: The value of the attribute requested. - attr_value = resource.Body('value') diff --git a/openstack/cluster/v1/cluster_policy.py b/openstack/cluster/v1/cluster_policy.py deleted file mode 100644 index 377e3d46..00000000 --- a/openstack/cluster/v1/cluster_policy.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class ClusterPolicy(resource.Resource): - resource_key = 'cluster_policy' - resources_key = 'cluster_policies' - base_path = '/clusters/%(cluster_id)s/policies' - service = cluster_service.ClusterService() - - # Capabilities - allow_list = True - allow_get = True - - _query_mapping = resource.QueryParameters( - 'sort', 'policy_name', 'policy_type', is_enabled='enabled') - - # Properties - #: ID of the policy object. - policy_id = resource.Body('policy_id', alternate_id=True) - #: Name of the policy object. - policy_name = resource.Body('policy_name') - #: ID of the cluster object. - cluster_id = resource.URI('cluster_id') - #: Name of the cluster object. - cluster_name = resource.Body('cluster_name') - #: Type string of the policy. - policy_type = resource.Body('policy_type') - #: Whether the policy is enabled on the cluster. *Type: bool* - is_enabled = resource.Body('enabled', type=bool) - #: Data associated with the cluster-policy binding. - data = resource.Body('data', type=dict) diff --git a/openstack/cluster/v1/event.py b/openstack/cluster/v1/event.py deleted file mode 100644 index d9b51fbb..00000000 --- a/openstack/cluster/v1/event.py +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class Event(resource.Resource): - resource_key = 'event' - resources_key = 'events' - base_path = '/events' - service = cluster_service.ClusterService() - - # Capabilities - allow_list = True - allow_get = True - - _query_mapping = resource.QueryParameters( - 'cluster_id', 'action', 'level', 'sort', 'global_project', - obj_id='oid', obj_name='oname', obj_type='otype', - ) - - # Properties - #: Timestamp string (in ISO8601 format) when the event was generated. - generated_at = resource.Body('timestamp') - #: The UUID of the object related to this event. - obj_id = resource.Body('oid') - #: The name of the object related to this event. - obj_name = resource.Body('oname') - #: The type name of the object related to this event. - obj_type = resource.Body('otype') - #: The UUID of the cluster related to this event, if any. - cluster_id = resource.Body('cluster_id') - #: The event level (priority). - level = resource.Body('level') - #: The ID of the user. - user_id = resource.Body('user') - #: The ID of the project (tenant). - project_id = resource.Body('project') - #: The string representation of the action associated with the event. - action = resource.Body('action') - #: The status of the associated object. - status = resource.Body('status') - #: A string description of the reason that brought the object into its - #: current status. - status_reason = resource.Body('status_reason') diff --git a/openstack/cluster/v1/node.py b/openstack/cluster/v1/node.py deleted file mode 100644 index cd067ba0..00000000 --- a/openstack/cluster/v1/node.py +++ /dev/null @@ -1,158 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource -from openstack import utils - - -class Node(resource.Resource): - resource_key = 'node' - resources_key = 'nodes' - base_path = '/nodes' - service = cluster_service.ClusterService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - patch_update = True - - _query_mapping = resource.QueryParameters( - 'show_details', 'name', 'sort', 'global_project', 'cluster_id', - 'status') - - # Properties - #: The name of the node. - name = resource.Body('name') - #: The ID of the physical object that backs the node. - physical_id = resource.Body('physical_id') - #: The ID of the cluster in which this node is a member. - #: A node is an orphan node if this field is empty. - cluster_id = resource.Body('cluster_id') - #: The ID of the profile used by this node. - profile_id = resource.Body('profile_id') - #: The domain ID of the node. - domain_id = resource.Body('domain') - #: The ID of the user who created this node. - user_id = resource.Body('user') - #: The ID of the project this node belongs to. - project_id = resource.Body('project') - #: The name of the profile used by this node. - profile_name = resource.Body('profile_name') - #: An integer that is unique inside the owning cluster. - #: A value of -1 means this node is an orphan node. - index = resource.Body('index', type=int) - #: A string indicating the role the node plays in a cluster. - role = resource.Body('role') - #: The timestamp of the node object's initialization. - #: *Type: datetime object parsed from ISO 8601 formatted string* - init_at = resource.Body('init_at') - #: The timestamp of the node's creation, i.e. the physical object - #: represented by this node is also created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.Body('created_at') - #: The timestamp the node was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.Body('updated_at') - #: A string indicating the node's status. - status = resource.Body('status') - #: A string describing why the node entered its current status. - status_reason = resource.Body('status_reason') - #: A map containing key-value pairs attached to the node. - metadata = resource.Body('metadata', type=dict) - #: A map containing some runtime data for this node. - data = resource.Body('data', type=dict) - #: A map containing the details of the physical object this node - #: represents - details = resource.Body('details', type=dict) - #: A map containing the dependency of nodes - dependents = resource.Body('dependents', type=dict) - - def _action(self, session, body): - """Procedure the invoke an action API. - - :param session: A session object used for sending request. - :param body: The body of action to be sent. - """ - url = utils.urljoin(self.base_path, self.id, 'actions') - resp = session.post(url, endpoint_filter=self.service, json=body) - return resp.json() - - def check(self, session, **params): - """An action procedure for the node to check its health status. - - :param session: A session object used for sending request. - :returns: A dictionary containing the action ID. - """ - body = { - 'check': params - } - return self._action(session, body) - - def recover(self, session, **params): - """An action procedure for the node to recover. - - :param session: A session object used for sending request. - :returns: A dictionary containing the action ID. - """ - body = { - 'recover': params - } - return self._action(session, body) - - def op(self, session, operation, **params): - """Perform an operation on the specified node. - - :param session: A session object used for sending request. - :param operation: A string representing the operation to be performed. - :param dict params: An optional dict providing the parameters for the - operation. - :returns: A dictionary containing the action ID. - """ - url = utils.urljoin(self.base_path, self.id, 'ops') - resp = session.post(url, endpoint_filter=self.service, - json={operation: params}) - return resp.json() - - def adopt(self, session, preview=False, **params): - """Adopt a node for management. - - :param session: A session object used for sending request. - :param preview: A boolean indicating whether the adoption is a - preview. A "preview" does not create the node object. - :param dict params: A dict providing the details of a node to be - adopted. - """ - path = "adopt-preview" if preview else "adopt" - url = utils.urljoin(self.base_path, path) - resp = session.post(url, endpoint_filter=self.service, json=params) - if preview: - return resp.json() - - self._translate_response(resp) - return self - - -class NodeDetail(Node): - base_path = '/nodes/%(node_id)s?show_details=True' - - allow_create = False - allow_get = True - allow_update = False - allow_delete = False - allow_list = False - - node_id = resource.URI('node_id') diff --git a/openstack/cluster/v1/policy.py b/openstack/cluster/v1/policy.py deleted file mode 100644 index 0137220b..00000000 --- a/openstack/cluster/v1/policy.py +++ /dev/null @@ -1,66 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class Policy(resource.Resource): - resource_key = 'policy' - resources_key = 'policies' - base_path = '/policies' - service = cluster_service.ClusterService() - - # Capabilities - allow_list = True - allow_get = True - allow_create = True - allow_delete = True - allow_update = True - - patch_update = True - - _query_mapping = resource.QueryParameters( - 'name', 'type', 'sort', 'global_project') - - # Properties - #: The name of the policy. - name = resource.Body('name') - #: The type name of the policy. - type = resource.Body('type') - #: The ID of the project this policy belongs to. - project_id = resource.Body('project') - # The domain ID of the policy. - domain_id = resource.Body('domain') - #: The ID of the user who created this policy. - user_id = resource.Body('user') - #: The timestamp when the policy is created. - created_at = resource.Body('created_at') - #: The timestamp when the policy was last updated. - updated_at = resource.Body('updated_at') - #: The specification of the policy. - spec = resource.Body('spec', type=dict) - #: A dictionary containing runtime data of the policy. - data = resource.Body('data', type=dict) - - -class PolicyValidate(Policy): - base_path = '/policies/validate' - - # Capabilities - allow_list = False - allow_get = False - allow_create = True - allow_delete = False - allow_update = False - - patch_update = False diff --git a/openstack/cluster/v1/policy_type.py b/openstack/cluster/v1/policy_type.py deleted file mode 100644 index aefcffec..00000000 --- a/openstack/cluster/v1/policy_type.py +++ /dev/null @@ -1,33 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class PolicyType(resource.Resource): - resource_key = 'policy_type' - resources_key = 'policy_types' - base_path = '/policy-types' - service = cluster_service.ClusterService() - - # Capabilities - allow_list = True - allow_get = True - - # Properties - #: Name of policy type. - name = resource.Body('name', alternate_id=True) - #: The schema of the policy type. - schema = resource.Body('schema') - #: The support status of the policy type - support_status = resource.Body('support_status') diff --git a/openstack/cluster/v1/profile.py b/openstack/cluster/v1/profile.py deleted file mode 100644 index 711b302f..00000000 --- a/openstack/cluster/v1/profile.py +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class Profile(resource.Resource): - resource_key = 'profile' - resources_key = 'profiles' - base_path = '/profiles' - service = cluster_service.ClusterService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - patch_update = True - - _query_mapping = resource.QueryParameters( - 'sort', 'global_project', 'type', 'name') - - # Bodyerties - #: The name of the profile - name = resource.Body('name') - #: The type of the profile. - type = resource.Body('type') - #: The ID of the project this profile belongs to. - project_id = resource.Body('project') - #: The domain ID of the profile. - domain_id = resource.Body('domain') - #: The ID of the user who created this profile. - user_id = resource.Body('user') - #: The spec of the profile. - spec = resource.Body('spec', type=dict) - #: A collection of key-value pairs that are attached to the profile. - metadata = resource.Body('metadata', type=dict) - #: Timestamp of when the profile was created. - created_at = resource.Body('created_at') - #: Timestamp of when the profile was last updated. - updated_at = resource.Body('updated_at') - - -class ProfileValidate(Profile): - base_path = '/profiles/validate' - allow_create = True - allow_get = False - allow_update = False - allow_delete = False - allow_list = False - - patch_update = False diff --git a/openstack/cluster/v1/profile_type.py b/openstack/cluster/v1/profile_type.py deleted file mode 100644 index 3b79297a..00000000 --- a/openstack/cluster/v1/profile_type.py +++ /dev/null @@ -1,33 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class ProfileType(resource.Resource): - resource_key = 'profile_type' - resources_key = 'profile_types' - base_path = '/profile-types' - service = cluster_service.ClusterService() - - # Capabilities - allow_list = True - allow_get = True - - # Properties - #: Name of the profile type. - name = resource.Body('name', alternate_id=True) - #: The schema of the profile type. - schema = resource.Body('schema') - #: The support status of the profile type - support_status = resource.Body('support_status') diff --git a/openstack/cluster/v1/receiver.py b/openstack/cluster/v1/receiver.py deleted file mode 100644 index d6940048..00000000 --- a/openstack/cluster/v1/receiver.py +++ /dev/null @@ -1,62 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class Receiver(resource.Resource): - resource_key = 'receiver' - resources_key = 'receivers' - base_path = '/receivers' - service = cluster_service.ClusterService() - - # Capabilities - allow_list = True - allow_get = True - allow_create = True - allow_update = True - allow_delete = True - - patch_update = True - - _query_mapping = resource.QueryParameters( - 'name', 'type', 'cluster_id', 'action', 'sort', 'global_project', - user_id='user') - - # Properties - #: The name of the receiver. - name = resource.Body('name') - #: The type of the receiver. - type = resource.Body('type') - #: The ID of the user who created the receiver, thus the owner of it. - user_id = resource.Body('user') - #: The ID of the project this receiver belongs to. - project_id = resource.Body('project') - #: The domain ID of the receiver. - domain_id = resource.Body('domain') - #: The ID of the targeted cluster. - cluster_id = resource.Body('cluster_id') - #: The name of the targeted action. - action = resource.Body('action') - #: Timestamp of when the receiver was created. - created_at = resource.Body('created_at') - #: Timestamp of when the receiver was last updated. - updated_at = resource.Body('updated_at') - #: The credential of the impersonated user. - actor = resource.Body('actor', type=dict) - #: A dictionary containing key-value pairs that are provided to the - #: targeted action. - params = resource.Body('params', type=dict) - #: The information about the channel through which you can trigger the - #: receiver hence the associated action. - channel = resource.Body('channel', type=dict) diff --git a/openstack/cluster/v1/service.py b/openstack/cluster/v1/service.py deleted file mode 100644 index 0bdfaa02..00000000 --- a/openstack/cluster/v1/service.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class Service(resource.Resource): - resource_key = 'service' - resources_key = 'services' - base_path = '/services' - service = cluster_service.ClusterService() - - # Capabilities - allow_list = True - - # Properties - #: Status of service - status = resource.Body('status') - #: State of service - state = resource.Body('state') - #: Name of service - binary = resource.Body('binary') - #: Disabled reason of service - disabled_reason = resource.Body('disabled_reason') - #: Host where service runs - host = resource.Body('host') - #: The timestamp the service was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.Body('updated_at') diff --git a/openstack/cluster/version.py b/openstack/cluster/version.py deleted file mode 100644 index 44549b60..00000000 --- a/openstack/cluster/version.py +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from openstack.cluster import cluster_service -from openstack import resource2 as resource - - -class Version(resource.Resource): - resource_key = 'version' - resources_key = 'versions' - base_path = '/' - service = cluster_service.ClusterService( - version=cluster_service.ClusterService.UNVERSIONED - ) - - # capabilities - allow_list = True - - # Properties - links = resource.Body('links') - status = resource.Body('status') diff --git a/openstack/compute/__init__.py b/openstack/compute/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/compute/compute_service.py b/openstack/compute/compute_service.py deleted file mode 100644 index 64c8bd9e..00000000 --- a/openstack/compute/compute_service.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class ComputeService(service_filter.ServiceFilter): - """The compute service.""" - - valid_versions = [service_filter.ValidVersion('v2')] - - def __init__(self, version=None): - """Create a compute service.""" - super(ComputeService, self).__init__(service_type='compute', - version=version) diff --git a/openstack/compute/v2/__init__.py b/openstack/compute/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/compute/v2/_proxy.py b/openstack/compute/v2/_proxy.py deleted file mode 100644 index 9ee9899b..00000000 --- a/openstack/compute/v2/_proxy.py +++ /dev/null @@ -1,1284 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute.v2 import availability_zone -from openstack.compute.v2 import extension -from openstack.compute.v2 import flavor as _flavor -from openstack.compute.v2 import hypervisor as _hypervisor -from openstack.compute.v2 import image as _image -from openstack.compute.v2 import keypair as _keypair -from openstack.compute.v2 import limits -from openstack.compute.v2 import server as _server -from openstack.compute.v2 import server_group as _server_group -from openstack.compute.v2 import server_interface as _server_interface -from openstack.compute.v2 import server_ip -from openstack.compute.v2 import service as _service -from openstack.compute.v2 import volume_attachment as _volume_attachment -from openstack import proxy2 -from openstack import resource2 - - -class Proxy(proxy2.BaseProxy): - - def find_extension(self, name_or_id, ignore_missing=True): - """Find a single extension - - :param name_or_id: The name or ID of an extension. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.compute.v2.extension.Extension` or - None - """ - return self._find(extension.Extension, name_or_id, - ignore_missing=ignore_missing) - - def extensions(self): - """Retrieve a generator of extensions - - :returns: A generator of extension instances. - :rtype: :class:`~openstack.compute.v2.extension.Extension` - """ - return self._list(extension.Extension, paginated=False) - - def find_flavor(self, name_or_id, ignore_missing=True): - """Find a single flavor - - :param name_or_id: The name or ID of a flavor. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.compute.v2.flavor.Flavor` or None - """ - return self._find(_flavor.Flavor, name_or_id, - ignore_missing=ignore_missing) - - def create_flavor(self, **attrs): - """Create a new flavor from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.compute.v2.flavor.Flavor`, - comprised of the properties on the Flavor class. - - :returns: The results of flavor creation - :rtype: :class:`~openstack.compute.v2.flavor.Flavor` - """ - return self._create(_flavor.Flavor, **attrs) - - def delete_flavor(self, flavor, ignore_missing=True): - """Delete a flavor - - :param flavor: The value can be either the ID of a flavor or a - :class:`~openstack.compute.v2.flavor.Flavor` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the flavor does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent flavor. - - :returns: ``None`` - """ - self._delete(_flavor.Flavor, flavor, ignore_missing=ignore_missing) - - def get_flavor(self, flavor): - """Get a single flavor - - :param flavor: The value can be the ID of a flavor or a - :class:`~openstack.compute.v2.flavor.Flavor` instance. - - :returns: One :class:`~openstack.compute.v2.flavor.Flavor` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_flavor.Flavor, flavor) - - def flavors(self, details=True, **query): - """Return a generator of flavors - - :param bool details: When ``True``, returns - :class:`~openstack.compute.v2.flavor.FlavorDetail` objects, - otherwise :class:`~openstack.compute.v2.flavor.Flavor`. - *Default: ``True``* - :param kwargs \*\*query: Optional query parameters to be sent to limit - the flavors being returned. - - :returns: A generator of flavor objects - """ - flv = _flavor.FlavorDetail if details else _flavor.Flavor - return self._list(flv, paginated=True, **query) - - def delete_image(self, image, ignore_missing=True): - """Delete an image - - :param image: The value can be either the ID of an image or a - :class:`~openstack.compute.v2.image.Image` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the image does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent image. - - :returns: ``None`` - """ - self._delete(_image.Image, image, ignore_missing=ignore_missing) - - def find_image(self, name_or_id, ignore_missing=True): - """Find a single image - - :param name_or_id: The name or ID of a image. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.compute.v2.image.Image` or None - """ - return self._find(_image.Image, name_or_id, - ignore_missing=ignore_missing) - - def get_image(self, image): - """Get a single image - - :param image: The value can be the ID of an image or a - :class:`~openstack.compute.v2.image.Image` instance. - - :returns: One :class:`~openstack.compute.v2.image.Image` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_image.Image, image) - - def images(self, details=True, **query): - """Return a generator of images - - :param bool details: When ``True``, returns - :class:`~openstack.compute.v2.image.ImageDetail` objects, - otherwise :class:`~openstack.compute.v2.image.Image`. - *Default: ``True``* - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of image objects - """ - img = _image.ImageDetail if details else _image.Image - return self._list(img, paginated=True, **query) - - def _get_base_resource(self, res, base): - # Metadata calls for Image and Server can work for both those - # resources but also ImageDetail and ServerDetail. If we get - # either class, use it, otherwise create an instance of the base. - if isinstance(res, base): - return res - else: - return base(id=res) - - def get_image_metadata(self, image): - """Return a dictionary of metadata for an image - - :param image: Either the ID of an image or a - :class:`~openstack.compute.v2.image.Image` or - :class:`~openstack.compute.v2.image.ImageDetail` - instance. - - :returns: A :class:`~openstack.compute.v2.image.Image` with only the - image's metadata. All keys and values are Unicode text. - :rtype: :class:`~openstack.compute.v2.image.Image` - """ - res = self._get_base_resource(image, _image.Image) - metadata = res.get_metadata(self._session) - result = _image.Image.existing(id=res.id, metadata=metadata) - return result - - def set_image_metadata(self, image, **metadata): - """Update metadata for an image - - :param image: Either the ID of an image or a - :class:`~openstack.compute.v2.image.Image` or - :class:`~openstack.compute.v2.image.ImageDetail` - instance. - :param kwargs metadata: Key/value pairs to be updated in the image's - metadata. No other metadata is modified - by this call. All keys and values are stored - as Unicode. - - :returns: A :class:`~openstack.compute.v2.image.Image` with only the - image's metadata. All keys and values are Unicode text. - :rtype: :class:`~openstack.compute.v2.image.Image` - """ - res = self._get_base_resource(image, _image.Image) - metadata = res.set_metadata(self._session, **metadata) - result = _image.Image.existing(id=res.id, metadata=metadata) - return result - - def delete_image_metadata(self, image, keys): - """Delete metadata for an image - - Note: This method will do a HTTP DELETE request for every key in keys. - - :param image: Either the ID of an image or a - :class:`~openstack.compute.v2.image.Image` or - :class:`~openstack.compute.v2.image.ImageDetail` - instance. - :param keys: The keys to delete. - - :rtype: ``None`` - """ - res = self._get_base_resource(image, _image.Image) - return res.delete_metadata(self._session, keys) - - def create_keypair(self, **attrs): - """Create a new keypair from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.compute.v2.keypair.Keypair`, - comprised of the properties on the Keypair class. - - :returns: The results of keypair creation - :rtype: :class:`~openstack.compute.v2.keypair.Keypair` - """ - return self._create(_keypair.Keypair, **attrs) - - def delete_keypair(self, keypair, ignore_missing=True): - """Delete a keypair - - :param keypair: The value can be either the ID of a keypair or a - :class:`~openstack.compute.v2.keypair.Keypair` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the keypair does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent keypair. - - :returns: ``None`` - """ - self._delete(_keypair.Keypair, keypair, ignore_missing=ignore_missing) - - def get_keypair(self, keypair): - """Get a single keypair - - :param keypair: The value can be the ID of a keypair or a - :class:`~openstack.compute.v2.keypair.Keypair` - instance. - - :returns: One :class:`~openstack.compute.v2.keypair.Keypair` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_keypair.Keypair, keypair) - - def find_keypair(self, name_or_id, ignore_missing=True): - """Find a single keypair - - :param name_or_id: The name or ID of a keypair. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.compute.v2.keypair.Keypair` or None - """ - return self._find(_keypair.Keypair, name_or_id, - ignore_missing=ignore_missing) - - def keypairs(self): - """Return a generator of keypairs - - :returns: A generator of keypair objects - :rtype: :class:`~openstack.compute.v2.keypair.Keypair` - """ - return self._list(_keypair.Keypair, paginated=False) - - def get_limits(self): - """Retrieve limits that are applied to the project's account - - :returns: A Limits object, including both - :class:`~openstack.compute.v2.limits.AbsoluteLimits` and - :class:`~openstack.compute.v2.limits.RateLimits` - :rtype: :class:`~openstack.compute.v2.limits.Limits` - """ - return self._get(limits.Limits) - - def create_server(self, **attrs): - """Create a new server from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.compute.v2.server.Server`, - comprised of the properties on the Server class. - - :returns: The results of server creation - :rtype: :class:`~openstack.compute.v2.server.Server` - """ - return self._create(_server.Server, **attrs) - - def delete_server(self, server, ignore_missing=True, force=False): - """Delete a server - - :param server: The value can be either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the server does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent server - :param bool force: When set to ``True``, the server deletion will be - forced immediatly. - - :returns: ``None`` - """ - if force: - server = self._get_resource(_server.Server, server) - server.force_delete(self._session) - else: - self._delete(_server.Server, server, ignore_missing=ignore_missing) - - def find_server(self, name_or_id, ignore_missing=True): - """Find a single server - - :param name_or_id: The name or ID of a server. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.compute.v2.server.Server` or None - """ - return self._find(_server.Server, name_or_id, - ignore_missing=ignore_missing) - - def get_server(self, server): - """Get a single server - - :param server: The value can be the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - - :returns: One :class:`~openstack.compute.v2.server.Server` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_server.Server, server) - - def servers(self, details=True, **query): - """Retrieve a generator of servers - - :param bool details: When set to ``False`` - :class:`~openstack.compute.v2.server.Server` instances - will be returned. The default, ``True``, will cause - :class:`~openstack.compute.v2.server.ServerDetail` - instances to be returned. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the servers being returned. Available parameters include: - - * changes_since: A time/date stamp for when the server last changed - status. - * image: An image resource or ID. - * flavor: A flavor resource or ID. - * name: Name of the server as a string. Can be queried with - regular expressions. The regular expression - ?name=bob returns both bob and bobb. If you must match on - only bob, you can use a regular expression that - matches the syntax of the underlying database server that - is implemented for Compute, such as MySQL or PostgreSQL. - * status: Value of the status of the server so that you can filter - on "ACTIVE" for example. - * host: Name of the host as a string. - * limit: Requests a specified page size of returned items from the - query. Returns a number of items up to the specified - limit value. Use the limit parameter to make an initial - limited request and use the ID of the last-seen item from - the response as the marker parameter value in a subsequent - limited request. - * marker: Specifies the ID of the last-seen item. Use the limit - parameter to make an initial limited request and use the - ID of the last-seen item from the response as the marker - parameter value in a subsequent limited request. - - :returns: A generator of server instances. - """ - srv = _server.ServerDetail if details else _server.Server - return self._list(srv, paginated=True, **query) - - def update_server(self, server, **attrs): - """Update a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :attrs kwargs: The attributes to update on the server represented - by ``server``. - - :returns: The updated server - :rtype: :class:`~openstack.compute.v2.server.Server` - """ - return self._update(_server.Server, server, **attrs) - - def change_server_password(self, server, new_password): - """Change the administrator password - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param str new_password: The new password to be set. - - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.change_password(self._session, new_password) - - def reset_server_state(self, server, state): - """Reset the state of server - - :param server: The server can be either the ID of a server or a - :class:`~openstack.compute.v2.server.Server`. - :param state: The state of the server to be set, `active` or - `error` are valid. - - :returns: None - """ - res = self._get_base_resource(server, _server.Server) - res.reset_state(self._session, state) - - def reboot_server(self, server, reboot_type): - """Reboot a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param str reboot_type: The type of reboot to perform. - "HARD" and "SOFT" are the current options. - - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.reboot(self._session, reboot_type) - - def rebuild_server(self, server, name, admin_password, **attrs): - """Rebuild a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param str name: The name of the server - :param str admin_password: The administrator password - :param bool preserve_ephemeral: Indicates whether the server - is rebuilt with the preservation of the ephemeral partition. - *Default: False* - :param str image: The id of an image to rebuild with. *Default: None* - :param str access_ipv4: The IPv4 address to rebuild with. - *Default: None* - :param str access_ipv6: The IPv6 address to rebuild with. - *Default: None* - :param dict metadata: A dictionary of metadata to rebuild with. - *Default: None* - :param personality: A list of dictionaries, each including a - **path** and **contents** key, to be injected - into the rebuilt server at launch. - *Default: None* - - :returns: The rebuilt :class:`~openstack.compute.v2.server.Server` - instance. - """ - server = self._get_resource(_server.Server, server) - return server.rebuild(self._session, name, admin_password, **attrs) - - def resize_server(self, server, flavor): - """Resize a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param flavor: Either the ID of a flavor or a - :class:`~openstack.compute.v2.flavor.Flavor` instance. - - :returns: None - """ - server = self._get_resource(_server.Server, server) - flavor_id = resource2.Resource._get_id(flavor) - server.resize(self._session, flavor_id) - - def confirm_server_resize(self, server): - """Confirm a server resize - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.confirm_resize(self._session) - - def revert_server_resize(self, server): - """Revert a server resize - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.revert_resize(self._session) - - def create_server_image(self, server, name, metadata=None): - """Create an image from a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param str name: The name of the image to be created. - :param dict metadata: A dictionary of metadata to be set on the image. - - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.create_image(self._session, name, metadata) - - def add_security_group_to_server(self, server, security_group): - """Add a security group to a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param security_group: Either the ID of a security group or a - :class:`~openstack.network.v2.security_group.SecurityGroup` - instance. - - :returns: None - """ - server = self._get_resource(_server.Server, server) - security_group_id = resource2.Resource._get_id(security_group) - server.add_security_group(self._session, security_group_id) - - def remove_security_group_from_server(self, server, security_group): - """Remove a security group from a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param security_group: Either the ID of a security group or a - :class:`~openstack.network.v2.security_group.SecurityGroup` - instance. - - :returns: None - """ - server = self._get_resource(_server.Server, server) - security_group_id = resource2.Resource._get_id(security_group) - server.remove_security_group(self._session, security_group_id) - - def add_fixed_ip_to_server(self, server, network_id): - """Adds a fixed IP address to a server instance. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param network_id: The ID of the network from which a fixed IP address - is about to be allocated. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.add_fixed_ip(self._session, network_id) - - def remove_fixed_ip_from_server(self, server, address): - """Removes a fixed IP address from a server instance. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param address: The fixed IP address to be disassociated from the - server. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.remove_fixed_ip(self._session, address) - - def add_floating_ip_to_server(self, server, address, fixed_address=None): - """Adds a floating IP address to a server instance. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param address: The floating IP address to be added to the server. - :param fixed_address: The fixed IP address to be associated with the - floating IP address. Used when the server is - connected to multiple networks. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.add_floating_ip(self._session, address, - fixed_address=fixed_address) - - def remove_floating_ip_from_server(self, server, address): - """Removes a floating IP address from a server instance. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param address: The floating IP address to be disassociated from the - server. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.remove_floating_ip(self._session, address) - - def backup_server(self, server, name, backup_type, rotation): - """Backup a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param name: The name of the backup image. - :param backup_type: The type of the backup, for example, daily. - :param rotation: The rotation of the back up image, the oldest - image will be removed when image count exceed - the rotation count. - - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.backup(self._session, name, backup_type, rotation) - - def pause_server(self, server): - """Pauses a server and changes its status to ``PAUSED``. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.pause(self._session) - - def unpause_server(self, server): - """Unpauses a paused server and changes its status to ``ACTIVE``. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.unpause(self._session) - - def suspend_server(self, server): - """Suspends a server and changes its status to ``SUSPENDED``. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.suspend(self._session) - - def resume_server(self, server): - """Resumes a suspended server and changes its status to ``ACTIVE``. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.resume(self._session) - - def lock_server(self, server): - """Locks a server. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.lock(self._session) - - def unlock_server(self, server): - """Unlocks a locked server. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.unlock(self._session) - - def rescue_server(self, server, admin_pass=None, image_ref=None): - """Puts a server in rescue mode and changes it status to ``RESCUE``. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param admin_pass: The password for the rescued server. If you omit - this parameter, the operation generates a new - password. - :param image_ref: The image reference to use to rescue your server. - This can be the image ID or its full URL. If you - omit this parameter, the base image reference will - be used. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.rescue(self._session, admin_pass=admin_pass, - image_ref=image_ref) - - def unrescue_server(self, server): - """Unrescues a server and changes its status to ``ACTIVE``. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.unrescue(self._session) - - def evacuate_server(self, server, host=None, admin_pass=None, force=None): - """Evacuates a server from a failed host to a new host. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param host: An optional parameter specifying the name or ID of the - host to which the server is evacuated. - :param admin_pass: An optional parameter specifying the administrative - password to access the evacuated or rebuilt server. - :param force: Force an evacuation by not verifying the provided - destination host by the scheduler. (New in API version - 2.29). - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.evacuate(self._session, host=host, admin_pass=admin_pass, - force=force) - - def start_server(self, server): - """Starts a stopped server and changes its state to ``ACTIVE``. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.start(self._session) - - def stop_server(self, server): - """Stops a running server and changes its state to ``SHUTOFF``. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.stop(self._session) - - def shelve_server(self, server): - """Shelves a server. - - All associated data and resources are kept but anything still in - memory is not retained. Policy defaults enable only users with - administrative role or the owner of the server to perform this - operation. Cloud provides could change this permission though. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.shelve(self._session) - - def unshelve_server(self, server): - """Unselves or restores a shelved server. - - Policy defaults enable only users with administrative role or the - owner of the server to perform this operation. Cloud provides could - change this permission though. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.unshelve(self._session) - - def get_server_console_output(self, server, length=None): - """Return the console output for a server. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param length: Optional number of line to fetch from the end of console - log. All lines will be returned if this is not specified. - :returns: The console output as a dict. Control characters will be - escaped to create a valid JSON string. - """ - server = self._get_resource(_server.Server, server) - return server.get_console_output(self._session, length=length) - - def wait_for_server(self, server, status='ACTIVE', failures=['ERROR'], - interval=2, wait=120): - return resource2.wait_for_status(self._session, server, status, - failures, interval, wait) - - def create_server_interface(self, server, **attrs): - """Create a new server interface from attributes - - :param server: The server can be either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance - that the interface belongs to. - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.compute.v2.server_interface.ServerInterface`, - comprised of the properties on the ServerInterface class. - - :returns: The results of server interface creation - :rtype: :class:`~openstack.compute.v2.server_interface.ServerInterface` - """ - server_id = resource2.Resource._get_id(server) - return self._create(_server_interface.ServerInterface, - server_id=server_id, **attrs) - - def delete_server_interface(self, server_interface, server=None, - ignore_missing=True): - """Delete a server interface - - :param server_interface: - The value can be either the ID of a server interface or a - :class:`~openstack.compute.v2.server_interface.ServerInterface` - instance. - :param server: This parameter need to be specified when ServerInterface - ID is given as value. It can be either the ID of a - server or a :class:`~openstack.compute.v2.server.Server` - instance that the interface belongs to. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the server interface does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent server interface. - - :returns: ``None`` - """ - server_id = self._get_uri_attribute(server_interface, server, - "server_id") - server_interface = resource2.Resource._get_id(server_interface) - - self._delete(_server_interface.ServerInterface, - port_id=server_interface, - server_id=server_id, - ignore_missing=ignore_missing) - - def get_server_interface(self, server_interface, server=None): - """Get a single server interface - - :param server_interface: - The value can be the ID of a server interface or a - :class:`~openstack.compute.v2.server_interface.ServerInterface` - instance. - :param server: This parameter need to be specified when ServerInterface - ID is given as value. It can be either the ID of a - server or a :class:`~openstack.compute.v2.server.Server` - instance that the interface belongs to. - - :returns: One - :class:`~openstack.compute.v2.server_interface.ServerInterface` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - server_id = self._get_uri_attribute(server_interface, server, - "server_id") - server_interface = resource2.Resource._get_id(server_interface) - - return self._get(_server_interface.ServerInterface, - server_id=server_id, port_id=server_interface) - - def server_interfaces(self, server): - """Return a generator of server interfaces - - :param server: The server can be either the ID of a server or a - :class:`~openstack.compute.v2.server.Server`. - - :returns: A generator of ServerInterface objects - :rtype: :class:`~openstack.compute.v2.server_interface.ServerInterface` - """ - server_id = resource2.Resource._get_id(server) - return self._list(_server_interface.ServerInterface, paginated=False, - server_id=server_id) - - def server_ips(self, server, network_label=None): - """Return a generator of server IPs - - :param server: The server can be either the ID of a server or a - :class:`~openstack.compute.v2.server.Server`. - :param network_label: The name of a particular network to list - IP addresses from. - - :returns: A generator of ServerIP objects - :rtype: :class:`~openstack.compute.v2.server_ip.ServerIP` - """ - server_id = resource2.Resource._get_id(server) - return self._list(server_ip.ServerIP, paginated=False, - server_id=server_id, network_label=network_label) - - def availability_zones(self, details=False): - """Return a generator of availability zones - - :param bool details: Return extra details about the availability - zones. This defaults to `False` as it generally - requires extra permission. - - :returns: A generator of availability zone - :rtype: :class:`~openstack.compute.v2.availability_zone.\ - AvailabilityZone` - """ - if details: - az = availability_zone.AvailabilityZoneDetail - else: - az = availability_zone.AvailabilityZone - - return self._list(az, paginated=False) - - def get_server_metadata(self, server): - """Return a dictionary of metadata for a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` or - :class:`~openstack.compute.v2.server.ServerDetail` - instance. - - :returns: A :class:`~openstack.compute.v2.server.Server` with only the - server's metadata. All keys and values are Unicode text. - :rtype: :class:`~openstack.compute.v2.server.Server` - """ - res = self._get_base_resource(server, _server.Server) - metadata = res.get_metadata(self._session) - result = _server.Server.existing(id=res.id, metadata=metadata) - return result - - def set_server_metadata(self, server, **metadata): - """Update metadata for a server - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` or - :class:`~openstack.compute.v2.server.ServerDetail` - instance. - :param kwargs metadata: Key/value pairs to be updated in the server's - metadata. No other metadata is modified - by this call. All keys and values are stored - as Unicode. - - :returns: A :class:`~openstack.compute.v2.server.Server` with only the - server's metadata. All keys and values are Unicode text. - :rtype: :class:`~openstack.compute.v2.server.Server` - """ - res = self._get_base_resource(server, _server.Server) - metadata = res.set_metadata(self._session, **metadata) - result = _server.Server.existing(id=res.id, metadata=metadata) - return result - - def delete_server_metadata(self, server, keys): - """Delete metadata for a server - - Note: This method will do a HTTP DELETE request for every key in keys. - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` or - :class:`~openstack.compute.v2.server.ServerDetail` - instance. - :param keys: The keys to delete - - :rtype: ``None`` - """ - res = self._get_base_resource(server, _server.Server) - return res.delete_metadata(self._session, keys) - - def create_server_group(self, **attrs): - """Create a new server group from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.compute.v2.server_group.ServerGroup`, - comprised of the properties on the ServerGroup class. - - :returns: The results of server group creation - :rtype: :class:`~openstack.compute.v2.server_group.ServerGroup` - """ - return self._create(_server_group.ServerGroup, **attrs) - - def delete_server_group(self, server_group, ignore_missing=True): - """Delete a server group - - :param server_group: The value can be either the ID of a server group - or a :class:`~openstack.compute.v2.server_group.ServerGroup` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the server group does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent server group. - - :returns: ``None`` - """ - self._delete(_server_group.ServerGroup, server_group, - ignore_missing=ignore_missing) - - def find_server_group(self, name_or_id, ignore_missing=True): - """Find a single server group - - :param name_or_id: The name or ID of a server group. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: - One :class:`~openstack.compute.v2.server_group.ServerGroup` object - or None - """ - return self._find(_server_group.ServerGroup, name_or_id, - ignore_missing=ignore_missing) - - def get_server_group(self, server_group): - """Get a single server group - - :param server_group: The value can be the ID of a server group or a - :class:`~openstack.compute.v2.server_group.ServerGroup` - instance. - - :returns: - A :class:`~openstack.compute.v2.server_group.ServerGroup` object. - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_server_group.ServerGroup, server_group) - - def server_groups(self, **query): - """Return a generator of server groups - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of ServerGroup objects - :rtype: :class:`~openstack.compute.v2.server_group.ServerGroup` - """ - return self._list(_server_group.ServerGroup, paginated=False, **query) - - def hypervisors(self): - """Return a generator of hypervisor - - :returns: A generator of hypervisor - :rtype: class: `~openstack.compute.v2.hypervisor.Hypervisor` - """ - - return self._list(_hypervisor.Hypervisor, paginated=False) - - def find_hypervisor(self, name_or_id, ignore_missing=True): - """Find a hypervisor from name or id to get the corresponding info - - :param name_or_id: The name or id of a hypervisor - - :returns: - One: class:`~openstack.compute.v2.hypervisor.Hypervisor` object - or None - """ - - return self._find(_hypervisor.Hypervisor, name_or_id, - ignore_missing=ignore_missing) - - def get_hypervisor(self, hypervisor): - """Get a single hypervisor - - :param hypervisor: The value can be the ID of a hypervisor or a - :class:`~openstack.compute.v2.hypervisor.Hypervisor` - instance. - - :returns: - A :class:`~openstack.compute.v2.hypervisor.Hypervisor` object. - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_hypervisor.Hypervisor, hypervisor) - - def force_service_down(self, service, host, binary): - """Force a service down - - :param service: Either the ID of a service or a - :class:`~openstack.compute.v2.server.Service` instance. - :param str host: The host where service runs. - :param str binary: The name of service. - - :returns: None - """ - service = self._get_resource(_service.Service, service) - service.force_down(self._session, host, binary) - - def disable_service(self, service, host, binary, disabled_reason=None): - """Disable a service - - :param service: Either the ID of a service or a - :class:`~openstack.compute.v2.server.Service` instance. - :param str host: The host where service runs. - :param str binary: The name of service. - :param str disabled_reason: The reason of force down a service. - - :returns: None - """ - service = self._get_resource(_service.Service, service) - service.disable(self._session, - host, binary, - disabled_reason) - - def enable_service(self, service, host, binary): - """Enable a service - - :param service: Either the ID of a service or a - :class:`~openstack.compute.v2.server.Service` instance. - :param str host: The host where service runs. - :param str binary: The name of service. - - - :returns: None - """ - service = self._get_resource(_service.Service, service) - service.enable(self._session, host, binary) - - def services(self): - """Return a generator of service - - :returns: A generator of service - :rtype: class: `~openstack.compute.v2.service.Service` - """ - - return self._list(_service.Service, paginated=False) - - def create_volume_attachment(self, server, **attrs): - """Create a new volume attachment from attributes - - :param server: The server can be either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param dict attrs: Keyword arguments which will be used to create a - :class:`~openstack.compute.v2.volume_attachment.VolumeAttachment`, - comprised of the properties on the VolumeAttachment class. - - :returns: The results of volume attachment creation - :rtype: - :class:`~openstack.compute.v2.volume_attachment.VolumeAttachment` - """ - server_id = resource2.Resource._get_id(server) - return self._create(_volume_attachment.VolumeAttachment, - server_id=server_id, **attrs) - - def update_volume_attachment(self, volume_attachment, server, - **attrs): - """update a volume attachment - - :param volume_attachment: - The value can be either the ID of a volume attachment or a - :class:`~openstack.compute.v2.volume_attachment.VolumeAttachment` - instance. - :param server: This parameter need to be specified when - VolumeAttachment ID is given as value. It can be - either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` - instance that the attachment belongs to. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the volume attachment does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent volume attachment. - - :returns: ``None`` - """ - server_id = self._get_uri_attribute(volume_attachment, server, - "server_id") - volume_attachment = resource2.Resource._get_id(volume_attachment) - - return self._update(_volume_attachment.VolumeAttachment, - attachment_id=volume_attachment, - server_id=server_id) - - def delete_volume_attachment(self, volume_attachment, server, - ignore_missing=True): - """Delete a volume attachment - - :param volume_attachment: - The value can be either the ID of a volume attachment or a - :class:`~openstack.compute.v2.volume_attachment.VolumeAttachment` - instance. - :param server: This parameter need to be specified when - VolumeAttachment ID is given as value. It can be either - the ID of a server or a - :class:`~openstack.compute.v2.server.Server` - instance that the attachment belongs to. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the volume attachment does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent volume attachment. - - :returns: ``None`` - """ - server_id = self._get_uri_attribute(volume_attachment, server, - "server_id") - volume_attachment = resource2.Resource._get_id(volume_attachment) - - self._delete(_volume_attachment.VolumeAttachment, - attachment_id=volume_attachment, - server_id=server_id, - ignore_missing=ignore_missing) - - def get_volume_attachment(self, volume_attachment, server, - ignore_missing=True): - """Get a single volume attachment - - :param volume_attachment: - The value can be the ID of a volume attachment or a - :class:`~openstack.compute.v2.volume_attachment.VolumeAttachment` - instance. - :param server: This parameter need to be specified when - VolumeAttachment ID is given as value. It can be either - the ID of a server or a - :class:`~openstack.compute.v2.server.Server` - instance that the attachment belongs to. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the volume attachment does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent volume attachment. - - :returns: One - :class:`~openstack.compute.v2.volume_attachment.VolumeAttachment` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - server_id = self._get_uri_attribute(volume_attachment, server, - "server_id") - volume_attachment = resource2.Resource._get_id(volume_attachment) - - return self._get(_volume_attachment.VolumeAttachment, - server_id=server_id, - attachment_id=volume_attachment, - ignore_missing=ignore_missing) - - def volume_attachments(self, server): - """Return a generator of volume attachments - - :param server: The server can be either the ID of a server or a - :class:`~openstack.compute.v2.server.Server`. - - :returns: A generator of VolumeAttachment objects - :rtype: - :class:`~openstack.compute.v2.volume_attachment.VolumeAttachment` - """ - server_id = resource2.Resource._get_id(server) - return self._list(_volume_attachment.VolumeAttachment, paginated=False, - server_id=server_id) - - def migrate_server(self, server): - """Migrate a server from one host to another - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.migrate(self._session) - - def live_migrate_server(self, server, host=None, force=False): - """Migrate a server from one host to target host - - :param server: Either the ID of a server or a - :class:`~openstack.compute.v2.server.Server` instance. - :param host: The host to which to migrate the server - :param force: Force a live-migration by not verifying the provided - destination host by the scheduler. - :returns: None - """ - server = self._get_resource(_server.Server, server) - server.live_migrate(self._session, host, force) diff --git a/openstack/compute/v2/availability_zone.py b/openstack/compute/v2/availability_zone.py deleted file mode 100644 index 56f49295..00000000 --- a/openstack/compute/v2/availability_zone.py +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 - - -class AvailabilityZone(resource2.Resource): - resources_key = 'availabilityZoneInfo' - base_path = '/os-availability-zone' - - service = compute_service.ComputeService() - - # capabilities - allow_list = True - - # Properties - #: name of availability zone - name = resource2.Body('zoneName') - #: state of availability zone - state = resource2.Body('zoneState') - #: hosts of availability zone - hosts = resource2.Body('hosts') - - -class AvailabilityZoneDetail(AvailabilityZone): - base_path = '/os-availability-zone/detail' diff --git a/openstack/compute/v2/extension.py b/openstack/compute/v2/extension.py deleted file mode 100644 index 6d368103..00000000 --- a/openstack/compute/v2/extension.py +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 - - -class Extension(resource2.Resource): - resource_key = 'extension' - resources_key = 'extensions' - base_path = '/extensions' - service = compute_service.ComputeService() - id_attribute = "alias" - - # capabilities - allow_get = True - allow_list = True - - # Properties - #: A short name by which this extension is also known. - alias = resource2.Body('alias', alternate_id=True) - #: Text describing this extension's purpose. - description = resource2.Body('description') - #: Links pertaining to this extension. This is a list of dictionaries, - #: each including keys ``href`` and ``rel``. - links = resource2.Body('links') - #: The name of the extension. - name = resource2.Body('name') - #: A URL pointing to the namespace for this extension. - namespace = resource2.Body('namespace') - #: Timestamp when this extension was last updated. - updated_at = resource2.Body('updated') diff --git a/openstack/compute/v2/flavor.py b/openstack/compute/v2/flavor.py deleted file mode 100644 index 34df465c..00000000 --- a/openstack/compute/v2/flavor.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 - - -class Flavor(resource2.Resource): - resource_key = 'flavor' - resources_key = 'flavors' - base_path = '/flavors' - service = compute_service.ComputeService() - - # capabilities - allow_create = True - allow_get = True - allow_delete = True - allow_list = True - - _query_mapping = resource2.QueryParameters("sort_key", "sort_dir", - min_disk="minDisk", - min_ram="minRam") - - # Properties - #: Links pertaining to this flavor. This is a list of dictionaries, - #: each including keys ``href`` and ``rel``. - links = resource2.Body('links') - #: The name of this flavor. - name = resource2.Body('name') - #: Size of the disk this flavor offers. *Type: int* - disk = resource2.Body('disk', type=int) - #: ``True`` if this is a publicly visible flavor. ``False`` if this is - #: a private image. *Type: bool* - is_public = resource2.Body('os-flavor-access:is_public', type=bool) - #: The amount of RAM (in MB) this flavor offers. *Type: int* - ram = resource2.Body('ram', type=int) - #: The number of virtual CPUs this flavor offers. *Type: int* - vcpus = resource2.Body('vcpus', type=int) - #: Size of the swap partitions. - swap = resource2.Body('swap') - #: Size of the ephemeral data disk attached to this server. *Type: int* - ephemeral = resource2.Body('OS-FLV-EXT-DATA:ephemeral', type=int) - #: ``True`` if this flavor is disabled, ``False`` if not. *Type: bool* - is_disabled = resource2.Body('OS-FLV-DISABLED:disabled', type=bool) - #: The bandwidth scaling factor this flavor receives on the network. - rxtx_factor = resource2.Body('rxtx_factor', type=float) - - -class FlavorDetail(Flavor): - base_path = '/flavors/detail' - - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_list = True diff --git a/openstack/compute/v2/hypervisor.py b/openstack/compute/v2/hypervisor.py deleted file mode 100644 index 25293f7e..00000000 --- a/openstack/compute/v2/hypervisor.py +++ /dev/null @@ -1,67 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from openstack.compute import compute_service -from openstack import resource2 - - -class Hypervisor(resource2.Resource): - resource_key = 'hypervisor' - resources_key = 'hypervisors' - base_path = '/os-hypervisors' - - service = compute_service.ComputeService() - - # capabilities - allow_get = True - allow_list = True - - # Properties - #: Status of hypervisor - status = resource2.Body('status') - #: State of hypervisor - state = resource2.Body('state') - #: Name of hypervisor - name = resource2.Body('hypervisor_hostname') - #: Service details - service_details = resource2.Body('service') - #: Count of the VCPUs in use - vcpus_used = resource2.Body('vcpus_used') - #: Count of all VCPUs - vcpus = resource2.Body('vcpus') - #: Count of the running virtual machines - running_vms = resource2.Body('running_vms') - #: The type of hypervisor - hypervisor_type = resource2.Body('hypervisor_type') - #: Version of the hypervisor - hypervisor_version = resource2.Body('hypervisor_version') - #: The amount, in gigabytes, of local storage used - local_disk_used = resource2.Body('local_gb_used') - #: The amount, in gigabytes, of the local storage device - local_disk_size = resource2.Body('local_gb') - #: The amount, in gigabytes, of free space on the local storage device - local_disk_free = resource2.Body('free_disk_gb') - #: The amount, in megabytes, of memory - memory_used = resource2.Body('memory_mb_used') - #: The amount, in megabytes, of total memory - memory_size = resource2.Body('memory_mb') - #: The amount, in megabytes, of available memory - memory_free = resource2.Body('free_ram_mb') - #: Measurement of the hypervisor's current workload - current_workload = resource2.Body('current_workload') - #: Information about the hypervisor's CPU - cpu_info = resource2.Body('cpu_info') - #: IP address of the host - host_ip = resource2.Body('host_ip') - #: Disk space available to the scheduler - disk_available = resource2.Body("disk_available_least") diff --git a/openstack/compute/v2/image.py b/openstack/compute/v2/image.py deleted file mode 100644 index a0cd539b..00000000 --- a/openstack/compute/v2/image.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack.compute.v2 import metadata -from openstack import resource2 - - -class Image(resource2.Resource, metadata.MetadataMixin): - resource_key = 'image' - resources_key = 'images' - base_path = '/images' - service = compute_service.ComputeService() - - # capabilities - allow_get = True - allow_delete = True - allow_list = True - - _query_mapping = resource2.QueryParameters("server", "name", - "status", "type", - min_disk="minDisk", - min_ram="minRam", - changes_since="changes-since") - - # Properties - #: Links pertaining to this image. This is a list of dictionaries, - #: each including keys ``href`` and ``rel``, and optionally ``type``. - links = resource2.Body('links') - #: The name of this image. - name = resource2.Body('name') - #: Timestamp when the image was created. - created_at = resource2.Body('created') - #: Metadata pertaining to this image. *Type: dict* - metadata = resource2.Body('metadata', type=dict) - #: The mimimum disk size. *Type: int* - min_disk = resource2.Body('minDisk', type=int) - #: The minimum RAM size. *Type: int* - min_ram = resource2.Body('minRam', type=int) - #: If this image is still building, its progress is represented here. - #: Once an image is created, progres will be 100. *Type: int* - progress = resource2.Body('progress', type=int) - #: The status of this image. - status = resource2.Body('status') - #: Timestamp when the image was updated. - updated_at = resource2.Body('updated') - #: Size of the image in bytes. *Type: int* - size = resource2.Body('OS-EXT-IMG-SIZE:size', type=int) - - -class ImageDetail(Image): - base_path = '/images/detail' - - allow_get = False - allow_delete = False - allow_list = True diff --git a/openstack/compute/v2/keypair.py b/openstack/compute/v2/keypair.py deleted file mode 100644 index 26580068..00000000 --- a/openstack/compute/v2/keypair.py +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 - - -class Keypair(resource2.Resource): - resource_key = 'keypair' - resources_key = 'keypairs' - base_path = '/os-keypairs' - service = compute_service.ComputeService() - - # capabilities - allow_create = True - allow_get = True - allow_delete = True - allow_list = True - - # Properties - #: The short fingerprint associated with the ``public_key`` for - #: this keypair. - fingerprint = resource2.Body('fingerprint') - # NOTE: There is in fact an 'id' field. However, it's not useful - # because all operations use the 'name' as an identifier. - # Additionally, the 'id' field only appears *after* creation, - # so suddenly you have an 'id' field filled in after the fact, - # and it just gets in the way. We need to cover this up by having - # the name be both our id and name. - #: The id identifying the keypair - id = resource2.Body('name') - #: A name identifying the keypair - name = resource2.Body('name', alternate_id=True) - #: The private key for the keypair - private_key = resource2.Body('private_key') - #: The SSH public key that is paired with the server. - public_key = resource2.Body('public_key') - - @classmethod - def list(cls, session, paginated=False): - resp = session.get(cls.base_path, endpoint_filter=cls.service, - headers={"Accept": "application/json"}) - resp = resp.json() - resp = resp[cls.resources_key] - - for data in resp: - value = cls.existing(**data[cls.resource_key]) - yield value diff --git a/openstack/compute/v2/limits.py b/openstack/compute/v2/limits.py deleted file mode 100644 index 113e2e85..00000000 --- a/openstack/compute/v2/limits.py +++ /dev/null @@ -1,109 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 - - -class AbsoluteLimits(resource2.Resource): - - #: The number of key-value pairs that can be set as image metadata. - image_meta = resource2.Body("maxImageMeta") - #: The maximum number of personality contents that can be supplied. - personality = resource2.Body("maxPersonality") - #: The maximum size, in bytes, of a personality. - personality_size = resource2.Body("maxPersonalitySize") - #: The maximum amount of security group rules allowed. - security_group_rules = resource2.Body("maxSecurityGroupRules") - #: The maximum amount of security groups allowed. - security_groups = resource2.Body("maxSecurityGroups") - #: The amount of security groups currently in use. - security_groups_used = resource2.Body("totalSecurityGroupsUsed") - #: The number of key-value pairs that can be set as sever metadata. - server_meta = resource2.Body("maxServerMeta") - #: The maximum amount of cores. - total_cores = resource2.Body("maxTotalCores") - #: The amount of cores currently in use. - total_cores_used = resource2.Body("totalCoresUsed") - #: The maximum amount of floating IPs. - floating_ips = resource2.Body("maxTotalFloatingIps") - #: The amount of floating IPs currently in use. - floating_ips_used = resource2.Body("totalFloatingIpsUsed") - #: The maximum amount of instances. - instances = resource2.Body("maxTotalInstances") - #: The amount of instances currently in use. - instances_used = resource2.Body("totalInstancesUsed") - #: The maximum amount of keypairs. - keypairs = resource2.Body("maxTotalKeypairs") - #: The maximum RAM size in megabytes. - total_ram = resource2.Body("maxTotalRAMSize") - #: The RAM size in megabytes currently in use. - total_ram_used = resource2.Body("totalRAMUsed") - #: The maximum amount of server groups. - server_groups = resource2.Body("maxServerGroups") - #: The amount of server groups currently in use. - server_groups_used = resource2.Body("totalServerGroupsUsed") - #: The maximum number of members in a server group. - server_group_members = resource2.Body("maxServerGroupMembers") - - -class RateLimit(resource2.Resource): - - #: A list of the specific limits that apply to the ``regex`` and ``uri``. - limits = resource2.Body("limit", type=list) - #: A regex representing which routes this rate limit applies to. - regex = resource2.Body("regex") - #: A URI representing which routes this rate limit applies to. - uri = resource2.Body("uri") - - -class Limits(resource2.Resource): - base_path = "/limits" - resource_key = "limits" - service = compute_service.ComputeService() - - allow_get = True - - absolute = resource2.Body("absolute", type=AbsoluteLimits) - rate = resource2.Body("rate", type=list) - - def get(self, session, requires_id=False): - """Get the Limits resource. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - - :returns: A Limits instance - :rtype: :class:`~openstack.compute.v2.limits.Limits` - """ - request = self._prepare_request(requires_id=False, prepend_key=False) - - response = session.get(request.uri, endpoint_filter=self.service) - - body = response.json() - body = body[self.resource_key] - - absolute_body = self._filter_component( - body["absolute"], AbsoluteLimits._body_mapping()) - self.absolute = AbsoluteLimits.existing(**absolute_body) - - rates_body = body["rate"] - - rates = [] - for rate_body in rates_body: - rate_body = self._filter_component(rate_body, - RateLimit._body_mapping()) - rates.append(RateLimit(**rate_body)) - - self.rate = rates - - return self diff --git a/openstack/compute/v2/metadata.py b/openstack/compute/v2/metadata.py deleted file mode 100644 index e611fd98..00000000 --- a/openstack/compute/v2/metadata.py +++ /dev/null @@ -1,98 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six - -from openstack import utils - - -class MetadataMixin(object): - - def _metadata(self, method, key=None, clear=False, delete=False, - **metadata): - for k, v in metadata.items(): - if not isinstance(v, six.string_types): - raise ValueError("The value for %s (%s) must be " - "a text string" % (k, v)) - - # If we're in a ServerDetail, we need to pop the "detail" portion - # of the URL off and then everything else will work the same. - pos = self.base_path.find("detail") - if pos != -1: - base = self.base_path[:pos] - else: - base = self.base_path - - if key is not None: - url = utils.urljoin(base, self.id, "metadata", key) - else: - url = utils.urljoin(base, self.id, "metadata") - - kwargs = {"endpoint_filter": self.service} - if metadata or clear: - # 'meta' is the key for singular modifications. - # 'metadata' is the key for mass modifications. - key = "meta" if key is not None else "metadata" - kwargs["json"] = {key: metadata} - - headers = {"Accept": ""} if delete else {} - - response = method(url, headers=headers, **kwargs) - - # DELETE doesn't return a JSON body while everything else does. - return response.json() if not delete else None - - def get_metadata(self, session): - """Retrieve metadata - - :param session: The session to use for this request. - - :returns: A dictionary of the requested metadata. All keys and values - are Unicode text. - :rtype: dict - """ - result = self._metadata(session.get) - return result["metadata"] - - def set_metadata(self, session, **metadata): - """Update metadata - - This call will replace only the metadata with the same keys - given here. Metadata with other keys will not be modified. - - :param session: The session to use for this request. - :param kwargs metadata: key/value metadata pairs to be update on - this server instance. All keys and values - are stored as Unicode. - - :returns: A dictionary of the metadata after being updated. - All keys and values are Unicode text. - :rtype: dict - """ - if not metadata: - return dict() - - result = self._metadata(session.post, **metadata) - return result["metadata"] - - def delete_metadata(self, session, keys): - """Delete metadata - - Note: This method will do a HTTP DELETE request for every key in keys. - - :param session: The session to use for this request. - :param list keys: The keys to delete. - - :rtype: ``None`` - """ - for key in keys: - self._metadata(session.delete, key=key, delete=True) diff --git a/openstack/compute/v2/server.py b/openstack/compute/v2/server.py deleted file mode 100644 index 574b7202..00000000 --- a/openstack/compute/v2/server.py +++ /dev/null @@ -1,379 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack.compute.v2 import metadata -from openstack import resource2 -from openstack import utils - - -class Server(resource2.Resource, metadata.MetadataMixin): - resource_key = 'server' - resources_key = 'servers' - base_path = '/servers' - service = compute_service.ComputeService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource2.QueryParameters("image", "flavor", "name", - "status", "host", "all_tenants", - "sort_key", "sort_dir", - "reservation_id", "tags", - "project_id", - tags_any="tags-any", - not_tags="not-tags", - not_tags_any="not-tags-any", - is_deleted="deleted", - ipv4_address="ip", - ipv6_address="ip6", - changes_since="changes-since") - - #: A list of dictionaries holding links relevant to this server. - links = resource2.Body('links') - - access_ipv4 = resource2.Body('accessIPv4') - access_ipv6 = resource2.Body('accessIPv6') - #: A dictionary of addresses this server can be accessed through. - #: The dictionary contains keys such as ``private`` and ``public``, - #: each containing a list of dictionaries for addresses of that type. - #: The addresses are contained in a dictionary with keys ``addr`` - #: and ``version``, which is either 4 or 6 depending on the protocol - #: of the IP address. *Type: dict* - addresses = resource2.Body('addresses', type=dict) - #: Timestamp of when the server was created. - created_at = resource2.Body('created') - #: The flavor reference, as a ID or full URL, for the flavor to use for - #: this server. - flavor_id = resource2.Body('flavorRef') - #: The flavor property as returned from server. - flavor = resource2.Body('flavor', type=dict) - #: An ID representing the host of this server. - host_id = resource2.Body('hostId') - #: The image reference, as a ID or full URL, for the image to use for - #: this server. - image_id = resource2.Body('imageRef') - #: The image property as returned from server. - image = resource2.Body('image', type=dict) - #: Metadata stored for this server. *Type: dict* - metadata = resource2.Body('metadata', type=dict) - #: While the server is building, this value represents the percentage - #: of completion. Once it is completed, it will be 100. *Type: int* - progress = resource2.Body('progress', type=int) - #: The ID of the project this server is associated with. - project_id = resource2.Body('tenant_id') - #: The state this server is in. Valid values include ``ACTIVE``, - #: ``BUILDING``, ``DELETED``, ``ERROR``, ``HARD_REBOOT``, ``PASSWORD``, - #: ``PAUSED``, ``REBOOT``, ``REBUILD``, ``RESCUED``, ``RESIZED``, - #: ``REVERT_RESIZE``, ``SHUTOFF``, ``SOFT_DELETED``, ``STOPPED``, - #: ``SUSPENDED``, ``UNKNOWN``, or ``VERIFY_RESIZE``. - status = resource2.Body('status') - #: Timestamp of when this server was last updated. - updated_at = resource2.Body('updated') - #: The ID of the owners of this server. - user_id = resource2.Body('user_id') - #: The name of an associated keypair - key_name = resource2.Body('key_name') - #: The disk configuration. Either AUTO or MANUAL. - disk_config = resource2.Body('OS-DCF:diskConfig') - #: Indicates whether a configuration drive enables metadata injection. - #: Not all cloud providers enable this feature. - has_config_drive = resource2.Body('config_drive') - #: The name of the availability zone this server is a part of. - availability_zone = resource2.Body('OS-EXT-AZ:availability_zone') - #: The power state of this server. - power_state = resource2.Body('OS-EXT-STS:power_state') - #: The task state of this server. - task_state = resource2.Body('OS-EXT-STS:task_state') - #: The VM state of this server. - vm_state = resource2.Body('OS-EXT-STS:vm_state') - #: A list of an attached volumes. Each item in the list contains at least - #: an "id" key to identify the specific volumes. - attached_volumes = resource2.Body( - 'os-extended-volumes:volumes_attached') - #: The timestamp when the server was launched. - launched_at = resource2.Body('OS-SRV-USG:launched_at') - #: The timestamp when the server was terminated (if it has been). - terminated_at = resource2.Body('OS-SRV-USG:terminated_at') - #: A list of applicable security groups. Each group contains keys for - #: description, name, id, and rules. - security_groups = resource2.Body('security_groups') - #: When a server is first created, it provides the administrator password. - admin_password = resource2.Body('adminPass') - #: The file path and contents, text only, to inject into the server at - #: launch. The maximum size of the file path data is 255 bytes. - #: The maximum limit is The number of allowed bytes in the decoded, - #: rather than encoded, data. - personality = resource2.Body('personality') - #: Configuration information or scripts to use upon launch. - #: Must be Base64 encoded. - user_data = resource2.Body('OS-EXT-SRV-ATTR:user_data') - #: Enables fine grained control of the block device mapping for an - #: instance. This is typically used for booting servers from volumes. - block_device_mapping = resource2.Body('block_device_mapping_v2') - #: The dictionary of data to send to the scheduler. - scheduler_hints = resource2.Body('OS-SCH-HNT:scheduler_hints', type=dict) - #: A networks object. Required parameter when there are multiple - #: networks defined for the tenant. When you do not specify the - #: networks parameter, the server attaches to the only network - #: created for the current tenant. - networks = resource2.Body('networks') - #: The hypervisor host name. Appears in the response for administrative - #: users only. - hypervisor_hostname = resource2.Body('OS-EXT-SRV-ATTR:hypervisor_hostname') - #: The instance name. The Compute API generates the instance name from the - #: instance name template. Appears in the response for administrative users - #: only. - instance_name = resource2.Body('OS-EXT-SRV-ATTR:instance_name') - - def _prepare_request(self, requires_id=True, prepend_key=True): - request = super(Server, self)._prepare_request(requires_id=requires_id, - prepend_key=prepend_key) - - server_body = request.body[self.resource_key] - - # Some names exist without prefix on requests but with a prefix - # on responses. If we find that we've populated one of these - # attributes with something and then go to make a request, swap out - # the name to the bare version. - - # Availability Zones exist with a prefix on response, but not request - az_key = "OS-EXT-AZ:availability_zone" - if az_key in server_body: - server_body["availability_zone"] = server_body.pop(az_key) - - # User Data exists with a prefix on response, but not request - ud_key = "OS-EXT-SRV-ATTR:user_data" - if ud_key in server_body: - server_body["user_data"] = server_body.pop(ud_key) - - # Scheduler hints are sent in a top-level scope, not within the - # resource_key scope like everything else. If we try to send - # scheduler_hints, pop them out of the resource_key scope and into - # their own top-level scope. - hint_key = "OS-SCH-HNT:scheduler_hints" - if hint_key in server_body: - request.body[hint_key] = server_body.pop(hint_key) - - return request - - def _action(self, session, body): - """Preform server actions given the message body.""" - # NOTE: This is using Server.base_path instead of self.base_path - # as both Server and ServerDetail instances can be acted on, but - # the URL used is sans any additional /detail/ part. - url = utils.urljoin(Server.base_path, self.id, 'action') - headers = {'Accept': ''} - return session.post( - url, endpoint_filter=self.service, json=body, headers=headers) - - def change_password(self, session, new_password): - """Change the administrator password to the given password.""" - body = {'changePassword': {'adminPass': new_password}} - self._action(session, body) - - def reboot(self, session, reboot_type): - """Reboot server where reboot_type might be 'SOFT' or 'HARD'.""" - body = {'reboot': {'type': reboot_type}} - self._action(session, body) - - def force_delete(self, session): - """Force delete a server.""" - body = {'forceDelete': None} - self._action(session, body) - - def rebuild(self, session, name, admin_password, - preserve_ephemeral=False, image=None, - access_ipv4=None, access_ipv6=None, - metadata=None, personality=None): - """Rebuild the server with the given arguments.""" - action = { - 'name': name, - 'adminPass': admin_password, - 'preserve_ephemeral': preserve_ephemeral - } - if image is not None: - action['imageRef'] = resource2.Resource._get_id(image) - if access_ipv4 is not None: - action['accessIPv4'] = access_ipv4 - if access_ipv6 is not None: - action['accessIPv6'] = access_ipv6 - if metadata is not None: - action['metadata'] = metadata - if personality is not None: - action['personality'] = personality - - body = {'rebuild': action} - response = self._action(session, body) - self._translate_response(response) - return self - - def resize(self, session, flavor): - """Resize server to flavor reference.""" - body = {'resize': {'flavorRef': flavor}} - self._action(session, body) - - def confirm_resize(self, session): - """Confirm the resize of the server.""" - body = {'confirmResize': None} - self._action(session, body) - - def revert_resize(self, session): - """Revert the resize of the server.""" - body = {'revertResize': None} - self._action(session, body) - - def create_image(self, session, name, metadata=None): - """Create image from server.""" - action = {'name': name} - if metadata is not None: - action['metadata'] = metadata - body = {'createImage': action} - self._action(session, body) - - def add_security_group(self, session, security_group): - body = {"addSecurityGroup": {"name": security_group}} - self._action(session, body) - - def remove_security_group(self, session, security_group): - body = {"removeSecurityGroup": {"name": security_group}} - self._action(session, body) - - def reset_state(self, session, state): - body = {"os-resetState": {"state": state}} - self._action(session, body) - - def add_fixed_ip(self, session, network_id): - body = {"addFixedIp": {"networkId": network_id}} - self._action(session, body) - - def remove_fixed_ip(self, session, address): - body = {"removeFixedIp": {"address": address}} - self._action(session, body) - - def add_floating_ip(self, session, address, fixed_address=None): - body = {"addFloatingIp": {"address": address}} - if fixed_address is not None: - body['addFloatingIp']['fixed_address'] = fixed_address - self._action(session, body) - - def remove_floating_ip(self, session, address): - body = {"removeFloatingIp": {"address": address}} - self._action(session, body) - - def backup(self, session, name, backup_type, rotation): - body = { - "createBackup": { - "name": name, - "backup_type": backup_type, - "rotation": rotation - } - } - self._action(session, body) - - def pause(self, session): - body = {"pause": None} - self._action(session, body) - - def unpause(self, session): - body = {"unpause": None} - self._action(session, body) - - def suspend(self, session): - body = {"suspend": None} - self._action(session, body) - - def resume(self, session): - body = {"resume": None} - self._action(session, body) - - def lock(self, session): - body = {"lock": None} - self._action(session, body) - - def unlock(self, session): - body = {"unlock": None} - self._action(session, body) - - def rescue(self, session, admin_pass=None, image_ref=None): - body = {"rescue": {}} - if admin_pass is not None: - body["rescue"]["adminPass"] = admin_pass - if image_ref is not None: - body["rescue"]["rescue_image_ref"] = image_ref - self._action(session, body) - - def unrescue(self, session): - body = {"unrescue": None} - self._action(session, body) - - def evacuate(self, session, host=None, admin_pass=None, force=None): - body = {"evacuate": {}} - if host is not None: - body["evacuate"]["host"] = host - if admin_pass is not None: - body["evacuate"]["adminPass"] = admin_pass - if force is not None: - body["evacuate"]["force"] = force - self._action(session, body) - - def start(self, session): - body = {"os-start": None} - self._action(session, body) - - def stop(self, session): - body = {"os-stop": None} - self._action(session, body) - - def shelve(self, session): - body = {"shelve": None} - self._action(session, body) - - def unshelve(self, session): - body = {"unshelve": None} - self._action(session, body) - - def migrate(self, session): - body = {"migrate": None} - self._action(session, body) - - def get_console_output(self, session, length=None): - body = {"os-getConsoleOutput": {}} - if length is not None: - body["os-getConsoleOutput"]["length"] = length - resp = self._action(session, body) - return resp.json() - - def live_migrate(self, session, host, force): - body = { - "os-migrateLive": { - "host": host, - "block_migration": "auto", - "force": force - } - } - self._action(session, body) - - -class ServerDetail(Server): - base_path = '/servers/detail' - - # capabilities - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_list = True diff --git a/openstack/compute/v2/server_group.py b/openstack/compute/v2/server_group.py deleted file mode 100644 index f57c8e58..00000000 --- a/openstack/compute/v2/server_group.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 - - -class ServerGroup(resource2.Resource): - resource_key = 'server_group' - resources_key = 'server_groups' - base_path = '/os-server-groups' - service = compute_service.ComputeService() - - _query_mapping = resource2.QueryParameters("all_projects") - - # capabilities - allow_create = True - allow_get = True - allow_delete = True - allow_list = True - - # Properties - #: A name identifying the server group - name = resource2.Body('name') - #: The list of policies supported by the server group - policies = resource2.Body('policies') - #: The list of members in the server group - member_ids = resource2.Body('members') - #: The metadata associated with the server group - metadata = resource2.Body('metadata') diff --git a/openstack/compute/v2/server_interface.py b/openstack/compute/v2/server_interface.py deleted file mode 100644 index 951f6e42..00000000 --- a/openstack/compute/v2/server_interface.py +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 - - -class ServerInterface(resource2.Resource): - resource_key = 'interfaceAttachment' - resources_key = 'interfaceAttachments' - base_path = '/servers/%(server_id)s/os-interface' - service = compute_service.ComputeService() - - # capabilities - allow_create = True - allow_get = True - allow_update = False - allow_delete = True - allow_list = True - - #: Fixed IP addresses with subnet IDs. - fixed_ips = resource2.Body('fixed_ips') - #: The MAC address. - mac_addr = resource2.Body('mac_addr') - #: The network ID. - net_id = resource2.Body('net_id') - #: The ID of the port for which you want to create an interface. - port_id = resource2.Body('port_id', alternate_id=True) - #: The port state. - port_state = resource2.Body('port_state') - #: The ID for the server. - server_id = resource2.URI('server_id') diff --git a/openstack/compute/v2/server_ip.py b/openstack/compute/v2/server_ip.py deleted file mode 100644 index bc90d645..00000000 --- a/openstack/compute/v2/server_ip.py +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 -from openstack import utils - - -class ServerIP(resource2.Resource): - resources_key = 'addresses' - base_path = '/servers/%(server_id)s/ips' - service = compute_service.ComputeService() - - # capabilities - allow_list = True - - # Properties - #: The IP address. The format of the address depends on :attr:`version` - address = resource2.Body('addr') - #: The network label, such as public or private. - network_label = resource2.URI('network_label') - #: The ID for the server. - server_id = resource2.URI('server_id') - # Version of the IP protocol. Currently either 4 or 6. - version = resource2.Body('version') - - @classmethod - def list(cls, session, paginated=False, server_id=None, - network_label=None, **params): - url = cls.base_path % {"server_id": server_id} - - if network_label is not None: - url = utils.urljoin(url, network_label) - - resp = session.get(url, endpoint_filter=cls.service) - resp = resp.json() - - if network_label is None: - resp = resp[cls.resources_key] - - for label, addresses in resp.items(): - for address in addresses: - yield cls.existing(network_label=label, - address=address["addr"], - version=address["version"]) diff --git a/openstack/compute/v2/service.py b/openstack/compute/v2/service.py deleted file mode 100644 index a36f67df..00000000 --- a/openstack/compute/v2/service.py +++ /dev/null @@ -1,82 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 -from openstack import utils - - -class Service(resource2.Resource): - resource_key = 'service' - resources_key = 'services' - base_path = '/os-services' - - service = compute_service.ComputeService() - - # capabilities - allow_list = True - allow_update = True - - # Properties - #: Status of service - status = resource2.Body('status') - #: State of service - state = resource2.Body('state') - #: Name of service - binary = resource2.Body('binary') - #: Id of service - id = resource2.Body('id') - #: Disabled reason of service - disables_reason = resource2.Body('disabled_reason') - #: Host where service runs - host = resource2.Body('host') - #: The availability zone of service - zone = resource2.Body("zone") - - def _action(self, session, action, body): - url = utils.urljoin(Service.base_path, action) - return session.put(url, endpoint_filter=self.service, json=body) - - def force_down(self, session, host, binary): - """Force a service down.""" - - body = { - 'host': host, - 'binary': binary, - 'forced_down': True, - } - - return self._action(session, 'force-down', body) - - def enable(self, session, host, binary): - """Enable service.""" - body = { - 'host': host, - 'binary': binary, - } - - return self._action(session, 'enable', body) - - def disable(self, session, host, binary, reason=None): - """Disable service.""" - body = { - 'host': host, - 'binary': binary, - } - - if not reason: - action = 'disable' - else: - body['disabled_reason'] = reason - action = 'disable-log-reason' - - return self._action(session, action, body) diff --git a/openstack/compute/v2/volume_attachment.py b/openstack/compute/v2/volume_attachment.py deleted file mode 100644 index 44ae47f6..00000000 --- a/openstack/compute/v2/volume_attachment.py +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 - - -class VolumeAttachment(resource2.Resource): - resource_key = 'volumeAttachment' - resources_key = 'volumeAttachments' - base_path = '/servers/%(server_id)s/os-volume_attachments' - service = compute_service.ComputeService() - - # capabilities - allow_create = True - allow_get = True - allow_update = False - allow_delete = True - allow_list = True - - _query_mapping = resource2.QueryParameters("limit", "offset") - - #: Name of the device such as, /dev/vdb. - device = resource2.Body('device') - #: The ID of the attachment. - id = resource2.Body('id') - #: The ID for the server. - server_id = resource2.URI('server_id') - #: The ID of the attached volume. - volume_id = resource2.Body('volumeId') - #: The ID of the attachment you want to delete or update. - attachment_id = resource2.Body('attachment_id', alternate_id=True) diff --git a/openstack/compute/version.py b/openstack/compute/version.py deleted file mode 100644 index 186f35e1..00000000 --- a/openstack/compute/version.py +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute import compute_service -from openstack import resource2 as resource - - -class Version(resource.Resource): - resource_key = 'version' - resources_key = 'versions' - base_path = '/' - service = compute_service.ComputeService( - version=compute_service.ComputeService.UNVERSIONED - ) - - # capabilities - allow_list = True - - # Properties - links = resource.Body('links') - status = resource.Body('status') - updated = resource.Body('updated') diff --git a/openstack/connection.py b/openstack/connection.py deleted file mode 100644 index 6f42d35d..00000000 --- a/openstack/connection.py +++ /dev/null @@ -1,286 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -The :class:`~openstack.connection.Connection` class is the primary interface -to the Python SDK it maintains a context for a connection to a cloud provider. -The connection has an attribute to access each supported service. The service -attributes are created dynamically based on user profiles and the service -catalog. - -Examples --------- - -At a minimum, the :class:`~openstack.connection.Connection` class needs to be -created with an authenticator or the parameters to build one. - -Create a connection -~~~~~~~~~~~~~~~~~~~ - -The following example constructor uses the identity authenticator using -username and password. The default settings for the transport are used -by this connection.:: - - from openstack import connection - auth_args = { - 'auth_url': 'http://172.20.1.108:5000/v3', - 'project_name': 'admin', - 'username': 'admin', - 'password': 'admin', - } - conn = connection.Connection(**auth_args) - -List -~~~~ - -Services are accessed through an attribute named after the service. A list -of all the projects is retrieved in this manner:: - - projects = conn.identity.list_projects() - -Find or create -~~~~~~~~~~~~~~ -If you wanted to make sure you had a network named 'jenkins', you would first -try to find it and if that fails, you would create it:: - - network = conn.network.find_network("jenkins") - if network is None: - network = conn.network.create_network({"name": "jenkins"}) - -""" -import logging -import sys - -from keystoneauth1.loading import base as ksa_loader -import os_client_config - -from openstack import exceptions -from openstack import profile as _profile -from openstack import proxy -from openstack import proxy2 -from openstack import session as _session -from openstack import utils - -_logger = logging.getLogger(__name__) - - -def from_config(cloud_name=None, cloud_config=None, options=None): - """Create a Connection using os-client-config - - :param str cloud_name: Use the `cloud_name` configuration details when - creating the Connection instance. - :param cloud_config: An instance of - `os_client_config.config.OpenStackConfig` - as returned from the os-client-config library. - If no `config` is provided, - `os_client_config.OpenStackConfig` will be called, - and the provided `cloud_name` will be used in - determining which cloud's configuration details - will be used in creation of the - `Connection` instance. - :param options: A namespace object; allows direct passing in of options to - be added to the cloud config. This does not have to be an - instance of argparse.Namespace, despite the naming of the - the `os_client_config.config.OpenStackConfig.get_one_cloud` - argument to which it is passed. - - :rtype: :class:`~openstack.connection.Connection` - """ - # TODO(thowe): I proposed that service name defaults to None in OCC - defaults = {} - prof = _profile.Profile() - services = [service.service_type for service in prof.get_services()] - for service in services: - defaults[service + '_service_name'] = None - # TODO(thowe): default is 2 which turns into v2 which doesn't work - # this stuff needs to be fixed where we keep version and path separated. - defaults['network_api_version'] = 'v2.0' - if cloud_config is None: - occ = os_client_config.OpenStackConfig(override_defaults=defaults) - cloud_config = occ.get_one_cloud(cloud=cloud_name, argparse=options) - - if cloud_config.debug: - utils.enable_logging(True, stream=sys.stdout) - - # TODO(mordred) we need to add service_type setting to openstacksdk. - # Some clouds have type overridden as well as name. - services = [service.service_type for service in prof.get_services()] - for service in cloud_config.get_services(): - if service in services: - version = cloud_config.get_api_version(service) - if version: - version = str(version) - if not version.startswith("v"): - version = "v" + version - prof.set_version(service, version) - name = cloud_config.get_service_name(service) - if name: - prof.set_name(service, name) - interface = cloud_config.get_interface(service) - if interface: - prof.set_interface(service, interface) - - region = cloud_config.get_region_name(service) - if region: - for service in services: - prof.set_region(service, region) - - # Auth - auth = cloud_config.config['auth'] - # TODO(thowe) We should be using auth_type - auth['auth_plugin'] = cloud_config.config['auth_type'] - if 'cacert' in auth: - auth['verify'] = auth.pop('cacert') - if 'cacert' in cloud_config.config: - auth['verify'] = cloud_config.config['cacert'] - insecure = cloud_config.config.get('insecure', False) - if insecure: - auth['verify'] = False - - cert = cloud_config.config.get('cert') - if cert: - key = cloud_config.config.get('key') - auth['cert'] = (cert, key) if key else cert - - return Connection(profile=prof, **auth) - - -class Connection(object): - - def __init__(self, session=None, authenticator=None, profile=None, - verify=True, cert=None, user_agent=None, - auth_plugin="password", - **auth_args): - """Create a context for a connection to a cloud provider. - - A connection needs a transport and an authenticator. The user may pass - in a transport and authenticator they want to use or they may pass in - the parameters to create a transport and authenticator. The connection - creates a - :class:`~openstack.session.Session` which uses the profile - and authenticator to perform HTTP requests. - - :param session: A session object compatible with - :class:`~openstack.session.Session`. - :type session: :class:`~openstack.session.Session` - :param authenticator: An authenticator derived from the base - authenticator plugin that was previously created. Two common - authentication identity plugins are - :class:`identity_v2 ` and - :class:`identity_v3 `. - If this parameter is not passed in, the connection will create an - authenticator. - :type authenticator: :class:`~openstack.auth.base.BaseAuthPlugin` - :param profile: If the user has any special profiles such as the - service name, region, version or interface, they may be provided - in the profile object. If no profiles are provided, the - services that appear first in the service catalog will be used. - :type profile: :class:`~openstack.profile.Profile` - :param bool verify: If a transport is not provided to the connection, - this parameter will be used to create a transport. If ``verify`` - is set to true, which is the default, the SSL cert will be - verified. It can also be set to a CA_BUNDLE path. - :param cert: If a transport is not provided to the connection then this - parameter will be used to create a transport. `cert` allows to - provide a client certificate file path or a tuple with client - certificate and key paths. - :type cert: str or tuple - :param str user_agent: If a transport is not provided to the - connection, this parameter will be used when creating a transport. - The value given here will be prepended to the default, which is - specified in :attr:`~openstack.transport.USER_AGENT`. - The resulting ``user_agent`` value is used for the ``User-Agent`` - HTTP header. - :param str auth_plugin: The name of authentication plugin to use. - The default value is ``password``. - :param auth_args: The rest of the parameters provided are assumed to be - authentication arguments that are used by the authentication - plugin. - """ - self.profile = profile if profile else _profile.Profile() - if session: - # Make sure it is the right kind of session. A keystoneauth1 - # session would work in some ways but show strange errors in - # others. E.g. a Resource.find would work with an id but fail when - # given a name because it attempts to catch - # openstack.exceptions.NotFoundException to signal that a search by - # ID failed before trying a search by name, but with a - # keystoneauth1 session the lookup by ID raises - # keystoneauth1.exceptions.NotFound instead. We need to ensure our - # Session class gets used so that our implementation of various - # methods always works as we expect. - if not isinstance(session, _session.Session): - raise exceptions.SDKException( - 'Session instance is from %s but must be from %s' % - (session.__module__, _session.__name__)) - self.session = session - else: - self.authenticator = self._create_authenticator(authenticator, - auth_plugin, - **auth_args) - self.session = _session.Session( - self.profile, auth=self.authenticator, verify=verify, - cert=cert, user_agent=user_agent) - - self._open() - - def _create_authenticator(self, authenticator, auth_plugin, **args): - if authenticator: - return authenticator - # TODO(thowe): Jamie was suggesting we should support other - # ways of loading the plugin - loader = ksa_loader.get_plugin_loader(auth_plugin) - load_args = {} - for opt in loader.get_options(): - if args.get(opt.dest): - load_args[opt.dest] = args[opt.dest] - return loader.load_from_options(**load_args) - - def _open(self): - """Open the connection. - - NOTE(thowe): Have this set up some lazy loader instead. - """ - for service in self.profile.get_services(): - self._load(service) - - def _load(self, service): - attr_name = service.get_service_module() - module = service.get_module() + "._proxy" - try: - __import__(module) - proxy_class = getattr(sys.modules[module], "Proxy") - if not (issubclass(proxy_class, proxy.BaseProxy) or - issubclass(proxy_class, proxy2.BaseProxy)): - raise TypeError("%s.Proxy must inherit from BaseProxy" % - proxy_class.__module__) - setattr(self, attr_name, proxy_class(self.session)) - except Exception as e: - _logger.warn("Unable to load %s: %s" % (module, e)) - - def authorize(self): - """Authorize this Connection - - **NOTE**: This method is optional. When an application makes a call - to any OpenStack service, this method allows you to request - a token manually before attempting to do anything else. - - :returns: A string token. - - :raises: :class:`~openstack.exceptions.HttpException` if the - authorization fails due to reasons like the credentials - provided are unable to be authorized or the `auth_plugin` - argument is missing, etc. - """ - headers = self.session.get_auth_headers() - - return headers.get('X-Auth-Token') if headers else None diff --git a/openstack/database/__init__.py b/openstack/database/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/database/database_service.py b/openstack/database/database_service.py deleted file mode 100644 index ced98053..00000000 --- a/openstack/database/database_service.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class DatabaseService(service_filter.ServiceFilter): - """The database service.""" - - valid_versions = [service_filter.ValidVersion('v1')] - - def __init__(self, version=None): - """Create a database service.""" - super(DatabaseService, self).__init__(service_type='database', - version=version) diff --git a/openstack/database/v1/__init__.py b/openstack/database/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/database/v1/_proxy.py b/openstack/database/v1/_proxy.py deleted file mode 100644 index 89a1702c..00000000 --- a/openstack/database/v1/_proxy.py +++ /dev/null @@ -1,311 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.database.v1 import database as _database -from openstack.database.v1 import flavor as _flavor -from openstack.database.v1 import instance as _instance -from openstack.database.v1 import user as _user -from openstack import proxy2 - - -class Proxy(proxy2.BaseProxy): - - def create_database(self, instance, **attrs): - """Create a new database from attributes - - :param instance: This can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.database.v1.database.Database`, - comprised of the properties on the Database class. - - :returns: The results of server creation - :rtype: :class:`~openstack.database.v1.database.Database` - """ - instance = self._get_resource(_instance.Instance, instance) - return self._create(_database.Database, instance_id=instance.id, - **attrs) - - def delete_database(self, database, instance=None, ignore_missing=True): - """Delete a database - - :param database: The value can be either the ID of a database or a - :class:`~openstack.database.v1.database.Database` instance. - :param instance: This parameter needs to be specified when - an ID is given as `database`. - It can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the database does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent database. - - :returns: ``None`` - """ - instance_id = self._get_uri_attribute(database, instance, - "instance_id") - self._delete(_database.Database, database, instance_id=instance_id, - ignore_missing=ignore_missing) - - def find_database(self, name_or_id, instance, ignore_missing=True): - """Find a single database - - :param name_or_id: The name or ID of a database. - :param instance: This can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.database.v1.database.Database` or None - """ - instance = self._get_resource(_instance.Instance, instance) - return self._find(_database.Database, name_or_id, - instance_id=instance.id, - ignore_missing=ignore_missing) - - def databases(self, instance, **query): - """Return a generator of databases - - :param instance: This can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - instance that the interface belongs to. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of database objects - :rtype: :class:`~openstack.database.v1.database.Database` - """ - instance = self._get_resource(_instance.Instance, instance) - return self._list(_database.Database, paginated=False, - instance_id=instance.id, **query) - - def get_database(self, database, instance=None): - """Get a single database - - :param instance: This parameter needs to be specified when - an ID is given as `database`. - It can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - :param database: The value can be the ID of a database or a - :class:`~openstack.database.v1.database.Database` - instance. - - :returns: One :class:`~openstack.database.v1.database.Database` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_database.Database, database) - - def find_flavor(self, name_or_id, ignore_missing=True): - """Find a single flavor - - :param name_or_id: The name or ID of a flavor. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.database.v1.flavor.Flavor` or None - """ - return self._find(_flavor.Flavor, name_or_id, - ignore_missing=ignore_missing) - - def get_flavor(self, flavor): - """Get a single flavor - - :param flavor: The value can be the ID of a flavor or a - :class:`~openstack.database.v1.flavor.Flavor` instance. - - :returns: One :class:`~openstack.database.v1.flavor.Flavor` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_flavor.Flavor, flavor) - - def flavors(self, **query): - """Return a generator of flavors - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of flavor objects - :rtype: :class:`~openstack.database.v1.flavor.Flavor` - """ - return self._list(_flavor.Flavor, paginated=False, **query) - - def create_instance(self, **attrs): - """Create a new instance from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.database.v1.instance.Instance`, - comprised of the properties on the Instance class. - - :returns: The results of server creation - :rtype: :class:`~openstack.database.v1.instance.Instance` - """ - return self._create(_instance.Instance, **attrs) - - def delete_instance(self, instance, ignore_missing=True): - """Delete an instance - - :param instance: The value can be either the ID of an instance or a - :class:`~openstack.database.v1.instance.Instance` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the instance does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent instance. - - :returns: ``None`` - """ - self._delete(_instance.Instance, instance, - ignore_missing=ignore_missing) - - def find_instance(self, name_or_id, ignore_missing=True): - """Find a single instance - - :param name_or_id: The name or ID of a instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.database.v1.instance.Instance` or None - """ - return self._find(_instance.Instance, name_or_id, - ignore_missing=ignore_missing) - - def get_instance(self, instance): - """Get a single instance - - :param instance: The value can be the ID of an instance or a - :class:`~openstack.database.v1.instance.Instance` - instance. - - :returns: One :class:`~openstack.database.v1.instance.Instance` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_instance.Instance, instance) - - def instances(self, **query): - """Return a generator of instances - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of instance objects - :rtype: :class:`~openstack.database.v1.instance.Instance` - """ - return self._list(_instance.Instance, paginated=False, **query) - - def update_instance(self, instance, **attrs): - """Update a instance - - :param instance: Either the id of a instance or a - :class:`~openstack.database.v1.instance.Instance` - instance. - :attrs kwargs: The attributes to update on the instance represented - by ``value``. - - :returns: The updated instance - :rtype: :class:`~openstack.database.v1.instance.Instance` - """ - return self._update(_instance.Instance, instance, **attrs) - - def create_user(self, instance, **attrs): - """Create a new user from attributes - - :param instance: This can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.database.v1.user.User`, - comprised of the properties on the User class. - - :returns: The results of server creation - :rtype: :class:`~openstack.database.v1.user.User` - """ - instance = self._get_resource(_instance.Instance, instance) - return self._create(_user.User, instance_id=instance.id, **attrs) - - def delete_user(self, user, instance=None, ignore_missing=True): - """Delete a user - - :param user: The value can be either the ID of a user or a - :class:`~openstack.database.v1.user.User` instance. - :param instance: This parameter needs to be specified when - an ID is given as `user`. - It can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the user does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent user. - - :returns: ``None`` - """ - instance = self._get_resource(_instance.Instance, instance) - self._delete(_user.User, user, ignore_missing=ignore_missing, - instance_id=instance.id) - - def find_user(self, name_or_id, instance, ignore_missing=True): - """Find a single user - - :param name_or_id: The name or ID of a user. - :param instance: This can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.database.v1.user.User` or None - """ - instance = self._get_resource(_instance.Instance, instance) - return self._find(_user.User, name_or_id, instance_id=instance.id, - ignore_missing=ignore_missing) - - def users(self, instance, **query): - """Return a generator of users - - :param instance: This can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of user objects - :rtype: :class:`~openstack.database.v1.user.User` - """ - instance = self._get_resource(_instance.Instance, instance) - return self._list(_user.User, instance_id=instance.id, - paginated=False, **query) - - def get_user(self, user, instance=None): - """Get a single user - - :param user: The value can be the ID of a user or a - :class:`~openstack.database.v1.user.User` instance. - :param instance: This parameter needs to be specified when - an ID is given as `database`. - It can be either the ID of an instance - or a :class:`~openstack.database.v1.instance.Instance` - - :returns: One :class:`~openstack.database.v1.user.User` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - instance = self._get_resource(_instance.Instance, instance) - return self._get(_user.User, user) diff --git a/openstack/database/v1/database.py b/openstack/database/v1/database.py deleted file mode 100644 index 3270ea98..00000000 --- a/openstack/database/v1/database.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.database import database_service -from openstack import resource2 as resource - - -class Database(resource.Resource): - resource_key = 'database' - resources_key = 'databases' - base_path = '/instances/%(instance_id)s/databases' - service = database_service.DatabaseService() - - # capabilities - allow_create = True - allow_delete = True - allow_list = True - - # Properties - #: Set of symbols and encodings. The default character set is ``utf8``. - character_set = resource.Body('character_set') - #: Set of rules for comparing characters in a character set. - #: The default value for collate is ``utf8_general_ci``. - collate = resource.Body('collate') - #: The ID of the instance - instance_id = resource.URI('instance_id') - #: The name of the database - name = resource.Body('name', alternate_id=True) diff --git a/openstack/database/v1/flavor.py b/openstack/database/v1/flavor.py deleted file mode 100644 index 38a06098..00000000 --- a/openstack/database/v1/flavor.py +++ /dev/null @@ -1,33 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.database import database_service -from openstack import resource2 as resource - - -class Flavor(resource.Resource): - resource_key = 'flavor' - resources_key = 'flavors' - base_path = '/flavors' - service = database_service.DatabaseService() - - # capabilities - allow_list = True - allow_get = True - - # Properties - #: Links associated with the flavor - links = resource.Body('links') - #: The name of the flavor - name = resource.Body('name') - #: The size in MB of RAM the flavor has - ram = resource.Body('ram') diff --git a/openstack/database/v1/instance.py b/openstack/database/v1/instance.py deleted file mode 100644 index 97660a98..00000000 --- a/openstack/database/v1/instance.py +++ /dev/null @@ -1,110 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.database import database_service -from openstack import resource2 as resource -from openstack import utils - - -class Instance(resource.Resource): - resource_key = 'instance' - resources_key = 'instances' - base_path = '/instances' - service = database_service.DatabaseService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: The flavor of the instance - flavor = resource.Body('flavor') - #: Links associated with the instance - links = resource.Body('links') - #: The name of the instance - name = resource.Body('name') - #: The status of the instance - status = resource.Body('status') - #: The size of the volume - volume = resource.Body('volume') - #: A dictionary of datastore details, often including 'type' and 'version' - #: keys - datastore = resource.Body('datastore', type=dict) - #: The ID of this instance - id = resource.Body('id') - #: The region this instance resides in - region = resource.Body('region') - #: The name of the host - hostname = resource.Body('hostname') - #: The timestamp when this instance was created - created_at = resource.Body('created') - #: The timestamp when this instance was updated - updated_at = resource.Body('updated') - - def enable_root_user(self, session): - """Enable login for the root user. - - This operation enables login from any host for the root user - and provides the user with a generated root password. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :returns: A dictionary with keys ``name`` and ``password`` specifying - the login credentials. - """ - url = utils.urljoin(self.base_path, self.id, 'root') - resp = session.post(url, endpoint_filter=self.service) - return resp.json()['user'] - - def is_root_enabled(self, session): - """Determine if root is enabled on an instance. - - Determine if root is enabled on this particular instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :returns: ``True`` if root user is enabled for a specified database - instance or ``False`` otherwise. - """ - url = utils.urljoin(self.base_path, self.id, 'root') - resp = session.get(url, endpoint_filter=self.service) - return resp.json()['rootEnabled'] - - def restart(self, session): - """Restart the database instance - - :returns: ``None`` - """ - body = {'restart': {}} - url = utils.urljoin(self.base_path, self.id, 'action') - session.post(url, endpoint_filter=self.service, json=body) - - def resize(self, session, flavor_reference): - """Resize the database instance - - :returns: ``None`` - """ - body = {'resize': {'flavorRef': flavor_reference}} - url = utils.urljoin(self.base_path, self.id, 'action') - session.post(url, endpoint_filter=self.service, json=body) - - def resize_volume(self, session, volume_size): - """Resize the volume attached to the instance - - :returns: ``None`` - """ - body = {'resize': {'volume': volume_size}} - url = utils.urljoin(self.base_path, self.id, 'action') - session.post(url, endpoint_filter=self.service, json=body) diff --git a/openstack/database/v1/user.py b/openstack/database/v1/user.py deleted file mode 100644 index a2f4116c..00000000 --- a/openstack/database/v1/user.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.database import database_service -from openstack import resource2 as resource -from openstack import utils - - -class User(resource.Resource): - resource_key = 'user' - resources_key = 'users' - base_path = '/instances/%(instance_id)s/users' - service = database_service.DatabaseService() - - # capabilities - allow_create = True - allow_delete = True - allow_list = True - - instance_id = resource.URI('instance_id') - - # Properties - #: Databases the user has access to - databases = resource.Body('databases') - #: The name of the user - name = resource.Body('name', alternate_id=True) - #: The password of the user - password = resource.Body('password') - - def _prepare_request(self, requires_id=True, prepend_key=True): - """Prepare a request for the database service's create call - - User.create calls require the resources_key. - The base_prepare_request would insert the resource_key (singular) - """ - body = {self.resources_key: self._body.dirty} - - uri = self.base_path % self._uri.attributes - uri = utils.urljoin(uri, self.id) - - return resource._Request(uri, body, None) diff --git a/openstack/exceptions.py b/openstack/exceptions.py deleted file mode 100644 index 069f020d..00000000 --- a/openstack/exceptions.py +++ /dev/null @@ -1,148 +0,0 @@ -# Copyright 2010 Jacob Kaplan-Moss -# Copyright 2011 Nebula, 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. -""" -Exception definitions. -""" - -import re - -import six - - -class SDKException(Exception): - """The base exception class for all exceptions this library raises.""" - def __init__(self, message=None, cause=None): - self.message = self.__class__.__name__ if message is None else message - self.cause = cause - super(SDKException, self).__init__(self.message) - - -class EndpointNotFound(SDKException): - """A mismatch occurred between what the client and server expect.""" - def __init__(self, message=None): - super(EndpointNotFound, self).__init__(message) - - -class InvalidResponse(SDKException): - """The response from the server is not valid for this request.""" - - def __init__(self, response): - super(InvalidResponse, self).__init__() - self.response = response - - -class InvalidRequest(SDKException): - """The request to the server is not valid.""" - - def __init__(self, message=None): - super(InvalidRequest, self).__init__(message) - - -class HttpException(SDKException): - - def __init__(self, message=None, details=None, response=None, - request_id=None, url=None, method=None, - http_status=None, cause=None): - super(HttpException, self).__init__(message=message, cause=cause) - self.details = details - self.response = response - self.request_id = request_id - self.url = url - self.method = method - self.http_status = http_status - - def __unicode__(self): - msg = self.__class__.__name__ + ": " + self.message - if self.details: - msg += ", " + six.text_type(self.details) - return msg - - def __str__(self): - return self.__unicode__() - - -class NotFoundException(HttpException): - """HTTP 404 Not Found.""" - pass - - -class MethodNotSupported(SDKException): - """The resource does not support this operation type.""" - def __init__(self, resource, method): - # This needs to work with both classes and instances. - try: - name = resource.__name__ - except AttributeError: - name = resource.__class__.__name__ - - message = ('The %s method is not supported for %s.%s' % - (method, resource.__module__, name)) - super(MethodNotSupported, self).__init__(message=message) - - -class DuplicateResource(SDKException): - """More than one resource exists with that name.""" - pass - - -class ResourceNotFound(NotFoundException): - """No resource exists with that name or id.""" - pass - - -class ResourceTimeout(SDKException): - """Timeout waiting for resource.""" - pass - - -class ResourceFailure(SDKException): - """General resource failure.""" - pass - - -def from_exception(exc): - """Return an instance of an HTTPException based on httplib response.""" - if exc.response.status_code == 404: - cls = NotFoundException - else: - cls = HttpException - - resp = exc.response - details = resp.text - resp_body = resp.content - content_type = resp.headers.get('content-type', '') - if resp_body and 'application/json' in content_type: - # Iterate over the nested objects to retrieve "message" attribute. - messages = [obj.get('message') for obj in resp.json().values() - if isinstance(obj, dict)] - # Join all of the messages together nicely and filter out any objects - # that don't have a "message" attr. - details = '\n'.join(msg for msg in messages if msg) - - elif resp_body and 'text/html' in content_type: - # Split the lines, strip whitespace and inline HTML from the response. - details = [re.sub(r'<.+?>', '', i.strip()) - for i in details.splitlines()] - details = [msg for msg in details if msg] - # Remove duplicates from the list. - details_temp = [] - for detail in details: - if detail not in details_temp: - details_temp.append(detail) - # Return joined string separated by colons. - details = ': '.join(details_temp) - return cls(details=details, message=exc.message, response=exc.response, - request_id=exc.request_id, url=exc.url, method=exc.method, - http_status=exc.http_status, cause=exc) diff --git a/openstack/format.py b/openstack/format.py deleted file mode 100644 index 94fd310f..00000000 --- a/openstack/format.py +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -class Formatter(object): - - @classmethod - def serialize(cls, value): - """Return a string representing the formatted value""" - raise NotImplementedError - - @classmethod - def deserialize(cls, value): - """Return a formatted object representing the value""" - raise NotImplementedError - - -class BoolStr(Formatter): - - @classmethod - def deserialize(cls, value): - """Convert a boolean string to a boolean""" - expr = str(value).lower() - if "true" == expr: - return True - elif "false" == expr: - return False - else: - raise ValueError("Unable to deserialize boolean string: %s" - % value) - - @classmethod - def serialize(cls, value): - """Convert a boolean to a boolean string""" - if isinstance(value, bool): - if value: - return "true" - else: - return "false" - else: - raise ValueError("Unable to serialize boolean string: %s" - % value) diff --git a/openstack/identity/__init__.py b/openstack/identity/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/identity/identity_service.py b/openstack/identity/identity_service.py deleted file mode 100644 index 4bcfafa5..00000000 --- a/openstack/identity/identity_service.py +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class IdentityService(service_filter.ServiceFilter): - """The identity service.""" - - valid_versions = [ - service_filter.ValidVersion('v3'), - service_filter.ValidVersion('v2'), - ] - - def __init__(self, **kwargs): - """Create an identity service.""" - kwargs['service_type'] = 'identity' - super(IdentityService, self).__init__(**kwargs) - - -class AdminService(IdentityService): - - def __init__(self, **kwargs): - kwargs['interface'] = service_filter.ServiceFilter.ADMIN - super(AdminService, self).__init__(**kwargs) diff --git a/openstack/identity/v2/__init__.py b/openstack/identity/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/identity/v2/_proxy.py b/openstack/identity/v2/_proxy.py deleted file mode 100644 index e371da5e..00000000 --- a/openstack/identity/v2/_proxy.py +++ /dev/null @@ -1,272 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity.v2 import extension as _extension -from openstack.identity.v2 import role as _role -from openstack.identity.v2 import tenant as _tenant -from openstack.identity.v2 import user as _user -from openstack import proxy2 as proxy - - -class Proxy(proxy.BaseProxy): - - def extensions(self): - """Retrieve a generator of extensions - - :returns: A generator of extension instances. - :rtype: :class:`~openstack.identity.v2.extension.Extension` - """ - return self._list(_extension.Extension, paginated=False) - - def get_extension(self, extension): - """Get a single extension - - :param extension: The value can be the ID of an extension or a - :class:`~openstack.identity.v2.extension.Extension` - instance. - - :returns: One :class:`~openstack.identity.v2.extension.Extension` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no extension can be found. - """ - return self._get(_extension.Extension, extension) - - def create_role(self, **attrs): - """Create a new role from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v2.role.Role`, - comprised of the properties on the Role class. - - :returns: The results of role creation - :rtype: :class:`~openstack.identity.v2.role.Role` - """ - return self._create(_role.Role, **attrs) - - def delete_role(self, role, ignore_missing=True): - """Delete a role - - :param role: The value can be either the ID of a role or a - :class:`~openstack.identity.v2.role.Role` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the role does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent role. - - :returns: ``None`` - """ - self._delete(_role.Role, role, ignore_missing=ignore_missing) - - def find_role(self, name_or_id, ignore_missing=True): - """Find a single role - - :param name_or_id: The name or ID of a role. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v2.role.Role` or None - """ - return self._find(_role.Role, name_or_id, - ignore_missing=ignore_missing) - - def get_role(self, role): - """Get a single role - - :param role: The value can be the ID of a role or a - :class:`~openstack.identity.v2.role.Role` instance. - - :returns: One :class:`~openstack.identity.v2.role.Role` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_role.Role, role) - - def roles(self, **query): - """Retrieve a generator of roles - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of role instances. - :rtype: :class:`~openstack.identity.v2.role.Role` - """ - return self._list(_role.Role, paginated=False, **query) - - def update_role(self, role, **attrs): - """Update a role - - :param role: Either the ID of a role or a - :class:`~openstack.identity.v2.role.Role` instance. - :attrs kwargs: The attributes to update on the role represented - by ``value``. - - :returns: The updated role - :rtype: :class:`~openstack.identity.v2.role.Role` - """ - return self._update(_role.Role, role, **attrs) - - def create_tenant(self, **attrs): - """Create a new tenant from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v2.tenant.Tenant`, - comprised of the properties on the Tenant class. - - :returns: The results of tenant creation - :rtype: :class:`~openstack.identity.v2.tenant.Tenant` - """ - return self._create(_tenant.Tenant, **attrs) - - def delete_tenant(self, tenant, ignore_missing=True): - """Delete a tenant - - :param tenant: The value can be either the ID of a tenant or a - :class:`~openstack.identity.v2.tenant.Tenant` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the tenant does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent tenant. - - :returns: ``None`` - """ - self._delete(_tenant.Tenant, tenant, ignore_missing=ignore_missing) - - def find_tenant(self, name_or_id, ignore_missing=True): - """Find a single tenant - - :param name_or_id: The name or ID of a tenant. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v2.tenant.Tenant` or None - """ - return self._find(_tenant.Tenant, name_or_id, - ignore_missing=ignore_missing) - - def get_tenant(self, tenant): - """Get a single tenant - - :param tenant: The value can be the ID of a tenant or a - :class:`~openstack.identity.v2.tenant.Tenant` instance. - - :returns: One :class:`~openstack.identity.v2.tenant.Tenant` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_tenant.Tenant, tenant) - - def tenants(self, **query): - """Retrieve a generator of tenants - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of tenant instances. - :rtype: :class:`~openstack.identity.v2.tenant.Tenant` - """ - return self._list(_tenant.Tenant, paginated=True, **query) - - def update_tenant(self, tenant, **attrs): - """Update a tenant - - :param tenant: Either the ID of a tenant or a - :class:`~openstack.identity.v2.tenant.Tenant` instance. - :attrs kwargs: The attributes to update on the tenant represented - by ``value``. - - :returns: The updated tenant - :rtype: :class:`~openstack.identity.v2.tenant.Tenant` - """ - return self._update(_tenant.Tenant, tenant, **attrs) - - def create_user(self, **attrs): - """Create a new user from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v2.user.User`, - comprised of the properties on the User class. - - :returns: The results of user creation - :rtype: :class:`~openstack.identity.v2.user.User` - """ - return self._create(_user.User, **attrs) - - def delete_user(self, user, ignore_missing=True): - """Delete a user - - :param user: The value can be either the ID of a user or a - :class:`~openstack.identity.v2.user.User` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the user does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent user. - - :returns: ``None`` - """ - self._delete(_user.User, user, ignore_missing=ignore_missing) - - def find_user(self, name_or_id, ignore_missing=True): - """Find a single user - - :param name_or_id: The name or ID of a user. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v2.user.User` or None - """ - return self._find(_user.User, name_or_id, - ignore_missing=ignore_missing) - - def get_user(self, user): - """Get a single user - - :param user: The value can be the ID of a user or a - :class:`~openstack.identity.v2.user.User` instance. - - :returns: One :class:`~openstack.identity.v2.user.User` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_user.User, user) - - def users(self, **query): - """Retrieve a generator of users - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of user instances. - :rtype: :class:`~openstack.identity.v2.user.User` - """ - return self._list(_user.User, paginated=False, **query) - - def update_user(self, user, **attrs): - """Update a user - - :param user: Either the ID of a user or a - :class:`~openstack.identity.v2.user.User` instance. - :attrs kwargs: The attributes to update on the user represented - by ``value``. - - :returns: The updated user - :rtype: :class:`~openstack.identity.v2.user.User` - """ - return self._update(_user.User, user, **attrs) diff --git a/openstack/identity/v2/extension.py b/openstack/identity/v2/extension.py deleted file mode 100644 index b4160aad..00000000 --- a/openstack/identity/v2/extension.py +++ /dev/null @@ -1,53 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Extension(resource.Resource): - resource_key = 'extension' - resources_key = 'extensions' - base_path = '/extensions' - service = identity_service.IdentityService() - - # capabilities - allow_list = True - allow_get = True - - # Properties - #: A unique identifier, which will be used for accessing the extension - #: through a dedicated url ``/extensions/*alias*``. The extension - #: alias uniquely identifies an extension and is prefixed by a vendor - #: identifier. *Type: string* - alias = resource.Body('alias', alternate_id=True) - #: A description of the extension. *Type: string* - description = resource.Body('description') - #: Links to the documentation in various format. *Type: string* - links = resource.Body('links') - #: The name of the extension. *Type: string* - name = resource.Body('name') - #: The second unique identifier of the extension after the alias. - #: It is usually a URL which will be used. Example: - #: "http://docs.openstack.org/identity/api/ext/s3tokens/v1.0" - #: *Type: string* - namespace = resource.Body('namespace') - #: The last time the extension has been modified (update date). - updated_at = resource.Body('updated') - - @classmethod - def list(cls, session, paginated=False, **params): - resp = session.get(cls.base_path, endpoint_filter=cls.service, - params=params) - resp = resp.json() - for data in resp[cls.resources_key]['values']: - yield cls.existing(**data) diff --git a/openstack/identity/v2/role.py b/openstack/identity/v2/role.py deleted file mode 100644 index b3b0a036..00000000 --- a/openstack/identity/v2/role.py +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import format -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Role(resource.Resource): - resource_key = 'role' - resources_key = 'roles' - base_path = '/OS-KSADM/roles' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: The description of the role. *Type: string* - description = resource.Body('description') - #: Setting this attribute to ``False`` prevents this role from being - #: available in the role list. *Type: bool* - is_enabled = resource.Body('enabled', type=format.BoolStr) - #: Unique role name. *Type: string* - name = resource.Body('name') diff --git a/openstack/identity/v2/tenant.py b/openstack/identity/v2/tenant.py deleted file mode 100644 index f6933d5a..00000000 --- a/openstack/identity/v2/tenant.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Tenant(resource.Resource): - resource_key = 'tenant' - resources_key = 'tenants' - base_path = '/tenants' - service = identity_service.AdminService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: The description of the tenant. *Type: string* - description = resource.Body('description') - #: Setting this attribute to ``False`` prevents users from authorizing - #: against this tenant. Additionally, all pre-existing tokens authorized - #: for the tenant are immediately invalidated. Re-enabling a tenant - #: does not re-enable pre-existing tokens. *Type: bool* - is_enabled = resource.Body('enabled', type=bool) - #: Unique tenant name. *Type: string* - name = resource.Body('name') diff --git a/openstack/identity/v2/user.py b/openstack/identity/v2/user.py deleted file mode 100644 index 0e5a5846..00000000 --- a/openstack/identity/v2/user.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class User(resource.Resource): - resource_key = 'user' - resources_key = 'users' - base_path = '/users' - service = identity_service.AdminService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: The email of this user. *Type: string* - email = resource.Body('email') - #: Setting this value to ``False`` prevents the user from authenticating or - #: receiving authorization. Additionally, all pre-existing tokens held by - #: the user are immediately invalidated. Re-enabling a user does not - #: re-enable pre-existing tokens. *Type: bool* - is_enabled = resource.Body('enabled', type=bool) - #: The name of this user. *Type: string* - name = resource.Body('name') diff --git a/openstack/identity/v3/__init__.py b/openstack/identity/v3/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/identity/v3/_proxy.py b/openstack/identity/v3/_proxy.py deleted file mode 100644 index 29f90f12..00000000 --- a/openstack/identity/v3/_proxy.py +++ /dev/null @@ -1,958 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import openstack.exceptions as exception -from openstack.identity.v3 import credential as _credential -from openstack.identity.v3 import domain as _domain -from openstack.identity.v3 import endpoint as _endpoint -from openstack.identity.v3 import group as _group -from openstack.identity.v3 import policy as _policy -from openstack.identity.v3 import project as _project -from openstack.identity.v3 import region as _region -from openstack.identity.v3 import role as _role -from openstack.identity.v3 import role_assignment as _role_assignment -from openstack.identity.v3 import role_domain_group_assignment \ - as _role_domain_group_assignment -from openstack.identity.v3 import role_domain_user_assignment \ - as _role_domain_user_assignment -from openstack.identity.v3 import role_project_group_assignment \ - as _role_project_group_assignment -from openstack.identity.v3 import role_project_user_assignment \ - as _role_project_user_assignment -from openstack.identity.v3 import service as _service -from openstack.identity.v3 import trust as _trust -from openstack.identity.v3 import user as _user -from openstack import proxy2 as proxy - - -class Proxy(proxy.BaseProxy): - - def create_credential(self, **attrs): - """Create a new credential from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.credential.Credential`, - comprised of the properties on the Credential class. - - :returns: The results of credential creation - :rtype: :class:`~openstack.identity.v3.credential.Credential` - """ - return self._create(_credential.Credential, **attrs) - - def delete_credential(self, credential, ignore_missing=True): - """Delete a credential - - :param credential: The value can be either the ID of a credential or a - :class:`~openstack.identity.v3.credential.Credential` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the credential does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent credential. - - :returns: ``None`` - """ - self._delete(_credential.Credential, credential, - ignore_missing=ignore_missing) - - def find_credential(self, name_or_id, ignore_missing=True): - """Find a single credential - - :param name_or_id: The name or ID of a credential. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v3.credential.Credential` - or None - """ - return self._find(_credential.Credential, name_or_id, - ignore_missing=ignore_missing) - - def get_credential(self, credential): - """Get a single credential - - :param credential: The value can be the ID of a credential or a - :class:`~openstack.identity.v3.credential.Credential` instance. - - :returns: One :class:`~openstack.identity.v3.credential.Credential` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_credential.Credential, credential) - - def credentials(self, **query): - """Retrieve a generator of credentials - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of credentials instances. - :rtype: :class:`~openstack.identity.v3.credential.Credential` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_credential.Credential, paginated=False, **query) - - def update_credential(self, credential, **attrs): - """Update a credential - - :param credential: Either the ID of a credential or a - :class:`~openstack.identity.v3.credential.Credential` instance. - :attrs kwargs: The attributes to update on the credential represented - by ``value``. - - :returns: The updated credential - :rtype: :class:`~openstack.identity.v3.credential.Credential` - """ - return self._update(_credential.Credential, credential, **attrs) - - def create_domain(self, **attrs): - """Create a new domain from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.domain.Domain`, - comprised of the properties on the Domain class. - - :returns: The results of domain creation - :rtype: :class:`~openstack.identity.v3.domain.Domain` - """ - return self._create(_domain.Domain, **attrs) - - def delete_domain(self, domain, ignore_missing=True): - """Delete a domain - - :param domain: The value can be either the ID of a domain or a - :class:`~openstack.identity.v3.domain.Domain` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the domain does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent domain. - - :returns: ``None`` - """ - self._delete(_domain.Domain, domain, ignore_missing=ignore_missing) - - def find_domain(self, name_or_id, ignore_missing=True): - """Find a single domain - - :param name_or_id: The name or ID of a domain. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v3.domain.Domain` or None - """ - return self._find(_domain.Domain, name_or_id, - ignore_missing=ignore_missing) - - def get_domain(self, domain): - """Get a single domain - - :param domain: The value can be the ID of a domain or a - :class:`~openstack.identity.v3.domain.Domain` instance. - - :returns: One :class:`~openstack.identity.v3.domain.Domain` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_domain.Domain, domain) - - def domains(self, **query): - """Retrieve a generator of domains - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of domain instances. - :rtype: :class:`~openstack.identity.v3.domain.Domain` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_domain.Domain, paginated=False, **query) - - def update_domain(self, domain, **attrs): - """Update a domain - - :param domain: Either the ID of a domain or a - :class:`~openstack.identity.v3.domain.Domain` instance. - :attrs kwargs: The attributes to update on the domain represented - by ``value``. - - :returns: The updated domain - :rtype: :class:`~openstack.identity.v3.domain.Domain` - """ - return self._update(_domain.Domain, domain, **attrs) - - def create_endpoint(self, **attrs): - """Create a new endpoint from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.endpoint.Endpoint`, - comprised of the properties on the Endpoint class. - - :returns: The results of endpoint creation - :rtype: :class:`~openstack.identity.v3.endpoint.Endpoint` - """ - return self._create(_endpoint.Endpoint, **attrs) - - def delete_endpoint(self, endpoint, ignore_missing=True): - """Delete an endpoint - - :param endpoint: The value can be either the ID of an endpoint or a - :class:`~openstack.identity.v3.endpoint.Endpoint` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the endpoint does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent endpoint. - - :returns: ``None`` - """ - self._delete(_endpoint.Endpoint, endpoint, - ignore_missing=ignore_missing) - - def find_endpoint(self, name_or_id, ignore_missing=True): - """Find a single endpoint - - :param name_or_id: The name or ID of a endpoint. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v3.endpoint.Endpoint` or None - """ - return self._find(_endpoint.Endpoint, name_or_id, - ignore_missing=ignore_missing) - - def get_endpoint(self, endpoint): - """Get a single endpoint - - :param endpoint: The value can be the ID of an endpoint or a - :class:`~openstack.identity.v3.endpoint.Endpoint` - instance. - - :returns: One :class:`~openstack.identity.v3.endpoint.Endpoint` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_endpoint.Endpoint, endpoint) - - def endpoints(self, **query): - """Retrieve a generator of endpoints - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of endpoint instances. - :rtype: :class:`~openstack.identity.v3.endpoint.Endpoint` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_endpoint.Endpoint, paginated=False, **query) - - def update_endpoint(self, endpoint, **attrs): - """Update a endpoint - - :param endpoint: Either the ID of a endpoint or a - :class:`~openstack.identity.v3.endpoint.Endpoint` - instance. - :attrs kwargs: The attributes to update on the endpoint represented - by ``value``. - - :returns: The updated endpoint - :rtype: :class:`~openstack.identity.v3.endpoint.Endpoint` - """ - return self._update(_endpoint.Endpoint, endpoint, **attrs) - - def create_group(self, **attrs): - """Create a new group from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.group.Group`, - comprised of the properties on the Group class. - - :returns: The results of group creation - :rtype: :class:`~openstack.identity.v3.group.Group` - """ - return self._create(_group.Group, **attrs) - - def delete_group(self, group, ignore_missing=True): - """Delete a group - - :param group: The value can be either the ID of a group or a - :class:`~openstack.identity.v3.group.Group` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the group does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent group. - - :returns: ``None`` - """ - self._delete(_group.Group, group, ignore_missing=ignore_missing) - - def find_group(self, name_or_id, ignore_missing=True): - """Find a single group - - :param name_or_id: The name or ID of a group. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v3.group.Group` or None - """ - return self._find(_group.Group, name_or_id, - ignore_missing=ignore_missing) - - def get_group(self, group): - """Get a single group - - :param group: The value can be the ID of a group or a - :class:`~openstack.identity.v3.group.Group` - instance. - - :returns: One :class:`~openstack.identity.v3.group.Group` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_group.Group, group) - - def groups(self, **query): - """Retrieve a generator of groups - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of group instances. - :rtype: :class:`~openstack.identity.v3.group.Group` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_group.Group, paginated=False, **query) - - def update_group(self, group, **attrs): - """Update a group - - :param group: Either the ID of a group or a - :class:`~openstack.identity.v3.group.Group` instance. - :attrs kwargs: The attributes to update on the group represented - by ``value``. - - :returns: The updated group - :rtype: :class:`~openstack.identity.v3.group.Group` - """ - return self._update(_group.Group, group, **attrs) - - def create_policy(self, **attrs): - """Create a new policy from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.policy.Policy`, - comprised of the properties on the Policy class. - - :returns: The results of policy creation - :rtype: :class:`~openstack.identity.v3.policy.Policy` - """ - return self._create(_policy.Policy, **attrs) - - def delete_policy(self, policy, ignore_missing=True): - """Delete a policy - - :param policy: The value can be either the ID of a policy or a - :class:`~openstack.identity.v3.policy.Policy` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the policy does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent policy. - - :returns: ``None`` - """ - self._delete(_policy.Policy, policy, ignore_missing=ignore_missing) - - def find_policy(self, name_or_id, ignore_missing=True): - """Find a single policy - - :param name_or_id: The name or ID of a policy. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v3.policy.Policy` or None - """ - return self._find(_policy.Policy, name_or_id, - ignore_missing=ignore_missing) - - def get_policy(self, policy): - """Get a single policy - - :param policy: The value can be the ID of a policy or a - :class:`~openstack.identity.v3.policy.Policy` instance. - - :returns: One :class:`~openstack.identity.v3.policy.Policy` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_policy.Policy, policy) - - def policies(self, **query): - """Retrieve a generator of policies - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of policy instances. - :rtype: :class:`~openstack.identity.v3.policy.Policy` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_policy.Policy, paginated=False, **query) - - def update_policy(self, policy, **attrs): - """Update a policy - - :param policy: Either the ID of a policy or a - :class:`~openstack.identity.v3.policy.Policy` instance. - :attrs kwargs: The attributes to update on the policy represented - by ``value``. - - :returns: The updated policy - :rtype: :class:`~openstack.identity.v3.policy.Policy` - """ - return self._update(_policy.Policy, policy, **attrs) - - def create_project(self, **attrs): - """Create a new project from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.project.Project`, - comprised of the properties on the Project class. - - :returns: The results of project creation - :rtype: :class:`~openstack.identity.v3.project.Project` - """ - return self._create(_project.Project, **attrs) - - def delete_project(self, project, ignore_missing=True): - """Delete a project - - :param project: The value can be either the ID of a project or a - :class:`~openstack.identity.v3.project.Project` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the project does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent project. - - :returns: ``None`` - """ - self._delete(_project.Project, project, ignore_missing=ignore_missing) - - def find_project(self, name_or_id, ignore_missing=True): - """Find a single project - - :param name_or_id: The name or ID of a project. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v3.project.Project` or None - """ - return self._find(_project.Project, name_or_id, - ignore_missing=ignore_missing) - - def get_project(self, project): - """Get a single project - - :param project: The value can be the ID of a project or a - :class:`~openstack.identity.v3.project.Project` instance. - - :returns: One :class:`~openstack.identity.v3.project.Project` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_project.Project, project) - - def projects(self, **query): - """Retrieve a generator of projects - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of project instances. - :rtype: :class:`~openstack.identity.v3.project.Project` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_project.Project, paginated=False, **query) - - def update_project(self, project, **attrs): - """Update a project - - :param project: Either the ID of a project or a - :class:`~openstack.identity.v3.project.Project` instance. - :attrs kwargs: The attributes to update on the project represented - by ``value``. - - :returns: The updated project - :rtype: :class:`~openstack.identity.v3.project.Project` - """ - return self._update(_project.Project, project, **attrs) - - def create_service(self, **attrs): - """Create a new service from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.service.Service`, - comprised of the properties on the Service class. - - :returns: The results of service creation - :rtype: :class:`~openstack.identity.v3.service.Service` - """ - return self._create(_service.Service, **attrs) - - def delete_service(self, service, ignore_missing=True): - """Delete a service - - :param service: The value can be either the ID of a service or a - :class:`~openstack.identity.v3.service.Service` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the service does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent service. - - :returns: ``None`` - """ - self._delete(_service.Service, service, ignore_missing=ignore_missing) - - def find_service(self, name_or_id, ignore_missing=True): - """Find a single service - - :param name_or_id: The name or ID of a service. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v3.service.Service` or None - """ - return self._find(_service.Service, name_or_id, - ignore_missing=ignore_missing) - - def get_service(self, service): - """Get a single service - - :param service: The value can be the ID of a service or a - :class:`~openstack.identity.v3.service.Service` instance. - - :returns: One :class:`~openstack.identity.v3.service.Service` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_service.Service, service) - - def services(self, **query): - """Retrieve a generator of services - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of service instances. - :rtype: :class:`~openstack.identity.v3.service.Service` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_service.Service, paginated=False, **query) - - def update_service(self, service, **attrs): - """Update a service - - :param service: Either the ID of a service or a - :class:`~openstack.identity.v3.service.Service` instance. - :attrs kwargs: The attributes to update on the service represented - by ``value``. - - :returns: The updated service - :rtype: :class:`~openstack.identity.v3.service.Service` - """ - return self._update(_service.Service, service, **attrs) - - def create_user(self, **attrs): - """Create a new user from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.user.User`, - comprised of the properties on the User class. - - :returns: The results of user creation - :rtype: :class:`~openstack.identity.v3.user.User` - """ - return self._create(_user.User, **attrs) - - def delete_user(self, user, ignore_missing=True): - """Delete a user - - :param user: The value can be either the ID of a user or a - :class:`~openstack.identity.v3.user.User` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the user does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent user. - - :returns: ``None`` - """ - self._delete(_user.User, user, ignore_missing=ignore_missing) - - def find_user(self, name_or_id, ignore_missing=True): - """Find a single user - - :param name_or_id: The name or ID of a user. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v3.user.User` or None - """ - return self._find(_user.User, name_or_id, - ignore_missing=ignore_missing) - - def get_user(self, user): - """Get a single user - - :param user: The value can be the ID of a user or a - :class:`~openstack.identity.v3.user.User` instance. - - :returns: One :class:`~openstack.identity.v3.user.User` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_user.User, user) - - def users(self, **query): - """Retrieve a generator of users - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of user instances. - :rtype: :class:`~openstack.identity.v3.user.User` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_user.User, paginated=False, **query) - - def update_user(self, user, **attrs): - """Update a user - - :param user: Either the ID of a user or a - :class:`~openstack.identity.v3.user.User` instance. - :attrs kwargs: The attributes to update on the user represented - by ``value``. - - :returns: The updated user - :rtype: :class:`~openstack.identity.v3.user.User` - """ - return self._update(_user.User, user, **attrs) - - def create_trust(self, **attrs): - """Create a new trust from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.trust.Trust`, - comprised of the properties on the Trust class. - - :returns: The results of trust creation - :rtype: :class:`~openstack.identity.v3.trust.Trust` - """ - return self._create(_trust.Trust, **attrs) - - def delete_trust(self, trust, ignore_missing=True): - """Delete a trust - - :param trust: The value can be either the ID of a trust or a - :class:`~openstack.identity.v3.trust.Trust` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the credential does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent credential. - - :returns: ``None`` - """ - self._delete(_trust.Trust, trust, ignore_missing=ignore_missing) - - def find_trust(self, name_or_id, ignore_missing=True): - """Find a single trust - - :param name_or_id: The name or ID of a trust. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.identity.v3.trust.Trust` or None - """ - return self._find(_trust.Trust, name_or_id, - ignore_missing=ignore_missing) - - def get_trust(self, trust): - """Get a single trust - - :param trust: The value can be the ID of a trust or a - :class:`~openstack.identity.v3.trust.Trust` instance. - - :returns: One :class:`~openstack.identity.v3.trust.Trust` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_trust.Trust, trust) - - def trusts(self, **query): - """Retrieve a generator of trusts - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of trust instances. - :rtype: :class:`~openstack.identity.v3.trust.Trust` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_trust.Trust, paginated=False, **query) - - def create_region(self, **attrs): - """Create a new region from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.region.Region`, - comprised of the properties on the Region class. - - :returns: The results of region creation. - :rtype: :class:`~openstack.identity.v3.region.Region` - """ - return self._create(_region.Region, **attrs) - - def delete_region(self, region, ignore_missing=True): - """Delete a region - - :param region: The value can be either the ID of a region or a - :class:`~openstack.identity.v3.region.Region` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the region does not exist. - When set to ``True``, no exception will be thrown when - attempting to delete a nonexistent region. - - :returns: ``None`` - """ - self._delete(_region.Region, region, ignore_missing=ignore_missing) - - def find_region(self, name_or_id, ignore_missing=True): - """Find a single region - - :param name_or_id: The name or ID of a region. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the region does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent region. - :returns: One :class:`~openstack.identity.v3.region.Region` or None - """ - return self._find(_region.Region, name_or_id, - ignore_missing=ignore_missing) - - def get_region(self, region): - """Get a single region - - :param region: The value can be the ID of a region or a - :class:`~openstack.identity.v3.region.Region` instance. - - :returns: One :class:`~openstack.identity.v3.region.Region` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no matching region can be found. - """ - return self._get(_region.Region, region) - - def regions(self, **query): - """Retrieve a generator of regions - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the regions being returned. - - :returns: A generator of region instances. - :rtype: :class:`~openstack.identity.v3.region.Region` - """ - # TODO(briancurtin): This is paginated but requires base list changes. - return self._list(_region.Region, paginated=False, **query) - - def update_region(self, region, **attrs): - """Update a region - - :param region: Either the ID of a region or a - :class:`~openstack.identity.v3.region.Region` instance. - :attrs kwargs: The attributes to update on the region represented - by ``value``. - - :returns: The updated region. - :rtype: :class:`~openstack.identity.v3.region.Region` - """ - return self._update(_region.Region, region, **attrs) - - def create_role(self, **attrs): - """Create a new role from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.identity.v3.role.Role`, - comprised of the properties on the Role class. - - :returns: The results of role creation. - :rtype: :class:`~openstack.identity.v3.role.Role` - """ - return self._create(_role.Role, **attrs) - - def delete_role(self, role, ignore_missing=True): - """Delete a role - - :param role: The value can be either the ID of a role or a - :class:`~openstack.identity.v3.role.Role` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the role does not exist. - When set to ``True``, no exception will be thrown when - attempting to delete a nonexistent role. - - :returns: ``None`` - """ - self._delete(_role.Role, role, ignore_missing=ignore_missing) - - def find_role(self, name_or_id, ignore_missing=True): - """Find a single role - - :param name_or_id: The name or ID of a role. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the role does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent role. - :returns: One :class:`~openstack.identity.v3.role.Role` or None - """ - return self._find(_role.Role, name_or_id, - ignore_missing=ignore_missing) - - def get_role(self, role): - """Get a single role - - :param role: The value can be the ID of a role or a - :class:`~openstack.identity.v3.role.Role` instance. - - :returns: One :class:`~openstack.identity.v3.role.Role` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no matching role can be found. - """ - return self._get(_role.Role, role) - - def roles(self, **query): - """Retrieve a generator of roles - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. The options - are: domain_id, name. - :return: A generator of role instances. - :rtype: :class:`~openstack.identity.v3.role.Role` - """ - return self._list(_role.Role, paginated=False, **query) - - def update_role(self, role, **attrs): - """Update a role - - :param role: Either the ID of a role or a - :class:`~openstack.identity.v3.role.Role` instance. - :param dict kwargs: The attributes to update on the role represented - by ``value``. Only name can be updated - - :returns: The updated role. - :rtype: :class:`~openstack.identity.v3.role.Role` - """ - return self._update(_role.Role, role, **attrs) - - def role_assignments_filter(self, domain=None, project=None, group=None, - user=None): - """Retrieve a generator of roles assigned to user/group - - :param domain: Either the ID of a domain or a - :class:`~openstack.identity.v3.domain.Domain` instance. - :param project: Either the ID of a project or a - :class:`~openstack.identity.v3.project.Project` - instance. - :param group: Either the ID of a group or a - :class:`~openstack.identity.v3.group.Group` instance. - :param user: Either the ID of a user or a - :class:`~openstack.identity.v3.user.User` instance. - :return: A generator of role instances. - :rtype: :class:`~openstack.identity.v3.role.Role` - """ - if domain and project: - raise exception.InvalidRequest( - 'Only one of domain or project can be specified') - - if domain is None and project is None: - raise exception.InvalidRequest( - 'Either domain or project should be specified') - - if group and user: - raise exception.InvalidRequest( - 'Only one of group or user can be specified') - - if group is None and user is None: - raise exception.InvalidRequest( - 'Either group or user should be specified') - - if domain: - domain = self._get_resource(_domain.Domain, domain) - if group: - group = self._get_resource(_group.Group, group) - return self._list( - _role_domain_group_assignment.RoleDomainGroupAssignment, - paginated=False, domain_id=domain.id, group_id=group.id) - else: - user = self._get_resource(_user.User, user) - return self._list( - _role_domain_user_assignment.RoleDomainUserAssignment, - paginated=False, domain_id=domain.id, user_id=user.id) - else: - project = self._get_resource(_project.Project, project) - if group: - group = self._get_resource(_group.Group, group) - return self._list( - _role_project_group_assignment.RoleProjectGroupAssignment, - paginated=False, project_id=project.id, group_id=group.id) - else: - user = self._get_resource(_user.User, user) - return self._list( - _role_project_user_assignment.RoleProjectUserAssignment, - paginated=False, project_id=project.id, user_id=user.id) - - def role_assignments(self, **query): - """Retrieve a generator of role assignments - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. The options - are: group_id, role_id, scope_domain_id, - scope_project_id, user_id, include_names, - include_subtree. - :return: - :class:`~openstack.identity.v3.role_assignment.RoleAssignment` - """ - return self._list(_role_assignment.RoleAssignment, - paginated=False, **query) diff --git a/openstack/identity/v3/credential.py b/openstack/identity/v3/credential.py deleted file mode 100644 index e4920997..00000000 --- a/openstack/identity/v3/credential.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Credential(resource.Resource): - resource_key = 'credential' - resources_key = 'credentials' - base_path = '/credentials' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - # Properties - #: Arbitrary blob of the credential data, to be parsed according to the - #: ``type``. *Type: string* - blob = resource.Body('blob') - #: References a project ID which limits the scope the credential applies - #: to. This attribute is **mandatory** if the credential type is ``ec2``. - #: *Type: string* - project_id = resource.Body('project_id') - #: Representing the credential type, such as ``ec2`` or ``cert``. - #: A specific implementation may determine the list of supported types. - #: *Type: string* - type = resource.Body('type') - #: References the user ID which owns the credential. *Type: string* - user_id = resource.Body('user_id') diff --git a/openstack/identity/v3/domain.py b/openstack/identity/v3/domain.py deleted file mode 100644 index 42e57649..00000000 --- a/openstack/identity/v3/domain.py +++ /dev/null @@ -1,100 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource -from openstack import utils - - -class Domain(resource.Resource): - resource_key = 'domain' - resources_key = 'domains' - base_path = '/domains' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - # Properties - #: The description of this domain. *Type: string* - description = resource.Body('description') - #: Setting this attribute to ``False`` prevents users from authorizing - #: against this domain or any projects owned by this domain, and prevents - #: users owned by this domain from authenticating or receiving any other - #: authorization. Additionally, all pre-existing tokens applicable - #: to the above entities are immediately invalidated. - #: Re-enabling a domain does not re-enable pre-existing tokens. - #: *Type: bool* - is_enabled = resource.Body('enabled', type=bool) - #: The globally unique name of this domain. *Type: string* - name = resource.Body('name') - #: The links related to the domain resource. - links = resource.Body('links') - - def assign_role_to_user(self, session, user, role): - """Assign role to user on domain""" - url = utils.urljoin(self.base_path, self.id, 'users', - user.id, 'roles', role.id) - resp = session.put(url, endpoint_filter=self.service) - if resp.status_code == 204: - return True - return False - - def validate_user_has_role(self, session, user, role): - """Validates that a user has a role on a domain""" - url = utils.urljoin(self.base_path, self.id, 'users', - user.id, 'roles', role.id) - resp = session.head(url, endpoint_filter=self.service) - if resp.status_code == 201: - return True - return False - - def unassign_role_from_user(self, session, user, role): - """Unassigns a role from a user on a domain""" - url = utils.urljoin(self.base_path, self.id, 'users', - user.id, 'roles', role.id) - resp = session.delete(url, endpoint_filter=self.service) - if resp.status_code == 204: - return True - return False - - def assign_role_to_group(self, session, group, role): - """Assign role to group on domain""" - url = utils.urljoin(self.base_path, self.id, 'groups', - group.id, 'roles', role.id) - resp = session.put(url, endpoint_filter=self.service) - if resp.status_code == 204: - return True - return False - - def validate_group_has_role(self, session, group, role): - """Validates that a group has a role on a domain""" - url = utils.urljoin(self.base_path, self.id, 'groups', - group.id, 'roles', role.id) - resp = session.head(url, endpoint_filter=self.service) - if resp.status_code == 201: - return True - return False - - def unassign_role_from_group(self, session, group, role): - """Unassigns a role from a group on a domain""" - url = utils.urljoin(self.base_path, self.id, 'groups', - group.id, 'roles', role.id) - resp = session.delete(url, endpoint_filter=self.service) - if resp.status_code == 204: - return True - return False diff --git a/openstack/identity/v3/endpoint.py b/openstack/identity/v3/endpoint.py deleted file mode 100644 index a088f7de..00000000 --- a/openstack/identity/v3/endpoint.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Endpoint(resource.Resource): - resource_key = 'endpoint' - resources_key = 'endpoints' - base_path = '/endpoints' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - # Properties - #: Describes the interface of the endpoint according to one of the - #: following values: - #: - #: - `public`: intended for consumption by end users, generally on a - #: publicly available network interface - #: - `internal`: not intended for consumption by end users, generally on an - #: unmetered internal network interface - #: - `admin`: intended only for consumption by those needing administrative - #: access to the service, generally on a secure network interface - #: - #: *Type: string* - interface = resource.Body('interface') - #: Setting this value to ``False`` prevents the endpoint from appearing - #: in the service catalog. *Type: bool* - is_enabled = resource.Body('enabled', type=bool) - #: The links for the region resource. - links = resource.Body('links') - #: Represents the containing region ID of the service endpoint. - #: *New in v3.2* *Type: string* - region_id = resource.Body('region_id') - #: References the service ID to which the endpoint belongs. *Type: string* - service_id = resource.Body('service_id') - #: Fully qualified URL of the service endpoint. *Type: string* - url = resource.Body('url') diff --git a/openstack/identity/v3/group.py b/openstack/identity/v3/group.py deleted file mode 100644 index b47c8cfd..00000000 --- a/openstack/identity/v3/group.py +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Group(resource.Resource): - resource_key = 'group' - resources_key = 'groups' - base_path = '/groups' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - # Properties - #: The description of this group. *Type: string* - description = resource.Body('description') - #: References the domain ID which owns the group; if a domain ID is not - #: specified by the client, the Identity service implementation will - #: default it to the domain ID to which the client's token is scoped. - #: *Type: string* - domain_id = resource.Body('domain_id') - #: Unique group name, within the owning domain. *Type: string* - name = resource.Body('name') diff --git a/openstack/identity/v3/policy.py b/openstack/identity/v3/policy.py deleted file mode 100644 index bd814d5b..00000000 --- a/openstack/identity/v3/policy.py +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Policy(resource.Resource): - resource_key = 'policy' - resources_key = 'policies' - base_path = '/policies' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - # Properties - #: The policy rule set itself, as a serialized blob. *Type: string* - blob = resource.Body('blob') - #: The links for the policy resource. - links = resource.Body('links') - #: The ID for the project. - project_id = resource.Body('project_id') - #: The MIME Media Type of the serialized policy blob. *Type: string* - type = resource.Body('type') - #: The ID of the user who owns the policy - user_id = resource.Body('user_id') diff --git a/openstack/identity/v3/project.py b/openstack/identity/v3/project.py deleted file mode 100644 index 3a1ab714..00000000 --- a/openstack/identity/v3/project.py +++ /dev/null @@ -1,107 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource -from openstack import utils - - -class Project(resource.Resource): - resource_key = 'project' - resources_key = 'projects' - base_path = '/projects' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - # Properties - #: The description of the project. *Type: string* - description = resource.Body('description') - #: References the domain ID which owns the project; if a domain ID is not - #: specified by the client, the Identity service implementation will - #: default it to the domain ID to which the client's token is scoped. - #: *Type: string* - domain_id = resource.Body('domain_id') - #: Indicates whether the project also acts as a domain. If set to True, - #: the project acts as both a project and a domain. Default is False. - #: New in version 3.6 - is_domain = resource.Body('is_domain', type=bool) - #: Setting this attribute to ``False`` prevents users from authorizing - #: against this project. Additionally, all pre-existing tokens authorized - #: for the project are immediately invalidated. Re-enabling a project - #: does not re-enable pre-existing tokens. *Type: bool* - is_enabled = resource.Body('enabled', type=bool) - #: Unique project name, within the owning domain. *Type: string* - name = resource.Body('name') - #: The ID of the parent of the project. - #: New in version 3.4 - parent_id = resource.Body('parent_id') - - def assign_role_to_user(self, session, user, role): - """Assign role to user on project""" - url = utils.urljoin(self.base_path, self.id, 'users', - user.id, 'roles', role.id) - resp = session.put(url, endpoint_filter=self.service) - if resp.status_code == 204: - return True - return False - - def validate_user_has_role(self, session, user, role): - """Validates that a user has a role on a project""" - url = utils.urljoin(self.base_path, self.id, 'users', - user.id, 'roles', role.id) - resp = session.head(url, endpoint_filter=self.service) - if resp.status_code == 201: - return True - return False - - def unassign_role_from_user(self, session, user, role): - """Unassigns a role from a user on a project""" - url = utils.urljoin(self.base_path, self.id, 'users', - user.id, 'roles', role.id) - resp = session.delete(url, endpoint_filter=self.service) - if resp.status_code == 204: - return True - return False - - def assign_role_to_group(self, session, group, role): - """Assign role to group on project""" - url = utils.urljoin(self.base_path, self.id, 'groups', - group.id, 'roles', role.id) - resp = session.put(url, endpoint_filter=self.service) - if resp.status_code == 204: - return True - return False - - def validate_group_has_role(self, session, group, role): - """Validates that a group has a role on a project""" - url = utils.urljoin(self.base_path, self.id, 'groups', - group.id, 'roles', role.id) - resp = session.head(url, endpoint_filter=self.service) - if resp.status_code == 201: - return True - return False - - def unassign_role_from_group(self, session, group, role): - """Unassigns a role from a group on a project""" - url = utils.urljoin(self.base_path, self.id, 'groups', - group.id, 'roles', role.id) - resp = session.delete(url, endpoint_filter=self.service) - if resp.status_code == 204: - return True - return False diff --git a/openstack/identity/v3/region.py b/openstack/identity/v3/region.py deleted file mode 100644 index 1fdd1c20..00000000 --- a/openstack/identity/v3/region.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Region(resource.Resource): - resource_key = 'region' - resources_key = 'regions' - base_path = '/regions' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - # Properties - #: User-facing description of the region. *Type: string* - description = resource.Body('description') - #: The links for the region resource. - links = resource.Body('links') - #: ID of parent region, if any. *Type: string* - parent_region_id = resource.Body('parent_region_id') diff --git a/openstack/identity/v3/role.py b/openstack/identity/v3/role.py deleted file mode 100644 index 58c8b0fb..00000000 --- a/openstack/identity/v3/role.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Role(resource.Resource): - resource_key = 'role' - resources_key = 'roles' - base_path = '/roles' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'name', 'domain_id') - - # Properties - #: Unique role name, within the owning domain. *Type: string* - name = resource.Body('name') - #: The links for the service resource. - links = resource.Body('links') diff --git a/openstack/identity/v3/role_assignment.py b/openstack/identity/v3/role_assignment.py deleted file mode 100644 index 459c275b..00000000 --- a/openstack/identity/v3/role_assignment.py +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class RoleAssignment(resource.Resource): - resource_key = 'role_assignment' - resources_key = 'role_assignments' - base_path = '/role_assignments' - service = identity_service.IdentityService() - - # capabilities - allow_list = True - - _query_mapping = resource.QueryParameters( - 'group_id', 'role_id', 'scope_domain_id', 'scope_project_id', - 'user_id', 'effective', 'include_names', 'include_subtree' - ) - - # Properties - #: The links for the service resource. - links = resource.Body('links') - #: The role (dictionary contains only id) *Type: dict* - role = resource.Body('role', type=dict) - #: The scope (either domain or group dictionary contains id) *Type: dict* - scope = resource.Body('scope', type=dict) - #: The user (dictionary contains only id) *Type: dict* - user = resource.Body('user', type=dict) - #: The group (dictionary contains only id) *Type: dict* - group = resource.Body('group', type=dict) diff --git a/openstack/identity/v3/role_domain_group_assignment.py b/openstack/identity/v3/role_domain_group_assignment.py deleted file mode 100644 index d7fadc3c..00000000 --- a/openstack/identity/v3/role_domain_group_assignment.py +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class RoleDomainGroupAssignment(resource.Resource): - resource_key = 'role' - resources_key = 'roles' - base_path = '/domains/%(domain_id)s/groups/%(group_id)s/roles' - service = identity_service.IdentityService() - - # capabilities - allow_list = True - - # Properties - #: name of the role *Type: string* - name = resource.Body('name') - #: The links for the service resource. - links = resource.Body('links') - #: The ID of the domain to list assignment from. *Type: string* - domain_id = resource.URI('domain_id') - #: The ID of the group to list assignment from. *Type: string* - group_id = resource.URI('group_id') diff --git a/openstack/identity/v3/role_domain_user_assignment.py b/openstack/identity/v3/role_domain_user_assignment.py deleted file mode 100644 index b4db0f52..00000000 --- a/openstack/identity/v3/role_domain_user_assignment.py +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class RoleDomainUserAssignment(resource.Resource): - resource_key = 'role' - resources_key = 'roles' - base_path = '/domains/%(domain_id)s/users/%(user_id)s/roles' - service = identity_service.IdentityService() - - # capabilities - allow_list = True - - # Properties - #: name of the role *Type: string* - name = resource.Body('name') - #: The links for the service resource. - links = resource.Body('links') - #: The ID of the domain to list assignment from. *Type: string* - domain_id = resource.URI('domain_id') - #: The ID of the user to list assignment from. *Type: string* - user_id = resource.URI('user_id') diff --git a/openstack/identity/v3/role_project_group_assignment.py b/openstack/identity/v3/role_project_group_assignment.py deleted file mode 100644 index 225410b5..00000000 --- a/openstack/identity/v3/role_project_group_assignment.py +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class RoleProjectGroupAssignment(resource.Resource): - resource_key = 'role' - resources_key = 'roles' - base_path = '/projects/%(project_id)s/groups/%(group_id)s/roles' - service = identity_service.IdentityService() - - # capabilities - allow_list = True - - # Properties - #: name of the role *Type: string* - name = resource.Body('name') - #: The links for the service resource. - links = resource.Body('links') - #: The ID of the project to list assignment from. *Type: string* - project_id = resource.URI('project_id') - #: The ID of the group to list assignment from. *Type: string* - group_id = resource.URI('group_id') diff --git a/openstack/identity/v3/role_project_user_assignment.py b/openstack/identity/v3/role_project_user_assignment.py deleted file mode 100644 index b1989794..00000000 --- a/openstack/identity/v3/role_project_user_assignment.py +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class RoleProjectUserAssignment(resource.Resource): - resource_key = 'role' - resources_key = 'roles' - base_path = '/projects/%(project_id)s/users/%(user_id)s/roles' - service = identity_service.IdentityService() - - # capabilities - allow_list = True - - # Properties - #: name of the role *Type: string* - name = resource.Body('name') - #: The links for the service resource. - links = resource.Body('links') - #: The ID of the project to list assignment from. *Type: string* - project_id = resource.URI('project_id') - #: The ID of the user to list assignment from. *Type: string* - user_id = resource.URI('user_id') diff --git a/openstack/identity/v3/service.py b/openstack/identity/v3/service.py deleted file mode 100644 index 4eb7c13c..00000000 --- a/openstack/identity/v3/service.py +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Service(resource.Resource): - resource_key = 'service' - resources_key = 'services' - base_path = '/services' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - # Properties - #: User-facing description of the service. *Type: string* - description = resource.Body('description') - #: Setting this value to ``False`` prevents the service and - #: its endpoints from appearing in the service catalog. *Type: bool* - is_enabled = resource.Body('enabled', type=bool) - #: The links for the service resource. - links = resource.Body('links') - #: User-facing name of the service. *Type: string* - name = resource.Body('name') - #: Describes the API implemented by the service. The following values are - #: recognized within the OpenStack ecosystem: ``compute``, ``image``, - #: ``ec2``, ``identity``, ``volume``, ``network``. To support non-core and - #: future projects, the value should not be validated against this list. - #: *Type: string* - type = resource.Body('type') diff --git a/openstack/identity/v3/trust.py b/openstack/identity/v3/trust.py deleted file mode 100644 index 5141e751..00000000 --- a/openstack/identity/v3/trust.py +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Trust(resource.Resource): - resource_key = 'trust' - resources_key = 'trusts' - base_path = '/OS-TRUST/trusts' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'trustor_user_id', 'trustee_user_id') - - # Properties - #: A boolean indicating whether the trust can be issued by the trustee as - #: a regulart trust. Default is ``False``. - allow_redelegation = resource.Body('allow_redelegation', type=bool) - #: If ``impersonation`` is set to ``False``, then the token's ``user`` - #: attribute will represent that of the trustee. *Type: bool* - is_impersonation = resource.Body('impersonation', type=bool) - #: Specifies the expiration time of the trust. A trust may be revoked - #: ahead of expiration. If the value represents a time in the past, - #: the trust is deactivated. - expires_at = resource.Body('expires_at') - #: If ``impersonation`` is set to true, then the ``user`` attribute - #: of tokens that are generated based on the trust will represent - #: that of the trustor rather than the trustee, thus allowing the trustee - #: to impersonate the trustor. - #: If ``impersonation`` is set to ``False``, then the token's ``user`` - #: attribute will represent that of the trustee. *Type: bool* - is_impersonation = resource.Body('impersonation', type=bool) - #: Links for the trust resource. - links = resource.Body('links') - #: ID of the project upon which the trustor is - #: delegating authorization. *Type: string* - project_id = resource.Body('project_id') - #: A role links object that includes 'next', 'previous', and self links - #: for roles. - role_links = resource.Body('role_links') - #: Specifies the subset of the trustor's roles on the ``project_id`` - #: to be granted to the trustee when the token in consumed. The - #: trustor must already be granted these roles in the project referenced - #: by the ``project_id`` attribute. *Type: list* - roles = resource.Body('roles') - #: Returned with redelegated trust provides information about the - #: predecessor in the trust chain. - redelegated_trust_id = resource.Body('redelegated_trust_id') - #: Redelegation count - redelegation_count = resource.Body('redelegation_count') - #: How many times the trust can be used to obtain a token. The value is - #: decreased each time a token is issued through the trust. Once it - #: reaches zero, no further tokens will be isued through the trust. - remaining_uses = resource.Body('remaining_uses') - #: Represents the user ID who is capable of consuming the trust. - #: *Type: string* - trustee_user_id = resource.Body('trustee_user_id') - #: Represents the user ID who created the trust, and who's authorization is - #: being delegated. *Type: string* - trustor_user_id = resource.Body('trustor_user_id') diff --git a/openstack/identity/v3/user.py b/openstack/identity/v3/user.py deleted file mode 100644 index 17f98089..00000000 --- a/openstack/identity/v3/user.py +++ /dev/null @@ -1,68 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class User(resource.Resource): - resource_key = 'user' - resources_key = 'users' - base_path = '/users' - service = identity_service.IdentityService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - # Properties - #: References the user's default project ID against which to authorize, - #: if the API user does not explicitly specify one when creating a token. - #: Setting this attribute does not grant any actual authorization on the - #: project, and is merely provided for the user's convenience. - #: Therefore, the referenced project does not need to exist within the - #: user's domain. - #: - #: *New in version 3.1* If the user does not have authorization to - #: their default project, the default project will be ignored at token - #: creation. *Type: string* - default_project_id = resource.Body('default_project_id') - #: The description of this user. *Type: string* - description = resource.Body('description') - #: References the domain ID which owns the user; if a domain ID is not - #: specified by the client, the Identity service implementation will - #: default it to the domain ID to which the client's token is scoped. - #: *Type: string* - domain_id = resource.Body('domain_id') - #: The email of this user. *Type: string* - email = resource.Body('email') - #: Setting this value to ``False`` prevents the user from authenticating or - #: receiving authorization. Additionally, all pre-existing tokens held by - #: the user are immediately invalidated. Re-enabling a user does not - #: re-enable pre-existing tokens. *Type: bool* - is_enabled = resource.Body('enabled', type=bool) - #: The links for the user resource. - links = resource.Body('links') - #: Unique user name, within the owning domain. *Type: string* - name = resource.Body('name') - #: The default form of credential used during authentication. - #: *Type: string* - password = resource.Body('password') - #: The date and time when the pasword expires. The time zone is UTC. - #: A None value means the password never expires. - #: This is a response object attribute, not valid for requests. - #: *New in version 3.7* - password_expires_at = resource.Body('password_expires_at') diff --git a/openstack/identity/version.py b/openstack/identity/version.py deleted file mode 100644 index 4564cab9..00000000 --- a/openstack/identity/version.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity import identity_service -from openstack import resource2 as resource - - -class Version(resource.Resource): - resource_key = 'version' - resources_key = 'versions' - base_path = '/' - service = identity_service.IdentityService( - version=identity_service.IdentityService.UNVERSIONED - ) - - # capabilities - allow_list = True - - # Properties - media_types = resource.Body('media-types') - status = resource.Body('status') - updated = resource.Body('updated') - - @classmethod - def list(cls, session, paginated=False, **params): - resp = session.get(cls.base_path, endpoint_filter=cls.service, - params=params) - resp = resp.json() - for data in resp[cls.resources_key]['values']: - yield cls.existing(**data) diff --git a/openstack/image/__init__.py b/openstack/image/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/image/image_service.py b/openstack/image/image_service.py deleted file mode 100644 index 55c43fd5..00000000 --- a/openstack/image/image_service.py +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class ImageService(service_filter.ServiceFilter): - """The image service.""" - - valid_versions = [ - service_filter.ValidVersion('v2'), - service_filter.ValidVersion('v1') - ] - - def __init__(self, version=None): - """Create an image service.""" - super(ImageService, self).__init__(service_type='image', - version=version) diff --git a/openstack/image/v1/__init__.py b/openstack/image/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/image/v1/_proxy.py b/openstack/image/v1/_proxy.py deleted file mode 100644 index e8d2ff53..00000000 --- a/openstack/image/v1/_proxy.py +++ /dev/null @@ -1,94 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.image.v1 import image as _image -from openstack import proxy2 as proxy - - -class Proxy(proxy.BaseProxy): - - def upload_image(self, **attrs): - """Upload a new image from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.image.v1.image.Image`, - comprised of the properties on the Image class. - - :returns: The results of image creation - :rtype: :class:`~openstack.image.v1.image.Image` - """ - return self._create(_image.Image, **attrs) - - def delete_image(self, image, ignore_missing=True): - """Delete an image - - :param image: The value can be either the ID of an image or a - :class:`~openstack.image.v1.image.Image` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the image does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent image. - - :returns: ``None`` - """ - self._delete(_image.Image, image, ignore_missing=ignore_missing) - - def find_image(self, name_or_id, ignore_missing=True): - """Find a single image - - :param name_or_id: The name or ID of a image. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.image.v1.image.Image` or None - """ - return self._find(_image.Image, name_or_id, - ignore_missing=ignore_missing) - - def get_image(self, image): - """Get a single image - - :param image: The value can be the ID of an image or a - :class:`~openstack.image.v1.image.Image` instance. - - :returns: One :class:`~openstack.image.v1.image.Image` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_image.Image, image) - - def images(self, **query): - """Return a generator of images - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of image objects - :rtype: :class:`~openstack.image.v1.image.Image` - """ - return self._list(_image.Image, paginated=True, **query) - - def update_image(self, image, **attrs): - """Update a image - - :param image: Either the ID of a image or a - :class:`~openstack.image.v1.image.Image` instance. - :attrs kwargs: The attributes to update on the image represented - by ``value``. - - :returns: The updated image - :rtype: :class:`~openstack.image.v1.image.Image` - """ - return self._update(_image.Image, image, **attrs) diff --git a/openstack/image/v1/image.py b/openstack/image/v1/image.py deleted file mode 100644 index 882f6133..00000000 --- a/openstack/image/v1/image.py +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.image import image_service -from openstack import resource2 as resource - - -class Image(resource.Resource): - resource_key = 'image' - resources_key = 'images' - base_path = '/images' - service = image_service.ImageService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - #: Hash of the image data used. The Image service uses this value - #: for verification. - checksum = resource.Body('checksum') - #: The container format refers to whether the VM image is in a file - #: format that also contains metadata about the actual VM. - #: Container formats include OVF and Amazon AMI. In addition, - #: a VM image might not have a container format - instead, - #: the image is just a blob of unstructured data. - container_format = resource.Body('container_format') - #: A URL to copy an image from - copy_from = resource.Body('copy_from') - #: The timestamp when this image was created. - created_at = resource.Body('created_at') - #: Valid values are: aki, ari, ami, raw, iso, vhd, vdi, qcow2, or vmdk. - #: The disk format of a VM image is the format of the underlying - #: disk image. Virtual appliance vendors have different formats for - #: laying out the information contained in a VM disk image. - disk_format = resource.Body('disk_format') - #: Defines whether the image can be deleted. - #: *Type: bool* - is_protected = resource.Body('protected', type=bool) - #: ``True`` if this is a public image. - #: *Type: bool* - is_public = resource.Body('is_public', type=bool) - #: A location for the image identified by a URI - location = resource.Body('location') - #: The minimum disk size in GB that is required to boot the image. - min_disk = resource.Body('min_disk') - #: The minimum amount of RAM in MB that is required to boot the image. - min_ram = resource.Body('min_ram') - #: Name for the image. Note that the name of an image is not unique - #: to a Glance node. The API cannot expect users to know the names - #: of images owned by others. - name = resource.Body('name') - #: The ID of the owner, or project, of the image. - owner_id = resource.Body('owner') - #: Properties, if any, that are associated with the image. - properties = resource.Body('properties') - #: The size of the image data, in bytes. - size = resource.Body('size') - #: The image status. - status = resource.Body('status') - #: The timestamp when this image was last updated. - updated_at = resource.Body('updated_at') diff --git a/openstack/image/v2/__init__.py b/openstack/image/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/image/v2/_proxy.py b/openstack/image/v2/_proxy.py deleted file mode 100644 index 14907dbd..00000000 --- a/openstack/image/v2/_proxy.py +++ /dev/null @@ -1,312 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import exceptions -from openstack.image.v2 import image as _image -from openstack.image.v2 import member as _member -from openstack import proxy2 -from openstack import resource2 - - -class Proxy(proxy2.BaseProxy): - - def upload_image(self, container_format=None, disk_format=None, - data=None, **attrs): - """Upload a new image from attributes - - :param container_format: Format of the container. - A valid value is ami, ari, aki, bare, - ovf, ova, or docker. - :param disk_format: The format of the disk. A valid value is ami, - ari, aki, vhd, vmdk, raw, qcow2, vdi, or iso. - :param data: The data to be uploaded as an image. - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.image.v2.image.Image`, - comprised of the properties on the Image class. - - :returns: The results of image creation - :rtype: :class:`~openstack.image.v2.image.Image` - """ - # container_format and disk_format are required to be set - # on the image by the time upload_image is called, but they're not - # required by the _create call. Enforce them here so that we don't - # need to handle a failure in _create, as upload_image will - # return a 400 with a message about disk_format and container_format - # not being set. - if not all([container_format, disk_format]): - raise exceptions.InvalidRequest( - "Both container_format and disk_format are required") - - img = self._create(_image.Image, disk_format=disk_format, - container_format=container_format, - **attrs) - - # TODO(briancurtin): Perhaps we should run img.upload_image - # in a background thread and just return what is called by - # self._create, especially because the upload_image call doesn't - # return anything anyway. Otherwise this blocks while uploading - # significant amounts of image data. - img.data = data - img.upload(self._session) - - return img - - def download_image(self, image, stream=False): - """Download an image - - This will download an image to memory when ``stream=False``, or allow - streaming downloads using an iterator when ``stream=True``. - For examples of working with streamed responses, see - :ref:`download_image-stream-true` and the Requests documentation - :ref:`body-content-workflow`. - - :param image: The value can be either the ID of an image or a - :class:`~openstack.image.v2.image.Image` instance. - - :param bool stream: When ``True``, return a :class:`requests.Response` - instance allowing you to iterate over the - response data stream instead of storing its entire - contents in memory. See - :meth:`requests.Response.iter_content` for more - details. *NOTE*: If you do not consume - the entirety of the response you must explicitly - call :meth:`requests.Response.close` or otherwise - risk inefficiencies with the ``requests`` - library's handling of connections. - - - When ``False``, return the entire - contents of the response. - - :returns: The bytes comprising the given Image when stream is - False, otherwise a :class:`requests.Response` - instance. - """ - - image = self._get_resource(_image.Image, image) - return image.download(self._session, stream=stream) - - def delete_image(self, image, ignore_missing=True): - """Delete an image - - :param image: The value can be either the ID of an image or a - :class:`~openstack.image.v2.image.Image` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the image does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent image. - - :returns: ``None`` - """ - self._delete(_image.Image, image, ignore_missing=ignore_missing) - - def find_image(self, name_or_id, ignore_missing=True): - """Find a single image - - :param name_or_id: The name or ID of a image. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.image.v2.image.Image` or None - """ - return self._find(_image.Image, name_or_id, - ignore_missing=ignore_missing) - - def get_image(self, image): - """Get a single image - - :param image: The value can be the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance. - - :returns: One :class:`~openstack.image.v2.image.Image` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_image.Image, image) - - def images(self, **query): - """Return a generator of images - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of image objects - :rtype: :class:`~openstack.image.v2.image.Image` - """ - return self._list(_image.Image, paginated=True, **query) - - def update_image(self, image, **attrs): - """Update a image - - :param image: Either the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance. - :attrs kwargs: The attributes to update on the image represented - by ``value``. - - :returns: The updated image - :rtype: :class:`~openstack.image.v2.image.Image` - """ - img = self._get_resource(_image.Image, image) - return img.update(self._session, **attrs) - - def deactivate_image(self, image): - """Deactivate an image - - :param image: Either the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance. - - :returns: None - """ - image = self._get_resource(_image.Image, image) - image.deactivate(self._session) - - def reactivate_image(self, image): - """Deactivate an image - - :param image: Either the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance. - - :returns: None - """ - image = self._get_resource(_image.Image, image) - image.reactivate(self._session) - - def add_tag(self, image, tag): - """Add a tag to an image - - :param image: The value can be the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance - that the member will be created for. - :param str tag: The tag to be added - - :returns: None - """ - image = self._get_resource(_image.Image, image) - image.add_tag(self._session, tag) - - def remove_tag(self, image, tag): - """Remove a tag to an image - - :param image: The value can be the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance - that the member will be created for. - :param str tag: The tag to be removed - - :returns: None - """ - image = self._get_resource(_image.Image, image) - image.remove_tag(self._session, tag) - - def add_member(self, image, **attrs): - """Create a new member from attributes - - :param image: The value can be the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance - that the member will be created for. - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.image.v2.member.Member`, - comprised of the properties on the Member class. - - :returns: The results of member creation - :rtype: :class:`~openstack.image.v2.member.Member` - """ - image_id = resource2.Resource._get_id(image) - return self._create(_member.Member, image_id=image_id, **attrs) - - def remove_member(self, member, image, ignore_missing=True): - """Delete a member - - :param member: The value can be either the ID of a member or a - :class:`~openstack.image.v2.member.Member` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the member does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent member. - - :returns: ``None`` - """ - image_id = resource2.Resource._get_id(image) - member_id = resource2.Resource._get_id(member) - self._delete(_member.Member, member_id=member_id, image_id=image_id, - ignore_missing=ignore_missing) - - def find_member(self, name_or_id, image, ignore_missing=True): - """Find a single member - - :param name_or_id: The name or ID of a member. - :param image: This is the image that the member belongs to, - the value can be the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.image.v2.member.Member` or None - """ - image_id = resource2.Resource._get_id(image) - return self._find(_member.Member, name_or_id, image_id=image_id, - ignore_missing=ignore_missing) - - def get_member(self, member, image): - """Get a single member on an image - - :param member: The value can be the ID of a member or a - :class:`~openstack.image.v2.member.Member` instance. - :param image: This is the image that the member belongs to. - The value can be the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance. - :returns: One :class:`~openstack.image.v2.member.Member` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - member_id = resource2.Resource._get_id(member) - image_id = resource2.Resource._get_id(image) - return self._get(_member.Member, member_id=member_id, - image_id=image_id) - - def members(self, image): - """Return a generator of members - - :param image: This is the image that the member belongs to, - the value can be the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance. - - :returns: A generator of member objects - :rtype: :class:`~openstack.image.v2.member.Member` - """ - image_id = resource2.Resource._get_id(image) - return self._list(_member.Member, paginated=False, - image_id=image_id) - - def update_member(self, member, image, **attrs): - """Update the member of an image - - :param member: Either the ID of a member or a - :class:`~openstack.image.v2.member.Member` instance. - :param image: This is the image that the member belongs to. - The value can be the ID of a image or a - :class:`~openstack.image.v2.image.Image` instance. - :attrs kwargs: The attributes to update on the member represented - by ``value``. - - :returns: The updated member - :rtype: :class:`~openstack.image.v2.member.Member` - """ - member_id = resource2.Resource._get_id(member) - image_id = resource2.Resource._get_id(image) - return self._update(_member.Member, member_id=member_id, - image_id=image_id, **attrs) diff --git a/openstack/image/v2/image.py b/openstack/image/v2/image.py deleted file mode 100644 index 61f970fa..00000000 --- a/openstack/image/v2/image.py +++ /dev/null @@ -1,301 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import hashlib -import logging - -import jsonpatch - -from openstack import exceptions -from openstack.image import image_service -from openstack import resource2 -from openstack import utils - -_logger = logging.getLogger(__name__) - - -class Image(resource2.Resource): - resources_key = 'images' - base_path = '/images' - service = image_service.ImageService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - patch_update = True - - _query_mapping = resource2.QueryParameters("name", "visibility", - "member_status", "owner", - "status", "size_min", - "size_max", "sort_key", - "sort_dir", "sort", "tag", - "created_at", "updated_at") - - # NOTE: Do not add "self" support here. If you've used Python before, - # you know that self, while not being a reserved word, has special - # meaning. You can't call a class initializer with the self name - # as the first argument and then additionally in kwargs, as we - # do when we're constructing instances from the JSON body. - # Resource.list explicitly pops off any "self" keys from bodies so - # that we don't end up getting the following: - # TypeError: __init__() got multiple values for argument 'self' - - # The image data (bytes or a file-like object) - data = None - # Properties - #: Hash of the image data used. The Image service uses this value - #: for verification. - checksum = resource2.Body('checksum') - #: The container format refers to whether the VM image is in a file - #: format that also contains metadata about the actual VM. - #: Container formats include OVF and Amazon AMI. In addition, - #: a VM image might not have a container format - instead, - #: the image is just a blob of unstructured data. - container_format = resource2.Body('container_format') - #: The date and time when the image was created. - created_at = resource2.Body('created_at') - #: Valid values are: aki, ari, ami, raw, iso, vhd, vdi, qcow2, or vmdk. - #: The disk format of a VM image is the format of the underlying - #: disk image. Virtual appliance vendors have different formats - #: for laying out the information contained in a VM disk image. - disk_format = resource2.Body('disk_format') - #: Defines whether the image can be deleted. - #: *Type: bool* - is_protected = resource2.Body('protected', type=bool) - #: The minimum disk size in GB that is required to boot the image. - min_disk = resource2.Body('min_disk') - #: The minimum amount of RAM in MB that is required to boot the image. - min_ram = resource2.Body('min_ram') - #: The name of the image. - name = resource2.Body('name') - #: The ID of the owner, or project, of the image. - owner_id = resource2.Body('owner') - #: Properties, if any, that are associated with the image. - properties = resource2.Body('properties', type=dict) - #: The size of the image data, in bytes. - size = resource2.Body('size', type=int) - #: When present, Glance will attempt to store the disk image data in the - #: backing store indicated by the value of the header. When not present, - #: Glance will store the disk image data in the backing store that is - #: marked default. Valid values are: file, s3, rbd, swift, cinder, - #: gridfs, sheepdog, or vsphere. - store = resource2.Body('store') - #: The image status. - status = resource2.Body('status') - #: Tags, if any, that are associated with the image. - tags = resource2.Body('tags') - #: The date and time when the image was updated. - updated_at = resource2.Body('updated_at') - #: The virtual size of the image. - virtual_size = resource2.Body('virtual_size') - #: The image visibility. - visibility = resource2.Body('visibility') - #: The URL for the virtual machine image file. - file = resource2.Body('file') - #: A list of URLs to access the image file in external store. - #: This list appears if the show_multiple_locations option is set - #: to true in the Image service's configuration file. - locations = resource2.Body('locations') - #: The URL to access the image file kept in external store. It appears - #: when you set the show_image_direct_url option to true in the - #: Image service's configuration file. - direct_url = resource2.Body('direct_url') - #: An image property. - path = resource2.Body('path') - #: Value of image property used in add or replace operations expressed - #: in JSON notation. For example, you must enclose strings in quotation - #: marks, and you do not enclose numeric values in quotation marks. - value = resource2.Body('value') - #: The URL to access the image file kept in external store. - url = resource2.Body('url') - #: The location metadata. - metadata = resource2.Body('metadata', type=dict) - - # Additional Image Properties - # https://docs.openstack.org/glance/latest/user/common-image-properties.html - # http://docs.openstack.org/cli-reference/glance-property-keys.html - #: The CPU architecture that must be supported by the hypervisor. - architecture = resource2.Body("architecture") - #: The hypervisor type. Note that qemu is used for both QEMU and - #: KVM hypervisor types. - hypervisor_type = resource2.Body("hypervisor-type") - #: Optional property allows created servers to have a different bandwidth - #: cap than that defined in the network they are attached to. - instance_type_rxtx_factor = resource2.Body("instance_type_rxtx_factor", - type=float) - # For snapshot images, this is the UUID of the server used to - #: create this image. - instance_uuid = resource2.Body('instance_uuid') - #: Specifies whether the image needs a config drive. - #: `mandatory` or `optional` (default if property is not used). - needs_config_drive = resource2.Body('img_config_drive') - #: The ID of an image stored in the Image service that should be used - #: as the kernel when booting an AMI-style image. - kernel_id = resource2.Body('kernel_id') - #: The common name of the operating system distribution in lowercase - os_distro = resource2.Body('os_distro') - #: The operating system version as specified by the distributor. - os_version = resource2.Body('os_version') - #: Secure Boot is a security standard. When the instance starts, - #: Secure Boot first examines software such as firmware and OS by - #: their signature and only allows them to run if the signatures are valid. - needs_secure_boot = resource2.Body('os_secure_boot') - #: The ID of image stored in the Image service that should be used as - #: the ramdisk when booting an AMI-style image. - ramdisk_id = resource2.Body('ramdisk_id') - #: The virtual machine mode. This represents the host/guest ABI - #: (application binary interface) used for the virtual machine. - vm_mode = resource2.Body('vm_mode') - #: The preferred number of sockets to expose to the guest. - hw_cpu_sockets = resource2.Body('hw_cpu_sockets', type=int) - #: The preferred number of cores to expose to the guest. - hw_cpu_cores = resource2.Body('hw_cpu_cores', type=int) - #: The preferred number of threads to expose to the guest. - hw_cpu_threads = resource2.Body('hw_cpu_threads', type=int) - #: Specifies the type of disk controller to attach disk devices to. - #: One of scsi, virtio, uml, xen, ide, or usb. - hw_disk_bus = resource2.Body('hw_disk_bus') - #: Adds a random-number generator device to the image's instances. - hw_rng_model = resource2.Body('hw_rng_model') - #: For libvirt: Enables booting an ARM system using the specified - #: machine type. - #: For Hyper-V: Specifies whether the Hyper-V instance will be a - #: generation 1 or generation 2 VM. - hw_machine_type = resource2.Body('hw_machine_type') - #: Enables the use of VirtIO SCSI (virtio-scsi) to provide block device - #: access for compute instances; by default, instances use VirtIO Block - #: (virtio-blk). - hw_scsi_model = resource2.Body('hw_scsi_model') - #: Specifies the count of serial ports that should be provided. - hw_serial_port_count = resource2.Body('hw_serial_port_count', type=int) - #: The video image driver used. - hw_video_model = resource2.Body('hw_video_model') - #: Maximum RAM for the video image. - hw_video_ram = resource2.Body('hw_video_ram', type=int) - #: Enables a virtual hardware watchdog device that carries out the - #: specified action if the server hangs. - hw_watchdog_action = resource2.Body('hw_watchdog_action') - #: The kernel command line to be used by the libvirt driver, instead - #: of the default. - os_command_line = resource2.Body('os_command_line') - #: Specifies the model of virtual network interface device to use. - hw_vif_model = resource2.Body('hw_vif_model') - #: If true, this enables the virtio-net multiqueue feature. - #: In this case, the driver sets the number of queues equal to the - #: number of guest vCPUs. This makes the network performance scale - #: across a number of vCPUs. - is_hw_vif_multiqueue_enabled = resource2.Body('hw_vif_multiqueue_enabled', - type=bool) - #: If true, enables the BIOS bootmenu. - is_hw_boot_menu_enabled = resource2.Body('hw_boot_menu', type=bool) - #: The virtual SCSI or IDE controller used by the hypervisor. - vmware_adaptertype = resource2.Body('vmware_adaptertype') - #: A VMware GuestID which describes the operating system installed - #: in the image. - vmware_ostype = resource2.Body('vmware_ostype') - #: If true, the root partition on the disk is automatically resized - #: before the instance boots. - has_auto_disk_config = resource2.Body('auto_disk_config', type=bool) - #: The operating system installed on the image. - os_type = resource2.Body('os_type') - - def _action(self, session, action): - """Call an action on an image ID.""" - url = utils.urljoin(self.base_path, self.id, 'actions', action) - return session.post(url, endpoint_filter=self.service) - - def deactivate(self, session): - """Deactivate an image - - Note: Only administrative users can view image locations - for deactivated images. - """ - self._action(session, "deactivate") - - def reactivate(self, session): - """Reactivate an image - - Note: The image must exist in order to be reactivated. - """ - self._action(session, "reactivate") - - def add_tag(self, session, tag): - """Add a tag to an image""" - url = utils.urljoin(self.base_path, self.id, 'tags', tag) - session.put(url, endpoint_filter=self.service) - - def remove_tag(self, session, tag): - """Remove a tag from an image""" - url = utils.urljoin(self.base_path, self.id, 'tags', tag) - session.delete(url, endpoint_filter=self.service) - - def upload(self, session): - """Upload data into an existing image""" - url = utils.urljoin(self.base_path, self.id, 'file') - session.put(url, endpoint_filter=self.service, data=self.data, - headers={"Content-Type": "application/octet-stream", - "Accept": ""}) - - def download(self, session, stream=False): - """Download the data contained in an image""" - # TODO(briancurtin): This method should probably offload the get - # operation into another thread or something of that nature. - url = utils.urljoin(self.base_path, self.id, 'file') - resp = session.get(url, endpoint_filter=self.service, stream=stream) - - # See the following bug report for details on why the checksum - # code may sometimes depend on a second GET call. - # https://bugs.launchpad.net/python-openstacksdk/+bug/1619675 - checksum = resp.headers.get("Content-MD5") - - if checksum is None: - # If we don't receive the Content-MD5 header with the download, - # make an additional call to get the image details and look at - # the checksum attribute. - details = self.get(session) - checksum = details.checksum - - # if we are returning the repsonse object, ensure that it - # has the content-md5 header so that the caller doesn't - # need to jump through the same hoops through which we - # just jumped. - if stream: - resp.headers['content-md5'] = checksum - return resp - - if checksum is not None: - digest = hashlib.md5(resp.content).hexdigest() - if digest != checksum: - raise exceptions.InvalidResponse( - "checksum mismatch: %s != %s" % (checksum, digest)) - else: - _logger.warn( - "Unable to verify the integrity of image %s" % (self.id)) - - return resp.content - - def update(self, session, **attrs): - url = utils.urljoin(self.base_path, self.id) - headers = { - 'Content-Type': 'application/openstack-images-v2.1-json-patch', - 'Accept': '' - } - original = self.to_dict() - patch_string = jsonpatch.make_patch(original, attrs).to_string() - resp = session.patch(url, endpoint_filter=self.service, - data=patch_string, - headers=headers) - self._translate_response(resp, has_body=True) - return self diff --git a/openstack/image/v2/member.py b/openstack/image/v2/member.py deleted file mode 100644 index 5548efd7..00000000 --- a/openstack/image/v2/member.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.image import image_service -from openstack import resource2 - - -class Member(resource2.Resource): - resources_key = 'members' - base_path = '/images/%(image_id)s/members' - service = image_service.ImageService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # See https://bugs.launchpad.net/glance/+bug/1526991 for member/member_id - # 'member' is documented incorrectly as being deprecated but it's the - # only thing that works. 'member_id' is not accepted. - - #: The ID of the image member. An image member is a tenant - #: with whom the image is shared. - member_id = resource2.Body('member', alternate_id=True) - #: The date and time when the member was created. - created_at = resource2.Body('created_at') - #: Image ID stored through the image API. Typically a UUID. - image_id = resource2.URI('image_id') - #: The status of the image. - status = resource2.Body('status') - #: The URL for schema of the member. - schema = resource2.Body('schema') - #: The date and time when the member was updated. - updated_at = resource2.Body('updated_at') diff --git a/openstack/key_manager/__init__.py b/openstack/key_manager/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/key_manager/key_manager_service.py b/openstack/key_manager/key_manager_service.py deleted file mode 100644 index 36d3b413..00000000 --- a/openstack/key_manager/key_manager_service.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class KeyManagerService(service_filter.ServiceFilter): - """The key manager service.""" - - valid_versions = [service_filter.ValidVersion('v1')] - - def __init__(self, version=None): - """Create a key manager service.""" - super(KeyManagerService, self).__init__(service_type='key-manager', - version=version) diff --git a/openstack/key_manager/v1/__init__.py b/openstack/key_manager/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/key_manager/v1/_format.py b/openstack/key_manager/v1/_format.py deleted file mode 100644 index 34698a38..00000000 --- a/openstack/key_manager/v1/_format.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import format - -from six.moves.urllib import parse - - -class HREFToUUID(format.Formatter): - - @classmethod - def deserialize(cls, value): - """Convert a HREF to the UUID portion""" - parts = parse.urlsplit(value) - - # Only try to proceed if we have an actual URI. - # Just check that we have a scheme, netloc, and path. - if not all(parts[:3]): - raise ValueError("Unable to convert %s to an ID" % value) - - # The UUID will be the last portion of the URI. - return parts.path.split("/")[-1] - - @classmethod - def serialize(cls, value): - # NOTE(briancurtin): If we had access to the session to get - # the endpoint we could do something smart here like take an ID - # and give back an HREF, but this will just have to be something - # that works different because Barbican does what it does... - return value diff --git a/openstack/key_manager/v1/_proxy.py b/openstack/key_manager/v1/_proxy.py deleted file mode 100644 index 0c65d262..00000000 --- a/openstack/key_manager/v1/_proxy.py +++ /dev/null @@ -1,262 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.key_manager.v1 import container as _container -from openstack.key_manager.v1 import order as _order -from openstack.key_manager.v1 import secret as _secret -from openstack import proxy2 - - -class Proxy(proxy2.BaseProxy): - - def create_container(self, **attrs): - """Create a new container from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.key_manager.v1.container.Container`, - comprised of the properties on the Container class. - - :returns: The results of container creation - :rtype: :class:`~openstack.key_manager.v1.container.Container` - """ - return self._create(_container.Container, **attrs) - - def delete_container(self, container, ignore_missing=True): - """Delete a container - - :param container: The value can be either the ID of a container or a - :class:`~openstack.key_manager.v1.container.Container` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the container does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent container. - - :returns: ``None`` - """ - self._delete(_container.Container, container, - ignore_missing=ignore_missing) - - def find_container(self, name_or_id, ignore_missing=True): - """Find a single container - - :param name_or_id: The name or ID of a container. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.key_manager.v1.container.Container` - or None - """ - return self._find(_container.Container, name_or_id, - ignore_missing=ignore_missing) - - def get_container(self, container): - """Get a single container - - :param container: The value can be the ID of a container or a - :class:`~openstack.key_manager.v1.container.Container` - instance. - - :returns: One :class:`~openstack.key_manager.v1.container.Container` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_container.Container, container) - - def containers(self, **query): - """Return a generator of containers - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of container objects - :rtype: :class:`~openstack.key_manager.v1.container.Container` - """ - return self._list(_container.Container, paginated=False, **query) - - def update_container(self, container, **attrs): - """Update a container - - :param container: Either the id of a container or a - :class:`~openstack.key_manager.v1.container.Container` - instance. - :attrs kwargs: The attributes to update on the container represented - by ``value``. - - :returns: The updated container - :rtype: :class:`~openstack.key_manager.v1.container.Container` - """ - return self._update(_container.Container, container, **attrs) - - def create_order(self, **attrs): - """Create a new order from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.key_manager.v1.order.Order`, - comprised of the properties on the Order class. - - :returns: The results of order creation - :rtype: :class:`~openstack.key_manager.v1.order.Order` - """ - return self._create(_order.Order, **attrs) - - def delete_order(self, order, ignore_missing=True): - """Delete an order - - :param order: The value can be either the ID of a order or a - :class:`~openstack.key_manager.v1.order.Order` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the order does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent order. - - :returns: ``None`` - """ - self._delete(_order.Order, order, ignore_missing=ignore_missing) - - def find_order(self, name_or_id, ignore_missing=True): - """Find a single order - - :param name_or_id: The name or ID of a order. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.key_manager.v1.order.Order` or None - """ - return self._find(_order.Order, name_or_id, - ignore_missing=ignore_missing) - - def get_order(self, order): - """Get a single order - - :param order: The value can be the ID of an order or a - :class:`~openstack.key_manager.v1.order.Order` - instance. - - :returns: One :class:`~openstack.key_manager.v1.order.Order` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_order.Order, order) - - def orders(self, **query): - """Return a generator of orders - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of order objects - :rtype: :class:`~openstack.key_manager.v1.order.Order` - """ - return self._list(_order.Order, paginated=False, **query) - - def update_order(self, order, **attrs): - """Update a order - - :param order: Either the id of a order or a - :class:`~openstack.key_manager.v1.order.Order` - instance. - :attrs kwargs: The attributes to update on the order represented - by ``value``. - - :returns: The updated order - :rtype: :class:`~openstack.key_manager.v1.order.Order` - """ - return self._update(_order.Order, order, **attrs) - - def create_secret(self, **attrs): - """Create a new secret from attributes - - :param dict attrs: Keyword arguments which will be used to create a - :class:`~openstack.key_manager.v1.secret.Secret`, - comprised of the properties on the Order class. - - :returns: The results of secret creation - :rtype: :class:`~openstack.key_manager.v1.secret.Secret` - """ - return self._create(_secret.Secret, **attrs) - - def delete_secret(self, secret, ignore_missing=True): - """Delete a secret - - :param secret: The value can be either the ID of a secret or a - :class:`~openstack.key_manager.v1.secret.Secret` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the secret does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent secret. - - :returns: ``None`` - """ - self._delete(_secret.Secret, secret, ignore_missing=ignore_missing) - - def find_secret(self, name_or_id, ignore_missing=True): - """Find a single secret - - :param name_or_id: The name or ID of a secret. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.key_manager.v1.secret.Secret` or - None - """ - return self._find(_secret.Secret, name_or_id, - ignore_missing=ignore_missing) - - def get_secret(self, secret): - """Get a single secret - - :param secret: The value can be the ID of a secret or a - :class:`~openstack.key_manager.v1.secret.Secret` - instance. - - :returns: One :class:`~openstack.key_manager.v1.secret.Secret` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_secret.Secret, secret) - - def secrets(self, **query): - """Return a generator of secrets - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of secret objects - :rtype: :class:`~openstack.key_manager.v1.secret.Secret` - """ - return self._list(_secret.Secret, paginated=False, **query) - - def update_secret(self, secret, **attrs): - """Update a secret - - :param secret: Either the id of a secret or a - :class:`~openstack.key_manager.v1.secret.Secret` - instance. - :attrs kwargs: The attributes to update on the secret represented - by ``value``. - - :returns: The updated secret - :rtype: :class:`~openstack.key_manager.v1.secret.Secret` - """ - return self._update(_secret.Secret, secret, **attrs) diff --git a/openstack/key_manager/v1/container.py b/openstack/key_manager/v1/container.py deleted file mode 100644 index dbfcdfa5..00000000 --- a/openstack/key_manager/v1/container.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.key_manager import key_manager_service -from openstack.key_manager.v1 import _format -from openstack import resource2 - - -class Container(resource2.Resource): - resources_key = 'containers' - base_path = '/containers' - service = key_manager_service.KeyManagerService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: A URI for this container - container_ref = resource2.Body('container_ref') - #: The ID for this container - container_id = resource2.Body('container_ref', alternate_id=True, - type=_format.HREFToUUID) - #: The timestamp when this container was created. - created_at = resource2.Body('created') - #: The name of this container - name = resource2.Body('name') - #: A list of references to secrets in this container - secret_refs = resource2.Body('secret_refs', type=list) - #: The status of this container - status = resource2.Body('status') - #: The type of this container - type = resource2.Body('type') - #: The timestamp when this container was updated. - updated_at = resource2.Body('updated') - #: A party interested in this container. - consumers = resource2.Body('consumers', type=list) diff --git a/openstack/key_manager/v1/order.py b/openstack/key_manager/v1/order.py deleted file mode 100644 index b7bed065..00000000 --- a/openstack/key_manager/v1/order.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.key_manager import key_manager_service -from openstack.key_manager.v1 import _format -from openstack import resource2 - - -class Order(resource2.Resource): - resources_key = 'orders' - base_path = '/orders' - service = key_manager_service.KeyManagerService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - #: Timestamp in ISO8601 format of when the order was created - created_at = resource2.Body('created') - #: Keystone Id of the user who created the order - creator_id = resource2.Body('creator_id') - #: A dictionary containing key-value parameters which specify the - #: details of an order request - meta = resource2.Body('meta', type=dict) - #: A URI for this order - order_ref = resource2.Body('order_ref') - #: The ID of this order - order_id = resource2.Body('order_ref', alternate_id=True, - type=_format.HREFToUUID) - #: Secret href associated with the order - secret_ref = resource2.Body('secret_ref') - #: Secret ID associated with the order - secret_id = resource2.Body('secret_ref', type=_format.HREFToUUID) - # The status of this order - status = resource2.Body('status') - #: Metadata associated with the order - sub_status = resource2.Body('sub_status') - #: Metadata associated with the order - sub_status_message = resource2.Body('sub_status_message') - # The type of order - type = resource2.Body('type') - #: Timestamp in ISO8601 format of the last time the order was updated. - updated_at = resource2.Body('updated') diff --git a/openstack/key_manager/v1/secret.py b/openstack/key_manager/v1/secret.py deleted file mode 100644 index 603b09ef..00000000 --- a/openstack/key_manager/v1/secret.py +++ /dev/null @@ -1,106 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.key_manager import key_manager_service -from openstack.key_manager.v1 import _format -from openstack import resource2 -from openstack import utils - - -class Secret(resource2.Resource): - resources_key = 'secrets' - base_path = '/secrets' - service = key_manager_service.KeyManagerService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource2.QueryParameters("name", "mode", "bits", - "secret_type", "acl_only", - "created", "updated", - "expiration", "sort", - algorithm="alg") - - # Properties - #: Metadata provided by a user or system for informational purposes - algorithm = resource2.Body('algorithm') - #: Metadata provided by a user or system for informational purposes. - #: Value must be greater than zero. - bit_length = resource2.Body('bit_length') - #: A list of content types - content_types = resource2.Body('content_types', type=dict) - #: Once this timestamp has past, the secret will no longer be available. - expires_at = resource2.Body('expiration') - #: Timestamp of when the secret was created. - created_at = resource2.Body('created') - #: Timestamp of when the secret was last updated. - updated_at = resource2.Body('updated') - #: The type/mode of the algorithm associated with the secret information. - mode = resource2.Body('mode') - #: The name of the secret set by the user - name = resource2.Body('name') - #: A URI to the sercret - secret_ref = resource2.Body('secret_ref') - #: The ID of the secret - # NOTE: This is not really how alternate IDs are supposed to work and - # ultimately means this has to work differently than all other services - # in all of OpenStack because of the departure from using actual IDs - # that even this service can't even use itself. - secret_id = resource2.Body('secret_ref', alternate_id=True, - type=_format.HREFToUUID) - #: Used to indicate the type of secret being stored. - secret_type = resource2.Body('secret_type') - #: The status of this secret - status = resource2.Body('status') - #: A timestamp when this secret was updated. - updated_at = resource2.Body('updated') - #: The secret's data to be stored. payload_content_type must also - #: be supplied if payload is included. (optional) - payload = resource2.Body('payload') - #: The media type for the content of the payload. - #: (required if payload is included) - payload_content_type = resource2.Body('payload_content_type') - #: The encoding used for the payload to be able to include it in - #: the JSON request. Currently only base64 is supported. - #: (required if payload is encoded) - payload_content_encoding = resource2.Body('payload_content_encoding') - - def get(self, session, requires_id=True): - request = self._prepare_request(requires_id=requires_id) - - response = session.get(request.uri, - endpoint_filter=self.service).json() - - content_type = None - if self.payload_content_type is not None: - content_type = self.payload_content_type - elif "content_types" in response: - content_type = response["content_types"]["default"] - - # Only try to get the payload if a content type has been explicitly - # specified or if one was found in the metadata response - if content_type is not None: - payload = session.get(utils.urljoin(request.uri, "payload"), - endpoint_filter=self.service, - headers={"Accept": content_type}) - response["payload"] = payload.text - - # We already have the JSON here so don't call into _translate_response - body = self._filter_component(response, self._body_mapping()) - self._body.attributes.update(body) - self._body.clean() - - return self diff --git a/openstack/load_balancer/__init__.py b/openstack/load_balancer/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/load_balancer/load_balancer_service.py b/openstack/load_balancer/load_balancer_service.py deleted file mode 100644 index 1ff22b22..00000000 --- a/openstack/load_balancer/load_balancer_service.py +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class LoadBalancerService(service_filter.ServiceFilter): - """The load balancer service.""" - - valid_versions = [service_filter.ValidVersion('v2')] - - def __init__(self, version=None): - """Create a load balancer service.""" - super(LoadBalancerService, self).__init__( - service_type='load_balancer', - version=version - ) diff --git a/openstack/load_balancer/v2/__init__.py b/openstack/load_balancer/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/load_balancer/v2/_proxy.py b/openstack/load_balancer/v2/_proxy.py deleted file mode 100644 index 224fddb5..00000000 --- a/openstack/load_balancer/v2/_proxy.py +++ /dev/null @@ -1,82 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.load_balancer.v2 import load_balancer as _lb -from openstack import proxy2 - - -class Proxy(proxy2.BaseProxy): - - def create_load_balancer(self, **attrs): - """Create a new load balancer from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.load_balancer.v2. - load_balancer.LoadBalancer`, - comprised of the properties on the - LoadBalancer class. - - :returns: The results of load balancer creation - :rtype: :class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer` - """ - return self._create(_lb.LoadBalancer, **attrs) - - def get_load_balancer(self, *attrs): - """Get a load balancer - - :param load_balancer: The value can be the name of a load balancer - or :class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer` - instance. - - :returns: One - :class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer` - """ - return self._get(_lb.LoadBalancer, *attrs) - - def load_balancers(self, **query): - """Retrieve a generator of load balancers - - :returns: A generator of load balancer instances - """ - return self._list(_lb.LoadBalancer, paginated=True, **query) - - def delete_load_balancer(self, load_balancer, ignore_missing=True): - """Delete a load balancer - - :param load_balancer: The load_balancer can be either the name or a - :class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer` - instance - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be raised when - the load balancer does not exist. - When set to ``True``, no exception will be set when attempting to - delete a nonexistent load balancer. - - :returns: ``None`` - """ - return self._delete(_lb.LoadBalancer, load_balancer, - ignore_missing=ignore_missing) - - def find_load_balancer(self, name_or_id, ignore_missing=True): - """Find a single load balancer - - :param name_or_id: The name or ID of a load balancer - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the load balancer does not exist. - When set to ``True``, no exception will be set when attempting - to delete a nonexistent load balancer. - - :returns: ``None`` - """ - return self._find(_lb.LoadBalancer, name_or_id, - ignore_missing=ignore_missing) diff --git a/openstack/load_balancer/v2/load_balancer.py b/openstack/load_balancer/v2/load_balancer.py deleted file mode 100644 index 509f0ae8..00000000 --- a/openstack/load_balancer/v2/load_balancer.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.load_balancer import load_balancer_service as lb_service -from openstack import resource2 as resource - - -class LoadBalancer(resource.Resource): - resource_key = 'loadbalancer' - resources_key = 'loadbalancers' - base_path = '/loadbalancers' - service = lb_service.LoadBalancerService() - - # capabilities - allow_create = True - allow_list = True - allow_get = True - allow_delete = True - - #: Properties - #: Timestamp when the load balancer was created - created_at = resource.Body('created_at') - #: The load balancer description - description = resource.Body('description') - #: The administrative state of the load balancer *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: List of listeners associated with this load balancer - listeners = resource.Body('listeners', type=list) - #: The load balancer name - name = resource.Body('name') - #: Operating status of the load balancer - operating_status = resource.Body('operating_status') - #: List of pools associated with this load balancer - pools = resource.Body('pools', type=list) - #: The ID of the project this load balancer is associated with. - project_id = resource.Body('project_id') - #: The provisioning status of this load balancer - provisioning_status = resource.Body('provisioning_status') - #: VIP address of load balancer - vip_address = resource.Body('vip_address') - #: VIP port ID - vip_port_id = resource.Body('vip_port_id') - #: VIP subnet ID - vip_subnet_id = resource.Body('vip_subnet_id') - #: Timestamp when the load balancer was last updated - updated_at = resource.Body('updated_at') diff --git a/openstack/load_balancer/version.py b/openstack/load_balancer/version.py deleted file mode 100644 index 4a829c2e..00000000 --- a/openstack/load_balancer/version.py +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.load_balancer import load_balancer_service as lb_service -from openstack import resource2 as resource - - -class Version(resource.Resource): - resource_key = 'version' - resources_key = 'versions' - base_path = '/' - service = lb_service.LoadBalancerService( - version=lb_service.LoadBalancerService.UNVERSIONED - ) - - # capabilities - allow_list = True - - # Properties - links = resource.Body('links') - status = resource.Body('status') diff --git a/openstack/message/__init__.py b/openstack/message/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/message/message_service.py b/openstack/message/message_service.py deleted file mode 100644 index e74bf80b..00000000 --- a/openstack/message/message_service.py +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class MessageService(service_filter.ServiceFilter): - """The message service.""" - - valid_versions = [service_filter.ValidVersion('v1'), - service_filter.ValidVersion('v2')] - - def __init__(self, version=None): - """Create a message service.""" - super(MessageService, self).__init__( - service_type='messaging', - version=version - ) diff --git a/openstack/message/v1/__init__.py b/openstack/message/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/message/v1/_proxy.py b/openstack/message/v1/_proxy.py deleted file mode 100644 index bdd25ef0..00000000 --- a/openstack/message/v1/_proxy.py +++ /dev/null @@ -1,93 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.message.v1 import claim -from openstack.message.v1 import message -from openstack.message.v1 import queue -from openstack import proxy -from openstack import utils - - -class Proxy(proxy.BaseProxy): - - @utils.deprecated(deprecated_in="0.9.16", removed_in="0.9.17", - details="Message v1 is deprecated since 2014. Use v2.") - def create_queue(self, **attrs): - """Create a new queue from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.message.v1.queue.Queue`, - comprised of the properties on the Queue class. - - :returns: The results of queue creation - :rtype: :class:`~openstack.message.v1.queue.Queue` - """ - return self._create(queue.Queue, **attrs) - - @utils.deprecated(deprecated_in="0.9.16", removed_in="0.9.17", - details="Message v1 is deprecated since 2014. Use v2.") - def delete_queue(self, value, ignore_missing=True): - """Delete a queue - - :param value: The value can be either the name of a queue or a - :class:`~openstack.message.v1.queue.Queue` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the queue does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent queue. - - :returns: ``None`` - """ - return self._delete(queue.Queue, value, ignore_missing=ignore_missing) - - @utils.deprecated(deprecated_in="0.9.16", removed_in="0.9.17", - details="Message v1 is deprecated since 2014. Use v2.") - def create_messages(self, values): - """Create new messages - - :param values: The list of - :class:`~openstack.message.v1.message.Message` objects - to create. - :type values: :py:class:`list` - - :returns: The list of - :class:`~openstack.message.v1.message.Message` objects - that were created. - """ - return message.Message.create_messages(self._session, values) - - @utils.deprecated(deprecated_in="0.9.16", removed_in="0.9.17", - details="Message v1 is deprecated since 2014. Use v2.") - def claim_messages(self, value): - """Claims a set of messages. - - :param value: The value must be a - :class:`~openstack.message.v1.claim.Claim` instance. - - :returns: The list of - :class:`~openstack.message.v1.message.Message` objects - that were claimed. - """ - return claim.Claim.claim_messages(self._session, value) - - @utils.deprecated(deprecated_in="0.9.16", removed_in="0.9.17", - details="Message v1 is deprecated since 2014. Use v2.") - def delete_message(self, value): - """Delete a message - - :param value: The value must be a - :class:`~openstack.message.v1.message.Message` instance. - - :returns: ``None`` - """ - message.Message.delete_by_id(self._session, value) diff --git a/openstack/message/v1/claim.py b/openstack/message/v1/claim.py deleted file mode 100644 index 5b8c25f6..00000000 --- a/openstack/message/v1/claim.py +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import json - -from openstack import exceptions -from openstack.message import message_service -from openstack.message.v1 import message -from openstack import resource - - -class Claim(resource.Resource): - resources_key = 'claims' - base_path = "/queues/%(queue_name)s/claims" - service = message_service.MessageService() - - # capabilities - allow_create = True - allow_list = False - allow_retrieve = False - allow_delete = False - - #: A ID for each client instance. The ID must be submitted in its - #: canonical form (for example, 3381af92-2b9e-11e3-b191-71861300734c). - #: The client generates this ID once. The client ID persists between - #: restarts of the client so the client should reuse that same ID. - #: All message-related operations require the use of the client ID in - #: the headers to ensure that messages are not echoed back to the client - #: that posted them, unless the client explicitly requests this. - client_id = None - - #: The name of the queue this Claim belongs to. - queue_name = None - - #: Specifies the number of Messages to return. - limit = None - - #: Specifies how long the server waits before releasing the claim, - #: in seconds. - ttl = resource.prop("ttl") - - #: Specifies the message grace period, in seconds. - grace = resource.prop("grace") - - @classmethod - def claim_messages(cls, session, claim): - """Create a remote resource from this instance.""" - url = cls._get_url({'queue_name': claim.queue_name}) - headers = {'Client-ID': claim.client_id} - params = {'limit': claim.limit} if claim.limit else None - body = [] - - try: - resp = session.post(url, endpoint_filter=cls.service, - headers=headers, - data=json.dumps(claim, cls=ClaimEncoder), - params=params) - body = resp.json() - except exceptions.InvalidResponse as e: - # The Message Service will respond with a 204 and no content in - # the body when there are no messages to claim. The transport - # layer doesn't like that and we have to correct for it here. - # Ultimately it's a bug in the v1.0 Message Service API. - # TODO(etoews): API is fixed in v1.1 so fix this for message.v1_1 - # https://wiki.openstack.org/wiki/Zaqar/specs/api/v1.1 - if e.response.status_code != 204: - raise e - - for message_attrs in body: - yield message.Message.new( - client_id=claim.client_id, - queue_name=claim.queue_name, - **message_attrs) - - -class ClaimEncoder(json.JSONEncoder): - def default(self, claim): - return {'ttl': claim.ttl, 'grace': claim.grace} diff --git a/openstack/message/v1/message.py b/openstack/message/v1/message.py deleted file mode 100644 index 4650032e..00000000 --- a/openstack/message/v1/message.py +++ /dev/null @@ -1,107 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import json - -from six.moves.urllib import parse - -from openstack.message import message_service -from openstack import resource - - -class Message(resource.Resource): - resources_key = 'messages' - base_path = "/queues/%(queue_name)s/messages" - service = message_service.MessageService() - - # capabilities - allow_create = True - allow_list = False - allow_retrieve = False - allow_delete = False - - #: A ID for each client instance. The ID must be submitted in its - #: canonical form (for example, 3381af92-2b9e-11e3-b191-71861300734c). - #: The client generates this ID once. The client ID persists between - #: restarts of the client so the client should reuse that same ID. - #: All message-related operations require the use of the client ID in - #: the headers to ensure that messages are not echoed back to the client - #: that posted them, unless the client explicitly requests this. - client_id = None - - #: The name of the queue this Message belongs to. - queue_name = None - - #: A relative href that references this Message. - href = resource.prop("href") - - #: An arbitrary JSON document that constitutes the body of the message - #: being sent. - body = resource.prop("body") - - #: Specifies how long the server waits, in seconds, before marking the - #: message as expired and removing it from the queue. - ttl = resource.prop("ttl") - - #: Specifies how long the message has been in the queue, in seconds. - age = resource.prop("age") - - @classmethod - def create_messages(cls, session, messages): - if len(messages) == 0: - raise ValueError('messages cannot be empty') - - for i, message in enumerate(messages, -1): - if message.queue_name != messages[i].queue_name: - raise ValueError('All queues in messages must be equal') - if message.client_id != messages[i].client_id: - raise ValueError('All clients in messages must be equal') - - url = cls._get_url({'queue_name': messages[0].queue_name}) - headers = {'Client-ID': messages[0].client_id} - - resp = session.post(url, endpoint_filter=cls.service, headers=headers, - data=json.dumps(messages, cls=MessageEncoder)) - resp = resp.json() - - messages_created = [] - hrefs = resp['resources'] - - for i, href in enumerate(hrefs): - message = Message.existing(**messages[i]) - message.href = href - messages_created.append(message) - - return messages_created - - @classmethod - def _strip_version(cls, href): - path = parse.urlparse(href).path - - if path.startswith('/v'): - return href[href.find('/', 1):] - else: - return href - - @classmethod - def delete_by_id(cls, session, message, path_args=None): - url = cls._strip_version(message.href) - headers = { - 'Client-ID': message.client_id, - 'Accept': '', - } - session.delete(url, endpoint_filter=cls.service, headers=headers) - - -class MessageEncoder(json.JSONEncoder): - def default(self, message): - return {'body': message.body, 'ttl': message.ttl} diff --git a/openstack/message/v1/queue.py b/openstack/message/v1/queue.py deleted file mode 100644 index dd10420f..00000000 --- a/openstack/message/v1/queue.py +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.message import message_service -from openstack import resource - - -class Queue(resource.Resource): - id_attribute = 'name' - resources_key = 'queues' - base_path = '/queues' - service = message_service.MessageService() - - # capabilities - allow_create = True - allow_list = False - allow_retrieve = False - allow_delete = True - - @classmethod - def create_by_id(cls, session, attrs, resource_id=None, path_args=None): - url = cls._get_url(path_args, resource_id) - headers = {'Accept': ''} - session.put(url, endpoint_filter=cls.service, headers=headers) - return {cls.id_attribute: resource_id} diff --git a/openstack/message/v2/__init__.py b/openstack/message/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/message/v2/_proxy.py b/openstack/message/v2/_proxy.py deleted file mode 100644 index 7652ec6c..00000000 --- a/openstack/message/v2/_proxy.py +++ /dev/null @@ -1,283 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.message.v2 import claim as _claim -from openstack.message.v2 import message as _message -from openstack.message.v2 import queue as _queue -from openstack.message.v2 import subscription as _subscription -from openstack import proxy2 -from openstack import resource2 - - -class Proxy(proxy2.BaseProxy): - - def create_queue(self, **attrs): - """Create a new queue from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.message.v2.queue.Queue`, - comprised of the properties on the Queue class. - - :returns: The results of queue creation - :rtype: :class:`~openstack.message.v2.queue.Queue` - """ - return self._create(_queue.Queue, **attrs) - - def get_queue(self, queue): - """Get a queue - - :param queue: The value can be the name of a queue or a - :class:`~openstack.message.v2.queue.Queue` instance. - - :returns: One :class:`~openstack.message.v2.queue.Queue` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - queue matching the name could be found. - """ - return self._get(_queue.Queue, queue) - - def queues(self, **query): - """Retrieve a generator of queues - - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the queues to be returned. Available parameters include: - - * limit: Requests at most the specified number of items be - returned from the query. - * marker: Specifies the ID of the last-seen queue. Use the limit - parameter to make an initial limited request and use the ID of - the last-seen queue from the response as the marker parameter - value in a subsequent limited request. - - :returns: A generator of queue instances. - """ - return self._list(_queue.Queue, paginated=True, **query) - - def delete_queue(self, value, ignore_missing=True): - """Delete a queue - - :param value: The value can be either the name of a queue or a - :class:`~openstack.message.v2.queue.Queue` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the queue does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent queue. - - :returns: ``None`` - """ - return self._delete(_queue.Queue, value, ignore_missing=ignore_missing) - - def post_message(self, queue_name, messages): - """Post messages to given queue - - :param queue_name: The name of target queue to post message to. - :param messages: List of messages body and TTL to post. - :type messages: :py:class:`list` - - :returns: A string includes location of messages successfully posted. - """ - message = self._get_resource(_message.Message, None, - queue_name=queue_name) - return message.post(self._session, messages) - - def messages(self, queue_name, **query): - """Retrieve a generator of messages - - :param queue_name: The name of target queue to query messages from. - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the messages to be returned. Available parameters include: - - * limit: Requests at most the specified number of items be - returned from the query. - * marker: Specifies the ID of the last-seen subscription. Use the - limit parameter to make an initial limited request and use the - ID of the last-seen subscription from the response as the - marker parameter value in a subsequent limited request. - * echo: Indicate if the messages can be echoed back to the client - that posted them. - * include_claimed: Indicate if the messages list should include - the claimed messages. - - :returns: A generator of message instances. - """ - query["queue_name"] = queue_name - return self._list(_message.Message, paginated=True, **query) - - def get_message(self, queue_name, message): - """Get a message - - :param queue_name: The name of target queue to get message from. - :param message: The value can be the name of a message or a - :class:`~openstack.message.v2.message.Message` instance. - - :returns: One :class:`~openstack.message.v2.message.Message` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - message matching the criteria could be found. - """ - message = self._get_resource(_message.Message, message, - queue_name=queue_name) - return self._get(_message.Message, message) - - def delete_message(self, queue_name, value, claim=None, - ignore_missing=True): - """Delete a message - - :param queue_name: The name of target queue to delete message from. - :param value: The value can be either the name of a message or a - :class:`~openstack.message.v2.message.Message` instance. - :param claim: The value can be the ID or a - :class:`~openstack.message.v2.claim.Claim` instance of - the claim seizing the message. If None, the message has - not been claimed. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the message does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent message. - - :returns: ``None`` - """ - message = self._get_resource(_message.Message, value, - queue_name=queue_name) - message.claim_id = resource2.Resource._get_id(claim) - return self._delete(_message.Message, message, - ignore_missing=ignore_missing) - - def create_subscription(self, queue_name, **attrs): - """Create a new subscription from attributes - - :param queue_name: The name of target queue to subscribe on. - :param dict attrs: Keyword arguments which will be used to create a - :class:`~openstack.message.v2.subscription.Subscription`, - comprised of the properties on the Subscription class. - - :returns: The results of subscription creation - :rtype: :class:`~openstack.message.v2.subscription.Subscription` - """ - return self._create(_subscription.Subscription, queue_name=queue_name, - **attrs) - - def subscriptions(self, queue_name, **query): - """Retrieve a generator of subscriptions - - :param queue_name: The name of target queue to subscribe on. - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the subscriptions to be returned. Available parameters - include: - - * limit: Requests at most the specified number of items be - returned from the query. - * marker: Specifies the ID of the last-seen subscription. Use the - limit parameter to make an initial limited request and use the - ID of the last-seen subscription from the response as the - marker parameter value in a subsequent limited request. - - :returns: A generator of subscription instances. - """ - query["queue_name"] = queue_name - return self._list(_subscription.Subscription, paginated=True, **query) - - def get_subscription(self, queue_name, subscription): - """Get a subscription - - :param queue_name: The name of target queue of subscription. - :param message: The value can be the ID of a subscription or a - :class:`~openstack.message.v2.subscription.Subscription` instance. - - :returns: One :class:`~openstack.message.v2.subscription.Subscription` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - subscription matching the criteria could be found. - """ - subscription = self._get_resource(_subscription.Subscription, - subscription, - queue_name=queue_name) - return self._get(_subscription.Subscription, subscription) - - def delete_subscription(self, queue_name, value, ignore_missing=True): - """Delete a subscription - - :param queue_name: The name of target queue to delete subscription - from. - :param value: The value can be either the name of a subscription or a - :class:`~openstack.message.v2.subscription.Subscription` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the subscription does not exist. - When set to ``True``, no exception will be thrown when - attempting to delete a nonexistent subscription. - - :returns: ``None`` - """ - subscription = self._get_resource(_subscription.Subscription, value, - queue_name=queue_name) - return self._delete(_subscription.Subscription, subscription, - ignore_missing=ignore_missing) - - def create_claim(self, queue_name, **attrs): - """Create a new claim from attributes - - :param queue_name: The name of target queue to claim message from. - :param dict attrs: Keyword arguments which will be used to create a - :class:`~openstack.message.v2.claim.Claim`, - comprised of the properties on the Claim class. - - :returns: The results of claim creation - :rtype: :class:`~openstack.message.v2.claim.Claim` - """ - return self._create(_claim.Claim, queue_name=queue_name, **attrs) - - def get_claim(self, queue_name, claim): - """Get a claim - - :param queue_name: The name of target queue to claim message from. - :param claim: The value can be either the ID of a claim or a - :class:`~openstack.message.v2.claim.Claim` instance. - - :returns: One :class:`~openstack.message.v2.claim.Claim` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - claim matching the criteria could be found. - """ - return self._get(_claim.Claim, claim, queue_name=queue_name) - - def update_claim(self, queue_name, claim, **attrs): - """Update an existing claim from attributes - - :param queue_name: The name of target queue to claim message from. - :param claim: The value can be either the ID of a claim or a - :class:`~openstack.message.v2.claim.Claim` instance. - :param dict attrs: Keyword arguments which will be used to update a - :class:`~openstack.message.v2.claim.Claim`, - comprised of the properties on the Claim class. - - :returns: The results of claim update - :rtype: :class:`~openstack.message.v2.claim.Claim` - """ - return self._update(_claim.Claim, claim, queue_name=queue_name, - **attrs) - - def delete_claim(self, queue_name, claim, ignore_missing=True): - """Delete a claim - - :param queue_name: The name of target queue to claim messages from. - :param claim: The value can be either the ID of a claim or a - :class:`~openstack.message.v2.claim.Claim` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the claim does not exist. - When set to ``True``, no exception will be thrown when - attempting to delete a nonexistent claim. - - :returns: ``None`` - """ - return self._delete(_claim.Claim, claim, queue_name=queue_name, - ignore_missing=ignore_missing) diff --git a/openstack/message/v2/claim.py b/openstack/message/v2/claim.py deleted file mode 100644 index 13585872..00000000 --- a/openstack/message/v2/claim.py +++ /dev/null @@ -1,124 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.message import message_service -from openstack import resource2 - - -class Claim(resource2.Resource): - # FIXME(anyone): The name string of `location` field of Zaqar API response - # is lower case. That is inconsistent with the guide from API-WG. This is - # a workaround for this issue. - location = resource2.Header("location") - - resources_key = 'claims' - base_path = '/queues/%(queue_name)s/claims' - service = message_service.MessageService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - patch_update = True - - # Properties - #: The value in seconds indicating how long the claim has existed. - age = resource2.Body("age") - #: In case worker stops responding for a long time, the server will - #: extend the lifetime of claimed messages to be at least as long as - #: the lifetime of the claim itself, plus the specified grace period. - #: Must between 60 and 43200 seconds(12 hours). - grace = resource2.Body("grace") - #: The number of messages to claim. Default 10, up to 20. - limit = resource2.Body("limit") - #: Messages have been successfully claimed. - messages = resource2.Body("messages") - #: Number of seconds the server wait before releasing the claim. Must - #: between 60 and 43200 seconds(12 hours). - ttl = resource2.Body("ttl") - #: The name of queue to claim message from. - queue_name = resource2.URI("queue_name") - #: The ID to identify the client accessing Zaqar API. Must be specified - #: in header for each API request. - client_id = resource2.Header("Client-ID") - #: The ID to identify the project. Must be provided when keystone - #: authentication is not enabled in Zaqar service. - project_id = resource2.Header("X-PROJECT-ID") - - def _translate_response(self, response, has_body=True): - super(Claim, self)._translate_response(response, has_body=has_body) - if has_body and self.location: - # Extract claim ID from location - self.id = self.location.split("claims/")[1] - - def create(self, session, prepend_key=False): - request = self._prepare_request(requires_id=False, - prepend_key=prepend_key) - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - request.headers.update(headers) - response = session.post(request.uri, endpoint_filter=self.service, - json=request.body, headers=request.headers) - - # For case no message was claimed successfully, 204 No Content - # message will be returned. In other cases, we translate response - # body which has `messages` field(list) included. - if response.status_code != 204: - self._translate_response(response) - - return self - - def get(self, session, requires_id=True): - request = self._prepare_request(requires_id=requires_id) - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - - request.headers.update(headers) - response = session.get(request.uri, endpoint_filter=self.service, - headers=request.headers) - self._translate_response(response) - - return self - - def update(self, session, prepend_key=False, has_body=False): - request = self._prepare_request(prepend_key=prepend_key) - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - - request.headers.update(headers) - session.patch(request.uri, endpoint_filter=self.service, - json=request.body, headers=request.headers) - - return self - - def delete(self, session): - request = self._prepare_request() - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - - request.headers.update(headers) - response = session.delete(request.uri, endpoint_filter=self.service, - headers=request.headers) - - self._translate_response(response, has_body=False) - return self diff --git a/openstack/message/v2/message.py b/openstack/message/v2/message.py deleted file mode 100644 index 668f69c0..00000000 --- a/openstack/message/v2/message.py +++ /dev/null @@ -1,143 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.message import message_service -from openstack import resource2 - - -class Message(resource2.Resource): - # FIXME(anyone): The name string of `location` field of Zaqar API response - # is lower case. That is inconsistent with the guide from API-WG. This is - # a workaround for this issue. - location = resource2.Header("location") - - resources_key = 'messages' - base_path = '/queues/%(queue_name)s/messages' - service = message_service.MessageService() - - # capabilities - allow_create = True - allow_list = True - allow_get = True - allow_delete = True - - _query_mapping = resource2.QueryParameters("echo", "include_claimed") - - # Properties - #: The value in second to specify how long the message has been - #: posted to the queue. - age = resource2.Body("age") - #: A dictionary specifies an arbitrary document that constitutes the - #: body of the message being sent. - body = resource2.Body("body") - #: An uri string describe the location of the message resource. - href = resource2.Body("href") - #: The value in seconds to specify how long the server waits before - #: marking the message as expired and removing it from the queue. - ttl = resource2.Body("ttl") - #: The name of target queue message is post to or got from. - queue_name = resource2.URI("queue_name") - #: The ID to identify the client accessing Zaqar API. Must be specified - #: in header for each API request. - client_id = resource2.Header("Client-ID") - #: The ID to identify the project accessing Zaqar API. Must be specified - #: in case keystone auth is not enabled in Zaqar service. - project_id = resource2.Header("X-PROJECT-ID") - - def post(self, session, messages): - request = self._prepare_request(requires_id=False, prepend_key=True) - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - request.headers.update(headers) - request.body = {'messages': messages} - response = session.post(request.uri, endpoint_filter=self.service, - json=request.body, headers=request.headers) - - return response.json()['resources'] - - @classmethod - def list(cls, session, paginated=True, **params): - """This method is a generator which yields message objects. - - This is almost the copy of list method of resource2.Resource class. - The only difference is the request header now includes `Client-ID` - and `X-PROJECT-ID` fields which are required by Zaqar v2 API. - """ - more_data = True - uri = cls.base_path % params - headers = { - "Client-ID": params.get('client_id', None) or str(uuid.uuid4()), - "X-PROJECT-ID": params.get('project_id', None - ) or session.get_project_id() - } - - query_params = cls._query_mapping._transpose(params) - while more_data: - resp = session.get(uri, endpoint_filter=cls.service, - headers=headers, params=query_params) - resp = resp.json() - resp = resp[cls.resources_key] - - if not resp: - more_data = False - - yielded = 0 - new_marker = None - for data in resp: - value = cls.existing(**data) - new_marker = value.id - yielded += 1 - yield value - - if not paginated: - return - if "limit" in query_params and yielded < query_params["limit"]: - return - query_params["limit"] = yielded - query_params["marker"] = new_marker - - def get(self, session, requires_id=True): - request = self._prepare_request(requires_id=requires_id) - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - - request.headers.update(headers) - response = session.get(request.uri, endpoint_filter=self.service, - headers=headers) - self._translate_response(response) - - return self - - def delete(self, session): - request = self._prepare_request() - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - - request.headers.update(headers) - # For Zaqar v2 API requires client to specify claim_id as query - # parameter when deleting a message that has been claimed, we - # rebuild the request URI if claim_id is not None. - if self.claim_id: - request.uri += '?claim_id=%s' % self.claim_id - response = session.delete(request.uri, endpoint_filter=self.service, - headers=headers) - - self._translate_response(response, has_body=False) - return self diff --git a/openstack/message/v2/queue.py b/openstack/message/v2/queue.py deleted file mode 100644 index 49f79f6e..00000000 --- a/openstack/message/v2/queue.py +++ /dev/null @@ -1,134 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.message import message_service -from openstack import resource2 - - -class Queue(resource2.Resource): - # FIXME(anyone): The name string of `location` field of Zaqar API response - # is lower case. That is inconsistent with the guide from API-WG. This is - # a workaround for this issue. - location = resource2.Header("location") - - resources_key = "queues" - base_path = "/queues" - service = message_service.MessageService() - - # capabilities - allow_create = True - allow_list = True - allow_get = True - allow_delete = True - - # Properties - #: The default TTL of messages defined for a queue, which will effect for - #: any messages posted to the queue. - default_message_ttl = resource2.Body("_default_message_ttl") - #: Description of the queue. - description = resource2.Body("description") - #: The max post size of messages defined for a queue, which will effect - #: for any messages posted to the queue. - max_messages_post_size = resource2.Body("_max_messages_post_size") - #: Name of the queue. The name is the unique identity of a queue. It - #: must not exceed 64 bytes in length, and it is limited to US-ASCII - #: letters, digits, underscores, and hyphens. - name = resource2.Body("name", alternate_id=True) - #: The ID to identify the client accessing Zaqar API. Must be specified - #: in header for each API request. - client_id = resource2.Header("Client-ID") - #: The ID to identify the project accessing Zaqar API. Must be specified - #: in case keystone auth is not enabled in Zaqar service. - project_id = resource2.Header("X-PROJECT-ID") - - def create(self, session, prepend_key=True): - request = self._prepare_request(requires_id=True, - prepend_key=prepend_key) - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - request.headers.update(headers) - response = session.put(request.uri, endpoint_filter=self.service, - json=request.body, headers=request.headers) - - self._translate_response(response, has_body=False) - return self - - @classmethod - def list(cls, session, paginated=False, **params): - """This method is a generator which yields queue objects. - - This is almost the copy of list method of resource2.Resource class. - The only difference is the request header now includes `Client-ID` - and `X-PROJECT-ID` fields which are required by Zaqar v2 API. - """ - more_data = True - query_params = cls._query_mapping._transpose(params) - uri = cls.base_path % params - headers = { - "Client-ID": params.get('client_id', None) or str(uuid.uuid4()), - "X-PROJECT-ID": params.get('project_id', None - ) or session.get_project_id() - } - - while more_data: - resp = session.get(uri, endpoint_filter=cls.service, - headers=headers, params=query_params) - resp = resp.json() - resp = resp[cls.resources_key] - - if not resp: - more_data = False - - yielded = 0 - new_marker = None - for data in resp: - value = cls.existing(**data) - new_marker = value.id - yielded += 1 - yield value - - if not paginated: - return - if "limit" in query_params and yielded < query_params["limit"]: - return - query_params["limit"] = yielded - query_params["marker"] = new_marker - - def get(self, session, requires_id=True): - request = self._prepare_request(requires_id=requires_id) - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - request.headers.update(headers) - response = session.get(request.uri, endpoint_filter=self.service, - headers=headers) - self._translate_response(response) - - return self - - def delete(self, session): - request = self._prepare_request() - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - request.headers.update(headers) - response = session.delete(request.uri, endpoint_filter=self.service, - headers=headers) - - self._translate_response(response, has_body=False) - return self diff --git a/openstack/message/v2/subscription.py b/openstack/message/v2/subscription.py deleted file mode 100644 index d5acdb05..00000000 --- a/openstack/message/v2/subscription.py +++ /dev/null @@ -1,144 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.message import message_service -from openstack import resource2 - - -class Subscription(resource2.Resource): - # FIXME(anyone): The name string of `location` field of Zaqar API response - # is lower case. That is inconsistent with the guide from API-WG. This is - # a workaround for this issue. - location = resource2.Header("location") - - resources_key = 'subscriptions' - base_path = '/queues/%(queue_name)s/subscriptions' - service = message_service.MessageService() - - # capabilities - allow_create = True - allow_list = True - allow_get = True - allow_delete = True - - # Properties - #: The value in seconds indicating how long the subscription has existed. - age = resource2.Body("age") - #: Alternate id of the subscription. This key is used in response of - #: subscription create API to return id of subscription created. - subscription_id = resource2.Body("subscription_id", alternate_id=True) - #: The extra metadata for the subscription. The value must be a dict. - #: If the subscriber is `mailto`. The options can contain `from` and - #: `subject` to indicate the email's author and title. - options = resource2.Body("options", type=dict) - #: The queue name which the subscription is registered on. - source = resource2.Body("source") - #: The destination of the message. Two kinds of subscribers are supported: - #: http/https and email. The http/https subscriber should start with - #: `http/https`. The email subscriber should start with `mailto`. - subscriber = resource2.Body("subscriber") - #: Number of seconds the subscription remains alive? The ttl value must - #: be great than 60 seconds. The default value is 3600 seconds. - ttl = resource2.Body("ttl") - #: The queue name which the subscription is registered on. - queue_name = resource2.URI("queue_name") - #: The ID to identify the client accessing Zaqar API. Must be specified - #: in header for each API request. - client_id = resource2.Header("Client-ID") - #: The ID to identify the project. Must be provided when keystone - #: authentication is not enabled in Zaqar service. - project_id = resource2.Header("X-PROJECT-ID") - - def create(self, session, prepend_key=True): - request = self._prepare_request(requires_id=False, - prepend_key=prepend_key) - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - request.headers.update(headers) - response = session.post(request.uri, endpoint_filter=self.service, - json=request.body, headers=request.headers) - - self._translate_response(response) - return self - - @classmethod - def list(cls, session, paginated=True, **params): - """This method is a generator which yields subscription objects. - - This is almost the copy of list method of resource2.Resource class. - The only difference is the request header now includes `Client-ID` - and `X-PROJECT-ID` fields which are required by Zaqar v2 API. - """ - more_data = True - uri = cls.base_path % params - headers = { - "Client-ID": params.get('client_id', None) or str(uuid.uuid4()), - "X-PROJECT-ID": params.get('project_id', None - ) or session.get_project_id() - } - - query_params = cls._query_mapping._transpose(params) - while more_data: - resp = session.get(uri, endpoint_filter=cls.service, - headers=headers, params=query_params) - resp = resp.json() - resp = resp[cls.resources_key] - - if not resp: - more_data = False - - yielded = 0 - new_marker = None - for data in resp: - value = cls.existing(**data) - new_marker = value.id - yielded += 1 - yield value - - if not paginated: - return - if "limit" in query_params and yielded < query_params["limit"]: - return - query_params["limit"] = yielded - query_params["marker"] = new_marker - - def get(self, session, requires_id=True): - request = self._prepare_request(requires_id=requires_id) - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - - request.headers.update(headers) - response = session.get(request.uri, endpoint_filter=self.service, - headers=request.headers) - self._translate_response(response) - - return self - - def delete(self, session): - request = self._prepare_request() - headers = { - "Client-ID": self.client_id or str(uuid.uuid4()), - "X-PROJECT-ID": self.project_id or session.get_project_id() - } - - request.headers.update(headers) - response = session.delete(request.uri, endpoint_filter=self.service, - headers=request.headers) - - self._translate_response(response, has_body=False) - return self diff --git a/openstack/message/version.py b/openstack/message/version.py deleted file mode 100644 index 431fd239..00000000 --- a/openstack/message/version.py +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.message import message_service -from openstack import resource - - -class Version(resource.Resource): - resource_key = 'version' - resources_key = 'versions' - base_path = '/' - service = message_service.MessageService( - version=message_service.MessageService.UNVERSIONED - ) - - # capabilities - allow_list = True - - # Properties - links = resource.prop('links') - status = resource.prop('status') diff --git a/openstack/metric/__init__.py b/openstack/metric/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/metric/metric_service.py b/openstack/metric/metric_service.py deleted file mode 100644 index b18153fb..00000000 --- a/openstack/metric/metric_service.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class MetricService(service_filter.ServiceFilter): - """The metric service.""" - - valid_versions = [service_filter.ValidVersion('v1')] - - def __init__(self, version=None): - """Create a metric service.""" - super(MetricService, self).__init__(service_type='metric', - version=version) diff --git a/openstack/metric/v1/__init__.py b/openstack/metric/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/metric/v1/_proxy.py b/openstack/metric/v1/_proxy.py deleted file mode 100644 index 31958e94..00000000 --- a/openstack/metric/v1/_proxy.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.metric.v1 import capabilities -from openstack import proxy2 as proxy - - -class Proxy(proxy.BaseProxy): - - def capabilities(self, **query): - """Return a generator of capabilities - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of capability objects - :rtype: :class:`~openstack.metric.v1.capabilities.Capabilities` - """ - return self._list(capabilities.Capabilities, paginated=False, **query) diff --git a/openstack/metric/v1/archive_policy.py b/openstack/metric/v1/archive_policy.py deleted file mode 100644 index 1c0d844c..00000000 --- a/openstack/metric/v1/archive_policy.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.metric import metric_service -from openstack import resource2 as resource - - -class ArchivePolicy(resource.Resource): - base_path = '/archive_policy' - service = metric_service.MetricService() - - # Supported Operations - allow_create = True - allow_get = True - allow_delete = True - allow_list = True - - # Properties - #: The name of this policy - name = resource.Body('name', alternate_id=True) - #: The definition of this policy - definition = resource.Body('definition', type=list) - #: The window of time older than the period that archives can be requested - back_window = resource.Body('back_window') - #: A list of the aggregation methods supported - aggregation_methods = resource.Body("aggregation_methods", type=list) diff --git a/openstack/metric/v1/capabilities.py b/openstack/metric/v1/capabilities.py deleted file mode 100644 index 90657475..00000000 --- a/openstack/metric/v1/capabilities.py +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.metric import metric_service -from openstack import resource2 as resource - - -class Capabilities(resource.Resource): - base_path = '/capabilities' - service = metric_service.MetricService() - - # Supported Operations - allow_get = True - - #: The supported methods of aggregation. - aggregation_methods = resource.Body('aggregation_methods', type=list) diff --git a/openstack/metric/v1/metric.py b/openstack/metric/v1/metric.py deleted file mode 100644 index 3e71b2c0..00000000 --- a/openstack/metric/v1/metric.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.metric import metric_service -from openstack import resource2 as resource - - -class Metric(resource.Resource): - base_path = '/metric' - service = metric_service.MetricService() - - # Supported Operations - allow_create = True - allow_get = True - allow_delete = True - allow_list = True - - # Properties - #: The name of the archive policy - archive_policy_name = resource.Body('archive_policy_name') - #: The archive policy - archive_policy = resource.Body('archive_policy') - #: The ID of the user who created this metric - created_by_user_id = resource.Body('created_by_user_id') - #: The ID of the project this metric was created under - created_by_project_id = resource.Body('created_by_project_id') - #: The identifier of this metric - resource_id = resource.Body('resource_id') - #: The name of this metric - name = resource.Body('name') diff --git a/openstack/metric/v1/resource.py b/openstack/metric/v1/resource.py deleted file mode 100644 index f66d5661..00000000 --- a/openstack/metric/v1/resource.py +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.metric import metric_service -from openstack import resource2 as resource - - -class Generic(resource.Resource): - base_path = '/resource/generic' - service = metric_service.MetricService() - - # Supported Operations - allow_create = True - allow_get = True - allow_delete = True - allow_list = True - allow_update = True - - # Properties - #: The identifier of this resource - id = resource.Body('id') - #: The ID of the user who created this resource - created_by_user_id = resource.Body('created_by_user_id') - #: The ID of the project this resource was created under - created_by_project_id = resource.Body('created_by_project_id') - #: The ID of the user - user_id = resource.Body('user_id') - #: The ID of the project - project_id = resource.Body('project_id') - #: Timestamp when this resource was started - started_at = resource.Body('started_at') - #: Timestamp when this resource was ended - ended_at = resource.Body('ended_at') - #: A dictionary of metrics collected on this resource - metrics = resource.Body('metrics', type=dict) - #: The type of resource - type = resource.Body('type') diff --git a/openstack/module_loader.py b/openstack/module_loader.py deleted file mode 100644 index faf271ac..00000000 --- a/openstack/module_loader.py +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Load various modules for authorization and eventually services. -""" -from stevedore import extension - - -def load_service_plugins(namespace): - service_plugins = extension.ExtensionManager( - namespace=namespace, - invoke_on_load=True, - ) - services = {} - for service in service_plugins: - service = service.obj - service.interface = None - services[service.service_type] = service - return services diff --git a/openstack/network/__init__.py b/openstack/network/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/network/network_service.py b/openstack/network/network_service.py deleted file mode 100644 index 28c20e4b..00000000 --- a/openstack/network/network_service.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class NetworkService(service_filter.ServiceFilter): - """The network service.""" - - valid_versions = [service_filter.ValidVersion('v2', 'v2.0')] - - def __init__(self, version=None): - """Create a network service.""" - super(NetworkService, self).__init__(service_type='network', - version=version) diff --git a/openstack/network/v2/__init__.py b/openstack/network/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/network/v2/_proxy.py b/openstack/network/v2/_proxy.py deleted file mode 100644 index 4ee8559a..00000000 --- a/openstack/network/v2/_proxy.py +++ /dev/null @@ -1,3035 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import exceptions -from openstack.network.v2 import address_scope as _address_scope -from openstack.network.v2 import agent as _agent -from openstack.network.v2 import auto_allocated_topology as \ - _auto_allocated_topology -from openstack.network.v2 import availability_zone -from openstack.network.v2 import extension -from openstack.network.v2 import flavor as _flavor -from openstack.network.v2 import floating_ip as _floating_ip -from openstack.network.v2 import health_monitor as _health_monitor -from openstack.network.v2 import listener as _listener -from openstack.network.v2 import load_balancer as _load_balancer -from openstack.network.v2 import metering_label as _metering_label -from openstack.network.v2 import metering_label_rule as _metering_label_rule -from openstack.network.v2 import network as _network -from openstack.network.v2 import network_ip_availability -from openstack.network.v2 import pool as _pool -from openstack.network.v2 import pool_member as _pool_member -from openstack.network.v2 import port as _port -from openstack.network.v2 import qos_bandwidth_limit_rule as \ - _qos_bandwidth_limit_rule -from openstack.network.v2 import qos_dscp_marking_rule as \ - _qos_dscp_marking_rule -from openstack.network.v2 import qos_minimum_bandwidth_rule as \ - _qos_minimum_bandwidth_rule -from openstack.network.v2 import qos_policy as _qos_policy -from openstack.network.v2 import qos_rule_type as _qos_rule_type -from openstack.network.v2 import quota as _quota -from openstack.network.v2 import rbac_policy as _rbac_policy -from openstack.network.v2 import router as _router -from openstack.network.v2 import security_group as _security_group -from openstack.network.v2 import security_group_rule as _security_group_rule -from openstack.network.v2 import segment as _segment -from openstack.network.v2 import service_profile as _service_profile -from openstack.network.v2 import service_provider as _service_provider -from openstack.network.v2 import subnet as _subnet -from openstack.network.v2 import subnet_pool as _subnet_pool -from openstack.network.v2 import vpn_service as _vpn_service -from openstack import proxy2 -from openstack import utils - - -class Proxy(proxy2.BaseProxy): - - def create_address_scope(self, **attrs): - """Create a new address scope from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.address_scope.AddressScope`, - comprised of the properties on the AddressScope class. - - :returns: The results of address scope creation - :rtype: :class:`~openstack.network.v2.address_scope.AddressScope` - """ - return self._create(_address_scope.AddressScope, **attrs) - - def delete_address_scope(self, address_scope, ignore_missing=True): - """Delete an address scope - - :param address_scope: The value can be either the ID of an - address scope or - a :class:`~openstack.network.v2.address_scope.AddressScope` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the address scope does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent address scope. - - :returns: ``None`` - """ - self._delete(_address_scope.AddressScope, address_scope, - ignore_missing=ignore_missing) - - def find_address_scope(self, name_or_id, ignore_missing=True): - """Find a single address scope - - :param name_or_id: The name or ID of an address scope. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.address_scope.AddressScope` - or None - """ - return self._find(_address_scope.AddressScope, name_or_id, - ignore_missing=ignore_missing) - - def get_address_scope(self, address_scope): - """Get a single address scope - - :param address_scope: The value can be the ID of an address scope or a - :class:`~openstack.network.v2.address_scope.AddressScope` instance. - - :returns: One :class:`~openstack.network.v2.address_scope.AddressScope` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_address_scope.AddressScope, address_scope) - - def address_scopes(self, **query): - """Return a generator of address scopes - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. - - * ``name``: Address scope name - * ``ip_version``: Address scope IP address version - * ``tenant_id``: Owner tenant ID - * ``shared``: Address scope is shared (boolean) - - :returns: A generator of address scope objects - :rtype: :class:`~openstack.network.v2.address_scope.AddressScope` - """ - return self._list(_address_scope.AddressScope, paginated=False, - **query) - - def update_address_scope(self, address_scope, **attrs): - """Update an address scope - - :param address_scope: Either the ID of an address scope or a - :class:`~openstack.network.v2.address_scope.AddressScope` instance. - :param dict attrs: The attributes to update on the address scope - represented by ``value``. - - :returns: The updated address scope - :rtype: :class:`~openstack.network.v2.address_scope.AddressScope` - """ - return self._update(_address_scope.AddressScope, address_scope, - **attrs) - - def agents(self, **query): - """Return a generator of network agents - - :param dict query: Optional query parameters to be sent to limit the - resources being returned. - - * ``agent_type``: Agent type. - * ``availability_zone``: The availability zone for an agent. - * ``binary``: The name of the agent's application binary. - * ``description``: The description of the agent. - * ``host``: The host (host name or host address) the agent is - running on. - * ``topic``: The message queue topic used. - * ``is_admin_state_up``: The administrative state of the agent. - * ``is_alive``: Whether the agent is alive. - - :returns: A generator of agents - :rtype: :class:`~openstack.network.v2.agent.Agent` - """ - return self._list(_agent.Agent, paginated=False, **query) - - def delete_agent(self, agent, ignore_missing=True): - """Delete a network agent - - :param agent: The value can be the ID of a agent or a - :class:`~openstack.network.v2.agent.Agent` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the agent does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent agent. - - :returns: ``None`` - """ - self._delete(_agent.Agent, agent, ignore_missing=ignore_missing) - - def get_agent(self, agent): - """Get a single network agent - - :param agent: The value can be the ID of a agent or a - :class:`~openstack.network.v2.agent.Agent` instance. - - :returns: One :class:`~openstack.network.v2.agent.Agent` - :rtype: :class:`~openstack.network.v2.agent.Agent` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_agent.Agent, agent) - - def update_agent(self, agent, **attrs): - """Update a network agent - - :param agent: The value can be the ID of a agent or a - :class:`~openstack.network.v2.agent.Agent` instance. - :param dict attrs: The attributes to update on the agent represented - by ``value``. - - :returns: One :class:`~openstack.network.v2.agent.Agent` - :rtype: :class:`~openstack.network.v2.agent.Agent` - """ - return self._update(_agent.Agent, agent, **attrs) - - def dhcp_agent_hosting_networks(self, agent, **query): - """A generator of networks hosted by a DHCP agent. - - :param agent: Either the agent id of an instance of - :class:`~openstack.network.v2.network_agent.Agent` - :param query: kwargs \*\*query: Optional query parameters to be sent - to limit the resources being returned. - :return: A generator of networks - """ - agent_obj = self._get_resource(_agent.Agent, agent) - return self._list(_network.DHCPAgentHostingNetwork, paginated=False, - agent_id=agent_obj.id, **query) - - def add_dhcp_agent_to_network(self, agent, network): - """Add a DHCP Agent to a network - - :param agent: Either the agent id of an instance of - :class:`~openstack.network.v2.network_agent.Agent` - :param network: Network instance - :return: - """ - network = self._get_resource(_network.Network, network) - agent = self._get_resource(_agent.Agent, agent) - return agent.add_agent_to_network(self._session, network.id) - - def remove_dhcp_agent_from_network(self, agent, network): - """Remove a DHCP Agent from a network - - :param agent: Either the agent id of an instance of - :class:`~openstack.network.v2.network_agent.Agent` - :param network: Network instance - :return: - """ - network = self._get_resource(_network.Network, network) - agent = self._get_resource(_agent.Agent, agent) - return agent.remove_agent_from_network(self._session, network.id) - - def network_hosting_dhcp_agents(self, network, **query): - """A generator of DHCP agents hosted on a network. - - :param network: The instance of - :class:`~openstack.network.v2.network.Network` - :param dict query: Optional query parameters to be sent to limit the - resources returned. - :return: A generator of hosted DHCP agents - """ - net = self._get_resource(_network.Network, network) - return self._list(_agent.NetworkHostingDHCPAgent, paginated=False, - network_id=net.id, **query) - - def get_auto_allocated_topology(self, project=None): - """Get the auto-allocated topology of a given tenant - - :param project: - The value is the ID or name of a project - - :returns: The auto-allocated topology - :rtype: :class:`~openstack.network.v2.\ - auto_allocated_topology.AutoAllocatedTopology` - """ - - # If project option is not given, grab project id from session - if project is None: - project = self._session.get_project_id() - return self._get(_auto_allocated_topology.AutoAllocatedTopology, - project) - - def delete_auto_allocated_topology(self, project=None, - ignore_missing=False): - """Delete auto-allocated topology - - :param project: - The value is the ID or name of a project - :param ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the topology does not exist. - When set to ``True``, no exception will be raised when - attempting to delete nonexistant topology - - :returns: ``None`` - """ - - # If project option is not given, grab project id from session - if project is None: - project = self._session.get_project_id() - self._delete(_auto_allocated_topology.AutoAllocatedTopology, - project, ignore_missing=ignore_missing) - - def validate_auto_allocated_topology(self, project=None): - """Validate the resources for auto allocation - - :param project: - The value is the ID or name of a project - - :returns: Whether all resources are correctly configured or not - :rtype: :class:`~openstack.network.v2.\ - auto_allocated_topology.ValidateTopology` - """ - - # If project option is not given, grab project id from session - if project is None: - project = self._session.get_project_id() - return self._get(_auto_allocated_topology.ValidateTopology, - project=project, requires_id=False) - - def availability_zones(self, **query): - """Return a generator of availability zones - - :param dict query: optional query parameters to be set to limit the - returned resources. Valid parameters include: - - * ``name``: The name of an availability zone. - * ``resource``: The type of resource for the availability zone. - - :returns: A generator of availability zone objects - :rtype: - :class:`~openstack.network.v2.availability_zone.AvailabilityZone` - """ - return self._list(availability_zone.AvailabilityZone, paginated=False) - - def find_extension(self, name_or_id, ignore_missing=True): - """Find a single extension - - :param name_or_id: The name or ID of a extension. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.extension.Extension` - or None - """ - return self._find(extension.Extension, name_or_id, - ignore_missing=ignore_missing) - - def extensions(self, **query): - """Return a generator of extensions - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Currently no - parameter is supported. - - :returns: A generator of extension objects - :rtype: :class:`~openstack.network.v2.extension.Extension` - """ - return self._list(extension.Extension, paginated=False, **query) - - def create_flavor(self, **attrs): - """Create a new network service flavor from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.flavor.Flavor`, - comprised of the properties on the Flavor class. - - :returns: The results of flavor creation - :rtype: :class:`~openstack.network.v2.flavor.Flavor` - """ - return self._create(_flavor.Flavor, **attrs) - - def delete_flavor(self, flavor, ignore_missing=True): - """Delete a network service flavor - - :param flavor: - The value can be either the ID of a flavor or a - :class:`~openstack.network.v2.flavor.Flavor` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the flavor does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent flavor. - - :returns: ``None`` - """ - self._delete(_flavor.Flavor, flavor, ignore_missing=ignore_missing) - - def find_flavor(self, name_or_id, ignore_missing=True): - """Find a single network service flavor - - :param name_or_id: The name or ID of a flavor. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.flavor.Flavor` or None - """ - return self._find(_flavor.Flavor, name_or_id, - ignore_missing=ignore_missing) - - def get_flavor(self, flavor): - """Get a single network service flavor - - :param flavor: - The value can be the ID of a flavor or a - :class:`~openstack.network.v2.flavor.Flavor` instance. - - :returns: One :class:`~openstack.network.v2.flavor.Flavor` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_flavor.Flavor, flavor) - - def update_flavor(self, flavor, **attrs): - """Update a network service flavor - - :param flavor: - Either the id of a flavor or a - :class:`~openstack.network.v2.flavor.Flavor` instance. - :attrs kwargs: The attributes to update on the flavor represented - by ``value``. - - :returns: The updated flavor - :rtype: :class:`~openstack.network.v2.flavor.Flavor` - """ - return self._update(_flavor.Flavor, flavor, **attrs) - - def flavors(self, **query): - """Return a generator of network service flavors - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters - include: - - * ``description``: The description of a flavor. - * ``is_enabled``: Whether a flavor is enabled. - * ``name``: The name of a flavor. - * ``service_type``: The service type to which a falvor applies. - - :returns: A generator of flavor objects - :rtype: :class:`~openstack.network.v2.flavor.Flavor` - """ - return self._list(_flavor.Flavor, paginated=True, **query) - - def associate_flavor_with_service_profile(self, flavor, service_profile): - """Associate network flavor with service profile. - - :param flavor: - Either the id of a flavor or a - :class:`~openstack.network.v2.flavor.Flavor` instance. - :param service_profile: - The value can be either the ID of a service profile or a - :class:`~openstack.network.v2.service_profile.ServiceProfile` - instance. - :return: - """ - flavor = self._get_resource(_flavor.Flavor, flavor) - service_profile = self._get_resource( - _service_profile.ServiceProfile, service_profile) - return flavor.associate_flavor_with_service_profile( - self._session, service_profile.id) - - def disassociate_flavor_from_service_profile( - self, flavor, service_profile): - """Disassociate network flavor from service profile. - - :param flavor: - Either the id of a flavor or a - :class:`~openstack.network.v2.flavor.Flavor` instance. - :param service_profile: - The value can be either the ID of a service profile or a - :class:`~openstack.network.v2.service_profile.ServiceProfile` - instance. - :return: - """ - flavor = self._get_resource(_flavor.Flavor, flavor) - service_profile = self._get_resource( - _service_profile.ServiceProfile, service_profile) - return flavor.disassociate_flavor_from_service_profile( - self._session, service_profile.id) - - def create_ip(self, **attrs): - """Create a new floating ip from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.floating_ip.FloatingIP`, - comprised of the properties on the FloatingIP class. - - :returns: The results of floating ip creation - :rtype: :class:`~openstack.network.v2.floating_ip.FloatingIP` - """ - return self._create(_floating_ip.FloatingIP, **attrs) - - def delete_ip(self, floating_ip, ignore_missing=True): - """Delete a floating ip - - :param floating_ip: The value can be either the ID of a floating ip - or a :class:`~openstack.network.v2.floating_ip.FloatingIP` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the floating ip does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent ip. - - :returns: ``None`` - """ - self._delete(_floating_ip.FloatingIP, floating_ip, - ignore_missing=ignore_missing) - - def find_available_ip(self): - """Find an available IP - - :returns: One :class:`~openstack.network.v2.floating_ip.FloatingIP` - or None - """ - return _floating_ip.FloatingIP.find_available(self._session) - - def find_ip(self, name_or_id, ignore_missing=True): - """Find a single IP - - :param name_or_id: The name or ID of an IP. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.floating_ip.FloatingIP` - or None - """ - return self._find(_floating_ip.FloatingIP, name_or_id, - ignore_missing=ignore_missing) - - def get_ip(self, floating_ip): - """Get a single floating ip - - :param floating_ip: The value can be the ID of a floating ip or a - :class:`~openstack.network.v2.floating_ip.FloatingIP` - instance. - - :returns: One :class:`~openstack.network.v2.floating_ip.FloatingIP` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_floating_ip.FloatingIP, floating_ip) - - def ips(self, **query): - """Return a generator of ips - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``description``: The description of a floating IP. - * ``fixed_ip_address``: The fixed IP address associated with a - floating IP address. - * ``floating_ip_address``: The IP address of a floating IP. - * ``floating_network_id``: The ID of the network associated with - a floating IP. - * ``port_id``: The ID of the port to which a floating IP is - associated. - * ``project_id``: The ID of the project a floating IP is - associated with. - * ``router_id``: The ID of an associated router. - * ``status``: The status of a floating IP, which can be ``ACTIVE`` - or ``DOWN``. - - :returns: A generator of floating IP objects - :rtype: :class:`~openstack.network.v2.floating_ip.FloatingIP` - """ - return self._list(_floating_ip.FloatingIP, paginated=False, **query) - - def update_ip(self, floating_ip, **attrs): - """Update a ip - - :param floating_ip: Either the id of a ip or a - :class:`~openstack.network.v2.floating_ip.FloatingIP` - instance. - :param dict attrs: The attributes to update on the ip represented - by ``value``. - - :returns: The updated ip - :rtype: :class:`~openstack.network.v2.floating_ip.FloatingIP` - """ - return self._update(_floating_ip.FloatingIP, floating_ip, **attrs) - - def create_health_monitor(self, **attrs): - """Create a new health monitor from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.health_monitor.HealthMonitor`, - comprised of the properties on the HealthMonitor class. - - :returns: The results of health monitor creation - :rtype: :class:`~openstack.network.v2.health_monitor.HealthMonitor` - """ - return self._create(_health_monitor.HealthMonitor, **attrs) - - def delete_health_monitor(self, health_monitor, ignore_missing=True): - """Delete a health monitor - - :param health_monitor: The value can be either the ID of a - health monitor or a - :class:`~openstack.network.v2.health_monitor.HealthMonitor` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the health monitor does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent health monitor. - - :returns: ``None`` - """ - self._delete(_health_monitor.HealthMonitor, health_monitor, - ignore_missing=ignore_missing) - - def find_health_monitor(self, name_or_id, ignore_missing=True): - """Find a single health monitor - - :param name_or_id: The name or ID of a health monitor. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.health_monitor. - HealthMonitor` or None - """ - return self._find(_health_monitor.HealthMonitor, - name_or_id, ignore_missing=ignore_missing) - - def get_health_monitor(self, health_monitor): - """Get a single health monitor - - :param health_monitor: The value can be the ID of a health monitor or a - :class:`~openstack.network.v2.health_monitor.HealthMonitor` - instance. - - :returns: One - :class:`~openstack.network.v2.health_monitor.HealthMonitor` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_health_monitor.HealthMonitor, health_monitor) - - def health_monitors(self, **query): - """Return a generator of health monitors - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``delay``: the time in milliseconds between sending probes. - * ``expected_codes``: The expected HTTP codes for a pssing HTTP(S) - monitor. - * ``http_method``: The HTTP method a monitor uses for requests. - * ``is_admin_state_up``: The administrative state of a health - monitor. - * ``max_retries``: The maximum consecutive health probe attempts. - * ``project_id``: The ID of the project this health monitor is - associated with. - * ``timeout``: The maximum number of milliseconds for a monitor to - wait for a connection to be established before it - times out. - * ``type``: The type of probe sent by the load balancer for health - check, which can be ``PING``, ``TCP``, ``HTTP`` or - ``HTTPS``. - * ``url_path``: The path portion of a URI that will be probed. - - :returns: A generator of health monitor objects - :rtype: :class:`~openstack.network.v2.health_monitor.HealthMonitor` - """ - return self._list(_health_monitor.HealthMonitor, paginated=False, - **query) - - def update_health_monitor(self, health_monitor, **attrs): - """Update a health monitor - - :param health_monitor: Either the id of a health monitor or a - :class:`~openstack.network.v2.health_monitor. - HealthMonitor` instance. - :param dict attrs: The attributes to update on the health monitor - represented by ``value``. - - :returns: The updated health monitor - :rtype: :class:`~openstack.network.v2.health_monitor.HealthMonitor` - """ - return self._update(_health_monitor.HealthMonitor, health_monitor, - **attrs) - - def create_listener(self, **attrs): - """Create a new listener from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.listener.Listener`, - comprised of the properties on the Listener class. - - :returns: The results of listener creation - :rtype: :class:`~openstack.network.v2.listener.Listener` - """ - return self._create(_listener.Listener, **attrs) - - def delete_listener(self, listener, ignore_missing=True): - """Delete a listener - - :param listener: The value can be either the ID of a listner or a - :class:`~openstack.network.v2.listener.Listener` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the listner does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent listener. - - :returns: ``None`` - """ - self._delete(_listener.Listener, listener, - ignore_missing=ignore_missing) - - def find_listener(self, name_or_id, ignore_missing=True): - """Find a single listener - - :param name_or_id: The name or ID of a listener. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.listener.Listener` or None - """ - return self._find(_listener.Listener, name_or_id, - ignore_missing=ignore_missing) - - def get_listener(self, listener): - """Get a single listener - - :param listener: The value can be the ID of a listener or a - :class:`~openstack.network.v2.listener.Listener` - instance. - - :returns: One :class:`~openstack.network.v2.listener.Listener` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_listener.Listener, listener) - - def listeners(self, **query): - """Return a generator of listeners - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``connection_limit``: The maximum number of connections - permitted for the load-balancer. - * ``default_pool_id``: The ID of the default pool. - * ``default_tls_container_ref``: A reference to a container of TLS - secret. - * ``description``: The description of a listener. - * ``is_admin_state_up``: The administrative state of the listener. - * ``name``: The name of a listener. - * ``project_id``: The ID of the project associated with a listener. - * ``protocol``: The protocol of the listener. - * ``protocol_port``: Port the listener will listen to. - - :returns: A generator of listener objects - :rtype: :class:`~openstack.network.v2.listener.Listener` - """ - return self._list(_listener.Listener, paginated=False, **query) - - def update_listener(self, listener, **attrs): - """Update a listener - - :param listener: Either the id of a listener or a - :class:`~openstack.network.v2.listener.Listener` - instance. - :param dict attrs: The attributes to update on the listener - represented by ``listener``. - - :returns: The updated listener - :rtype: :class:`~openstack.network.v2.listener.Listener` - """ - return self._update(_listener.Listener, listener, **attrs) - - def create_load_balancer(self, **attrs): - """Create a new load balancer from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.load_balancer.LoadBalancer`, - comprised of the properties on the LoadBalancer class. - - :returns: The results of load balancer creation - :rtype: :class:`~openstack.network.v2.load_balancer.LoadBalancer` - """ - return self._create(_load_balancer.LoadBalancer, **attrs) - - def delete_load_balancer(self, load_balancer, ignore_missing=True): - """Delete a load balancer - - :param load_balancer: The value can be the ID of a load balancer or a - :class:`~openstack.network.v2.load_balancer.LoadBalancer` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the load balancer does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent load balancer. - - :returns: ``None`` - """ - self._delete(_load_balancer.LoadBalancer, load_balancer, - ignore_missing=ignore_missing) - - def find_load_balancer(self, name_or_id, ignore_missing=True): - """Find a single load balancer - - :param name_or_id: The name or ID of a load balancer. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.load_balancer.LoadBalancer` - or None - """ - return self._find(_load_balancer.LoadBalancer, name_or_id, - ignore_missing=ignore_missing) - - def get_load_balancer(self, load_balancer): - """Get a single load balancer - - :param load_balancer: The value can be the ID of a load balancer or a - :class:`~openstack.network.v2.load_balancer.LoadBalancer` - instance. - - :returns: One :class:`~openstack.network.v2.load_balancer.LoadBalancer` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_load_balancer.LoadBalancer, load_balancer) - - def load_balancers(self, **query): - """Return a generator of load balancers - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of load balancer objects - :rtype: :class:`~openstack.network.v2.load_balancer.LoadBalancer` - """ - return self._list(_load_balancer.LoadBalancer, paginated=False, - **query) - - def update_load_balancer(self, load_balancer, **attrs): - """Update a load balancer - - :param load_balancer: Either the id of a load balancer or a - :class:`~openstack.network.v2.load_balancer.LoadBalancer` - instance. - :param dict attrs: The attributes to update on the load balancer - represented by ``load_balancer``. - - :returns: The updated load balancer - :rtype: :class:`~openstack.network.v2.load_balancer.LoadBalancer` - """ - return self._update(_load_balancer.LoadBalancer, load_balancer, - **attrs) - - def create_metering_label(self, **attrs): - """Create a new metering label from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.metering_label.MeteringLabel`, - comprised of the properties on the MeteringLabel class. - - :returns: The results of metering label creation - :rtype: :class:`~openstack.network.v2.metering_label.MeteringLabel` - """ - return self._create(_metering_label.MeteringLabel, **attrs) - - def delete_metering_label(self, metering_label, ignore_missing=True): - """Delete a metering label - - :param metering_label: - The value can be either the ID of a metering label or a - :class:`~openstack.network.v2.metering_label.MeteringLabel` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the metering label does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent metering label. - - :returns: ``None`` - """ - self._delete(_metering_label.MeteringLabel, metering_label, - ignore_missing=ignore_missing) - - def find_metering_label(self, name_or_id, ignore_missing=True): - """Find a single metering label - - :param name_or_id: The name or ID of a metering label. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.metering_label. - MeteringLabel` or None - """ - return self._find(_metering_label.MeteringLabel, name_or_id, - ignore_missing=ignore_missing) - - def get_metering_label(self, metering_label): - """Get a single metering label - - :param metering_label: The value can be the ID of a metering label or a - :class:`~openstack.network.v2.metering_label.MeteringLabel` - instance. - - :returns: One - :class:`~openstack.network.v2.metering_label.MeteringLabel` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_metering_label.MeteringLabel, metering_label) - - def metering_labels(self, **query): - """Return a generator of metering labels - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``description``: Description of a metering label. - * ``name``: Name of a metering label. - * ``is_shared``: Boolean indicating whether a metering label is - shared. - * ``project_id``: The ID of the project a metering label is - associated with. - - :returns: A generator of metering label objects - :rtype: :class:`~openstack.network.v2.metering_label.MeteringLabel` - """ - return self._list(_metering_label.MeteringLabel, paginated=False, - **query) - - def update_metering_label(self, metering_label, **attrs): - """Update a metering label - - :param metering_label: Either the id of a metering label or a - :class:`~openstack.network.v2.metering_label. - MeteringLabel` instance. - :param dict attrs: The attributes to update on the metering label - represented by ``metering_label``. - - :returns: The updated metering label - :rtype: :class:`~openstack.network.v2.metering_label.MeteringLabel` - """ - return self._update(_metering_label.MeteringLabel, metering_label, - **attrs) - - def create_metering_label_rule(self, **attrs): - """Create a new metering label rule from attributes - - :param dict attrs: Keyword arguments which will be used to create a - :class:`~openstack.network.v2.metering_label_rule.\ - MeteringLabelRule`, comprised of the properties on - the MeteringLabelRule class. - - :returns: The results of metering label rule creation - :rtype: :class:`~openstack.network.v2.metering_label_rule.\ - MeteringLabelRule` - """ - return self._create(_metering_label_rule.MeteringLabelRule, **attrs) - - def delete_metering_label_rule(self, metering_label_rule, - ignore_missing=True): - """Delete a metering label rule - - :param metering_label_rule: - The value can be either the ID of a metering label rule - or a :class:`~openstack.network.v2.metering_label_rule.\ - MeteringLabelRule` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be raised - when the metering label rule does not exist. When set to ``True``, - no exception will be set when attempting to delete a nonexistent - metering label rule. - - :returns: ``None`` - """ - self._delete(_metering_label_rule.MeteringLabelRule, - metering_label_rule, ignore_missing=ignore_missing) - - def find_metering_label_rule(self, name_or_id, ignore_missing=True): - """Find a single metering label rule - - :param name_or_id: The name or ID of a metering label rule. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.metering_label_rule. - MeteringLabelRule` or None - """ - return self._find(_metering_label_rule.MeteringLabelRule, name_or_id, - ignore_missing=ignore_missing) - - def get_metering_label_rule(self, metering_label_rule): - """Get a single metering label rule - - :param metering_label_rule: - The value can be the ID of a metering label rule or a - :class:`~openstack.network.v2.metering_label_rule.\ - MeteringLabelRule` instance. - - :returns: One - :class:`~openstack.network.v2.metering_label_rule.\ - MeteringLabelRule` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_metering_label_rule.MeteringLabelRule, - metering_label_rule) - - def metering_label_rules(self, **query): - """Return a generator of metering label rules - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``direction``: The direction in which metering label rule is - applied. - * ``metering_label_id``: The ID of a metering label this rule is - associated with. - * ``project_id``: The ID of the project the metering label rule is - associated with. - * ``remote_ip_prefix``: The remote IP prefix to be associated with - this metering label rule. - - :returns: A generator of metering label rule objects - :rtype: :class:`~openstack.network.v2.metering_label_rule. - MeteringLabelRule` - """ - return self._list(_metering_label_rule.MeteringLabelRule, - paginated=False, **query) - - def update_metering_label_rule(self, metering_label_rule, **attrs): - """Update a metering label rule - - :param metering_label_rule: - Either the id of a metering label rule or a - :class:`~openstack.network.v2.metering_label_rule. - MeteringLabelRule` instance. - :param dict attrs: The attributes to update on the metering label rule - represented by ``metering_label_rule``. - - :returns: The updated metering label rule - :rtype: :class:`~openstack.network.v2.metering_label_rule. - MeteringLabelRule` - """ - return self._update(_metering_label_rule.MeteringLabelRule, - metering_label_rule, **attrs) - - def create_network(self, **attrs): - """Create a new network from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.network.Network`, - comprised of the properties on the Network class. - - :returns: The results of network creation - :rtype: :class:`~openstack.network.v2.network.Network` - """ - return self._create(_network.Network, **attrs) - - def delete_network(self, network, ignore_missing=True): - """Delete a network - - :param network: - The value can be either the ID of a network or a - :class:`~openstack.network.v2.network.Network` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the network does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent network. - - :returns: ``None`` - """ - self._delete(_network.Network, network, ignore_missing=ignore_missing) - - def find_network(self, name_or_id, ignore_missing=True): - """Find a single network - - :param name_or_id: The name or ID of a network. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.network.Network` or None - """ - return self._find(_network.Network, name_or_id, - ignore_missing=ignore_missing) - - def get_network(self, network): - """Get a single network - - :param network: - The value can be the ID of a network or a - :class:`~openstack.network.v2.network.Network` instance. - - :returns: One :class:`~openstack.network.v2.network.Network` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_network.Network, network) - - def networks(self, **query): - """Return a generator of networks - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. Available parameters include: - - * ``description``: The network description. - * ``ipv4_address_scope_id``: The ID of the IPv4 address scope for - the network. - * ``ipv6_address_scope_id``: The ID of the IPv6 address scope for - the network. - * ``is_admin_state_up``: Network administrative state - * ``is_port_security_enabled``: The port security status. - * ``is_router_external``: Network is external or not. - * ``is_shared``: Whether the network is shared across projects. - * ``name``: The name of the network. - * ``status``: Network status - * ``project_id``: Owner tenant ID - * ``provider_network_type``: Network physical mechanism - * ``provider_physical_network``: Physical network - * ``provider_segmentation_id``: VLAN ID for VLAN networks or Tunnel - ID for GENEVE/GRE/VXLAN networks - - :returns: A generator of network objects - :rtype: :class:`~openstack.network.v2.network.Network` - """ - return self._list(_network.Network, paginated=False, **query) - - def update_network(self, network, **attrs): - """Update a network - - :param network: Either the id of a network or an instance of type - :class:`~openstack.network.v2.network.Network`. - :param dict attrs: The attributes to update on the network represented - by ``network``. - - :returns: The updated network - :rtype: :class:`~openstack.network.v2.network.Network` - """ - return self._update(_network.Network, network, **attrs) - - def find_network_ip_availability(self, name_or_id, ignore_missing=True): - """Find IP availability of a network - - :param name_or_id: The name or ID of a network. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.network_ip_availability. - NetworkIPAvailability` or None - """ - return self._find(network_ip_availability.NetworkIPAvailability, - name_or_id, ignore_missing=ignore_missing) - - def get_network_ip_availability(self, network): - """Get IP availability of a network - - :param network: - The value can be the ID of a network or a - :class:`~openstack.network.v2.network.Network` instance. - - :returns: One :class:`~openstack.network.v2.network_ip_availability. - NetworkIPAvailability` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(network_ip_availability.NetworkIPAvailability, - network) - - def network_ip_availabilities(self, **query): - """Return a generator of network ip availabilities - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. Available parameters include: - - * ``ip_version``: IP version of the network - * ``network_id``: ID of network to use when listening network IP - availability. - * ``network_name``: The name of the network for the particular - network IP availability. - * ``project_id``: Owner tenant ID - - :returns: A generator of network ip availability objects - :rtype: :class:`~openstack.network.v2.network_ip_availability. - NetworkIPAvailability` - """ - return self._list(network_ip_availability.NetworkIPAvailability, - paginated=False, **query) - - def create_pool(self, **attrs): - """Create a new pool from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.pool.Pool`, - comprised of the properties on the Pool class. - - :returns: The results of pool creation - :rtype: :class:`~openstack.network.v2.pool.Pool` - """ - return self._create(_pool.Pool, **attrs) - - def delete_pool(self, pool, ignore_missing=True): - """Delete a pool - - :param pool: The value can be either the ID of a pool or a - :class:`~openstack.network.v2.pool.Pool` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the pool does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent pool. - - :returns: ``None`` - """ - self._delete(_pool.Pool, pool, ignore_missing=ignore_missing) - - def find_pool(self, name_or_id, ignore_missing=True): - """Find a single pool - - :param name_or_id: The name or ID of a pool. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.pool.Pool` or None - """ - return self._find(_pool.Pool, name_or_id, - ignore_missing=ignore_missing) - - def get_pool(self, pool): - """Get a single pool - - :param pool: The value can be the ID of a pool or a - :class:`~openstack.network.v2.pool.Pool` instance. - - :returns: One :class:`~openstack.network.v2.pool.Pool` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_pool.Pool, pool) - - def pools(self, **query): - """Return a generator of pools - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``description``: The description for the pool. - * ``is_admin_state_up``: The administrative state of the pool. - * ``lb_algorithm``: The load-balancer algorithm used, which is one - of ``round-robin``, ``least-connections`` and so on. - * ``name``: The name of the node pool. - * ``project_id``: The ID of the project the pool is associated - with. - * ``protocol``: The protocol used by the pool, which is one of - ``TCP``, ``HTTP`` or ``HTTPS``. - * ``provider``: The name of the provider of the load balancer - service. - * ``subnet_id``: The subnet on which the members of the pool are - located. - * ``virtual_ip_id``: The ID of the virtual IP used. - - :returns: A generator of pool objects - :rtype: :class:`~openstack.network.v2.pool.Pool` - """ - return self._list(_pool.Pool, paginated=False, **query) - - def update_pool(self, pool, **attrs): - """Update a pool - - :param pool: Either the id of a pool or a - :class:`~openstack.network.v2.pool.Pool` instance. - :param dict attrs: The attributes to update on the pool represented - by ``pool``. - - :returns: The updated pool - :rtype: :class:`~openstack.network.v2.pool.Pool` - """ - return self._update(_pool.Pool, pool, **attrs) - - def create_pool_member(self, pool, **attrs): - """Create a new pool member from attributes - - :param pool: The pool can be either the ID of a pool or a - :class:`~openstack.network.v2.pool.Pool` instance that - the member will be created in. - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.pool_member.PoolMember`, - comprised of the properties on the PoolMember class. - - :returns: The results of pool member creation - :rtype: :class:`~openstack.network.v2.pool_member.PoolMember` - """ - poolobj = self._get_resource(_pool.Pool, pool) - return self._create(_pool_member.PoolMember, pool_id=poolobj.id, - **attrs) - - def delete_pool_member(self, pool_member, pool, ignore_missing=True): - """Delete a pool member - - :param pool_member: - The member can be either the ID of a pool member or a - :class:`~openstack.network.v2.pool_member.PoolMember` instance. - :param pool: The pool can be either the ID of a pool or a - :class:`~openstack.network.v2.pool.Pool` instance that - the member belongs to. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the pool member does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent pool member. - - :returns: ``None`` - """ - poolobj = self._get_resource(_pool.Pool, pool) - self._delete(_pool_member.PoolMember, pool_member, - ignore_missing=ignore_missing, pool_id=poolobj.id) - - def find_pool_member(self, name_or_id, pool, ignore_missing=True): - """Find a single pool member - - :param str name_or_id: The name or ID of a pool member. - :param pool: The pool can be either the ID of a pool or a - :class:`~openstack.network.v2.pool.Pool` instance that - the member belongs to. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.pool_member.PoolMember` - or None - """ - poolobj = self._get_resource(_pool.Pool, pool) - return self._find(_pool_member.PoolMember, name_or_id, - ignore_missing=ignore_missing, pool_id=poolobj.id) - - def get_pool_member(self, pool_member, pool): - """Get a single pool member - - :param pool_member: The member can be the ID of a pool member or a - :class:`~openstack.network.v2.pool_member.PoolMember` - instance. - :param pool: The pool can be either the ID of a pool or a - :class:`~openstack.network.v2.pool.Pool` instance that - the member belongs to. - - :returns: One :class:`~openstack.network.v2.pool_member.PoolMember` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - poolobj = self._get_resource(_pool.Pool, pool) - return self._get(_pool_member.PoolMember, pool_member, - pool_id=poolobj.id) - - def pool_members(self, pool, **query): - """Return a generator of pool members - - :param pool: The pool can be either the ID of a pool or a - :class:`~openstack.network.v2.pool.Pool` instance that - the member belongs to. - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``address``: The IP address of the pool member. - * ``is_admin_state_up``: The administrative state of the pool - member. - * ``name``: Name of the pool member. - * ``project_id``: The ID of the project this pool member is - associated with. - * ``protocol_port``: The port on which the application is hosted. - * ``subnet_id``: Subnet ID in which to access this pool member. - * ``weight``: A positive integer value that indicates the relative - portion of traffic that this member should receive from the - pool. - - :returns: A generator of pool member objects - :rtype: :class:`~openstack.network.v2.pool_member.PoolMember` - """ - poolobj = self._get_resource(_pool.Pool, pool) - return self._list(_pool_member.PoolMember, paginated=False, - pool_id=poolobj.id, **query) - - def update_pool_member(self, pool_member, pool, **attrs): - """Update a pool member - - :param pool_member: Either the ID of a pool member or a - :class:`~openstack.network.v2.pool_member.PoolMember` - instance. - :param pool: The pool can be either the ID of a pool or a - :class:`~openstack.network.v2.pool.Pool` instance that - the member belongs to. - :param dict attrs: The attributes to update on the pool member - represented by ``pool_member``. - - :returns: The updated pool member - :rtype: :class:`~openstack.network.v2.pool_member.PoolMember` - """ - poolobj = self._get_resource(_pool.Pool, pool) - return self._update(_pool_member.PoolMember, pool_member, - pool_id=poolobj.id, **attrs) - - def create_port(self, **attrs): - """Create a new port from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.port.Port`, - comprised of the properties on the Port class. - - :returns: The results of port creation - :rtype: :class:`~openstack.network.v2.port.Port` - """ - return self._create(_port.Port, **attrs) - - def delete_port(self, port, ignore_missing=True): - """Delete a port - - :param port: The value can be either the ID of a port or a - :class:`~openstack.network.v2.port.Port` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the port does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent port. - - :returns: ``None`` - """ - self._delete(_port.Port, port, ignore_missing=ignore_missing) - - def find_port(self, name_or_id, ignore_missing=True): - """Find a single port - - :param name_or_id: The name or ID of a port. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.port.Port` or None - """ - return self._find(_port.Port, name_or_id, - ignore_missing=ignore_missing) - - def get_port(self, port): - """Get a single port - - :param port: The value can be the ID of a port or a - :class:`~openstack.network.v2.port.Port` instance. - - :returns: One :class:`~openstack.network.v2.port.Port` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_port.Port, port) - - def ports(self, **query): - """Return a generator of ports - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. Available parameters include: - - * ``description``: The port description. - * ``device_id``: Port device ID. - * ``device_owner``: Port device owner (e.g. ``network:dhcp``). - * ``ip_address``: IP addresses of an allowed address pair. - * ``is_admin_state_up``: The administrative state of the port. - * ``is_port_security_enabled``: The port security status. - * ``mac_address``: Port MAC address. - * ``name``: The port name. - * ``network_id``: ID of network that owns the ports. - * ``project_id``: The ID of the project who owns the network. - * ``status``: The port status. Value is ``ACTIVE`` or ``DOWN``. - * ``subnet_id``: The ID of the subnet. - - :returns: A generator of port objects - :rtype: :class:`~openstack.network.v2.port.Port` - """ - return self._list(_port.Port, paginated=False, **query) - - def update_port(self, port, **attrs): - """Update a port - - :param port: Either the id of a port or a - :class:`~openstack.network.v2.port.Port` instance. - :param dict attrs: The attributes to update on the port represented - by ``port``. - - :returns: The updated port - :rtype: :class:`~openstack.network.v2.port.Port` - """ - return self._update(_port.Port, port, **attrs) - - def add_ip_to_port(self, port, ip): - ip['port_id'] = port.id - return ip.update(self._session) - - def remove_ip_from_port(self, ip): - ip['port_id'] = None - return ip.update(self._session) - - def get_subnet_ports(self, subnet_id): - result = [] - ports = self.ports() - for puerta in ports: - for fixed_ip in puerta.fixed_ips: - if fixed_ip['subnet_id'] == subnet_id: - result.append(puerta) - return result - - def create_qos_bandwidth_limit_rule(self, qos_policy, **attrs): - """Create a new bandwidth limit rule - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2. - qos_bandwidth_limit_rule.QoSBandwidthLimitRule`, - comprised of the properties on the - QoSBandwidthLimitRule class. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - - :returns: The results of resource creation - :rtype: :class:`~openstack.network.v2.qos_bandwidth_limit_rule. - QoSBandwidthLimitRule` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._create(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - qos_policy_id=policy.id, **attrs) - - def delete_qos_bandwidth_limit_rule(self, qos_rule, qos_policy, - ignore_missing=True): - """Delete a bandwidth limit rule - - :param qos_rule: The value can be either the ID of a bandwidth limit - rule or a :class:`~openstack.network.v2. - qos_bandwidth_limit_rule.QoSBandwidthLimitRule` - instance. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent bandwidth limit rule. - - :returns: ``None`` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - self._delete(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - qos_rule, ignore_missing=ignore_missing, - qos_policy_id=policy.id) - - def find_qos_bandwidth_limit_rule(self, qos_rule_id, qos_policy, - ignore_missing=True): - """Find a bandwidth limit rule - - :param qos_rule_id: The ID of a bandwidth limit rule. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.qos_bandwidth_limit_rule. - QoSBandwidthLimitRule` or None - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._find(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - qos_rule_id, ignore_missing=ignore_missing, - qos_policy_id=policy.id) - - def get_qos_bandwidth_limit_rule(self, qos_rule, qos_policy): - """Get a single bandwidth limit rule - - :param qos_rule: The value can be the ID of a minimum bandwidth rule or - a :class:`~openstack.network.v2. - qos_bandwidth_limit_rule.QoSBandwidthLimitRule` - instance. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :returns: One :class:`~openstack.network.v2.qos_bandwidth_limit_rule. - QoSBandwidthLimitRule` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._get(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - qos_rule, qos_policy_id=policy.id) - - def qos_bandwidth_limit_rules(self, qos_policy, **query): - """Return a generator of bandwidth limit rules - - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - :returns: A generator of bandwidth limit rule objects - :rtype: :class:`~openstack.network.v2.qos_bandwidth_limit_rule. - QoSBandwidthLimitRule` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._list(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - paginated=False, qos_policy_id=policy.id, **query) - - def update_qos_bandwidth_limit_rule(self, qos_rule, qos_policy, - **attrs): - """Update a bandwidth limit rule - - :param qos_rule: Either the id of a bandwidth limit rule or a - :class:`~openstack.network.v2. - qos_bandwidth_limit_rule.QoSBandwidthLimitRule` - instance. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :attrs kwargs: The attributes to update on the bandwidth limit rule - represented by ``value``. - - :returns: The updated minimum bandwidth rule - :rtype: :class:`~openstack.network.v2.qos_bandwidth_limit_rule. - QoSBandwidthLimitRule` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._update(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - qos_rule, qos_policy_id=policy.id, **attrs) - - def create_qos_dscp_marking_rule(self, qos_policy, **attrs): - """Create a new QoS DSCP marking rule - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2. - qos_dscp_marking_rule.QoSDSCPMarkingRule`, - comprised of the properties on the - QosDscpMarkingRule class. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - - :returns: The results of router creation - :rtype: :class:`~openstack.network.v2.qos_dscp_marking_rule. - QoSDSCPMarkingRule` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._create(_qos_dscp_marking_rule.QoSDSCPMarkingRule, - qos_policy_id=policy.id, **attrs) - - def delete_qos_dscp_marking_rule(self, qos_rule, qos_policy, - ignore_missing=True): - """Delete a QoS DSCP marking rule - - :param qos_rule: The value can be either the ID of a minimum bandwidth - rule or a :class:`~openstack.network.v2. - qos_dscp_marking_rule.QoSDSCPMarkingRule` - instance. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent minimum bandwidth rule. - - :returns: ``None`` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - self._delete(_qos_dscp_marking_rule.QoSDSCPMarkingRule, - qos_rule, ignore_missing=ignore_missing, - qos_policy_id=policy.id) - - def find_qos_dscp_marking_rule(self, qos_rule_id, qos_policy, - ignore_missing=True): - """Find a QoS DSCP marking rule - - :param qos_rule_id: The ID of a QoS DSCP marking rule. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.qos_dscp_marking_rule. - QoSDSCPMarkingRule` or None - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._find(_qos_dscp_marking_rule.QoSDSCPMarkingRule, - qos_rule_id, ignore_missing=ignore_missing, - qos_policy_id=policy.id) - - def get_qos_dscp_marking_rule(self, qos_rule, qos_policy): - """Get a single QoS DSCP marking rule - - :param qos_rule: The value can be the ID of a minimum bandwidth rule or - a :class:`~openstack.network.v2.qos_dscp_marking_rule. - QoSDSCPMarkingRule` instance. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :returns: One :class:`~openstack.network.v2.qos_dscp_marking_rule. - QoSDSCPMarkingRule` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._get(_qos_dscp_marking_rule.QoSDSCPMarkingRule, - qos_rule, qos_policy_id=policy.id) - - def qos_dscp_marking_rules(self, qos_policy, **query): - """Return a generator of QoS DSCP marking rules - - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - :returns: A generator of QoS DSCP marking rule objects - :rtype: :class:`~openstack.network.v2.qos_dscp_marking_rule. - QoSDSCPMarkingRule` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._list(_qos_dscp_marking_rule.QoSDSCPMarkingRule, - paginated=False, qos_policy_id=policy.id, **query) - - def update_qos_dscp_marking_rule(self, qos_rule, qos_policy, **attrs): - """Update a QoS DSCP marking rule - - :param qos_rule: Either the id of a minimum bandwidth rule or a - :class:`~openstack.network.v2.qos_dscp_marking_rule. - QoSDSCPMarkingRule` instance. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :attrs kwargs: The attributes to update on the QoS DSCP marking rule - represented by ``value``. - - :returns: The updated QoS DSCP marking rule - :rtype: :class:`~openstack.network.v2.qos_dscp_marking_rule. - QoSDSCPMarkingRule` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._update(_qos_dscp_marking_rule.QoSDSCPMarkingRule, - qos_rule, qos_policy_id=policy.id, **attrs) - - def create_qos_minimum_bandwidth_rule(self, qos_policy, **attrs): - """Create a new minimum bandwidth rule - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2. - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule`, - comprised of the properties on the - QoSMinimumBandwidthRule class. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - - :returns: The results of resource creation - :rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. - QoSMinimumBandwidthRule` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._create( - _qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - qos_policy_id=policy.id, **attrs) - - def delete_qos_minimum_bandwidth_rule(self, qos_rule, qos_policy, - ignore_missing=True): - """Delete a minimum bandwidth rule - - :param qos_rule: The value can be either the ID of a minimum bandwidth - rule or a :class:`~openstack.network.v2. - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule` - instance. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent minimum bandwidth rule. - - :returns: ``None`` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - self._delete(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - qos_rule, ignore_missing=ignore_missing, - qos_policy_id=policy.id) - - def find_qos_minimum_bandwidth_rule(self, qos_rule_id, qos_policy, - ignore_missing=True): - """Find a minimum bandwidth rule - - :param qos_rule_id: The ID of a minimum bandwidth rule. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. - QoSMinimumBandwidthRule` or None - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._find(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - qos_rule_id, ignore_missing=ignore_missing, - qos_policy_id=policy.id) - - def get_qos_minimum_bandwidth_rule(self, qos_rule, qos_policy): - """Get a single minimum bandwidth rule - - :param qos_rule: The value can be the ID of a minimum bandwidth rule or - a :class:`~openstack.network.v2. - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule` - instance. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :returns: One :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. - QoSMinimumBandwidthRule` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._get(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - qos_rule, qos_policy_id=policy.id) - - def qos_minimum_bandwidth_rules(self, qos_policy, **query): - """Return a generator of minimum bandwidth rules - - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - :returns: A generator of minimum bandwidth rule objects - :rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. - QoSMinimumBandwidthRule` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._list(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - paginated=False, qos_policy_id=policy.id, **query) - - def update_qos_minimum_bandwidth_rule(self, qos_rule, qos_policy, - **attrs): - """Update a minimum bandwidth rule - - :param qos_rule: Either the id of a minimum bandwidth rule or a - :class:`~openstack.network.v2. - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule` - instance. - :param qos_policy: The value can be the ID of the QoS policy that the - rule belongs or a :class:`~openstack.network.v2. - qos_policy.QoSPolicy` instance. - :attrs kwargs: The attributes to update on the minimum bandwidth rule - represented by ``value``. - - :returns: The updated minimum bandwidth rule - :rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. - QoSMinimumBandwidthRule` - """ - policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) - return self._update(_qos_minimum_bandwidth_rule. - QoSMinimumBandwidthRule, qos_rule, - qos_policy_id=policy.id, **attrs) - - def create_qos_policy(self, **attrs): - """Create a new QoS policy from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.qos_policy. - QoSPolicy`, comprised of the properties on the - QoSPolicy class. - - :returns: The results of QoS policy creation - :rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy` - """ - return self._create(_qos_policy.QoSPolicy, **attrs) - - def delete_qos_policy(self, qos_policy, ignore_missing=True): - """Delete a QoS policy - - :param qos_policy: The value can be either the ID of a QoS policy or a - :class:`~openstack.network.v2.qos_policy.QoSPolicy` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the QoS policy does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent QoS policy. - - :returns: ``None`` - """ - self._delete(_qos_policy.QoSPolicy, qos_policy, - ignore_missing=ignore_missing) - - def find_qos_policy(self, name_or_id, ignore_missing=True): - """Find a single QoS policy - - :param name_or_id: The name or ID of a QoS policy. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.qos_policy.QoSPolicy` or - None - """ - return self._find(_qos_policy.QoSPolicy, name_or_id, - ignore_missing=ignore_missing) - - def get_qos_policy(self, qos_policy): - """Get a single QoS policy - - :param qos_policy: The value can be the ID of a QoS policy or a - :class:`~openstack.network.v2.qos_policy.QoSPolicy` - instance. - - :returns: One :class:`~openstack.network.v2.qos_policy.QoSPolicy` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_qos_policy.QoSPolicy, qos_policy) - - def qos_policies(self, **query): - """Return a generator of QoS policies - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``description``: The description of a QoS policy. - * ``is_shared``: Whether the policy is shared among projects. - * ``name``: The name of a QoS policy. - * ``project_id``: The ID of the project who owns the network. - - :returns: A generator of QoS policy objects - :rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy` - """ - return self._list(_qos_policy.QoSPolicy, paginated=False, **query) - - def update_qos_policy(self, qos_policy, **attrs): - """Update a QoS policy - - :param qos_policy: Either the id of a QoS policy or a - :class:`~openstack.network.v2.qos_policy.QoSPolicy` - instance. - :attrs kwargs: The attributes to update on the QoS policy represented - by ``value``. - - :returns: The updated QoS policy - :rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy` - """ - return self._update(_qos_policy.QoSPolicy, qos_policy, **attrs) - - def qos_rule_types(self, **query): - """Return a generator of QoS rule types - - :param dict query: Optional query parameters to be sent to limit the - resources returned. Valid parameters include: - - * ``type``: The type of the QoS rule type. - - :returns: A generator of QoS rule type objects - :rtype: :class:`~openstack.network.v2.qos_rule_type.QoSRuleType` - """ - return self._list(_qos_rule_type.QoSRuleType, paginated=False, **query) - - def delete_quota(self, quota, ignore_missing=True): - """Delete a quota (i.e. reset to the default quota) - - :param quota: The value can be either the ID of a quota or a - :class:`~openstack.network.v2.quota.Quota` instance. - The ID of a quota is the same as the project ID - for the quota. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when quota does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent quota. - - :returns: ``None`` - """ - self._delete(_quota.Quota, quota, ignore_missing=ignore_missing) - - def get_quota(self, quota): - """Get a quota - - :param quota: The value can be the ID of a quota or a - :class:`~openstack.network.v2.quota.Quota` instance. - The ID of a quota is the same as the project ID - for the quota. - - :returns: One :class:`~openstack.network.v2.quota.Quota` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_quota.Quota, quota) - - def get_quota_default(self, quota): - """Get a default quota - - :param quota: The value can be the ID of a default quota or a - :class:`~openstack.network.v2.quota.QuotaDefault` - instance. The ID of a default quota is the same - as the project ID for the default quota. - - :returns: One :class:`~openstack.network.v2.quota.QuotaDefault` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - quota_obj = self._get_resource(_quota.Quota, quota) - return self._get(_quota.QuotaDefault, project=quota_obj.id, - requires_id=False) - - def quotas(self, **query): - """Return a generator of quotas - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Currently no query - parameter is supported. - - :returns: A generator of quota objects - :rtype: :class:`~openstack.network.v2.quota.Quota` - """ - return self._list(_quota.Quota, paginated=False, **query) - - def update_quota(self, quota, **attrs): - """Update a quota - - :param quota: Either the ID of a quota or a - :class:`~openstack.network.v2.quota.Quota` instance. - The ID of a quota is the same as the project ID - for the quota. - :param dict attrs: The attributes to update on the quota represented - by ``quota``. - - :returns: The updated quota - :rtype: :class:`~openstack.network.v2.quota.Quota` - """ - return self._update(_quota.Quota, quota, **attrs) - - def create_rbac_policy(self, **attrs): - """Create a new RBAC policy from attributes - - :param dict attrs: Keyword arguments which will be used to create a - :class:`~openstack.network.v2.rbac_policy.RBACPolicy`, - comprised of the properties on the RBACPolicy class. - - :return: The results of RBAC policy creation - :rtype: :class:`~openstack.network.v2.rbac_policy.RBACPolicy` - """ - return self._create(_rbac_policy.RBACPolicy, **attrs) - - def delete_rbac_policy(self, rbac_policy, ignore_missing=True): - """Delete a RBAC policy - - :param rbac_policy: The value can be either the ID of a RBAC policy or - a :class:`~openstack.network.v2.rbac_policy.RBACPolicy` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the RBAC policy does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent RBAC policy. - - :returns: ``None`` - """ - self._delete(_rbac_policy.RBACPolicy, rbac_policy, - ignore_missing=ignore_missing) - - def find_rbac_policy(self, rbac_policy, ignore_missing=True): - """Find a single RBAC policy - - :param rbac_policy: The ID of a RBAC policy. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One - :class:`~openstack.network.v2.rbac_policy.RBACPolicy` or None - """ - return self._find(_rbac_policy.RBACPolicy, rbac_policy, - ignore_missing=ignore_missing) - - def get_rbac_policy(self, rbac_policy): - """Get a single RBAC policy - - :param rbac_policy: The value can be the ID of a RBAC policy or a - :class:`~openstack.network.v2.rbac_policy.RBACPolicy` instance. - - :returns: One :class:`~openstack.network.v2.rbac_policy.RBACPolicy` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_rbac_policy.RBACPolicy, rbac_policy) - - def rbac_policies(self, **query): - """Return a generator of RBAC policies - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Available parameters - include: - - * ``action``: RBAC policy action - * ``object_type``: Type of the object that the RBAC policy affects - * ``target_project_id``: ID of the tenant that the RBAC policy - affects - * ``project_id``: Owner tenant ID - - :returns: A generator of rbac objects - :rtype: :class:`~openstack.network.v2.rbac_policy.RBACPolicy` - """ - return self._list(_rbac_policy.RBACPolicy, paginated=False, **query) - - def update_rbac_policy(self, rbac_policy, **attrs): - """Update a RBAC policy - - :param rbac_policy: Either the id of a RBAC policy or a - :class:`~openstack.network.v2.rbac_policy.RBACPolicy` instance. - :param dict attrs: The attributes to update on the RBAC policy - represented by ``rbac_policy``. - - :returns: The updated RBAC policy - :rtype: :class:`~openstack.network.v2.rbac_policy.RBACPolicy` - """ - return self._update(_rbac_policy.RBACPolicy, rbac_policy, **attrs) - - def create_router(self, **attrs): - """Create a new router from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.router.Router`, - comprised of the properties on the Router class. - - :returns: The results of router creation - :rtype: :class:`~openstack.network.v2.router.Router` - """ - return self._create(_router.Router, **attrs) - - def delete_router(self, router, ignore_missing=True): - """Delete a router - - :param router: The value can be either the ID of a router or a - :class:`~openstack.network.v2.router.Router` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the router does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent router. - - :returns: ``None`` - """ - self._delete(_router.Router, router, ignore_missing=ignore_missing) - - def find_router(self, name_or_id, ignore_missing=True): - """Find a single router - - :param name_or_id: The name or ID of a router. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.router.Router` or None - """ - return self._find(_router.Router, name_or_id, - ignore_missing=ignore_missing) - - def get_router(self, router): - """Get a single router - - :param router: The value can be the ID of a router or a - :class:`~openstack.network.v2.router.Router` instance. - - :returns: One :class:`~openstack.network.v2.router.Router` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_router.Router, router) - - def routers(self, **query): - """Return a generator of routers - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``description``: The description of a router. - * ``flavor_id``: The ID of the flavor. - * ``is_admin_state_up``: Router administrative state is up or not - * ``is_distributed``: The distributed state of a router - * ``is_ha``: The highly-available state of a router - * ``name``: Router name - * ``project_id``: The ID of the project this router is associated - with. - * ``status``: The status of the router. - - :returns: A generator of router objects - :rtype: :class:`~openstack.network.v2.router.Router` - """ - return self._list(_router.Router, paginated=False, **query) - - def update_router(self, router, **attrs): - """Update a router - - :param router: Either the id of a router or a - :class:`~openstack.network.v2.router.Router` instance. - :param dict attrs: The attributes to update on the router represented - by ``router``. - - :returns: The updated router - :rtype: :class:`~openstack.network.v2.router.Router` - """ - return self._update(_router.Router, router, **attrs) - - def add_interface_to_router(self, router, subnet_id=None, port_id=None): - """Add Interface to a router - - :param router: Either the router ID or an instance of - :class:`~openstack.network.v2.router.Router` - :param subnet_id: ID of the subnet - :param port_id: ID of the port - :returns: Router with updated interface - :rtype: :class: `~openstack.network.v2.router.Router` - """ - body = {} - if port_id: - body = {'port_id': port_id} - else: - body = {'subnet_id': subnet_id} - router = self._get_resource(_router.Router, router) - return router.add_interface(self._session, **body) - - def remove_interface_from_router(self, router, subnet_id=None, - port_id=None): - """Remove Interface from a router - - :param router: Either the router ID or an instance of - :class:`~openstack.network.v2.router.Router` - :param subnet: ID of the subnet - :param port: ID of the port - :returns: Router with updated interface - :rtype: :class: `~openstack.network.v2.router.Router` - """ - - body = {} - if port_id: - body = {'port_id': port_id} - else: - body = {'subnet_id': subnet_id} - router = self._get_resource(_router.Router, router) - return router.remove_interface(self._session, **body) - - def add_gateway_to_router(self, router, **body): - """Add Gateway to a router - - :param router: Either the router ID or an instance of - :class:`~openstack.network.v2.router.Router` - :param body: Body with the gateway information - :returns: Router with updated interface - :rtype: :class: `~openstack.network.v2.router.Router` - """ - router = self._get_resource(_router.Router, router) - return router.add_gateway(self._session, **body) - - def remove_gateway_from_router(self, router, **body): - """Remove Gateway from a router - - :param router: Either the router ID or an instance of - :class:`~openstack.network.v2.router.Router` - :param body: Body with the gateway information - :returns: Router with updated interface - :rtype: :class: `~openstack.network.v2.router.Router` - """ - router = self._get_resource(_router.Router, router) - return router.remove_gateway(self._session, **body) - - def routers_hosting_l3_agents(self, router, **query): - """Return a generator of L3 agent hosting a router - - :param router: Either the router id or an instance of - :class:`~openstack.network.v2.router.Router` - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources returned - - :returns: A generator of Router L3 Agents - :rtype: :class:`~openstack.network.v2.router.RouterL3Agents` - """ - router = self._get_resource(_router.Router, router) - return self._list(_agent.RouterL3Agent, paginated=False, - router_id=router.id, **query) - - def agent_hosted_routers(self, agent, **query): - """Return a generator of routers hosted by a L3 agent - - :param agent: Either the agent id of an instance of - :class:`~openstack.network.v2.network_agent.Agent` - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources returned - - :returns: A generator of routers - :rtype: :class:`~openstack.network.v2.agent.L3AgentRouters` - """ - agent = self._get_resource(_agent.Agent, agent) - return self._list(_router.L3AgentRouter, paginated=False, - agent_id=agent.id, **query) - - def add_router_to_agent(self, agent, router): - """Add router to L3 agent - - :param agent: Either the id of an agent - :class:`~openstack.network.v2.agent.Agent` instance - :param router: A router instance - :returns: Agent with attached router - :rtype: :class:`~openstack.network.v2.agent.Agent` - """ - agent = self._get_resource(_agent.Agent, agent) - router = self._get_resource(_router.Router, router) - return agent.add_router_to_agent(self._session, router.id) - - def remove_router_from_agent(self, agent, router): - """Remove router from L3 agent - - :param agent: Either the id of an agent or an - :class:`~openstack.network.v2.agent.Agent` instance - :param router: A router instance - :returns: Agent with removed router - :rtype: :class:`~openstack.network.v2.agent.Agent` - """ - agent = self._get_resource(_agent.Agent, agent) - router = self._get_resource(_router.Router, router) - return agent.remove_router_from_agent(self._session, router.id) - - def create_security_group(self, **attrs): - """Create a new security group from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.security_group.SecurityGroup`, - comprised of the properties on the SecurityGroup class. - - :returns: The results of security group creation - :rtype: :class:`~openstack.network.v2.security_group.SecurityGroup` - """ - return self._create(_security_group.SecurityGroup, **attrs) - - def delete_security_group(self, security_group, ignore_missing=True): - """Delete a security group - - :param security_group: - The value can be either the ID of a security group or a - :class:`~openstack.network.v2.security_group.SecurityGroup` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the security group does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent security group. - - :returns: ``None`` - """ - self._delete(_security_group.SecurityGroup, security_group, - ignore_missing=ignore_missing) - - def find_security_group(self, name_or_id, ignore_missing=True): - """Find a single security group - - :param name_or_id: The name or ID of a security group. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.security_group. - SecurityGroup` or None - """ - return self._find(_security_group.SecurityGroup, name_or_id, - ignore_missing=ignore_missing) - - def get_security_group(self, security_group): - """Get a single security group - - :param security_group: The value can be the ID of a security group or a - :class:`~openstack.network.v2.security_group.SecurityGroup` - instance. - - :returns: One - :class:`~openstack.network.v2.security_group.SecurityGroup` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_security_group.SecurityGroup, security_group) - - def security_groups(self, **query): - """Return a generator of security groups - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Valid parameters are: - - * ``description``: Security group description - * ``name``: The name of a security group - * ``project_id``: The ID of the project this security group is - associated with. - - :returns: A generator of security group objects - :rtype: :class:`~openstack.network.v2.security_group.SecurityGroup` - """ - return self._list(_security_group.SecurityGroup, paginated=False, - **query) - - def update_security_group(self, security_group, **attrs): - """Update a security group - - :param security_group: Either the id of a security group or a - :class:`~openstack.network.v2.security_group.SecurityGroup` - instance. - :param dict attrs: The attributes to update on the security group - represented by ``security_group``. - - :returns: The updated security group - :rtype: :class:`~openstack.network.v2.security_group.SecurityGroup` - """ - return self._update(_security_group.SecurityGroup, security_group, - **attrs) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="See the Network user guide for an example") - def security_group_open_port(self, sgid, port, protocol='tcp'): - rule = { - 'direction': 'ingress', - 'remote_ip_prefix': '0.0.0.0/0', - 'protocol': protocol, - 'port_range_max': port, - 'port_range_min': port, - 'security_group_id': sgid, - 'ethertype': 'IPv4' - } - return self.create_security_group_rule(**rule) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details="See the Network user guide for an example") - def security_group_allow_ping(self, sgid): - rule = { - 'direction': 'ingress', - 'remote_ip_prefix': '0.0.0.0/0', - 'protocol': 'icmp', - 'port_range_max': None, - 'port_range_min': None, - 'security_group_id': sgid, - 'ethertype': 'IPv4' - } - return self.create_security_group_rule(**rule) - - def create_security_group_rule(self, **attrs): - """Create a new security group rule from attributes - - :param dict attrs: Keyword arguments which will be used to create a - :class:`~openstack.network.v2.security_group_rule. - SecurityGroupRule`, comprised of the properties on the - SecurityGroupRule class. - - :returns: The results of security group rule creation - :rtype: :class:`~openstack.network.v2.security_group_rule.\ - SecurityGroupRule` - """ - return self._create(_security_group_rule.SecurityGroupRule, **attrs) - - def delete_security_group_rule(self, security_group_rule, - ignore_missing=True): - """Delete a security group rule - - :param security_group_rule: - The value can be either the ID of a security group rule - or a :class:`~openstack.network.v2.security_group_rule. - SecurityGroupRule` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the security group rule does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent security group rule. - - :returns: ``None`` - """ - self._delete(_security_group_rule.SecurityGroupRule, - security_group_rule, ignore_missing=ignore_missing) - - def find_security_group_rule(self, name_or_id, ignore_missing=True): - """Find a single security group rule - - :param str name_or_id: The ID of a security group rule. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.security_group_rule. - SecurityGroupRule` or None - """ - return self._find(_security_group_rule.SecurityGroupRule, - name_or_id, ignore_missing=ignore_missing) - - def get_security_group_rule(self, security_group_rule): - """Get a single security group rule - - :param security_group_rule: - The value can be the ID of a security group rule or a - :class:`~openstack.network.v2.security_group_rule.\ - SecurityGroupRule` instance. - - :returns: :class:`~openstack.network.v2.security_group_rule.\ - SecurityGroupRule` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_security_group_rule.SecurityGroupRule, - security_group_rule) - - def security_group_rules(self, **query): - """Return a generator of security group rules - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. Available parameters include: - - * ``description``: The security group rule description - * ``direction``: Security group rule direction - * ``ether_type``: Must be IPv4 or IPv6, and addresses represented - in CIDR must match the ingress or egress rule. - * ``project_id``: The ID of the project this security group rule - is associated with. - * ``protocol``: Security group rule protocol - * ``remote_group_id``: ID of a remote security group - * ``security_group_id``: ID of security group that owns the rules - - :returns: A generator of security group rule objects - :rtype: :class:`~openstack.network.v2.security_group_rule. - SecurityGroupRule` - """ - return self._list(_security_group_rule.SecurityGroupRule, - paginated=False, **query) - - def create_segment(self, **attrs): - """Create a new segment from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.segment.Segment`, - comprised of the properties on the Segment class. - - :returns: The results of segment creation - :rtype: :class:`~openstack.network.v2.segment.Segment` - """ - return self._create(_segment.Segment, **attrs) - - def delete_segment(self, segment, ignore_missing=True): - """Delete a segment - - :param segment: The value can be either the ID of a segment or a - :class:`~openstack.network.v2.segment.Segment` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the segment does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent segment. - - :returns: ``None`` - """ - self._delete(_segment.Segment, segment, ignore_missing=ignore_missing) - - def find_segment(self, name_or_id, ignore_missing=True): - """Find a single segment - - :param name_or_id: The name or ID of a segment. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.segment.Segment` or None - """ - return self._find(_segment.Segment, name_or_id, - ignore_missing=ignore_missing) - - def get_segment(self, segment): - """Get a single segment - - :param segment: The value can be the ID of a segment or a - :class:`~openstack.network.v2.segment.Segment` - instance. - - :returns: One :class:`~openstack.network.v2.segment.Segment` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_segment.Segment, segment) - - def segments(self, **query): - """Return a generator of segments - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. Available parameters include: - - * ``description``: The segment description - * ``name``: Name of the segments - * ``network_id``: ID of the network that owns the segments - * ``network_type``: Network type for the segments - * ``physical_network``: Physical network name for the segments - * ``segmentation_id``: Segmentation ID for the segments - - :returns: A generator of segment objects - :rtype: :class:`~openstack.network.v2.segment.Segment` - """ - return self._list(_segment.Segment, paginated=False, **query) - - def update_segment(self, segment, **attrs): - """Update a segment - - :param segment: Either the id of a segment or a - :class:`~openstack.network.v2.segment.Segment` - instance. - :attrs kwargs: The attributes to update on the segment represented - by ``value``. - - :returns: The update segment - :rtype: :class:`~openstack.network.v2.segment.Segment` - """ - return self._update(_segment.Segment, segment, **attrs) - - def service_providers(self, **query): - """Return a generator of service providers - - :param kwargs \*\* query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of service provider objects - :rtype: :class:`~openstack.network.v2.service_provider.ServiceProvider` - """ - - return self._list(_service_provider.ServiceProvider, - paginated=False, **query) - - def create_service_profile(self, **attrs): - """Create a new network service flavor profile from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.service_profile - .ServiceProfile`, - comprised of the properties on the ServiceProfile - class. - - :returns: The results of service profile creation - :rtype: :class:`~openstack.network.v2.service_profile.ServiceProfile` - """ - return self._create(_service_profile.ServiceProfile, **attrs) - - def delete_service_profile(self, service_profile, ignore_missing=True): - """Delete a network service flavor profile - - :param service_profile: The value can be either the ID of a service - profile or a - :class:`~openstack.network.v2.service_profile - .ServiceProfile` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the service profile does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent service profile. - - :returns: ``None`` - """ - self._delete(_service_profile.ServiceProfile, service_profile, - ignore_missing=ignore_missing) - - def find_service_profile(self, name_or_id, ignore_missing=True): - """Find a single network service flavor profile - - :param name_or_id: The name or ID of a service profile. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.service_profile - .ServiceProfile` or None - """ - return self._find(_service_profile.ServiceProfile, name_or_id, - ignore_missing=ignore_missing) - - def get_service_profile(self, service_profile): - """Get a single network service flavor profile - - :param service_profile: The value can be the ID of a service_profile or - a :class:`~openstack.network.v2.service_profile.ServiceProfile` - instance. - - :returns: One :class:`~openstack.network.v2.service_profile - .ServiceProfile` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_service_profile.ServiceProfile, service_profile) - - def service_profiles(self, **query): - """Return a generator of network service flavor profiles - - :param dict query: Optional query parameters to be sent to limit the - resources returned. Available parameters inclue: - - * ``description``: The description of the service flavor profile - * ``driver``: Provider driver for the service flavor profile - * ``is_enabled``: Whether the profile is enabled - * ``project_id``: The owner project ID - - :returns: A generator of service profile objects - :rtype: :class:`~openstack.network.v2.service_profile.ServiceProfile` - """ - return self._list(_service_profile.ServiceProfile, paginated=True, - **query) - - def update_service_profile(self, service_profile, **attrs): - """Update a network flavor service profile - - :param service_profile: Either the id of a service profile or a - :class:`~openstack.network.v2.service_profile - .ServiceProfile` instance. - :attrs kwargs: The attributes to update on the service profile - represented by ``value``. - - :returns: The updated service profile - :rtype: :class:`~openstack.network.v2.service_profile.ServiceProfile` - """ - return self._update(_service_profile.ServiceProfile, service_profile, - **attrs) - - def create_subnet(self, **attrs): - """Create a new subnet from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.subnet.Subnet`, - comprised of the properties on the Subnet class. - - :returns: The results of subnet creation - :rtype: :class:`~openstack.network.v2.subnet.Subnet` - """ - return self._create(_subnet.Subnet, **attrs) - - def delete_subnet(self, subnet, ignore_missing=True): - """Delete a subnet - - :param subnet: The value can be either the ID of a subnet or a - :class:`~openstack.network.v2.subnet.Subnet` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the subnet does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent subnet. - - :returns: ``None`` - """ - self._delete(_subnet.Subnet, subnet, ignore_missing=ignore_missing) - - def find_subnet(self, name_or_id, ignore_missing=True): - """Find a single subnet - - :param name_or_id: The name or ID of a subnet. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.subnet.Subnet` or None - """ - return self._find(_subnet.Subnet, name_or_id, - ignore_missing=ignore_missing) - - def get_subnet(self, subnet): - """Get a single subnet - - :param subnet: The value can be the ID of a subnet or a - :class:`~openstack.network.v2.subnet.Subnet` instance. - - :returns: One :class:`~openstack.network.v2.subnet.Subnet` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_subnet.Subnet, subnet) - - def subnets(self, **query): - """Return a generator of subnets - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. Available parameters include: - - * ``cidr``: Subnet CIDR - * ``description``: The subnet description - * ``gateway_ip``: Subnet gateway IP address - * ``ip_version``: Subnet IP address version - * ``ipv6_address_mode``: The IPv6 adress mode - * ``ipv6_ra_mode``: The IPv6 router advertisement mode - * ``is_dhcp_enabled``: Subnet has DHCP enabled (boolean) - * ``name``: Subnet name - * ``network_id``: ID of network that owns the subnets - * ``project_id``: Owner tenant ID - * ``subnet_pool_id``: The subnet pool ID from which to obtain a - CIDR. - - :returns: A generator of subnet objects - :rtype: :class:`~openstack.network.v2.subnet.Subnet` - """ - return self._list(_subnet.Subnet, paginated=False, **query) - - def update_subnet(self, subnet, **attrs): - """Update a subnet - - :param subnet: Either the id of a subnet or a - :class:`~openstack.network.v2.subnet.Subnet` instance. - :param dict attrs: The attributes to update on the subnet represented - by ``subnet``. - - :returns: The updated subnet - :rtype: :class:`~openstack.network.v2.subnet.Subnet` - """ - return self._update(_subnet.Subnet, subnet, **attrs) - - def create_subnet_pool(self, **attrs): - """Create a new subnet pool from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.subnet_pool.SubnetPool`, - comprised of the properties on the SubnetPool class. - - :returns: The results of subnet pool creation - :rtype: :class:`~openstack.network.v2.subnet_pool.SubnetPool` - """ - return self._create(_subnet_pool.SubnetPool, **attrs) - - def delete_subnet_pool(self, subnet_pool, ignore_missing=True): - """Delete a subnet pool - - :param subnet_pool: The value can be either the ID of a subnet pool or - a :class:`~openstack.network.v2.subnet_pool.SubnetPool` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the subnet pool does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent subnet pool. - - :returns: ``None`` - """ - self._delete(_subnet_pool.SubnetPool, subnet_pool, - ignore_missing=ignore_missing) - - def find_subnet_pool(self, name_or_id, ignore_missing=True): - """Find a single subnet pool - - :param name_or_id: The name or ID of a subnet pool. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.subnet_pool.SubnetPool` - or None - """ - return self._find(_subnet_pool.SubnetPool, name_or_id, - ignore_missing=ignore_missing) - - def get_subnet_pool(self, subnet_pool): - """Get a single subnet pool - - :param subnet_pool: The value can be the ID of a subnet pool or a - :class:`~openstack.network.v2.subnet_pool.SubnetPool` instance. - - :returns: One :class:`~openstack.network.v2.subnet_pool.SubnetPool` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_subnet_pool.SubnetPool, subnet_pool) - - def subnet_pools(self, **query): - """Return a generator of subnet pools - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. Available parameters include: - - * ``address_scope_id``: Subnet pool address scope ID - * ``description``: The subnet pool description - * ``ip_version``: The IP address family - * ``is_default``: Subnet pool is the default (boolean) - * ``is_shared``: Subnet pool is shared (boolean) - * ``name``: Subnet pool name - * ``project_id``: Owner tenant ID - - :returns: A generator of subnet pool objects - :rtype: :class:`~openstack.network.v2.subnet_pool.SubnetPool` - """ - return self._list(_subnet_pool.SubnetPool, paginated=False, **query) - - def update_subnet_pool(self, subnet_pool, **attrs): - """Update a subnet pool - - :param subnet_pool: Either the ID of a subnet pool or a - :class:`~openstack.network.v2.subnet_pool.SubnetPool` instance. - :param dict attrs: The attributes to update on the subnet pool - represented by ``subnet_pool``. - - :returns: The updated subnet pool - :rtype: :class:`~openstack.network.v2.subnet_pool.SubnetPool` - """ - return self._update(_subnet_pool.SubnetPool, subnet_pool, **attrs) - - @staticmethod - def _check_tag_support(resource): - try: - # Check 'tags' attribute exists - resource.tags - except AttributeError: - raise exceptions.InvalidRequest( - '%s resource does not support tag' % - resource.__class__.__name__) - - def set_tags(self, resource, tags): - """Replace tags of a specified resource with specified tags - - :param resource: - :class:`~openstack.resource2.Resource` instance. - :param tags: New tags to be set. - :type tags: "list" - - :returns: The updated resource - :rtype: :class:`~openstack.resource2.Resource` - """ - self._check_tag_support(resource) - return resource.set_tags(self._session, tags) - - def create_vpn_service(self, **attrs): - """Create a new vpn service from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.network.v2.vpn_service.VPNService`, - comprised of the properties on the VPNService class. - - :returns: The results of vpn service creation - :rtype: :class:`~openstack.network.v2.vpn_service.VPNService` - """ - return self._create(_vpn_service.VPNService, **attrs) - - def delete_vpn_service(self, vpn_service, ignore_missing=True): - """Delete a vpn service - - :param vpn_service: - The value can be either the ID of a vpn service or a - :class:`~openstack.network.v2.vpn_service.VPNService` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the vpn service does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent vpn service. - - :returns: ``None`` - """ - self._delete(_vpn_service.VPNService, vpn_service, - ignore_missing=ignore_missing) - - def find_vpn_service(self, name_or_id, ignore_missing=True): - """Find a single vpn service - - :param name_or_id: The name or ID of a vpn service. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.network.v2.vpn_service.VPNService` - or None - """ - return self._find(_vpn_service.VPNService, name_or_id, - ignore_missing=ignore_missing) - - def get_vpn_service(self, vpn_service): - """Get a single vpn service - - :param vpn_service: The value can be the ID of a vpn service or a - :class:`~openstack.network.v2.vpn_service.VPNService` - instance. - - :returns: One - :class:`~openstack.network.v2.vpn_service.VPNService` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_vpn_service.VPNService, vpn_service) - - def vpn_services(self, **query): - """Return a generator of vpn services - - :param dict query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of vpn service objects - :rtype: :class:`~openstack.network.v2.vpn_service.VPNService` - """ - return self._list(_vpn_service.VPNService, paginated=False, **query) - - def update_vpn_service(self, vpn_service, **attrs): - """Update a vpn service - - :param vpn_service: Either the id of a vpn service or a - :class:`~openstack.network.v2.vpn_service.VPNService` instance. - :param dict attrs: The attributes to update on the VPN service - represented by ``vpn_service``. - - :returns: The updated vpnservice - :rtype: :class:`~openstack.network.v2.vpn_service.VPNService` - """ - return self._update(_vpn_service.VPNService, vpn_service, **attrs) diff --git a/openstack/network/v2/address_scope.py b/openstack/network/v2/address_scope.py deleted file mode 100644 index 1364fcfd..00000000 --- a/openstack/network/v2/address_scope.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class AddressScope(resource.Resource): - """Address scope extension.""" - resource_key = 'address_scope' - resources_key = 'address_scopes' - base_path = '/address-scopes' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'name', 'ip_version', - project_id='tenant_id', - is_shared='shared', - ) - - # Properties - #: The address scope name. - name = resource.Body('name') - #: The ID of the project that owns the address scope. - project_id = resource.Body('tenant_id') - #: The IP address family of the address scope. - #: *Type: int* - ip_version = resource.Body('ip_version', type=int) - #: Indicates whether this address scope is shared across all projects. - #: *Type: bool* - is_shared = resource.Body('shared', type=bool) diff --git a/openstack/network/v2/agent.py b/openstack/network/v2/agent.py deleted file mode 100644 index bb58ed41..00000000 --- a/openstack/network/v2/agent.py +++ /dev/null @@ -1,125 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource -from openstack import utils - - -class Agent(resource.Resource): - """Neutron agent extension.""" - resource_key = 'agent' - resources_key = 'agents' - base_path = '/agents' - service = network_service.NetworkService() - - # capabilities - allow_create = False - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # NOTE: We skip query for JSON fields and datetime fields - _query_mapping = resource.QueryParameters( - 'agent_type', 'availability_zone', 'binary', 'description', 'host', - 'topic', - is_admin_state_up='admin_state_up', is_alive='alive', - ) - - # Properties - #: The type of network agent. - agent_type = resource.Body('agent_type') - #: Availability zone for the network agent. - availability_zone = resource.Body('availability_zone') - #: The name of the network agent's application binary. - binary = resource.Body('binary') - #: Network agent configuration data specific to the agent_type. - configuration = resource.Body('configurations') - #: Timestamp when the network agent was created. - created_at = resource.Body('created_at') - #: The network agent description. - description = resource.Body('description') - #: Timestamp when the network agent's heartbeat was last seen. - last_heartbeat_at = resource.Body('heartbeat_timestamp') - #: The host the agent is running on. - host = resource.Body('host') - #: The administrative state of the network agent, which is up - #: ``True`` or down ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: Whether or not the network agent is alive. - #: *Type: bool* - is_alive = resource.Body('alive', type=bool) - #: Timestamp when the network agent was last started. - started_at = resource.Body('started_at') - #: The messaging queue topic the network agent subscribes to. - topic = resource.Body('topic') - #: The HA state of the L3 agent. This is one of 'active', 'standby' or - #: 'fault' for HA routers, or None for other types of routers. - ha_state = resource.Body('ha_state') - - def add_agent_to_network(self, session, network_id): - body = {'network_id': network_id} - url = utils.urljoin(self.base_path, self.id, 'dhcp-networks') - resp = session.post(url, endpoint_filter=self.service, json=body) - return resp.json() - - def remove_agent_from_network(self, session, network_id): - body = {'network_id': network_id} - url = utils.urljoin(self.base_path, self.id, 'dhcp-networks', - network_id) - session.delete(url, endpoint_filter=self.service, json=body) - - def add_router_to_agent(self, session, router): - body = {'router_id': router} - url = utils.urljoin(self.base_path, self.id, 'l3-routers') - resp = session.post(url, endpoint_filter=self.service, json=body) - return resp.json() - - def remove_router_from_agent(self, session, router): - body = {'router_id': router} - url = utils.urljoin(self.base_path, self.id, 'l3-routers', router) - session.delete(url, endpoint_filter=self.service, json=body) - - -class NetworkHostingDHCPAgent(Agent): - resource_key = 'agent' - resources_key = 'agents' - resource_name = 'dhcp-agent' - base_path = '/networks/%(network_id)s/dhcp-agents' - service = network_service.NetworkService() - - # capabilities - allow_create = False - allow_get = True - allow_update = False - allow_delete = False - allow_list = True - - # NOTE: Doesn't support query yet. - - -class RouterL3Agent(Agent): - resource_key = 'agent' - resources_key = 'agents' - base_path = '/routers/%(router_id)s/l3-agents' - resource_name = 'l3-agent' - service = network_service.NetworkService() - - # capabilities - allow_create = False - allow_retrieve = True - allow_update = False - allow_delete = False - allow_list = True - - # NOTE: No query parameter is supported diff --git a/openstack/network/v2/auto_allocated_topology.py b/openstack/network/v2/auto_allocated_topology.py deleted file mode 100644 index 84cf0bfa..00000000 --- a/openstack/network/v2/auto_allocated_topology.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class AutoAllocatedTopology(resource.Resource): - resource_name = 'auto_allocated_topology' - resource_key = 'auto_allocated_topology' - base_path = '/auto-allocated-topology' - service = network_service.NetworkService() - - # Capabilities - allow_create = False - allow_get = True - allow_update = False - allow_delete = True - allow_list = False - - # NOTE: this resource doesn't support list or query - - # Properties - #: Project ID - #: If project is not specified the topology will be created - #: for project user is authenticated against. - #: Will return in error if resources have not been configured correctly - #: To use this feature auto-allocated-topology, subnet_allocation, - #: external-net and router extensions must be enabled and set up. - project_id = resource.Body('tenant_id') - - -class ValidateTopology(AutoAllocatedTopology): - base_path = '/auto-allocated-topology/%(project)s?fields=dry-run' - - #: Validate requirements before running (Does not return topology) - #: Will return "Deployment error:" if the resources required have not - #: been correctly set up. - dry_run = resource.Body('dry_run') - project = resource.URI('project') diff --git a/openstack/network/v2/availability_zone.py b/openstack/network/v2/availability_zone.py deleted file mode 100644 index dd55f179..00000000 --- a/openstack/network/v2/availability_zone.py +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as _resource - - -class AvailabilityZone(_resource.Resource): - resource_key = 'availability_zone' - resources_key = 'availability_zones' - base_path = '/availability_zones' - service = network_service.NetworkService() - - # capabilities - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_list = True - - # NOTE: We don't support query by state yet because there is a mapping - # at neutron side difficult to map. - _query_mapping = _resource.QueryParameters( - name='availability_zone', resource='agent_type') - - # Properties - #: Name of the availability zone. - name = _resource.Body('name') - #: Type of resource for the availability zone, such as ``network``. - resource = _resource.Body('resource') - #: State of the availability zone, either ``available`` or - #: ``unavailable``. - state = _resource.Body('state') diff --git a/openstack/network/v2/extension.py b/openstack/network/v2/extension.py deleted file mode 100644 index 76c79c8e..00000000 --- a/openstack/network/v2/extension.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class Extension(resource.Resource): - resource_key = 'extension' - resources_key = 'extensions' - base_path = '/extensions' - service = network_service.NetworkService() - - # capabilities - allow_get = True - allow_list = True - - # NOTE: No query parameters supported - - # Properties - #: An alias the extension is known under. - alias = resource.Body('alias', alternate_id=True) - #: Text describing what the extension does. - description = resource.Body('description') - #: Links pertaining to this extension. - links = resource.Body('links') - #: The name of this extension. - name = resource.Body('name') - #: Timestamp when the extension was last updated. - updated_at = resource.Body('updated') diff --git a/openstack/network/v2/flavor.py b/openstack/network/v2/flavor.py deleted file mode 100644 index 46e9579a..00000000 --- a/openstack/network/v2/flavor.py +++ /dev/null @@ -1,60 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource -from openstack import utils - - -class Flavor(resource.Resource): - resource_key = 'flavor' - resources_key = 'flavors' - base_path = '/flavors' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'description', 'name', 'service_type', is_enabled='enabled') - - # properties - #: description for the flavor - description = resource.Body('description') - #: Sets enabled flag - is_enabled = resource.Body('enabled', type=bool) - #: The name of the flavor - name = resource.Body('name') - #: Service type to which the flavor applies - service_type = resource.Body('service_type') - #: IDs of service profiles associated with this flavor - service_profile_ids = resource.Body('service_profiles', type=list) - - def associate_flavor_with_service_profile( - self, session, service_profile_id=None): - flavor_id = self.id - url = utils.urljoin(self.base_path, flavor_id, 'service_profiles') - body = {"service_profile": {"id": service_profile_id}} - resp = session.post(url, endpoint_filter=self.service, json=body) - return resp.json() - - def disassociate_flavor_from_service_profile( - self, session, service_profile_id=None): - flavor_id = self.id - url = utils.urljoin( - self.base_path, flavor_id, 'service_profiles', service_profile_id) - session.delete(url, endpoint_filter=self.service) - return None diff --git a/openstack/network/v2/floating_ip.py b/openstack/network/v2/floating_ip.py deleted file mode 100644 index 9a738509..00000000 --- a/openstack/network/v2/floating_ip.py +++ /dev/null @@ -1,75 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class FloatingIP(resource.Resource): - name_attribute = "floating_ip_address" - resource_name = "floating ip" - resource_key = 'floatingip' - resources_key = 'floatingips' - base_path = '/floatingips' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'description', 'fixed_ip_address', 'floating_ip_address', - 'floating_network_id', 'port_id', 'router_id', 'status', - project_id='tenant_id') - - # Properties - #: Timestamp at which the floating IP was created. - created_at = resource.Body('created_at') - #: The floating IP description. - description = resource.Body('description') - #: The fixed IP address associated with the floating IP. If you - #: intend to associate the floating IP with a fixed IP at creation - #: time, then you must indicate the identifier of the internal port. - #: If an internal port has multiple associated IP addresses, the - #: service chooses the first IP unless you explicitly specify the - #: parameter fixed_ip_address to select a specific IP. - fixed_ip_address = resource.Body('fixed_ip_address') - #: The floating IP address. - floating_ip_address = resource.Body('floating_ip_address') - #: Floating IP object doesn't have name attribute, set ip address to name - #: so that user could find floating IP by UUID or IP address using find_ip - name = floating_ip_address - #: The ID of the network associated with the floating IP. - floating_network_id = resource.Body('floating_network_id') - #: The port ID. - port_id = resource.Body('port_id') - #: The ID of the project this floating IP is associated with. - project_id = resource.Body('tenant_id') - #: Revision number of the floating IP. *Type: int* - revision_number = resource.Body('revision_number', type=int) - #: The ID of an associated router. - router_id = resource.Body('router_id') - #: The floating IP status. Value is ``ACTIVE`` or ``DOWN``. - status = resource.Body('status') - #: Timestamp at which the floating IP was last updated. - updated_at = resource.Body('updated_at') - - @classmethod - def find_available(cls, session): - info = cls.list(session, fields='id', port_id='') - try: - return next(info) - except StopIteration: - return None diff --git a/openstack/network/v2/health_monitor.py b/openstack/network/v2/health_monitor.py deleted file mode 100644 index 1a636fe1..00000000 --- a/openstack/network/v2/health_monitor.py +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class HealthMonitor(resource.Resource): - resource_key = 'healthmonitor' - resources_key = 'healthmonitors' - base_path = '/lbaas/healthmonitors' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'delay', 'expected_codes', 'http_method', 'max_retries', - 'timeout', 'type', 'url_path', - is_admin_state_up='adminstate_up', - project_id='tenant_id', - ) - - # Properties - #: The time, in seconds, between sending probes to members. - delay = resource.Body('delay') - #: Expected HTTP codes for a passing HTTP(S) monitor. - expected_codes = resource.Body('expected_codes') - #: The HTTP method that the monitor uses for requests. - http_method = resource.Body('http_method') - #: The administrative state of the health monitor, which is up - #: ``True`` or down ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: Maximum consecutive health probe tries. - max_retries = resource.Body('max_retries') - #: Name of the health monitor. - name = resource.Body('name') - #: List of pools associated with this health monitor - #: *Type: list of dicts which contain the pool IDs* - pool_ids = resource.Body('pools', type=list) - #: The ID of the project this health monitor is associated with. - project_id = resource.Body('tenant_id') - #: The maximum number of seconds for a monitor to wait for a - #: connection to be established before it times out. This value must - #: be less than the delay value. - timeout = resource.Body('timeout') - #: The type of probe sent by the load balancer to verify the member - #: state, which is PING, TCP, HTTP, or HTTPS. - type = resource.Body('type') - #: Path portion of URI that will be probed if type is HTTP(S). - url_path = resource.Body('url_path') diff --git a/openstack/network/v2/listener.py b/openstack/network/v2/listener.py deleted file mode 100644 index 39bf8b1c..00000000 --- a/openstack/network/v2/listener.py +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class Listener(resource.Resource): - resource_key = 'listener' - resources_key = 'listeners' - base_path = '/lbaas/listeners' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'connection_limit', 'default_pool_id', 'default_tls_container_ref', - 'description', 'name', 'project_id', 'protocol', 'protocol_port', - is_admin_state_up='admin_state_up' - ) - - # Properties - #: The maximum number of connections permitted for this load balancer. - #: Default is infinite. - connection_limit = resource.Body('connection_limit') - #: ID of default pool. Must have compatible protocol with listener. - default_pool_id = resource.Body('default_pool_id') - #: A reference to a container of TLS secrets. - default_tls_container_ref = resource.Body('default_tls_container_ref') - #: Description for the listener. - description = resource.Body('description') - #: The administrative state of the listener, which is up - #: ``True`` or down ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: List of load balancers associated with this listener. - #: *Type: list of dicts which contain the load balancer IDs* - load_balancer_ids = resource.Body('loadbalancers') - #: Name of the listener - name = resource.Body('name') - #: The ID of the project this listener is associated with. - project_id = resource.Body('project_id') - #: The protocol of the listener, which is TCP, HTTP, HTTPS - #: or TERMINATED_HTTPS. - protocol = resource.Body('protocol') - #: Port the listener will listen to, e.g. 80. - protocol_port = resource.Body('protocol_port') - #: A list of references to TLS secrets. - #: *Type: list* - sni_container_refs = resource.Body('sni_container_refs') diff --git a/openstack/network/v2/load_balancer.py b/openstack/network/v2/load_balancer.py deleted file mode 100644 index 60f6df74..00000000 --- a/openstack/network/v2/load_balancer.py +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class LoadBalancer(resource.Resource): - resource_key = 'loadbalancer' - resources_key = 'loadbalancers' - base_path = '/lbaas/loadbalancers' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: Description for the load balancer. - description = resource.Body('description') - #: The administrative state of the load balancer, which is up - #: ``True`` or down ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: List of listeners associated with this load balancer. - #: *Type: list of dicts which contain the listener IDs* - listener_ids = resource.Body('listeners', type=list) - #: Name of the load balancer - name = resource.Body('name') - #: Status of load_balancer operating, e.g. ONLINE, OFFLINE. - operating_status = resource.Body('operating_status') - #: List of pools associated with this load balancer. - #: *Type: list of dicts which contain the pool IDs* - pool_ids = resource.Body('pools', type=list) - #: The ID of the project this load balancer is associated with. - project_id = resource.Body('tenant_id') - #: The name of the provider. - provider = resource.Body('provider') - #: Status of load balancer provisioning, e.g. ACTIVE, INACTIVE. - provisioning_status = resource.Body('provisioning_status') - #: The IP address of the VIP. - vip_address = resource.Body('vip_address') - #: The ID of the port for the VIP. - vip_port_id = resource.Body('vip_port_id') - #: The ID of the subnet on which to allocate the VIP address. - vip_subnet_id = resource.Body('vip_subnet_id') diff --git a/openstack/network/v2/metering_label.py b/openstack/network/v2/metering_label.py deleted file mode 100644 index 31220e44..00000000 --- a/openstack/network/v2/metering_label.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class MeteringLabel(resource.Resource): - resource_key = 'metering_label' - resources_key = 'metering_labels' - base_path = '/metering/metering-labels' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'description', 'name', - is_shared='shared', - project_id='tenant_id' - ) - - # Properties - #: Description of the metering label. - description = resource.Body('description') - #: Name of the metering label. - name = resource.Body('name') - #: The ID of the project this metering label is associated with. - project_id = resource.Body('tenant_id') - #: Indicates whether this label is shared across all tenants. - #: *Type: bool* - is_shared = resource.Body('shared', type=bool) diff --git a/openstack/network/v2/metering_label_rule.py b/openstack/network/v2/metering_label_rule.py deleted file mode 100644 index 568d054b..00000000 --- a/openstack/network/v2/metering_label_rule.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class MeteringLabelRule(resource.Resource): - resource_key = 'metering_label_rule' - resources_key = 'metering_label_rules' - base_path = '/metering/metering-label-rules' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'direction', 'metering_label_id', 'remote_ip_prefix', - project_id='tenant_id', - ) - - # Properties - #: ingress or egress: The direction in which metering label rule is - #: applied. Default: ``"ingress"`` - direction = resource.Body('direction') - #: Specify whether the ``remote_ip_prefix`` will be excluded or not - #: from traffic counters of the metering label, ie: to not count the - #: traffic of a specific IP address of a range. Default: ``False``, - #: *Type: bool* - is_excluded = resource.Body('excluded', type=bool) - #: The metering label ID to associate with this metering label rule. - metering_label_id = resource.Body('metering_label_id') - #: The ID of the project this metering label rule is associated with. - project_id = resource.Body('tenant_id') - #: The remote IP prefix to be associated with this metering label rule. - remote_ip_prefix = resource.Body('remote_ip_prefix') diff --git a/openstack/network/v2/network.py b/openstack/network/v2/network.py deleted file mode 100644 index cbdd4518..00000000 --- a/openstack/network/v2/network.py +++ /dev/null @@ -1,135 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack.network.v2 import tag -from openstack import resource2 as resource - - -class Network(resource.Resource, tag.TagMixin): - resource_key = 'network' - resources_key = 'networks' - base_path = '/networks' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # NOTE: We don't support query on list or datetime fields yet - _query_mapping = resource.QueryParameters( - 'description', 'name', 'project_id', 'status', - ipv4_address_scope_id='ipv4_address_scope', - ipv6_address_scope_id='ipv6_address_scope', - is_admin_state_up='admin_state_up', - is_port_security_enabled='port_security_enabled', - is_router_external='router:external', - is_shared='shared', - provider_network_type='provider:network_type', - provider_physical_network='provider:physical_network', - provider_segmentation_id='provider:segmentation_id', - **tag.TagMixin._tag_query_parameters - ) - - # Properties - #: Availability zone hints to use when scheduling the network. - #: *Type: list of availability zone names* - availability_zone_hints = resource.Body('availability_zone_hints') - #: Availability zones for the network. - #: *Type: list of availability zone names* - availability_zones = resource.Body('availability_zones') - #: Timestamp when the network was created. - created_at = resource.Body('created_at') - #: The network description. - description = resource.Body('description') - #: The DNS domain associated. - dns_domain = resource.Body('dns_domain') - #: The ID of the IPv4 address scope for the network. - ipv4_address_scope_id = resource.Body('ipv4_address_scope') - #: The ID of the IPv6 address scope for the network. - ipv6_address_scope_id = resource.Body('ipv6_address_scope') - #: The administrative state of the network, which is up ``True`` or - #: down ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: Whether or not this is the default external network. - #: *Type: bool* - is_default = resource.Body('is_default', type=bool) - #: The port security status, which is enabled ``True`` or disabled - #: ``False``. *Type: bool* *Default: False* - #: Available for multiple provider extensions. - is_port_security_enabled = resource.Body('port_security_enabled', - type=bool, - default=False) - #: Whether or not the router is external. - #: *Type: bool* *Default: False* - is_router_external = resource.Body('router:external', type=bool, - default=False) - #: Indicates whether this network is shared across all tenants. - #: By default, only administrative users can change this value. - #: *Type: bool* - is_shared = resource.Body('shared', type=bool) - #: Read-only. The maximum transmission unit (MTU) of the network resource. - mtu = resource.Body('mtu', type=int) - #: The network name. - name = resource.Body('name') - #: The ID of the project this network is associated with. - project_id = resource.Body('project_id') - #: The type of physical network that maps to this network resource. - #: For example, ``flat``, ``vlan``, ``vxlan``, or ``gre``. - #: Available for multiple provider extensions. - provider_network_type = resource.Body('provider:network_type') - #: The physical network where this network object is implemented. - #: Available for multiple provider extensions. - provider_physical_network = resource.Body('provider:physical_network') - #: An isolated segment ID on the physical network. The provider - #: network type defines the segmentation model. - #: Available for multiple provider extensions. - provider_segmentation_id = resource.Body('provider:segmentation_id') - #: The ID of the QoS policy attached to the port. - qos_policy_id = resource.Body('qos_policy_id') - #: Revision number of the network. *Type: int* - revision_number = resource.Body('revision_number', type=int) - #: A list of provider segment objects. - #: Available for multiple provider extensions. - segments = resource.Body('segments') - #: The network status. - status = resource.Body('status') - #: The associated subnet IDs. - #: *Type: list of strs of the subnet IDs* - subnet_ids = resource.Body('subnets', type=list) - #: Timestamp when the network was last updated. - updated_at = resource.Body('updated_at') - #: Indicates the VLAN transparency mode of the network - is_vlan_transparent = resource.Body('vlan_transparent', type=bool) - #: A list of assocaited tags - #: *Type: list of tag strings* - tags = resource.Body('tags', type=list) - - -class DHCPAgentHostingNetwork(Network): - resource_key = 'network' - resources_key = 'networks' - base_path = '/agents/%(agent_id)s/dhcp-networks' - resource_name = 'dhcp-network' - service = network_service.NetworkService() - - # capabilities - allow_create = False - allow_get = True - allow_update = False - allow_delete = False - allow_list = True - - # NOTE: No query parameter is supported diff --git a/openstack/network/v2/network_ip_availability.py b/openstack/network/v2/network_ip_availability.py deleted file mode 100644 index 132fbc94..00000000 --- a/openstack/network/v2/network_ip_availability.py +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class NetworkIPAvailability(resource.Resource): - resource_key = 'network_ip_availability' - resources_key = 'network_ip_availabilities' - base_path = '/network-ip-availabilities' - name_attribute = 'network_name' - service = network_service.NetworkService() - - # capabilities - allow_create = False - allow_get = True - allow_update = False - allow_delete = False - allow_list = True - - _query_mapping = resource.QueryParameters( - 'network_id', 'network_name', - project_id='tenant_id' - ) - - # Properties - #: Network ID to use when listing network IP availability. - network_id = resource.Body('network_id') - #: Network Name for the particular network IP availability. - network_name = resource.Body('network_name') - #: The Subnet IP Availability of all subnets of a network. - #: *Type: list* - subnet_ip_availability = resource.Body('subnet_ip_availability', type=list) - #: The ID of the project this network IP availability is associated with. - project_id = resource.Body('tenant_id') - #: The total ips of a network. - #: *Type: int* - total_ips = resource.Body('total_ips', type=int) - #: The used or consumed ip of a network - #: *Type: int* - used_ips = resource.Body('used_ips', type=int) diff --git a/openstack/network/v2/pool.py b/openstack/network/v2/pool.py deleted file mode 100644 index 27888d89..00000000 --- a/openstack/network/v2/pool.py +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class Pool(resource.Resource): - resource_key = 'pool' - resources_key = 'pools' - base_path = '/lbaas/pools' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'description', 'lb_algorithm', 'name', - 'protocol', 'provider', 'subnet_id', 'virtual_ip_id', - is_admin_state_up='admin_state_up', - project_id='tenant_id', - ) - - # Properties - #: Description for the pool. - description = resource.Body('description') - #: The ID of the associated health monitors. - health_monitor_ids = resource.Body('health_monitors', type=list) - #: The statuses of the associated health monitors. - health_monitor_status = resource.Body('health_monitor_status', type=list) - #: The administrative state of the pool, which is up ``True`` or down - #: ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: The load-balancer algorithm, which is round-robin, least-connections, - #: and so on. This value, which must be supported, is dependent on the - #: load-balancer provider. Round-robin must be supported. - lb_algorithm = resource.Body('lb_algorithm') - #: List of associated listeners. - #: *Type: list of dicts which contain the listener IDs* - listener_ids = resource.Body('listeners', type=list) - #: List of associated load balancers. - #: *Type: list of dicts which contain the load balancer IDs* - load_balancer_ids = resource.Body('loadbalancers', type=list) - #: List of members that belong to the pool. - #: *Type: list of dicts which contain the member IDs* - member_ids = resource.Body('members', type=list) - #: Pool name. Does not have to be unique. - name = resource.Body('name') - #: The ID of the project this pool is associated with. - project_id = resource.Body('tenant_id') - #: The protocol of the pool, which is TCP, HTTP, or HTTPS. - protocol = resource.Body('protocol') - #: The provider name of the load balancer service. - provider = resource.Body('provider') - #: Human readable description of the status. - status = resource.Body('status') - #: The status of the network. - status_description = resource.Body('status_description') - #: The subnet on which the members of the pool will be located. - subnet_id = resource.Body('subnet_id') - #: Session persistence algorithm that should be used (if any). - #: *Type: dict with keys ``type`` and ``cookie_name``* - session_persistence = resource.Body('session_persistence') - #: The ID of the virtual IP (VIP) address. - virtual_ip_id = resource.Body('vip_id') diff --git a/openstack/network/v2/pool_member.py b/openstack/network/v2/pool_member.py deleted file mode 100644 index 2d8dba05..00000000 --- a/openstack/network/v2/pool_member.py +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class PoolMember(resource.Resource): - resource_key = 'member' - resources_key = 'members' - base_path = '/lbaas/pools/%(pool_id)s/members' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'address', 'name', 'protocol_port', 'subnet_id', 'weight', - is_admin_state_up='admin_state_up', - project_id='tenant_id', - ) - - # Properties - #: The ID of the owning pool - pool_id = resource.URI('pool_id') - #: The IP address of the pool member. - address = resource.Body('address') - #: The administrative state of the pool member, which is up ``True`` or - #: down ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: Name of the pool member. - name = resource.Body('name') - #: The ID of the project this pool member is associated with. - project_id = resource.Body('tenant_id') - #: The port on which the application is hosted. - protocol_port = resource.Body('protocol_port', type=int) - #: Subnet ID in which to access this pool member. - subnet_id = resource.Body('subnet_id') - #: A positive integer value that indicates the relative portion of traffic - #: that this member should receive from the pool. For example, a member - #: with a weight of 10 receives five times as much traffic as a member - #: with weight of 2. - weight = resource.Body('weight', type=int) diff --git a/openstack/network/v2/port.py b/openstack/network/v2/port.py deleted file mode 100644 index b6f94665..00000000 --- a/openstack/network/v2/port.py +++ /dev/null @@ -1,134 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack.network.v2 import tag -from openstack import resource2 as resource - - -class Port(resource.Resource, tag.TagMixin): - resource_key = 'port' - resources_key = 'ports' - base_path = '/ports' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # NOTE: we skip query on list or datetime fields for now - _query_mapping = resource.QueryParameters( - 'description', 'device_id', 'device_owner', 'ip_address', - 'mac_address', 'name', 'network_id', 'status', 'subnet_id', - is_admin_state_up='admin_state_up', - is_port_security_enabled='port_security_enabled', - project_id='tenant_id', - **tag.TagMixin._tag_query_parameters - ) - - # Properties - #: Allowed address pairs. - allowed_address_pairs = resource.Body('allowed_address_pairs', type=list) - #: The ID of the host where the port is allocated. In some cases, - #: different implementations can run on different hosts. - binding_host_id = resource.Body('binding:host_id') - #: A dictionary the enables the application running on the specified - #: host to pass and receive vif port-specific information to the plug-in. - #: *Type: dict* - binding_profile = resource.Body('binding:profile', type=dict) - #: Read-only. A dictionary that enables the application to pass - #: information about functions that the Networking API provides. - #: To enable or disable port filtering features such as security group - #: and anti-MAC/IP spoofing, specify ``port_filter: True`` or - #: ``port_filter: False``. *Type: dict* - binding_vif_details = resource.Body('binding:vif_details', type=dict) - #: Read-only. The vif type for the specified port. - binding_vif_type = resource.Body('binding:vif_type') - #: The vnic type that is bound to the neutron port. - #: - #: In POST and PUT operations, specify a value of ``normal`` (virtual nic), - #: ``direct`` (pci passthrough), or ``macvtap`` - #: (virtual interface with a tap-like software interface). - #: These values support SR-IOV PCI passthrough networking. - #: The ML2 plug-in supports the vnic_type. - #: - #: In GET operations, the binding:vnic_type extended attribute is - #: visible to only port owners and administrative users. - binding_vnic_type = resource.Body('binding:vnic_type') - #: Timestamp when the port was created. - created_at = resource.Body('created_at') - #: Underlying data plane status of this port. - data_plane_status = resource.Body('data_plane_status') - #: The port description. - description = resource.Body('description') - #: Device ID of this port. - device_id = resource.Body('device_id') - #: Device owner of this port (e.g. ``network:dhcp``). - device_owner = resource.Body('device_owner') - #: DNS assignment for the port. - dns_assignment = resource.Body('dns_assignment') - #: DNS name for the port. - dns_name = resource.Body('dns_name') - #: Extra DHCP options. - extra_dhcp_opts = resource.Body('extra_dhcp_opts', type=list) - #: IP addresses of an allowed address pair. - ip_address = resource.Body('ip_address') - #: IP addresses for the port. Includes the IP address and subnet ID. - fixed_ips = resource.Body('fixed_ips', type=list) - #: The administrative state of the port, which is up ``True`` or - #: down ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: The port security status, which is enabled ``True`` or disabled - #: ``False``. *Type: bool* *Default: False* - is_port_security_enabled = resource.Body('port_security_enabled', - type=bool, default=False) - #: The MAC address of an allowed address pair. - mac_address = resource.Body('mac_address') - #: The port name. - name = resource.Body('name') - #: The ID of the attached network. - network_id = resource.Body('network_id') - #: The ID of the project who owns the network. Only administrative - #: users can specify a project ID other than their own. - project_id = resource.Body('tenant_id') - #: The extra DHCP option name. - option_name = resource.Body('opt_name') - #: The extra DHCP option value. - option_value = resource.Body('opt_value') - #: The ID of the QoS policy attached to the port. - qos_policy_id = resource.Body('qos_policy_id') - #: Revision number of the port. *Type: int* - revision_number = resource.Body('revision_number', type=int) - #: The IDs of any attached security groups. - #: *Type: list of strs of the security group IDs* - security_group_ids = resource.Body('security_groups', type=list) - #: The port status. Value is ``ACTIVE`` or ``DOWN``. - status = resource.Body('status') - #: The ID of the subnet. If you specify only a subnet UUID, OpenStack - #: networking allocates an available IP from that subnet to the port. - #: If you specify both a subnet ID and an IP address, OpenStack networking - #: tries to allocate the address to the port. - subnet_id = resource.Body('subnet_id') - #: Read-only. The trunk referring to this parent port and its subports. - #: Present for trunk parent ports if ``trunk-details`` extension is loaded. - #: *Type: dict with keys: trunk_id, sub_ports. - #: sub_ports is a list of dicts with keys: - #: port_id, segmentation_type, segmentation_id, mac_address* - trunk_details = resource.Body('trunk_details', type=dict) - #: Timestamp when the port was last updated. - updated_at = resource.Body('updated_at') - #: A list of assocaited tags - #: *Type: list of tag strings* - tags = resource.Body('tags', type=list) diff --git a/openstack/network/v2/qos_bandwidth_limit_rule.py b/openstack/network/v2/qos_bandwidth_limit_rule.py deleted file mode 100644 index ba5c32d8..00000000 --- a/openstack/network/v2/qos_bandwidth_limit_rule.py +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class QoSBandwidthLimitRule(resource.Resource): - resource_key = 'bandwidth_limit_rule' - resources_key = 'bandwidth_limit_rules' - base_path = '/qos/policies/%(qos_policy_id)s/bandwidth_limit_rules' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: The ID of the QoS policy who owns rule. - qos_policy_id = resource.URI('qos_policy_id') - #: Maximum bandwidth in kbps. - max_kbps = resource.Body('max_kbps') - #: Maximum burst bandwidth in kbps. - max_burst_kbps = resource.Body('max_burst_kbps') - #: Traffic direction from the tenant point of view ('egress', 'ingress'). - direction = resource.Body('direction') diff --git a/openstack/network/v2/qos_dscp_marking_rule.py b/openstack/network/v2/qos_dscp_marking_rule.py deleted file mode 100644 index c01a6e54..00000000 --- a/openstack/network/v2/qos_dscp_marking_rule.py +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class QoSDSCPMarkingRule(resource.Resource): - resource_key = 'dscp_marking_rule' - resources_key = 'dscp_marking_rules' - base_path = '/qos/policies/%(qos_policy_id)s/dscp_marking_rules' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: The ID of the QoS policy who owns rule. - qos_policy_id = resource.URI('qos_policy_id') - #: DSCP mark field. - dscp_mark = resource.Body('dscp_mark') diff --git a/openstack/network/v2/qos_minimum_bandwidth_rule.py b/openstack/network/v2/qos_minimum_bandwidth_rule.py deleted file mode 100644 index 09577dc9..00000000 --- a/openstack/network/v2/qos_minimum_bandwidth_rule.py +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class QoSMinimumBandwidthRule(resource.Resource): - resource_key = 'minimum_bandwidth_rule' - resources_key = 'minimum_bandwidth_rules' - base_path = '/qos/policies/%(qos_policy_id)s/minimum_bandwidth_rules' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: The ID of the QoS policy who owns rule. - qos_policy_id = resource.URI('qos_policy_id') - #: Minimum bandwidth in kbps. - min_kbps = resource.Body('min_kbps') - #: Traffic direction from the tenant point of view. Valid values: 'egress' - direction = resource.Body('direction') diff --git a/openstack/network/v2/qos_policy.py b/openstack/network/v2/qos_policy.py deleted file mode 100644 index f14de70a..00000000 --- a/openstack/network/v2/qos_policy.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class QoSPolicy(resource.Resource): - resource_key = 'policy' - resources_key = 'policies' - base_path = '/qos/policies' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'name', 'description', 'is_default', - project_id='tenant_id', - is_shared='shared', - ) - - # Properties - #: QoS policy name. - name = resource.Body('name') - #: The ID of the project who owns the network. Only administrative - #: users can specify a project ID other than their own. - project_id = resource.Body('tenant_id') - #: The QoS policy description. - description = resource.Body('description') - #: Indicates whether this QoS policy is the default policy for this - #: project. - #: *Type: bool* - is_default = resource.Body('is_default', type=bool) - #: Indicates whether this QoS policy is shared across all projects. - #: *Type: bool* - is_shared = resource.Body('shared', type=bool) - #: List of QoS rules applied to this QoS policy. - rules = resource.Body('rules') diff --git a/openstack/network/v2/qos_rule_type.py b/openstack/network/v2/qos_rule_type.py deleted file mode 100644 index 2f33f59b..00000000 --- a/openstack/network/v2/qos_rule_type.py +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class QoSRuleType(resource.Resource): - resource_key = 'rule_type' - resources_key = 'rule_types' - base_path = '/qos/rule-types' - service = network_service.NetworkService() - - # capabilities - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_list = True - - _query_mapping = resource.QueryParameters('type') - - # Properties - #: QoS rule type name. - type = resource.Body('type') diff --git a/openstack/network/v2/quota.py b/openstack/network/v2/quota.py deleted file mode 100644 index c37e712a..00000000 --- a/openstack/network/v2/quota.py +++ /dev/null @@ -1,84 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class Quota(resource.Resource): - resource_key = 'quota' - resources_key = 'quotas' - base_path = '/quotas' - service = network_service.NetworkService() - - # capabilities - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: The maximum amount of floating IPs you can have. *Type: int* - floating_ips = resource.Body('floatingip', type=int) - #: The maximum amount of health monitors you can create. *Type: int* - health_monitors = resource.Body('healthmonitor', type=int) - #: The maximum amount of listeners you can create. *Type: int* - listeners = resource.Body('listener', type=int) - #: The maximum amount of load balancers you can create. *Type: int* - load_balancers = resource.Body('loadbalancer', type=int) - #: The maximum amount of L7 policies you can create. *Type: int* - l7_policies = resource.Body('l7policy', type=int) - #: The maximum amount of networks you can create. *Type: int* - networks = resource.Body('network', type=int) - #: The maximum amount of pools you can create. *Type: int* - pools = resource.Body('pool', type=int) - #: The maximum amount of ports you can create. *Type: int* - ports = resource.Body('port', type=int) - #: The ID of the project these quota values are for. - project_id = resource.Body('tenant_id', alternate_id=True) - #: The maximum amount of RBAC policies you can create. *Type: int* - rbac_policies = resource.Body('rbac_policy', type=int) - #: The maximum amount of routers you can create. *Type: int* - routers = resource.Body('router', type=int) - #: The maximum amount of subnets you can create. *Type: int* - subnets = resource.Body('subnet', type=int) - #: The maximum amount of subnet pools you can create. *Type: int* - subnet_pools = resource.Body('subnetpool', type=int) - #: The maximum amount of security group rules you can create. *Type: int* - security_group_rules = resource.Body('security_group_rule', type=int) - #: The maximum amount of security groups you can create. *Type: int* - security_groups = resource.Body('security_group', type=int) - - def _prepare_request(self, requires_id=True, prepend_key=False): - _request = super(Quota, self)._prepare_request(requires_id, - prepend_key) - if self.resource_key in _request.body: - _body = _request.body[self.resource_key] - else: - _body = _request.body - if 'id' in _body: - del _body['id'] - return _request - - -class QuotaDefault(Quota): - base_path = '/quotas/%(project)s/default' - - # capabilities - allow_retrieve = True - allow_update = False - allow_delete = False - allow_list = False - - # Properties - #: The ID of the project. - project = resource.URI('project') diff --git a/openstack/network/v2/rbac_policy.py b/openstack/network/v2/rbac_policy.py deleted file mode 100644 index 16c3022a..00000000 --- a/openstack/network/v2/rbac_policy.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class RBACPolicy(resource.Resource): - resource_key = 'rbac_policy' - resources_key = 'rbac_policies' - base_path = '/rbac-policies' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'action', 'object_id', 'object_type', 'project_id', - 'target_project_id', - ) - - # Properties - #: ID of the object that this RBAC policy affects. - object_id = resource.Body('object_id') - #: The ID of the project this RBAC will be enforced. - target_project_id = resource.Body('target_tenant') - #: The owner project ID. - project_id = resource.Body('tenant_id') - #: Type of the object that this RBAC policy affects. - object_type = resource.Body('object_type') - #: Action for the RBAC policy. - action = resource.Body('action') diff --git a/openstack/network/v2/router.py b/openstack/network/v2/router.py deleted file mode 100644 index 7fa58dba..00000000 --- a/openstack/network/v2/router.py +++ /dev/null @@ -1,152 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack.network.v2 import tag -from openstack import resource2 as resource -from openstack import utils - - -class Router(resource.Resource, tag.TagMixin): - resource_key = 'router' - resources_key = 'routers' - base_path = '/routers' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # NOTE: We don't support query on datetime, list or dict fields - _query_mapping = resource.QueryParameters( - 'description', 'flavor_id', 'name', 'status', - is_admin_state_up='admin_state_up', - is_distributed='distributed', - is_ha='ha', - project_id='tenant_id', - **tag.TagMixin._tag_query_parameters - ) - - # Properties - #: Availability zone hints to use when scheduling the router. - #: *Type: list of availability zone names* - availability_zone_hints = resource.Body('availability_zone_hints', - type=list) - #: Availability zones for the router. - #: *Type: list of availability zone names* - availability_zones = resource.Body('availability_zones', type=list) - #: Timestamp when the router was created. - created_at = resource.Body('created_at') - #: The router description. - description = resource.Body('description') - #: The ``network_id``, for the external gateway. *Type: dict* - external_gateway_info = resource.Body('external_gateway_info', type=dict) - #: The ID of the flavor. - flavor_id = resource.Body('flavor_id') - #: The administrative state of the router, which is up ``True`` - #: or down ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: The distributed state of the router, which is distributed ``True`` - #: or not ``False``. *Type: bool* *Default: False* - is_distributed = resource.Body('distributed', type=bool, default=False) - #: The highly-available state of the router, which is highly available - #: ``True`` or not ``False``. *Type: bool* *Default: False* - is_ha = resource.Body('ha', type=bool, default=False) - #: The router name. - name = resource.Body('name') - #: The ID of the project this router is associated with. - project_id = resource.Body('tenant_id') - #: Revision number of the router. *Type: int* - revision_number = resource.Body('revision', type=int) - #: The extra routes configuration for the router. - routes = resource.Body('routes', type=list) - #: The router status. - status = resource.Body('status') - #: Timestamp when the router was created. - updated_at = resource.Body('updated_at') - #: A list of assocaited tags - #: *Type: list of tag strings* - tags = resource.Body('tags', type=list) - - def add_interface(self, session, **body): - """Add an internal interface to a logical router. - - :param session: The session to communicate through. - :type session: :class:`~openstack.session.Session` - :param dict body: The body requested to be updated on the router - - :returns: The body of the response as a dictionary. - """ - url = utils.urljoin(self.base_path, self.id, 'add_router_interface') - resp = session.put(url, endpoint_filter=self.service, json=body) - return resp.json() - - def remove_interface(self, session, **body): - """Remove an internal interface from a logical router. - - :param session: The session to communicate through. - :type session: :class:`~openstack.session.Session` - :param dict body: The body requested to be updated on the router - - :returns: The body of the response as a dictionary. - """ - url = utils.urljoin(self.base_path, self.id, 'remove_router_interface') - resp = session.put(url, endpoint_filter=self.service, json=body) - return resp.json() - - def add_gateway(self, session, **body): - """Add an external gateway to a logical router. - - :param session: The session to communicate through. - :type session: :class:`~openstack.session.Session` - :param dict body: The body requested to be updated on the router - - :returns: The body of the response as a dictionary. - """ - url = utils.urljoin(self.base_path, self.id, - 'add_gateway_router') - resp = session.put(url, endpoint_filter=self.service, json=body) - return resp.json() - - def remove_gateway(self, session, **body): - """Remove an external gateway from a logical router. - - :param session: The session to communicate through. - :type session: :class:`~openstack.session.Session` - :param dict body: The body requested to be updated on the router - - :returns: The body of the response as a dictionary. - """ - url = utils.urljoin(self.base_path, self.id, - 'remove_gateway_router') - resp = session.put(url, endpoint_filter=self.service, json=body) - return resp.json() - - -class L3AgentRouter(Router): - resource_key = 'router' - resources_key = 'routers' - base_path = '/agents/%(agent_id)s/l3-routers' - resource_name = 'l3-router' - service = network_service.NetworkService() - - # capabilities - allow_create = False - allow_retrieve = True - allow_update = False - allow_delete = False - allow_list = True - -# NOTE: No query parameter is supported diff --git a/openstack/network/v2/security_group.py b/openstack/network/v2/security_group.py deleted file mode 100644 index 2b7e0ff5..00000000 --- a/openstack/network/v2/security_group.py +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class SecurityGroup(resource.Resource): - resource_key = 'security_group' - resources_key = 'security_groups' - base_path = '/security-groups' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'description', 'name', - project_id='tenant_id', - ) - - # Properties - #: Timestamp when the security group was created. - created_at = resource.Body('created_at') - #: The security group description. - description = resource.Body('description') - #: The security group name. - name = resource.Body('name') - #: The ID of the project this security group is associated with. - project_id = resource.Body('tenant_id') - #: Revision number of the security group. *Type: int* - revision_number = resource.Body('revision_number', type=int) - #: A list of - #: :class:`~openstack.network.v2.security_group_rule.SecurityGroupRule` - #: objects. *Type: list* - security_group_rules = resource.Body('security_group_rules', type=list) - #: Timestamp when the security group was last updated. - updated_at = resource.Body('updated_at') diff --git a/openstack/network/v2/security_group_rule.py b/openstack/network/v2/security_group_rule.py deleted file mode 100644 index 6ea5e84a..00000000 --- a/openstack/network/v2/security_group_rule.py +++ /dev/null @@ -1,80 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class SecurityGroupRule(resource.Resource): - resource_key = 'security_group_rule' - resources_key = 'security_group_rules' - base_path = '/security-group-rules' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = False - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'description', 'direction', 'protocol', - 'remote_group_id', 'security_group_id', - ether_type='ethertype', - project_id='tenant_id', - - ) - - # Properties - #: Timestamp when the security group rule was created. - created_at = resource.Body('created_at') - #: The security group rule description. - description = resource.Body('description') - #: ``ingress`` or ``egress``: The direction in which the security group - #: rule is applied. For a compute instance, an ingress security group - #: rule is applied to incoming ingress traffic for that instance. - #: An egress rule is applied to traffic leaving the instance. - direction = resource.Body('direction') - #: Must be IPv4 or IPv6, and addresses represented in CIDR must match - #: the ingress or egress rules. - ether_type = resource.Body('ethertype') - #: The maximum port number in the range that is matched by the - #: security group rule. The port_range_min attribute constrains - #: the port_range_max attribute. If the protocol is ICMP, this - #: value must be an ICMP type. - port_range_max = resource.Body('port_range_max', type=int) - #: The minimum port number in the range that is matched by the - #: security group rule. If the protocol is TCP or UDP, this value - #: must be less than or equal to the value of the port_range_max - #: attribute. If the protocol is ICMP, this value must be an ICMP type. - port_range_min = resource.Body('port_range_min', type=int) - #: The ID of the project this security group rule is associated with. - project_id = resource.Body('tenant_id') - #: The protocol that is matched by the security group rule. - #: Valid values are ``null``, ``tcp``, ``udp``, and ``icmp``. - protocol = resource.Body('protocol') - #: The remote security group ID to be associated with this security - #: group rule. You can specify either ``remote_group_id`` or - #: ``remote_ip_prefix`` in the request body. - remote_group_id = resource.Body('remote_group_id') - #: The remote IP prefix to be associated with this security group rule. - #: You can specify either ``remote_group_id`` or ``remote_ip_prefix`` - #: in the request body. This attribute matches the specified IP prefix - #: as the source IP address of the IP packet. - remote_ip_prefix = resource.Body('remote_ip_prefix') - #: Revision number of the security group rule. *Type: int* - revision_number = resource.Body('revision_number', type=int) - #: The security group ID to associate with this security group rule. - security_group_id = resource.Body('security_group_id') - #: Timestamp when the security group rule was last updated. - updated_at = resource.Body('updated_at') diff --git a/openstack/network/v2/segment.py b/openstack/network/v2/segment.py deleted file mode 100644 index 8d211ecb..00000000 --- a/openstack/network/v2/segment.py +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class Segment(resource.Resource): - resource_key = 'segment' - resources_key = 'segments' - base_path = '/segments' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'description', 'name', 'network_id', 'network_type', - 'physical_network', 'segmentation_id', - ) - - # Properties - #: The segment description. - description = resource.Body('description') - #: The segment name. - name = resource.Body('name') - #: The ID of the network associated with this segment. - network_id = resource.Body('network_id') - #: The type of network associated with this segment, such as - #: ``flat``, ``geneve``, ``gre``, ``local``, ``vlan`` or ``vxlan``. - network_type = resource.Body('network_type') - #: The name of the physical network associated with this segment. - physical_network = resource.Body('physical_network') - #: The segmentation ID for this segment. The network type - #: defines the segmentation model, VLAN ID for ``vlan`` network type - #: and tunnel ID for ``geneve``, ``gre`` and ``vxlan`` network types. - #: *Type: int* - segmentation_id = resource.Body('segmentation_id', type=int) diff --git a/openstack/network/v2/service_profile.py b/openstack/network/v2/service_profile.py deleted file mode 100644 index 0af0a340..00000000 --- a/openstack/network/v2/service_profile.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class ServiceProfile(resource.Resource): - resource_key = 'service_profile' - resources_key = 'service_profiles' - base_path = '/service_profiles' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'description', 'driver', - is_enabled='enabled', - project_id='tenant_id' - ) - # Properties - #: Description of the service flavor profile. - description = resource.Body('description') - #: Provider driver for the service flavor profile - driver = resource.Body('driver') - #: Sets enabled flag - is_enabled = resource.Body('enabled', type=bool) - #: Metainformation of the service flavor profile - meta_info = resource.Body('metainfo') - #: The owner project ID - project_id = resource.Body('tenant_id') diff --git a/openstack/network/v2/service_provider.py b/openstack/network/v2/service_provider.py deleted file mode 100644 index 0f668030..00000000 --- a/openstack/network/v2/service_provider.py +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class ServiceProvider(resource.Resource): - resources_key = 'service_providers' - base_path = '/service-providers' - service = network_service.NetworkService() - - # Capabilities - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_list = True - - _query_mapping = resource.QueryParameters( - 'service_type', 'name', - is_default='default' - ) - - # Properties - #: Service type (FIREWALL, FLAVORS, METERING, QOS, etc..) - service_type = resource.Body('service_type') - #: Name of the service type - name = resource.Body('name') - #: The default value of service type - is_default = resource.Body('default', type=bool) diff --git a/openstack/network/v2/subnet.py b/openstack/network/v2/subnet.py deleted file mode 100644 index a9e95ad5..00000000 --- a/openstack/network/v2/subnet.py +++ /dev/null @@ -1,94 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack.network.v2 import tag -from openstack import resource2 as resource - - -class Subnet(resource.Resource, tag.TagMixin): - resource_key = 'subnet' - resources_key = 'subnets' - base_path = '/subnets' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # NOTE: Query on list or datetime fields are currently not supported. - _query_mapping = resource.QueryParameters( - 'cidr', 'description', 'gateway_ip', 'ip_version', - 'ipv6_address_mode', 'ipv6_ra_mode', 'name', 'network_id', - 'segment_id', - is_dhcp_enabled='enable_dhcp', - project_id='tenant_id', - subnet_pool_id='subnetpool_id', - use_default_subnet_pool='use_default_subnetpool', - **tag.TagMixin._tag_query_parameters - ) - - # Properties - #: List of allocation pools each of which has a start and an end address - #: for this subnet - allocation_pools = resource.Body('allocation_pools', type=list) - #: The CIDR. - cidr = resource.Body('cidr') - #: Timestamp when the subnet was created. - created_at = resource.Body('created_at') - #: The subnet description. - description = resource.Body('description') - #: A list of DNS nameservers. - dns_nameservers = resource.Body('dns_nameservers', type=list) - #: The gateway IP address. - gateway_ip = resource.Body('gateway_ip') - #: A list of host routes. - host_routes = resource.Body('host_routes', type=list) - #: The IP version, which is 4 or 6. - #: *Type: int* - ip_version = resource.Body('ip_version', type=int) - #: The IPv6 address modes which are 'dhcpv6-stateful', 'dhcpv6-stateless' - #: or 'slacc'. - ipv6_address_mode = resource.Body('ipv6_address_mode') - #: The IPv6 router advertisements modes which can be 'slaac', - #: 'dhcpv6-stateful', 'dhcpv6-stateless'. - ipv6_ra_mode = resource.Body('ipv6_ra_mode') - #: Set to ``True`` if DHCP is enabled and ``False`` if DHCP is disabled. - #: *Type: bool* - is_dhcp_enabled = resource.Body('enable_dhcp', type=bool) - #: The subnet name. - name = resource.Body('name') - #: The ID of the attached network. - network_id = resource.Body('network_id') - #: The ID of the project this subnet is associated with. - project_id = resource.Body('tenant_id') - #: Revision number of the subnet. *Type: int* - revision_number = resource.Body('revision_number', type=int) - #: The ID of the segment this subnet is associated with. - segment_id = resource.Body('segment_id') - #: Service types for this subnet - service_types = resource.Body('service_types', type=list) - #: The subnet pool ID from which to obtain a CIDR. - subnet_pool_id = resource.Body('subnetpool_id') - #: Timestamp when the subnet was last updated. - updated_at = resource.Body('updated_at') - #: Whether to use the default subnet pool to obtain a CIDR. - use_default_subnet_pool = resource.Body( - 'use_default_subnetpool', - type=bool - ) - #: A list of assocaited tags - #: *Type: list of tag strings* - tags = resource.Body('tags', type=list) diff --git a/openstack/network/v2/subnet_pool.py b/openstack/network/v2/subnet_pool.py deleted file mode 100644 index 86a43590..00000000 --- a/openstack/network/v2/subnet_pool.py +++ /dev/null @@ -1,84 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack.network.v2 import tag -from openstack import resource2 as resource - - -class SubnetPool(resource.Resource, tag.TagMixin): - resource_key = 'subnetpool' - resources_key = 'subnetpools' - base_path = '/subnetpools' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - _query_mapping = resource.QueryParameters( - 'address_scope_id', 'description', 'ip_version', 'is_default', - 'name', - is_shared='shared', - project_id='tenant_id', - **tag.TagMixin._tag_query_parameters - ) - - # Properties - #: The ID of the address scope associated with the subnet pool. - address_scope_id = resource.Body('address_scope_id') - #: Timestamp when the subnet pool was created. - created_at = resource.Body('created_at') - #: The length of the prefix to allocate when the cidr or prefixlen - #: attributes are omitted when creating a subnet. *Type: int* - default_prefix_length = resource.Body('default_prefixlen', type=int) - #: A per-project quota on the prefix space that can be allocated - #: from the subnet pool for project subnets. For IPv4 subnet pools, - #: default_quota is measured in units of /32. For IPv6 subnet pools, - #: default_quota is measured units of /64. All projects that use the - #: subnet pool have the same prefix quota applied. *Type: int* - default_quota = resource.Body('default_quota', type=int) - #: The subnet pool description. - description = resource.Body('description') - #: Read-only. The IP address family of the list of prefixes. - #: *Type: int* - ip_version = resource.Body('ip_version', type=int) - #: Whether or not this is the default subnet pool. - #: *Type: bool* - is_default = resource.Body('is_default', type=bool) - #: Indicates whether this subnet pool is shared across all projects. - #: *Type: bool* - is_shared = resource.Body('shared', type=bool) - #: The maximum prefix length that can be allocated from the - #: subnet pool. *Type: int* - maximum_prefix_length = resource.Body('max_prefixlen', type=int) - #: The minimum prefix length that can be allocated from the - #: subnet pool. *Type: int* - minimum_prefix_length = resource.Body('min_prefixlen', type=int) - #: The subnet pool name. - name = resource.Body('name') - #: The ID of the project that owns the subnet pool. - project_id = resource.Body('tenant_id') - #: A list of subnet prefixes that are assigned to the subnet pool. - #: The adjacent prefixes are merged and treated as a single prefix. - #: *Type: list* - prefixes = resource.Body('prefixes', type=list) - #: Revision number of the subnet pool. *Type: int* - revision_number = resource.Body('revision_number', type=int) - #: Timestamp when the subnet pool was last updated. - updated_at = resource.Body('updated_at') - #: A list of assocaited tags - #: *Type: list of tag strings* - tags = resource.Body('tags', type=list) diff --git a/openstack/network/v2/tag.py b/openstack/network/v2/tag.py deleted file mode 100644 index b216e2eb..00000000 --- a/openstack/network/v2/tag.py +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import utils - - -class TagMixin(object): - - _tag_query_parameters = { - 'tags': 'tags', - 'any_tags': 'tags-any', - 'not_tags': 'not-tags', - 'not_any_tags': 'not-tags-any', - } - - def set_tags(self, session, tags): - url = utils.urljoin(self.base_path, self.id, 'tags') - session.put(url, endpoint_filter=self.service, - json={'tags': tags}) - self._body.attributes.update({'tags': tags}) - return self diff --git a/openstack/network/v2/vpn_service.py b/openstack/network/v2/vpn_service.py deleted file mode 100644 index 55556b42..00000000 --- a/openstack/network/v2/vpn_service.py +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -# NOTE: The VPN service is unmaintained, need to consider remove it - -class VPNService(resource.Resource): - resource_key = 'vpnservice' - resources_key = 'vpnservices' - base_path = '/vpn/vpnservices' - service = network_service.NetworkService() - - # capabilities - allow_create = True - allow_get = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: Human-readable description for the vpnservice. - description = resource.Body('description') - #: The external IPv4 address that is used for the VPN service. - external_v4_ip = resource.Body('external_v4_ip') - #: The external IPv6 address that is used for the VPN service. - external_v6_ip = resource.Body('external_v6_ip') - #: The administrative state of the vpnservice, which is up ``True`` or - #: down ``False``. *Type: bool* - is_admin_state_up = resource.Body('admin_state_up', type=bool) - #: The vpnservice name. - name = resource.Body('name') - #: ID of the router into which the VPN service is inserted. - router_id = resource.Body('router_id') - #: The ID of the project this vpnservice is associated with. - project_id = resource.Body('tenant_id') - #: The vpnservice status. - status = resource.Body('status') - #: The ID of the subnet on which the tenant wants the vpnservice. - subnet_id = resource.Body('subnet_id') diff --git a/openstack/network/version.py b/openstack/network/version.py deleted file mode 100644 index a3b520b7..00000000 --- a/openstack/network/version.py +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network import network_service -from openstack import resource2 as resource - - -class Version(resource.Resource): - resource_key = 'version' - resources_key = 'versions' - base_path = '/' - service = network_service.NetworkService( - version=network_service.NetworkService.UNVERSIONED - ) - - # capabilities - allow_list = True - - # Properties - links = resource.Body('links') - status = resource.Body('status') diff --git a/openstack/object_store/__init__.py b/openstack/object_store/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/object_store/object_store_service.py b/openstack/object_store/object_store_service.py deleted file mode 100644 index 1f58b97c..00000000 --- a/openstack/object_store/object_store_service.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class ObjectStoreService(service_filter.ServiceFilter): - """The object store service.""" - - valid_versions = [service_filter.ValidVersion('v1')] - - def __init__(self, version=None): - """Create an object store service.""" - super(ObjectStoreService, self).__init__(service_type='object-store', - version=version) diff --git a/openstack/object_store/v1/__init__.py b/openstack/object_store/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/object_store/v1/_base.py b/openstack/object_store/v1/_base.py deleted file mode 100644 index 17df9355..00000000 --- a/openstack/object_store/v1/_base.py +++ /dev/null @@ -1,86 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may - -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.object_store import object_store_service -from openstack import resource - - -class BaseResource(resource.Resource): - service = object_store_service.ObjectStoreService() - - #: Metadata stored for this resource. *Type: dict* - metadata = dict() - - _custom_metadata_prefix = None - _system_metadata = dict() - - def _calculate_headers(self, metadata): - headers = dict() - for key in metadata: - if key in self._system_metadata: - header = self._system_metadata[key] - else: - header = self._custom_metadata_prefix + key - headers[header] = metadata[key] - return headers - - def set_metadata(self, session, metadata): - url = self._get_url(self, self.id) - session.post(url, endpoint_filter=self.service, - headers=self._calculate_headers(metadata)) - - def delete_metadata(self, session, keys): - url = self._get_url(self, self.id) - headers = {key: '' for key in keys} - session.post(url, endpoint_filter=self.service, - headers=self._calculate_headers(headers)) - - def _set_metadata(self): - self.metadata = dict() - headers = self.get_headers() - - for header in headers: - if header.startswith(self._custom_metadata_prefix): - key = header[len(self._custom_metadata_prefix):].lower() - self.metadata[key] = headers[header] - - def get(self, session, include_headers=False, args=None): - super(BaseResource, self).get(session, include_headers, args) - self._set_metadata() - return self - - def head(self, session): - super(BaseResource, self).head(session) - self._set_metadata() - return self - - @classmethod - def update_by_id(cls, session, resource_id, attrs, path_args=None): - """Update a Resource with the given attributes. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource_id: This resource's identifier, if needed by - the request. The default is ``None``. - :param dict attrs: The attributes to be sent in the body - of the request. - :param dict path_args: This parameter is sent by the base - class but is ignored for this method. - - :return: A ``dict`` representing the response headers. - """ - url = cls._get_url(None, resource_id) - headers = attrs.get(resource.HEADERS, dict()) - headers['Accept'] = '' - return session.post(url, endpoint_filter=cls.service, - headers=headers).headers diff --git a/openstack/object_store/v1/_proxy.py b/openstack/object_store/v1/_proxy.py deleted file mode 100644 index 78a48902..00000000 --- a/openstack/object_store/v1/_proxy.py +++ /dev/null @@ -1,318 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.object_store.v1 import account as _account -from openstack.object_store.v1 import container as _container -from openstack.object_store.v1 import obj as _obj -from openstack import proxy - - -class Proxy(proxy.BaseProxy): - - def get_account_metadata(self): - """Get metadata for this account. - - :rtype: - :class:`~openstack.object_store.v1.account.Account` - """ - return self._head(_account.Account) - - def set_account_metadata(self, **metadata): - """Set metadata for this account. - - :param kwargs metadata: Key/value pairs to be set as metadata - on the container. Custom metadata can be set. - Custom metadata are keys and values defined - by the user. - """ - account = self._get_resource(_account.Account, None) - account.set_metadata(self._session, metadata) - - def delete_account_metadata(self, keys): - """Delete metadata for this account. - - :param keys: The keys of metadata to be deleted. - """ - account = self._get_resource(_account.Account, None) - account.delete_metadata(self._session, keys) - - def containers(self, **query): - """Obtain Container objects for this account. - - :param kwargs query: Optional query parameters to be sent to limit - the resources being returned. - - :rtype: A generator of - :class:`~openstack.object_store.v1.container.Container` objects. - """ - return _container.Container.list(self._session, **query) - - def create_container(self, **attrs): - """Create a new container from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.object_store.v1.container.Container`, - comprised of the properties on the Container class. - - :returns: The results of container creation - :rtype: :class:`~openstack.object_store.v1.container.Container` - """ - return self._create(_container.Container, **attrs) - - def delete_container(self, container, ignore_missing=True): - """Delete a container - - :param container: The value can be either the name of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the container does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent server. - - :returns: ``None`` - """ - self._delete(_container.Container, container, - ignore_missing=ignore_missing) - - def get_container_metadata(self, container): - """Get metadata for a container - - :param container: The value can be the name of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - - :returns: One :class:`~openstack.object_store.v1.container.Container` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._head(_container.Container, container) - - def set_container_metadata(self, container, **metadata): - """Set metadata for a container. - - :param container: The value can be the name of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - :param kwargs metadata: Key/value pairs to be set as metadata - on the container. Both custom and system - metadata can be set. Custom metadata are keys - and values defined by the user. System - metadata are keys defined by the Object Store - and values defined by the user. The system - metadata keys are: - - - `content_type` - - `is_content_type_detected` - - `versions_location` - - `read_ACL` - - `write_ACL` - - `sync_to` - - `sync_key` - """ - res = self._get_resource(_container.Container, container) - res.set_metadata(self._session, metadata) - - def delete_container_metadata(self, container, keys): - """Delete metadata for a container. - - :param container: The value can be the ID of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - :param keys: The keys of metadata to be deleted. - """ - res = self._get_resource(_container.Container, container) - res.delete_metadata(self._session, keys) - - def objects(self, container, **query): - """Return a generator that yields the Container's objects. - - :param container: A container object or the name of a container - that you want to retrieve objects from. - :type container: - :class:`~openstack.object_store.v1.container.Container` - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :rtype: A generator of - :class:`~openstack.object_store.v1.obj.Object` objects. - """ - container = _container.Container.from_id(container) - - objs = _obj.Object.list(self._session, - path_args={"container": container.name}, - **query) - for obj in objs: - obj.container = container.name - yield obj - - def _get_container_name(self, obj, container): - if isinstance(obj, _obj.Object): - if obj.container is not None: - return obj.container - if container is not None: - container = _container.Container.from_id(container) - return container.name - - raise ValueError("container must be specified") - - def get_object(self, obj, container=None): - """Get the data associated with an object - - :param obj: The value can be the name of an object or a - :class:`~openstack.object_store.v1.obj.Object` instance. - :param container: The value can be the name of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - - :returns: The contents of the object. Use the - :func:`~get_object_metadata` - method if you want an object resource. - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - # TODO(briancurtin): call this download_object and make sure it's - # just returning the raw data, like download_image does - container_name = self._get_container_name(obj, container) - - return self._get(_obj.Object, obj, - path_args={"container": container_name}) - - def download_object(self, obj, container=None, path=None): - """Download the data contained inside an object to disk. - - :param obj: The value can be the name of an object or a - :class:`~openstack.object_store.v1.obj.Object` instance. - :param container: The value can be the name of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - :param path str: Location to write the object contents. - - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - # TODO(briancurtin): download_object should really have the behavior - # of get_object, and this writing to a file should not exist. - # TODO(briancurtin): This method should probably offload the get - # operation into another thread or something of that nature. - with open(path, "w") as out: - out.write(self.get_object(obj, container)) - - def upload_object(self, **attrs): - """Upload a new object from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.object_store.v1.obj.Object`, - comprised of the properties on the Object class. - **Required**: A `container` argument must be specified, - which is either the ID of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - - :returns: The results of object creation - :rtype: :class:`~openstack.object_store.v1.container.Container` - """ - container = attrs.pop("container", None) - container_name = self._get_container_name(None, container) - - return self._create(_obj.Object, - path_args={"container": container_name}, **attrs) - - def copy_object(self): - """Copy an object.""" - raise NotImplementedError - - def delete_object(self, obj, ignore_missing=True, container=None): - """Delete an object - - :param obj: The value can be either the name of an object or a - :class:`~openstack.object_store.v1.container.Container` - instance. - :param container: The value can be the ID of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the object does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent server. - - :returns: ``None`` - """ - container_name = self._get_container_name(obj, container) - - self._delete(_obj.Object, obj, ignore_missing=ignore_missing, - path_args={"container": container_name}) - - def get_object_metadata(self, obj, container=None): - """Get metadata for an object. - - :param obj: The value can be the name of an object or a - :class:`~openstack.object_store.v1.obj.Object` instance. - :param container: The value can be the ID of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - - :returns: One :class:`~openstack.object_store.v1.obj.Object` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - container_name = self._get_container_name(obj, container) - - return self._head(_obj.Object, obj, - path_args={"container": container_name}) - - def set_object_metadata(self, obj, container=None, **metadata): - """Set metadata for an object. - - Note: This method will do an extra HEAD call. - - :param obj: The value can be the name of an object or a - :class:`~openstack.object_store.v1.obj.Object` instance. - :param container: The value can be the name of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - :param kwargs metadata: Key/value pairs to be set as metadata - on the container. Both custom and system - metadata can be set. Custom metadata are keys - and values defined by the user. System - metadata are keys defined by the Object Store - and values defined by the user. The system - metadata keys are: - - - `content_type` - - `content_encoding` - - `content_disposition` - - `delete_after` - - `delete_at` - - `is_content_type_detected` - """ - container_name = self._get_container_name(obj, container) - res = self._get_resource(_obj.Object, obj, - path_args={"container": container_name}) - res.set_metadata(self._session, metadata) - - def delete_object_metadata(self, obj, container=None, keys=None): - """Delete metadata for an object. - - :param obj: The value can be the name of an object or a - :class:`~openstack.object_store.v1.obj.Object` instance. - :param container: The value can be the ID of a container or a - :class:`~openstack.object_store.v1.container.Container` - instance. - :param keys: The keys of metadata to be deleted. - """ - container_name = self._get_container_name(obj, container) - res = self._get_resource(_obj.Object, obj, - path_args={"container": container_name}) - res.delete_metadata(self._session, keys) diff --git a/openstack/object_store/v1/account.py b/openstack/object_store/v1/account.py deleted file mode 100644 index 8857882d..00000000 --- a/openstack/object_store/v1/account.py +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may - -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.object_store.v1 import _base -from openstack import resource - - -class Account(_base.BaseResource): - _custom_metadata_prefix = "X-Account-Meta-" - - base_path = "/" - - allow_retrieve = True - allow_update = True - allow_head = True - - #: The total number of bytes that are stored in Object Storage for - #: the account. - account_bytes_used = resource.header("x-account-bytes-used", type=int) - #: The number of containers. - account_container_count = resource.header("x-account-container-count", - type=int) - #: The number of objects in the account. - account_object_count = resource.header("x-account-object-count", type=int) - #: The secret key value for temporary URLs. If not set, - #: this header is not returned by this operation. - meta_temp_url_key = resource.header("x-account-meta-temp-url-key") - #: A second secret key value for temporary URLs. If not set, - #: this header is not returned by this operation. - meta_temp_url_key_2 = resource.header("x-account-meta-temp-url-key-2") - #: The timestamp of the transaction. - timestamp = resource.header("x-timestamp") diff --git a/openstack/object_store/v1/container.py b/openstack/object_store/v1/container.py deleted file mode 100644 index 678846d6..00000000 --- a/openstack/object_store/v1/container.py +++ /dev/null @@ -1,125 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may - -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.object_store.v1 import _base -from openstack import resource - - -class Container(_base.BaseResource): - _custom_metadata_prefix = "X-Container-Meta-" - _system_metadata = { - "content_type": "content-type", - "is_content_type_detected": "x-detect-content-type", - "versions_location": "x-versions-location", - "read_ACL": "x-container-read", - "write_ACL": "x-container-write", - "sync_to": "x-container-sync-to", - "sync_key": "x-container-sync-key" - } - - base_path = "/" - id_attribute = "name" - - allow_create = True - allow_retrieve = True - allow_update = True - allow_delete = True - allow_list = True - allow_head = True - - # Container body data (when id=None) - #: The name of the container. - name = resource.prop("name") - #: The number of objects in the container. - count = resource.prop("count") - #: The total number of bytes that are stored in Object Storage - #: for the container. - bytes = resource.prop("bytes") - - # Container metadata (when id=name) - #: The number of objects. - object_count = resource.header("x-container-object-count", type=int) - #: The count of bytes used in total. - bytes_used = resource.header("x-container-bytes-used", type=int) - #: The timestamp of the transaction. - timestamp = resource.header("x-timestamp") - - # Request headers (when id=None) - #: If set to True, Object Storage queries all replicas to return the - #: most recent one. If you omit this header, Object Storage responds - #: faster after it finds one valid replica. Because setting this - #: header to True is more expensive for the back end, use it only - #: when it is absolutely needed. *Type: bool* - is_newest = resource.header("x-newest", type=bool) - - # Request headers (when id=name) - #: The ACL that grants read access. If not set, this header is not - #: returned by this operation. - read_ACL = resource.header("x-container-read") - #: The ACL that grants write access. If not set, this header is not - #: returned by this operation. - write_ACL = resource.header("x-container-write") - #: The destination for container synchronization. If not set, - #: this header is not returned by this operation. - sync_to = resource.header("x-container-sync-to") - #: The secret key for container synchronization. If not set, - #: this header is not returned by this operation. - sync_key = resource.header("x-container-sync-key") - #: Enables versioning on this container. The value is the name - #: of another container. You must UTF-8-encode and then URL-encode - #: the name before you include it in the header. To disable - #: versioning, set the header to an empty string. - versions_location = resource.header("x-versions-location") - #: The MIME type of the list of names. - content_type = resource.header("content-type") - #: If set to true, Object Storage guesses the content type based - #: on the file extension and ignores the value sent in the - #: Content-Type header, if present. *Type: bool* - is_content_type_detected = resource.header("x-detect-content-type", - type=bool) - #: In combination with Expect: 100-Continue, specify an - #: "If-None-Match: \*" header to query whether the server already - #: has a copy of the object before any data is sent. - if_none_match = resource.header("if-none-match") - - @classmethod - def create_by_id(cls, session, attrs, resource_id=None): - """Create a Resource from its attributes. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param dict attrs: The attributes to be sent in the body - of the request. - :param resource_id: This resource's identifier, if needed by - the request. The default is ``None``. - - :return: A ``dict`` representing the response headers. - """ - url = cls._get_url(None, resource_id) - headers = attrs.get(resource.HEADERS, dict()) - headers['Accept'] = '' - return session.put(url, endpoint_filter=cls.service, - headers=headers).headers - - def create(self, session): - """Create a Resource from this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - - :return: This instance. - """ - resp = self.create_by_id(session, self._attrs, self.id) - self.set_headers(resp) - self._reset_dirty() - return self diff --git a/openstack/object_store/v1/obj.py b/openstack/object_store/v1/obj.py deleted file mode 100644 index 1be77ec1..00000000 --- a/openstack/object_store/v1/obj.py +++ /dev/null @@ -1,233 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may - -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from openstack.object_store import object_store_service -from openstack.object_store.v1 import _base -from openstack import resource - - -class Object(_base.BaseResource): - _custom_metadata_prefix = "X-Object-Meta-" - _system_metadata = { - "content_disposition": "content-disposition", - "content_encoding": "content-encoding", - "content_type": "content-type", - "delete_after": "x-delete-after", - "delete_at": "x-delete-at", - "is_content_type_detected": "x-detect-content-type", - } - - base_path = "/%(container)s" - service = object_store_service.ObjectStoreService() - id_attribute = "name" - - allow_create = True - allow_retrieve = True - allow_update = True - allow_delete = True - allow_list = True - allow_head = True - - # Data to be passed during a POST call to create an object on the server. - data = None - - # URL parameters - #: The unique name for the container. - container = resource.prop("container") - #: The unique name for the object. - name = resource.prop("name") - - # Object details - hash = resource.prop("hash") - bytes = resource.prop("bytes") - - # Headers for HEAD and GET requests - #: If set to True, Object Storage queries all replicas to return - #: the most recent one. If you omit this header, Object Storage - #: responds faster after it finds one valid replica. Because - #: setting this header to True is more expensive for the back end, - #: use it only when it is absolutely needed. *Type: bool* - is_newest = resource.header("x-newest", type=bool) - #: TODO(briancurtin) there's a lot of content here... - range = resource.header("range", type=dict) - #: See http://www.ietf.org/rfc/rfc2616.txt. - if_match = resource.header("if-match", type=dict) - #: In combination with Expect: 100-Continue, specify an - #: "If-None-Match: \*" header to query whether the server already - #: has a copy of the object before any data is sent. - if_none_match = resource.header("if-none-match", type=dict) - #: See http://www.ietf.org/rfc/rfc2616.txt. - if_modified_since = resource.header("if-modified-since", type=dict) - #: See http://www.ietf.org/rfc/rfc2616.txt. - if_unmodified_since = resource.header("if-unmodified-since", type=dict) - - # Query parameters - #: Used with temporary URLs to sign the request. For more - #: information about temporary URLs, see OpenStack Object Storage - #: API v1 Reference. - signature = resource.header("signature") - #: Used with temporary URLs to specify the expiry time of the - #: signature. For more information about temporary URLs, see - #: OpenStack Object Storage API v1 Reference. - expires_at = resource.header("expires") - #: If you include the multipart-manifest=get query parameter and - #: the object is a large object, the object contents are not - #: returned. Instead, the manifest is returned in the - #: X-Object-Manifest response header for dynamic large objects - #: or in the response body for static large objects. - multipart_manifest = resource.header("multipart-manifest") - - # Response headers from HEAD and GET - #: HEAD operations do not return content. However, in this - #: operation the value in the Content-Length header is not the - #: size of the response body. Instead it contains the size of - #: the object, in bytes. - content_length = resource.header("content-length") - #: The MIME type of the object. - content_type = resource.header("content-type") - #: The type of ranges that the object accepts. - accept_ranges = resource.header("accept-ranges") - #: For objects smaller than 5 GB, this value is the MD5 checksum - #: of the object content. The value is not quoted. - #: For manifest objects, this value is the MD5 checksum of the - #: concatenated string of MD5 checksums and ETags for each of - #: the segments in the manifest, and not the MD5 checksum of - #: the content that was downloaded. Also the value is enclosed - #: in double-quote characters. - #: You are strongly recommended to compute the MD5 checksum of - #: the response body as it is received and compare this value - #: with the one in the ETag header. If they differ, the content - #: was corrupted, so retry the operation. - etag = resource.header("etag") - #: Set to True if this object is a static large object manifest object. - #: *Type: bool* - is_static_large_object = resource.header("x-static-large-object", - type=bool) - #: If set, the value of the Content-Encoding metadata. - #: If not set, this header is not returned by this operation. - content_encoding = resource.header("content-encoding") - #: If set, specifies the override behavior for the browser. - #: For example, this header might specify that the browser use - #: a download program to save this file rather than show the file, - #: which is the default. - #: If not set, this header is not returned by this operation. - content_disposition = resource.header("content-disposition") - #: Specifies the number of seconds after which the object is - #: removed. Internally, the Object Storage system stores this - #: value in the X-Delete-At metadata item. - delete_after = resource.header("x-delete-after", type=int) - #: If set, the time when the object will be deleted by the system - #: in the format of a UNIX Epoch timestamp. - #: If not set, this header is not returned by this operation. - delete_at = resource.header("x-delete-at") - #: If set, to this is a dynamic large object manifest object. - #: The value is the container and object name prefix of the - #: segment objects in the form container/prefix. - object_manifest = resource.header("x-object-manifest") - #: The timestamp of the transaction. - timestamp = resource.header("x-timestamp") - #: The date and time that the object was created or the last - #: time that the metadata was changed. - last_modified_at = resource.header("last_modified", alias="last-modified") - - # Headers for PUT and POST requests - #: Set to chunked to enable chunked transfer encoding. If used, - #: do not set the Content-Length header to a non-zero value. - transfer_encoding = resource.header("transfer-encoding") - #: If set to true, Object Storage guesses the content type based - #: on the file extension and ignores the value sent in the - #: Content-Type header, if present. *Type: bool* - is_content_type_detected = resource.header("x-detect-content-type", - type=bool) - #: If set, this is the name of an object used to create the new - #: object by copying the X-Copy-From object. The value is in form - #: {container}/{object}. You must UTF-8-encode and then URL-encode - #: the names of the container and object before you include them - #: in the header. - #: Using PUT with X-Copy-From has the same effect as using the - #: COPY operation to copy an object. - copy_from = resource.header("x-copy-from") - - # The Object Store treats the metadata for its resources inconsistently so - # Object.set_metadata must override the BaseResource.set_metadata to - # account for it. - def set_metadata(self, session, metadata): - # Filter out items with empty values so the create metadata behaviour - # is the same as account and container - filtered_metadata = \ - {key: value for key, value in metadata.items() if value} - - # Get a copy of the original metadata so it doesn't get erased on POST - # and update it with the new metadata values. - obj = self.head(session) - metadata2 = copy.deepcopy(obj.metadata) - metadata2.update(filtered_metadata) - - # Include any original system metadata so it doesn't get erased on POST - for key in self._system_metadata: - value = getattr(obj, key) - if value and key not in metadata2: - metadata2[key] = value - - super(Object, self).set_metadata(session, metadata2) - - # The Object Store treats the metadata for its resources inconsistently so - # Object.delete_metadata must override the BaseResource.delete_metadata to - # account for it. - def delete_metadata(self, session, keys): - # Get a copy of the original metadata so it doesn't get erased on POST - # and update it with the new metadata values. - obj = self.head(session) - metadata = copy.deepcopy(obj.metadata) - - # Include any original system metadata so it doesn't get erased on POST - for key in self._system_metadata: - value = getattr(obj, key) - if value: - metadata[key] = value - - # Remove the metadata - for key in keys: - if key == 'delete_after': - del(metadata['delete_at']) - else: - del(metadata[key]) - - url = self._get_url(self, self.id) - session.post(url, endpoint_filter=self.service, - headers=self._calculate_headers(metadata)) - - def get(self, session, include_headers=False, args=None): - url = self._get_url(self, self.id) - headers = {'Accept': 'bytes'} - resp = session.get(url, endpoint_filter=self.service, headers=headers) - resp = resp.content - self._set_metadata() - return resp - - def create(self, session): - url = self._get_url(self, self.id) - - headers = self.get_headers() - headers['Accept'] = '' - if self.data is not None: - resp = session.put(url, endpoint_filter=self.service, - data=self.data, - headers=headers).headers - else: - resp = session.post(url, endpoint_filter=self.service, data=None, - headers=headers).headers - self.set_headers(resp) - return self diff --git a/openstack/orchestration/__init__.py b/openstack/orchestration/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/orchestration/orchestration_service.py b/openstack/orchestration/orchestration_service.py deleted file mode 100644 index 0333ff74..00000000 --- a/openstack/orchestration/orchestration_service.py +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class OrchestrationService(service_filter.ServiceFilter): - """The orchestration service.""" - - valid_versions = [service_filter.ValidVersion('v1')] - - def __init__(self, version=None): - """Create an orchestration service.""" - super(OrchestrationService, self).__init__( - service_type='orchestration', - version=version, - requires_project_id=True, - ) diff --git a/openstack/orchestration/v1/__init__.py b/openstack/orchestration/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/orchestration/v1/_proxy.py b/openstack/orchestration/v1/_proxy.py deleted file mode 100644 index fad49ccf..00000000 --- a/openstack/orchestration/v1/_proxy.py +++ /dev/null @@ -1,362 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import exceptions -from openstack.orchestration.v1 import resource as _resource -from openstack.orchestration.v1 import software_config as _sc -from openstack.orchestration.v1 import software_deployment as _sd -from openstack.orchestration.v1 import stack as _stack -from openstack.orchestration.v1 import stack_environment as _stack_environment -from openstack.orchestration.v1 import stack_files as _stack_files -from openstack.orchestration.v1 import stack_template as _stack_template -from openstack.orchestration.v1 import template as _template -from openstack import proxy2 - - -class Proxy(proxy2.BaseProxy): - - def create_stack(self, preview=False, **attrs): - """Create a new stack from attributes - - :param bool perview: When ``True``, returns - an :class:`~openstack.orchestration.v1.stack.StackPreview` object, - otherwise an :class:`~openstack.orchestration.v1.stack.Stack` - object. - *Default: ``False``* - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.orchestration.v1.stack.Stack`, - comprised of the properties on the Stack class. - - :returns: The results of stack creation - :rtype: :class:`~openstack.orchestration.v1.stack.Stack` - """ - res_type = _stack.StackPreview if preview else _stack.Stack - return self._create(res_type, **attrs) - - def find_stack(self, name_or_id, ignore_missing=True): - """Find a single stack - - :param name_or_id: The name or ID of a stack. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.orchestration.v1.stack.Stack` or None - """ - return self._find(_stack.Stack, name_or_id, - ignore_missing=ignore_missing) - - def stacks(self, **query): - """Return a generator of stacks - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of stack objects - :rtype: :class:`~openstack.orchestration.v1.stack.Stack` - """ - return self._list(_stack.Stack, paginated=False, **query) - - def get_stack(self, stack): - """Get a single stack - - :param stack: The value can be the ID of a stack or a - :class:`~openstack.orchestration.v1.stack.Stack` instance. - - :returns: One :class:`~openstack.orchestration.v1.stack.Stack` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_stack.Stack, stack) - - def update_stack(self, stack, **attrs): - """Update a stack - - :param stack: The value can be the ID of a stack or a - :class:`~openstack.orchestration.v1.stack.Stack` instance. - :param kwargs \*\*attrs: The attributes to update on the stack - represented by ``value``. - - :returns: The updated stack - :rtype: :class:`~openstack.orchestration.v1.stack.Stack` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._update(_stack.Stack, stack, **attrs) - - def delete_stack(self, stack, ignore_missing=True): - """Delete a stack - - :param stack: The value can be either the ID of a stack or a - :class:`~openstack.orchestration.v1.stack.Stack` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the stack does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent stack. - - :returns: ``None`` - """ - self._delete(_stack.Stack, stack, ignore_missing=ignore_missing) - - def check_stack(self, stack): - """Check a stack's status - - Since this is an asynchronous action, the only way to check the result - is to track the stack's status. - - :param stack: The value can be either the ID of a stack or an instance - of :class:`~openstack.orchestration.v1.stack.Stack`. - :returns: ``None`` - """ - if isinstance(stack, _stack.Stack): - stk_obj = stack - else: - stk_obj = _stack.Stack.existing(id=stack) - - stk_obj.check(self._session) - - def get_stack_template(self, stack): - """Get template used by a stack - - :param stack: The value can be the ID of a stack or an instance of - :class:`~openstack.orchestration.v1.stack.Stack` - - :returns: One object of - :class:`~openstack.orchestration.v1.stack_template.StackTemplate` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - if isinstance(stack, _stack.Stack): - obj = stack - else: - obj = self._find(_stack.Stack, stack, ignore_missing=False) - - return self._get(_stack_template.StackTemplate, requires_id=False, - stack_name=obj.name, stack_id=obj.id) - - def get_stack_environment(self, stack): - """Get environment used by a stack - - :param stack: The value can be the ID of a stack or an instance of - :class:`~openstack.orchestration.v1.stack.Stack` - - :returns: One object of - :class:`~openstack.orchestration.v1.stack_environment.\ - StackEnvironment` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - resource can be found. - """ - if isinstance(stack, _stack.Stack): - obj = stack - else: - obj = self._find(_stack.Stack, stack, ignore_missing=False) - - return self._get(_stack_environment.StackEnvironment, - requires_id=False, stack_name=obj.name, - stack_id=obj.id) - - def get_stack_files(self, stack): - """Get files used by a stack - - :param stack: The value can be the ID of a stack or an instance of - :class:`~openstack.orchestration.v1.stack.Stack` - - :returns: A dictionary containing the names and contents of all files - used by the stack. - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when the stack cannot be found. - """ - if isinstance(stack, _stack.Stack): - stk = stack - else: - stk = self._find(_stack.Stack, stack, ignore_missing=False) - - obj = _stack_files.StackFiles(stack_name=stk.name, stack_id=stk.id) - return obj.get(self._session) - - def resources(self, stack, **query): - """Return a generator of resources - - :param stack: This can be a stack object, or the name of a stack - for which the resources are to be listed. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of resource objects if the stack exists and - there are resources in it. If the stack cannot be found, - an exception is thrown. - :rtype: A generator of - :class:`~openstack.orchestration.v1.resource.Resource` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when the stack cannot be found. - """ - # first try treat the value as a stack object or an ID - if isinstance(stack, _stack.Stack): - obj = stack - else: - obj = self._find(_stack.Stack, stack, ignore_missing=False) - - return self._list(_resource.Resource, paginated=False, - stack_name=obj.name, stack_id=obj.id, **query) - - def create_software_config(self, **attrs): - """Create a new software config from attributes - - :param dict attrs: Keyword arguments which will be used to create a - :class:`~openstack.orchestration.v1.software_config.SoftwareConfig`, - comprised of the properties on the SoftwareConfig class. - - :returns: The results of software config creation - :rtype: - :class:`~openstack.orchestration.v1.software_config.SoftwareConfig` - """ - return self._create(_sc.SoftwareConfig, **attrs) - - def software_configs(self, **query): - """Returns a generator of software configs - - :param dict query: Optional query parameters to be sent to limit the - software configs returned. - :returns: A generator of software config objects. - :rtype: :class:`~openstack.orchestration.v1.software_config.\ - SoftwareConfig` - """ - return self._list(_sc.SoftwareConfig, paginated=True, **query) - - def get_software_config(self, software_config): - """Get details about a specific software config. - - :param software_config: The value can be the ID of a software config - or a instace of - :class:`~openstack.orchestration.v1.software_config.SoftwareConfig`, - - :returns: An object of type - :class:`~openstack.orchestration.v1.software_config.SoftwareConfig` - """ - return self._get(_sc.SoftwareConfig, software_config) - - def delete_software_config(self, software_config, ignore_missing=True): - """Delete a software config - - :param software_config: The value can be either the ID of a software - config or an instance of - :class:`~openstack.orchestration.v1.software_config.SoftwareConfig` - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the software config does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent software config. - :returns: ``None`` - """ - self._delete(_sc.SoftwareConfig, software_config, - ignore_missing=ignore_missing) - - def create_software_deployment(self, **attrs): - """Create a new software deployment from attributes - - :param dict attrs: Keyword arguments which will be used to create a - :class:`~openstack.orchestration.v1.software_deployment.SoftwareDeployment`, - comprised of the properties on the SoftwareDeployment class. - - :returns: The results of software deployment creation - :rtype: - :class:`~openstack.orchestration.v1.software_deployment.SoftwareDeployment` - """ - return self._create(_sd.SoftwareDeployment, **attrs) - - def software_deployments(self, **query): - """Returns a generator of software deployments - - :param dict query: Optional query parameters to be sent to limit the - software deployments returned. - :returns: A generator of software deployment objects. - :rtype: :class:`~openstack.orchestration.v1.software_deployment.\ - SoftwareDeployment` - """ - return self._list(_sd.SoftwareDeployment, paginated=False, **query) - - def get_software_deployment(self, software_deployment): - """Get details about a specific software deployment resource - - :param software_deployment: The value can be the ID of a software - deployment or an instace of - :class:`~openstack.orchestration.v1.software_deployment.SoftwareDeployment`, - - :returns: An object of type - :class:`~openstack.orchestration.v1.software_deployment.SoftwareDeployment` - """ - return self._get(_sd.SoftwareDeployment, software_deployment) - - def delete_software_deployment(self, software_deployment, - ignore_missing=True): - """Delete a software deployment - - :param software_deployment: The value can be either the ID of a - software deployment or an instance of - :class:`~openstack.orchestration.v1.software_deployment.SoftwareDeployment` - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the software deployment does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent software deployment. - :returns: ``None`` - """ - self._delete(_sd.SoftwareDeployment, software_deployment, - ignore_missing=ignore_missing) - - def update_software_deployment(self, software_deployment, **attrs): - """Update a software deployment - - :param server: Either the ID of a software deployment or an instance of - :class:`~openstack.orchestration.v1.software_deployment.SoftwareDeployment` - :param dict attrs: The attributes to update on the software deployment - represented by ``software_deployment``. - - :returns: The updated software deployment - :rtype: :class:`~openstack.orchestration.v1.software_deployment.\ - SoftwareDeployment` - """ - return self._update(_sd.SoftwareDeployment, software_deployment, - **attrs) - - def validate_template(self, template, environment=None, template_url=None, - ignore_errors=None): - """Validates a template. - - :param template: The stack template on which the validation is - performed. - :param environment: A JSON environment for the stack, if provided. - :param template_url: A URI to the location containing the stack - template for validation. This parameter is only - required if the ``template`` parameter is None. - This parameter is ignored if ``template`` is - specified. - :param ignore_errors: A string containing comma separated error codes - to ignore. Currently the only valid error code - is '99001'. - :returns: The result of template validation. - :raises: :class:`~openstack.exceptions.InvalidRequest` if neither - `template` not `template_url` is provided. - :raises: :class:`~openstack.exceptions.HttpException` if the template - fails the validation. - """ - if template is None and template_url is None: - raise exceptions.InvalidRequest( - "'template_url' must be specified when template is None") - - tmpl = _template.Template.new() - return tmpl.validate(self._session, template, environment=environment, - template_url=template_url, - ignore_errors=ignore_errors) diff --git a/openstack/orchestration/v1/resource.py b/openstack/orchestration/v1/resource.py deleted file mode 100644 index f2a0a563..00000000 --- a/openstack/orchestration/v1/resource.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.orchestration import orchestration_service -from openstack import resource2 as resource - - -class Resource(resource.Resource): - name_attribute = 'resource_name' - resource_key = 'resource' - resources_key = 'resources' - base_path = '/stacks/%(stack_name)s/%(stack_id)s/resources' - service = orchestration_service.OrchestrationService() - - # capabilities - allow_create = False - allow_list = True - allow_retrieve = False - allow_delete = False - allow_update = False - - # Properties - #: A list of dictionaries containing links relevant to the resource. - links = resource.Body('links') - #: ID of the logical resource, usually the literal name of the resource - #: as it appears in the stack template. - logical_resource_id = resource.Body('logical_resource_id', - alternate_id=True) - #: Name of the resource. - name = resource.Body('resource_name') - #: ID of the physical resource (if any) that backs up the resource. For - #: example, it contains a nova server ID if the resource is a nova - #: server. - physical_resource_id = resource.Body('physical_resource_id') - #: A list of resource names that depend on this resource. This - #: property facilitates the deduction of resource dependencies. - #: *Type: list* - required_by = resource.Body('required_by', type=list) - #: A string representation of the resource type. - resource_type = resource.Body('resource_type') - #: A string representing the status the resource is currently in. - status = resource.Body('resource_status') - #: A string that explains why the resource is in its current status. - status_reason = resource.Body('resource_status_reason') - #: Timestamp of the last update made to the resource. - updated_at = resource.Body('updated_time') diff --git a/openstack/orchestration/v1/software_config.py b/openstack/orchestration/v1/software_config.py deleted file mode 100644 index c0f12885..00000000 --- a/openstack/orchestration/v1/software_config.py +++ /dev/null @@ -1,53 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.orchestration import orchestration_service -from openstack import resource2 as resource - - -class SoftwareConfig(resource.Resource): - resource_key = 'software_config' - resources_key = 'software_configs' - base_path = '/software_configs' - service = orchestration_service.OrchestrationService() - - # capabilities - allow_create = True - allow_list = True - allow_get = True - allow_delete = True - allow_update = False - - # Properties - #: Configuration script or manifest that defines which configuration is - #: performed - config = resource.Body('config') - #: The date and time when the software config resource was created. - created_at = resource.Body('creation_time') - #: A string indicating the namespace used for grouping software configs. - group = resource.Body('group') - #: A list of schemas each representing an input this software config - #: expects. - inputs = resource.Body('inputs') - #: Name of the software config. - name = resource.Body('name') - #: A string that contains options that are specific to the configuraiton - #: management tool that this resource uses. - options = resource.Body('options') - #: A list of schemas each representing an output this software config - #: produces. - outputs = resource.Body('outputs') - - def create(self, session): - # This overrides the default behavior of resource creation because - # heat doesn't accept resource_key in its request. - return super(SoftwareConfig, self).create(session, prepend_key=False) diff --git a/openstack/orchestration/v1/software_deployment.py b/openstack/orchestration/v1/software_deployment.py deleted file mode 100644 index 3fb22eaf..00000000 --- a/openstack/orchestration/v1/software_deployment.py +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.orchestration import orchestration_service -from openstack import resource2 as resource - - -class SoftwareDeployment(resource.Resource): - resource_key = 'software_deployment' - resources_key = 'software_deployments' - base_path = '/software_deployments' - service = orchestration_service.OrchestrationService() - - # capabilities - allow_create = True - allow_list = True - allow_get = True - allow_delete = True - allow_update = True - - # Properties - #: The stack action that triggers this deployment resource. - action = resource.Body('action') - #: The UUID of the software config resource that runs when applying to the - #: server. - config_id = resource.Body('config_id') - #: A map containing the names and values of all inputs to the config. - input_values = resource.Body('input_values', type=dict) - #: A map containing the names and values from the deployment. - output_values = resource.Body('output_values', type=dict) - #: The UUID of the compute server to which the configuration applies. - server_id = resource.Body('server_id') - #: The ID of the authentication project which can also perform operations - #: on this deployment. - stack_user_project_id = resource.Body('stack_user_project_id') - #: Current status of the software deployment. - status = resource.Body('status') - #: Error description for the last status change. - status_reason = resource.Body('status_reason') - #: The date and time when the software deployment resource was created. - created_at = resource.Body('creation_time') - #: The date and time when the software deployment resource was created. - updated_at = resource.Body('updated_time') - - def create(self, session): - # This overrides the default behavior of resource creation because - # heat doesn't accept resource_key in its request. - return super(SoftwareDeployment, self).create( - session, prepend_key=False) - - def update(self, session): - # This overrides the default behavior of resource creation because - # heat doesn't accept resource_key in its request. - return super(SoftwareDeployment, self).update( - session, prepend_key=False) diff --git a/openstack/orchestration/v1/stack.py b/openstack/orchestration/v1/stack.py deleted file mode 100644 index 5445d11f..00000000 --- a/openstack/orchestration/v1/stack.py +++ /dev/null @@ -1,114 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import exceptions -from openstack.orchestration import orchestration_service -from openstack import resource2 as resource -from openstack import utils - - -class Stack(resource.Resource): - name_attribute = 'stack_name' - resource_key = 'stack' - resources_key = 'stacks' - base_path = '/stacks' - service = orchestration_service.OrchestrationService() - - # capabilities - allow_create = True - allow_list = True - allow_get = True - allow_update = True - allow_delete = True - - # Properties - #: Placeholder for AWS compatible template listing capabilities - #: required by the stack. - capabilities = resource.Body('capabilities') - #: Timestamp of the stack creation. - created_at = resource.Body('creation_time') - #: A text description of the stack. - description = resource.Body('description') - #: Whether the stack will support a rollback operation on stack - #: create/update failures. *Type: bool* - is_rollback_disabled = resource.Body('disable_rollback', type=bool) - #: A list of dictionaries containing links relevant to the stack. - links = resource.Body('links') - #: Name of the stack. - name = resource.Body('stack_name') - #: Placeholder for future extensions where stack related events - #: can be published. - notification_topics = resource.Body('notification_topics') - #: A list containing output keys and values from the stack, if any. - outputs = resource.Body('outputs') - #: The ID of the owner stack if any. - owner_id = resource.Body('stack_owner') - #: A dictionary containing the parameter names and values for the stack. - parameters = resource.Body('parameters', type=dict) - #: The ID of the parent stack if any - parent_id = resource.Body('parent') - #: A string representation of the stack status, e.g. ``CREATE_COMPLETE``. - status = resource.Body('stack_status') - #: A text explaining how the stack transits to its current status. - status_reason = resource.Body('stack_status_reason') - #: A list of strings used as tags on the stack - tags = resource.Body('tags') - #: A dict containing the template use for stack creation. - template = resource.Body('template', type=dict) - #: Stack template description text. Currently contains the same text - #: as that of the ``description`` property. - template_description = resource.Body('template_description') - #: A string containing the URL where a stack template can be found. - template_url = resource.Body('template_url') - #: Stack operation timeout in minutes. - timeout_mins = resource.Body('timeout_mins') - #: Timestamp of last update on the stack. - updated_at = resource.Body('updated_time') - #: The ID of the user project created for this stack. - user_project_id = resource.Body('stack_user_project_id') - - def create(self, session): - # This overrides the default behavior of resource creation because - # heat doesn't accept resource_key in its request. - return super(Stack, self).create(session, prepend_key=False) - - def update(self, session): - # This overrides the default behavior of resource creation because - # heat doesn't accept resource_key in its request. - return super(Stack, self).update(session, prepend_key=False, - has_body=False) - - def _action(self, session, body): - """Perform stack actions""" - url = utils.urljoin(self.base_path, self._get_id(self), 'actions') - resp = session.post(url, endpoint_filter=self.service, json=body) - return resp.json() - - def check(self, session): - return self._action(session, {'check': ''}) - - def get(self, session, requires_id=True): - stk = super(Stack, self).get(session, requires_id=requires_id) - if stk and stk.status in ['DELETE_COMPLETE', 'ADOPT_COMPLETE']: - raise exceptions.NotFoundException( - "No stack found for %s" % stk.id) - return stk - - -class StackPreview(Stack): - base_path = '/stacks/preview' - - allow_create = True - allow_list = False - allow_get = False - allow_update = False - allow_delete = False diff --git a/openstack/orchestration/v1/stack_environment.py b/openstack/orchestration/v1/stack_environment.py deleted file mode 100644 index 7ffc5d5f..00000000 --- a/openstack/orchestration/v1/stack_environment.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.orchestration import orchestration_service -from openstack import resource2 as resource - - -class StackEnvironment(resource.Resource): - - service = orchestration_service.OrchestrationService() - base_path = "/stacks/%(stack_name)s/%(stack_id)s/environment" - - # capabilities - allow_create = False - allow_list = False - allow_get = True - allow_delete = False - allow_update = False - - # Properties - #: Name of the stack where the template is referenced. - stack_name = resource.URI('stack_name') - #: ID of the stack where the template is referenced. - stack_id = resource.URI('stack_id') - #: A list of parameter names whose values are encrypted - encrypted_param_names = resource.Body('encrypted_param_names') - #: A list of event sinks - event_sinks = resource.Body('event_sinks') - #: A map of parameters and their default values defined for the stack. - parameter_defaults = resource.Body('parameter_defaults') - #: A map of parametes defined in the stack template. - parameters = resource.Body('parameters', type=dict) - #: A map containing customized resource definitions. - resource_registry = resource.Body('resource_registry', type=dict) diff --git a/openstack/orchestration/v1/stack_files.py b/openstack/orchestration/v1/stack_files.py deleted file mode 100644 index b1fb2457..00000000 --- a/openstack/orchestration/v1/stack_files.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.orchestration import orchestration_service -from openstack import resource2 as resource - - -class StackFiles(resource.Resource): - - service = orchestration_service.OrchestrationService() - base_path = "/stacks/%(stack_name)s/%(stack_id)s/files" - - # capabilities - allow_create = False - allow_list = False - allow_get = True - allow_delete = False - allow_update = False - - # Properties - #: Name of the stack where the template is referenced. - stack_name = resource.URI('stack_name') - #: ID of the stack where the template is referenced. - stack_id = resource.URI('stack_id') - - def get(self, session): - # The stack files response contains a map of filenames and file - # contents. - request = self._prepare_request(requires_id=False) - return session.get(request.uri, endpoint_filter=self.service) diff --git a/openstack/orchestration/v1/stack_template.py b/openstack/orchestration/v1/stack_template.py deleted file mode 100644 index 35b2db4c..00000000 --- a/openstack/orchestration/v1/stack_template.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.orchestration import orchestration_service -from openstack import resource2 as resource - - -class StackTemplate(resource.Resource): - - service = orchestration_service.OrchestrationService() - base_path = "/stacks/%(stack_name)s/%(stack_id)s/template" - - # capabilities - allow_create = False - allow_list = False - allow_get = True - allow_delete = False - allow_update = False - - # Properties - #: Name of the stack where the template is referenced. - stack_name = resource.URI('stack_name') - #: ID of the stack where the template is referenced. - stack_id = resource.URI('stack_id') - #: The description specified in the template - description = resource.Body('Description') - #: The version of the orchestration HOT template. - heat_template_version = resource.Body('heat_template_version') - #: Key and value that contain output data. - outputs = resource.Body('outputs', type=dict) - #: Key and value pairs that contain template parameters - parameters = resource.Body('parameters', type=dict) - #: Key and value pairs that contain definition of resources in the - #: template - resources = resource.Body('resources', type=dict) diff --git a/openstack/orchestration/v1/template.py b/openstack/orchestration/v1/template.py deleted file mode 100644 index 5c822726..00000000 --- a/openstack/orchestration/v1/template.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from six.moves.urllib import parse - -from openstack.orchestration import orchestration_service -from openstack import resource2 as resource - - -class Template(resource.Resource): - service = orchestration_service.OrchestrationService() - - # capabilities - allow_create = False - allow_list = False - allow_get = False - allow_delete = False - allow_update = False - - # Properties - #: The description specified in the template - description = resource.Body('Description') - #: Key and value pairs that contain template parameters - parameters = resource.Body('Parameters', type=dict) - #: A list of parameter groups each contains a lsit of parameter names. - parameter_groups = resource.Body('ParameterGroups', type=list) - - def validate(self, session, template, environment=None, template_url=None, - ignore_errors=None): - url = '/validate' - - body = {'template': template} - if environment is not None: - body['environment'] = environment - if template_url is not None: - body['template_url'] = template_url - if ignore_errors: - qry = parse.urlencode({'ignore_errors': ignore_errors}) - url = '?'.join([url, qry]) - - resp = session.post(url, endpoint_filter=self.service, json=body) - self._translate_response(resp) - return self diff --git a/openstack/orchestration/version.py b/openstack/orchestration/version.py deleted file mode 100644 index ecfdbc8e..00000000 --- a/openstack/orchestration/version.py +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.orchestration import orchestration_service -from openstack import resource2 as resource - - -class Version(resource.Resource): - resource_key = 'version' - resources_key = 'versions' - base_path = '/' - service = orchestration_service.OrchestrationService( - version=orchestration_service.OrchestrationService.UNVERSIONED - ) - - # capabilities - allow_list = True - - # Properties - links = resource.Body('links') - status = resource.Body('status') diff --git a/openstack/profile.py b/openstack/profile.py deleted file mode 100644 index 69994faf..00000000 --- a/openstack/profile.py +++ /dev/null @@ -1,210 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -:class:`~openstack.profile.Profile` is the class that is used to -define the various preferences for different services. The preferences that -are currently supported are service name, region, version and interface. -The :class:`~openstack.profile.Profile` and the -:class:`~openstack.connection.Connection` classes are the most important -user facing classes. - -Examples --------- - -The :class:`~openstack.profile.Profile` class is constructed -with no arguments. - -Set Methods -~~~~~~~~~~~ - -A user's preferences are set based on the service type. Service type would -normally be something like 'compute', 'identity', 'object-store', etc.:: - - from openstack import profile - prof = profile.Profile() - prof.set_name('compute', 'matrix') - prof.set_region(prof.ALL, 'zion') - prof.set_version('identity', 'v3') - prof.set_interface('object-store', 'internal') - for service in prof.get_services(): - print(prof.get_filter(service.service_type) - -The resulting preference print out would look something like:: - - service_type=compute,region=zion,service_name=matrix - service_type=network,region=zion - service_type=database,region=zion - service_type=image,region=zion - service_type=metering,region=zion - service_type=orchestration,region=zion - service_type=object-store,interface=internal,region=zion - service_type=identity,region=zion,version=v3 -""" - -import copy -import logging - -from openstack.bare_metal import bare_metal_service -from openstack.block_store import block_store_service -from openstack.cluster import cluster_service -from openstack.compute import compute_service -from openstack.database import database_service -from openstack import exceptions -from openstack.identity import identity_service -from openstack.image import image_service -from openstack.key_manager import key_manager_service -from openstack.load_balancer import load_balancer_service as lb_service -from openstack.message import message_service -from openstack import module_loader -from openstack.network import network_service -from openstack.object_store import object_store_service -from openstack.orchestration import orchestration_service -from openstack.telemetry.alarm import alarm_service -from openstack.telemetry import telemetry_service -from openstack.workflow import workflow_service - -_logger = logging.getLogger(__name__) - - -class Profile(object): - - ALL = "*" - """Wildcard service identifier representing all services.""" - - def __init__(self, plugins=None): - """User preference for each service. - - :param plugins: List of entry point namespaces to load. - - Create a new :class:`~openstack.profile.Profile` - object with no preferences defined, but knowledge of the services. - Services are identified by their service type, e.g.: 'identity', - 'compute', etc. - """ - self._services = {} - - self._add_service(alarm_service.AlarmService(version="v2")) - self._add_service(bare_metal_service.BareMetalService(version="v1")) - self._add_service(block_store_service.BlockStoreService(version="v2")) - self._add_service(cluster_service.ClusterService(version="v1")) - self._add_service(compute_service.ComputeService(version="v2")) - self._add_service(database_service.DatabaseService(version="v1")) - self._add_service(identity_service.IdentityService(version="v3")) - self._add_service(image_service.ImageService(version="v2")) - self._add_service(key_manager_service.KeyManagerService(version="v1")) - self._add_service(lb_service.LoadBalancerService(version="v2")) - self._add_service(message_service.MessageService(version="v1")) - self._add_service(network_service.NetworkService(version="v2")) - self._add_service( - object_store_service.ObjectStoreService(version="v1")) - self._add_service( - orchestration_service.OrchestrationService(version="v1")) - self._add_service(telemetry_service.TelemetryService(version="v2")) - self._add_service(workflow_service.WorkflowService(version="v2")) - - if plugins: - for plugin in plugins: - self._load_plugin(plugin) - self.service_keys = sorted(self._services.keys()) - - def __repr__(self): - return repr(self._services) - - def _add_service(self, serv): - serv.interface = None - self._services[serv.service_type] = serv - - def _load_plugin(self, namespace): - """Load a service plugin. - - :param str namespace: Entry point namespace - """ - services = module_loader.load_service_plugins(namespace) - for service_type in services: - if service_type in self._services: - _logger.debug("Overriding %s with %s", service_type, - services[service_type]) - self._add_service(services[service_type]) - - def get_filter(self, service): - """Get a service preference. - - :param str service: Desired service type. - """ - return copy.copy(self._get_filter(service)) - - def _get_filter(self, service): - """Get a service preference. - - :param str service: Desired service type. - """ - serv = self._services.get(service, None) - if serv is not None: - return serv - msg = ("Service %s not in list of valid services: %s" % - (service, self.service_keys)) - raise exceptions.SDKException(msg) - - def _get_services(self, service): - return self.service_keys if service == self.ALL else [service] - - def _setter(self, service, attr, value): - for service in self._get_services(service): - setattr(self._get_filter(service), attr, value) - - def get_services(self): - """Get a list of all the known services.""" - services = [] - for name, service in self._services.items(): - services.append(service) - return services - - def set_name(self, service, name): - """Set the desired name for the specified service. - - :param str service: Service type. - :param str name: Desired service name. - """ - self._setter(service, "service_name", name) - - def set_region(self, service, region): - """Set the desired region for the specified service. - - :param str service: Service type. - :param str region: Desired service region. - """ - self._setter(service, "region", region) - - def set_version(self, service, version): - """Set the desired version for the specified service. - - :param str service: Service type. - :param str version: Desired service version. - """ - self._get_filter(service).version = version - - def set_api_version(self, service, api_version): - """Set the desired API micro-version for the specified service. - - :param str service: Service type. - :param str api_version: Desired service API micro-version. - """ - self._setter(service, "api_version", api_version) - - def set_interface(self, service, interface): - """Set the desired interface for the specified service. - - :param str service: Service type. - :param str interface: Desired service interface. - """ - self._setter(service, "interface", interface) diff --git a/openstack/proxy.py b/openstack/proxy.py deleted file mode 100644 index cbe8616e..00000000 --- a/openstack/proxy.py +++ /dev/null @@ -1,296 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import exceptions -from openstack import resource - - -# The _check_resource decorator is used on BaseProxy methods to ensure that -# the `actual` argument is in fact the type of the `expected` argument. -# It does so under two cases: -# 1. When strict=False, if and only if `actual` is a Resource instance, -# it is checked to see that it's an instance of the `expected` class. -# This allows `actual` to be other types, such as strings, when it makes -# sense to accept a raw id value. -# 2. When strict=True, `actual` must be an instance of the `expected` class. -def _check_resource(strict=False): - def wrap(method): - def check(self, expected, actual=None, *args, **kwargs): - if (strict and actual is not None and not - isinstance(actual, resource.Resource)): - raise ValueError("A %s must be passed" % expected.__name__) - elif (isinstance(actual, resource.Resource) and not - isinstance(actual, expected)): - raise ValueError("Expected %s but received %s" % ( - expected.__name__, actual.__class__.__name__)) - - return method(self, expected, actual, *args, **kwargs) - return check - return wrap - - -class BaseProxy(object): - - def __init__(self, session): - self._session = session - - def _get_resource(self, resource_type, value, path_args=None): - """Get a resource object to work on - - :param resource_type: The type of resource to operate on. This should - be a subclass of - :class:`~openstack.resource.Resource` with a - ``from_id`` method. - :param value: The ID of a resource or an object of ``resource_type`` - class if using an existing instance, or None to create a - new instance. - :param path_args: A dict containing arguments for forming the request - URL, if needed. - """ - if value is None: - # Create a bare resource - res = resource_type() - elif not isinstance(value, resource_type): - # Create from an ID - args = {resource_type.id_attribute: - resource.Resource.get_id(value)} - res = resource_type.existing(**args) - else: - # An existing resource instance - res = value - - # Set any intermediate path arguments, but don't overwrite Nones. - if path_args is not None: - res.update_attrs(ignore_none=True, **path_args) - - return res - - def _find(self, resource_type, name_or_id, path_args=None, - ignore_missing=True): - """Find a resource - - :param name_or_id: The name or ID of a resource to find. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - - :returns: An instance of ``resource_type`` or None - """ - return resource_type.find(self._session, name_or_id, - path_args=path_args, - ignore_missing=ignore_missing) - - @_check_resource(strict=False) - def _delete(self, resource_type, value, path_args=None, - ignore_missing=True): - """Delete a resource - - :param resource_type: The type of resource to delete. This should - be a :class:`~openstack.resource.Resource` - subclass with a ``from_id`` method. - :param value: The value to delete. Can be either the ID of a - resource or a :class:`~openstack.resource.Resource` - subclass. - :param path_args: A dict containing arguments for forming the request - URL, if needed. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent resource. - - :returns: The result of the ``delete`` - :raises: ``ValueError`` if ``value`` is a - :class:`~openstack.resource.Resource` that doesn't match - the ``resource_type``. - :class:`~openstack.exceptions.ResourceNotFound` when - ignore_missing if ``False`` and a nonexistent resource - is attempted to be deleted. - - """ - res = self._get_resource(resource_type, value, path_args) - - try: - rv = res.delete(self._session) - except exceptions.NotFoundException as e: - if ignore_missing: - return None - else: - # Reraise with a more specific type and message - raise exceptions.ResourceNotFound( - message="No %s found for %s" % - (resource_type.__name__, value), - details=e.details, response=e.response, - request_id=e.request_id, url=e.url, method=e.method, - http_status=e.http_status, cause=e.cause) - - return rv - - @_check_resource(strict=False) - def _update(self, resource_type, value, path_args=None, **attrs): - """Update a resource - - :param resource_type: The type of resource to update. - :type resource_type: :class:`~openstack.resource.Resource` - :param value: The resource to update. This must either be a - :class:`~openstack.resource.Resource` or an id - that corresponds to a resource. - :param path_args: A dict containing arguments for forming the request - URL, if needed. - :param **attrs: Attributes to update on a Resource object. - These attributes will be used in conjunction with - ``resource_type``. - - :returns: The result of the ``update`` - :rtype: :class:`~openstack.resource.Resource` - """ - res = self._get_resource(resource_type, value, path_args) - res.update_attrs(attrs) - return res.update(self._session) - - def _create(self, resource_type, path_args=None, **attrs): - """Create a resource from attributes - - :param resource_type: The type of resource to create. - :type resource_type: :class:`~openstack.resource.Resource` - :param path_args: A dict containing arguments for forming the request - URL, if needed. - :param **attrs: Attributes from which to create a Resource object. - These attributes will be used in conjunction with - ``resource_type``. - - :returns: The result of the ``create`` - :rtype: :class:`~openstack.resource.Resource` - """ - res = resource_type.new(**attrs) - if path_args is not None: - res.update_attrs(path_args) - return res.create(self._session) - - @_check_resource(strict=False) - def _get(self, resource_type, value=None, path_args=None, args=None): - """Get a resource - - :param resource_type: The type of resource to get. - :type resource_type: :class:`~openstack.resource.Resource` - :param value: The value to get. Can be either the ID of a - resource or a :class:`~openstack.resource.Resource` - subclass. - :param path_args: A dict containing arguments for forming the request - URL, if needed. - :param args: A optional dict containing arguments that will be - translated into query strings when forming the request URL. - - :returns: The result of the ``get`` - :rtype: :class:`~openstack.resource.Resource` - """ - res = self._get_resource(resource_type, value, path_args) - - try: - return res.get(self._session, args=args) - except exceptions.NotFoundException as e: - raise exceptions.ResourceNotFound( - message="No %s found for %s" % - (resource_type.__name__, value), - details=e.details, response=e.response, - request_id=e.request_id, url=e.url, method=e.method, - http_status=e.http_status, cause=e.cause) - - def _list(self, resource_type, value=None, paginated=False, - path_args=None, **query): - """List a resource - - :param resource_type: The type of resource to delete. This should - be a :class:`~openstack.resource.Resource` - subclass with a ``from_id`` method. - :param value: The resource to list. It can be the ID of a resource, or - a :class:`~openstack.resource.Resource` object. When set - to None, a new bare resource is created. - :param bool paginated: When set to ``False``, expect all of the data - to be returned in one response. When set to - ``True``, the resource supports data being - returned across multiple pages. - :param path_args: A dictionary containing arguments for use when - forming the request URL for resource retrieval. - :param kwargs **query: Keyword arguments that are sent to the list - method, which are then attached as query - parameters on the request URL. - - :returns: A generator of Resource objects. - :raises: ``ValueError`` if ``value`` is a - :class:`~openstack.resource.Resource` that doesn't match - the ``resource_type``. - """ - res = self._get_resource(resource_type, value, path_args) - - query = res.convert_ids(query) - return res.list(self._session, path_args=path_args, - paginated=paginated, params=query) - - def _head(self, resource_type, value=None, path_args=None): - """Retrieve a resource's header - - :param resource_type: The type of resource to retrieve. - :type resource_type: :class:`~openstack.resource.Resource` - :param value: The value of a specific resource to retreive headers - for. Can be either the ID of a resource, - a :class:`~openstack.resource.Resource` subclass, - or ``None``. - :param path_args: A dict containing arguments for forming the request - URL, if needed. - - :returns: The result of the ``head`` call - :rtype: :class:`~openstack.resource.Resource` - """ - res = self._get_resource(resource_type, value, path_args) - - return res.head(self._session) - - def wait_for_status(self, value, status, failures=[], interval=2, - wait=120): - """Wait for a resource to be in a particular status. - - :param value: The resource to wait on to reach the status. The - resource must have a status attribute. - :type value: :class:`~openstack.resource.Resource` - :param status: Desired status of the resource. - :param list failures: Statuses that would indicate the transition - failed such as 'ERROR'. - :param interval: Number of seconds to wait between checks. - :param wait: Maximum number of seconds to wait for the change. - - :return: Method returns resource on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` transition - to status failed to occur in wait seconds. - :raises: :class:`~openstack.exceptions.ResourceFailure` resource - transitioned to one of the failure states. - :raises: :class:`~AttributeError` if the resource does not have a - status attribute - """ - return resource.wait_for_status(self._session, value, status, - failures, interval, wait) - - def wait_for_delete(self, value, interval=2, wait=120): - """Wait for the resource to be deleted. - - :param value: The resource to wait on to be deleted. - :type value: :class:`~openstack.resource.Resource` - :param interval: Number of seconds to wait between checks. - :param wait: Maximum number of seconds to wait for the delete. - - :return: Method returns resource on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` transition - to delete failed to occur in wait seconds. - """ - return resource.wait_for_delete(self._session, value, interval, wait) diff --git a/openstack/proxy2.py b/openstack/proxy2.py deleted file mode 100644 index 0a7fcb37..00000000 --- a/openstack/proxy2.py +++ /dev/null @@ -1,319 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import exceptions -from openstack import resource2 -from openstack import utils - - -# The _check_resource decorator is used on BaseProxy methods to ensure that -# the `actual` argument is in fact the type of the `expected` argument. -# It does so under two cases: -# 1. When strict=False, if and only if `actual` is a Resource instance, -# it is checked to see that it's an instance of the `expected` class. -# This allows `actual` to be other types, such as strings, when it makes -# sense to accept a raw id value. -# 2. When strict=True, `actual` must be an instance of the `expected` class. -def _check_resource(strict=False): - def wrap(method): - def check(self, expected, actual=None, *args, **kwargs): - if (strict and actual is not None and not - isinstance(actual, resource2.Resource)): - raise ValueError("A %s must be passed" % expected.__name__) - elif (isinstance(actual, resource2.Resource) and not - isinstance(actual, expected)): - raise ValueError("Expected %s but received %s" % ( - expected.__name__, actual.__class__.__name__)) - - return method(self, expected, actual, *args, **kwargs) - return check - return wrap - - -class BaseProxy(object): - - def __init__(self, session): - self._session = session - - def _get_resource(self, resource_type, value, **attrs): - """Get a resource object to work on - - :param resource_type: The type of resource to operate on. This should - be a subclass of - :class:`~openstack.resource2.Resource` with a - ``from_id`` method. - :param value: The ID of a resource or an object of ``resource_type`` - class if using an existing instance, or None to create a - new instance. - :param path_args: A dict containing arguments for forming the request - URL, if needed. - """ - if value is None: - # Create a bare resource - res = resource_type.new(**attrs) - elif not isinstance(value, resource_type): - # Create from an ID - res = resource_type.new(id=value, **attrs) - else: - # An existing resource instance - res = value - res._update(**attrs) - - return res - - def _get_uri_attribute(self, child, parent, name): - """Get a value to be associated with a URI attribute - - `child` will not be None here as it's a required argument - on the proxy method. `parent` is allowed to be None if `child` - is an actual resource, but when an ID is given for the child - one must also be provided for the parent. An example of this - is that a parent is a Server and a child is a ServerInterface. - """ - if parent is None: - value = getattr(child, name) - else: - value = resource2.Resource._get_id(parent) - return value - - def _find(self, resource_type, name_or_id, ignore_missing=True, - **attrs): - """Find a resource - - :param name_or_id: The name or ID of a resource to find. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource2. - :param dict attrs: Attributes to be passed onto the - :meth:`~openstack.resource2.Resource.find` - method, such as query parameters. - - :returns: An instance of ``resource_type`` or None - """ - return resource_type.find(self._session, name_or_id, - ignore_missing=ignore_missing, - **attrs) - - @_check_resource(strict=False) - def _delete(self, resource_type, value, ignore_missing=True, **attrs): - """Delete a resource - - :param resource_type: The type of resource to delete. This should - be a :class:`~openstack.resource2.Resource` - subclass with a ``from_id`` method. - :param value: The value to delete. Can be either the ID of a - resource or a :class:`~openstack.resource2.Resource` - subclass. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent resource2. - :param dict attrs: Attributes to be passed onto the - :meth:`~openstack.resource2.Resource.delete` - method, such as the ID of a parent resource. - - :returns: The result of the ``delete`` - :raises: ``ValueError`` if ``value`` is a - :class:`~openstack.resource2.Resource` that doesn't match - the ``resource_type``. - :class:`~openstack.exceptions.ResourceNotFound` when - ignore_missing if ``False`` and a nonexistent resource - is attempted to be deleted. - - """ - res = self._get_resource(resource_type, value, **attrs) - - try: - rv = res.delete(self._session) - except exceptions.NotFoundException as e: - if ignore_missing: - return None - else: - # Reraise with a more specific type and message - raise exceptions.ResourceNotFound( - message="No %s found for %s" % - (resource_type.__name__, value), - details=e.details, response=e.response, - request_id=e.request_id, url=e.url, method=e.method, - http_status=e.http_status, cause=e.cause) - - return rv - - @_check_resource(strict=False) - def _update(self, resource_type, value, **attrs): - """Update a resource - - :param resource_type: The type of resource to update. - :type resource_type: :class:`~openstack.resource2.Resource` - :param value: The resource to update. This must either be a - :class:`~openstack.resource2.Resource` or an id - that corresponds to a resource2. - :param dict attrs: Attributes to be passed onto the - :meth:`~openstack.resource2.Resource.update` - method to be updated. These should correspond - to either :class:`~openstack.resource2.Body` - or :class:`~openstack.resource2.Header` - values on this resource. - - :returns: The result of the ``update`` - :rtype: :class:`~openstack.resource2.Resource` - """ - res = self._get_resource(resource_type, value, **attrs) - return res.update(self._session) - - def _create(self, resource_type, **attrs): - """Create a resource from attributes - - :param resource_type: The type of resource to create. - :type resource_type: :class:`~openstack.resource2.Resource` - :param path_args: A dict containing arguments for forming the request - URL, if needed. - :param dict attrs: Attributes to be passed onto the - :meth:`~openstack.resource2.Resource.create` - method to be created. These should correspond - to either :class:`~openstack.resource2.Body` - or :class:`~openstack.resource2.Header` - values on this resource. - - :returns: The result of the ``create`` - :rtype: :class:`~openstack.resource2.Resource` - """ - res = resource_type.new(**attrs) - return res.create(self._session) - - @_check_resource(strict=False) - def _get(self, resource_type, value=None, requires_id=True, **attrs): - """Get a resource - - :param resource_type: The type of resource to get. - :type resource_type: :class:`~openstack.resource2.Resource` - :param value: The value to get. Can be either the ID of a - resource or a :class:`~openstack.resource2.Resource` - subclass. - :param dict attrs: Attributes to be passed onto the - :meth:`~openstack.resource2.Resource.get` - method. These should correspond - to either :class:`~openstack.resource2.Body` - or :class:`~openstack.resource2.Header` - values on this resource. - - :returns: The result of the ``get`` - :rtype: :class:`~openstack.resource2.Resource` - """ - res = self._get_resource(resource_type, value, **attrs) - - try: - return res.get(self._session, requires_id=requires_id) - except exceptions.NotFoundException as e: - raise exceptions.ResourceNotFound( - message="No %s found for %s" % - (resource_type.__name__, value), - details=e.details, response=e.response, - request_id=e.request_id, url=e.url, method=e.method, - http_status=e.http_status, cause=e.cause) - - def _list(self, resource_type, value=None, paginated=False, **attrs): - """List a resource - - :param resource_type: The type of resource to delete. This should - be a :class:`~openstack.resource2.Resource` - subclass with a ``from_id`` method. - :param value: The resource to list. It can be the ID of a resource, or - a :class:`~openstack.resource2.Resource` object. When set - to None, a new bare resource is created. - :param bool paginated: When set to ``False``, expect all of the data - to be returned in one response. When set to - ``True``, the resource supports data being - returned across multiple pages. - :param dict attrs: Attributes to be passed onto the - :meth:`~openstack.resource2.Resource.list` method. These should - correspond to either :class:`~openstack.resource2.URI` values - or appear in :data:`~openstack.resource2.Resource._query_mapping`. - - :returns: A generator of Resource objects. - :raises: ``ValueError`` if ``value`` is a - :class:`~openstack.resource2.Resource` that doesn't match - the ``resource_type``. - """ - res = self._get_resource(resource_type, value, **attrs) - return res.list(self._session, paginated=paginated, **attrs) - - def _head(self, resource_type, value=None, **attrs): - """Retrieve a resource's header - - :param resource_type: The type of resource to retrieve. - :type resource_type: :class:`~openstack.resource2.Resource` - :param value: The value of a specific resource to retreive headers - for. Can be either the ID of a resource, - a :class:`~openstack.resource2.Resource` subclass, - or ``None``. - :param dict attrs: Attributes to be passed onto the - :meth:`~openstack.resource2.Resource.head` method. - These should correspond to - :class:`~openstack.resource2.URI` values. - - :returns: The result of the ``head`` call - :rtype: :class:`~openstack.resource2.Resource` - """ - res = self._get_resource(resource_type, value, **attrs) - return res.head(self._session) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details=("This is no longer a part of the proxy base, " - "service-specific subclasses should expose " - "this as needed. See resource2.wait_for_status " - "for this behavior")) - def wait_for_status(self, value, status, failures=[], interval=2, - wait=120): - """Wait for a resource to be in a particular status. - - :param value: The resource to wait on to reach the status. The - resource must have a status attribute. - :type value: :class:`~openstack.resource2.Resource` - :param status: Desired status of the resource2. - :param list failures: Statuses that would indicate the transition - failed such as 'ERROR'. - :param interval: Number of seconds to wait between checks. - :param wait: Maximum number of seconds to wait for the change. - - :return: Method returns resource on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` transition - to status failed to occur in wait seconds. - :raises: :class:`~openstack.exceptions.ResourceFailure` resource - transitioned to one of the failure states. - :raises: :class:`~AttributeError` if the resource does not have a - status attribute - """ - return resource2.wait_for_status(self._session, value, status, - failures, interval, wait) - - @utils.deprecated(deprecated_in="0.9.14", removed_in="1.0", - details=("This is no longer a part of the proxy base, " - "service-specific subclasses should expose " - "this as needed. See resource2.wait_for_delete " - "for this behavior")) - def wait_for_delete(self, value, interval=2, wait=120): - """Wait for the resource to be deleted. - - :param value: The resource to wait on to be deleted. - :type value: :class:`~openstack.resource2.Resource` - :param interval: Number of seconds to wait between checks. - :param wait: Maximum number of seconds to wait for the delete. - - :return: Method returns resource on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` transition - to delete failed to occur in wait seconds. - """ - return resource2.wait_for_delete(self._session, value, interval, wait) diff --git a/openstack/resource.py b/openstack/resource.py deleted file mode 100644 index 2bc559e7..00000000 --- a/openstack/resource.py +++ /dev/null @@ -1,1034 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -The :class:`~openstack.resource.Resource` class is a base -class that represent a remote resource. Attributes of the resource -are defined by the responses from the server rather than in code so -that we don't have to try and keep up with all possible attributes -and extensions. This may be changed in the future. - -The :class:`~openstack.resource.prop` class is a helper for -definiting properties in a resource. - -For update management, :class:`~openstack.resource.Resource` -maintains a dirty list so when updating an object only the attributes -that have actually been changed are sent to the server. - -There is also some support here for lazy loading that needs improvement. - -There are plenty of examples of use of this class in the SDK code. -""" - -import abc -import collections -import copy -import itertools -import time - -import six -from six.moves.urllib import parse as url_parse - -from openstack import exceptions -from openstack import format -from openstack import utils - - -class prop(object): - """A helper for defining properties in a resource. - - A prop defines some known attributes within a resource's values. - For example we know a User resource will have a name: - - >>> class User(Resource): - ... name = prop('name') - ... - >>> u = User() - >>> u.name = 'John Doe' - >>> print u['name'] - John Doe - - User objects can now be accessed via the User().name attribute. The 'name' - value we pass as an attribute is the name of the attribute in the message. - This means that you don't need to use the same name for your attribute as - will be set within the object. For example: - - >>> class User(Resource): - ... name = prop('userName') - ... - >>> u = User() - >>> u.name = 'John Doe' - >>> print u['userName'] - John Doe - - There is limited validation ability in props. - - You can validate the type of values that are set: - - >>> class User(Resource): - ... name = prop('userName') - ... age = prop('age', type=int) - ... - >>> u = User() - >>> u.age = 'thirty' - TypeError: Invalid type for attr age - - - By specifying an alias attribute name, that alias will be read when the - primary attribute name does not appear within the resource: - - >>> class User(Resource): - ... name = prop('address', alias='location') - ... - >>> u = User(location='Far Away') - >>> print u['address'] - Far Away - """ - - def __init__(self, name, alias=None, type=None, default=None): - self.name = name - self.type = type - self.alias = alias - self.default = default - - def __get__(self, instance, owner): - if instance is None: - return None - try: - value = instance[self.name] - # self.type() should not be called on None objects. - if value is None: - return None - except KeyError: - try: - value = instance[self.alias] - except (KeyError, AttributeError): - # If we either don't find the key or we don't have an alias - return self.default - - if self.type and not isinstance(value, self.type): - if issubclass(self.type, Resource): - if isinstance(value, six.string_types): - value = self.type({self.type.id_attribute: value}) - else: - value = self.type(value) - elif issubclass(self.type, format.Formatter): - value = self.type.deserialize(value) - else: - value = self.type(value) - - return value - - def __set__(self, instance, value): - if (self.type and not isinstance(value, self.type) and - value != self.default): - if issubclass(self.type, Resource): - if isinstance(value, six.string_types): - value = self.type({self.type.id_attribute: value}) - else: - value = self.type(value) - elif issubclass(self.type, format.Formatter): - value = self.type.serialize(value) - else: - value = str(self.type(value)) # validate to fail fast - - # If we already have a value set for the alias name, pop it out - # and store the real name instead. This happens when the alias - # has the same name as this prop is named. - if self.alias in instance._attrs: - instance._attrs.pop(self.alias) - - instance[self.name] = value - - def __delete__(self, instance): - try: - del instance[self.name] - except KeyError: - try: - del instance[self.alias] - except KeyError: - pass - - -#: Key in attributes for header properties -HEADERS = 'headers' - - -class header(prop): - """A helper for defining header properties in a resource. - - This property should be used for values passed in the header of a resource. - Header values are stored in a special 'headers' attribute of a resource. - Using this property will make it easier for users to access those values. - For example, and object store container: - - >>> class Container(Resource): - ... name = prop("name") - ... object_count = header("x-container-object-count") - ... - >>> c = Container({name='pix'}) - >>> c.head(session) - >>> print c["headers"]["x-container-object-count"] - 4 - >>> print c.object_count - 4 - - The first print shows accessing the header value without the property - and the second print shows accessing the header with the property helper. - """ - - def _get_headers(self, instance): - if instance is None: - return None - if HEADERS in instance: - return instance[HEADERS] - return None - - def __get__(self, instance, owner): - headers = self._get_headers(instance) - return super(header, self).__get__(headers, owner) - - def __set__(self, instance, value): - headers = self._get_headers(instance) - if headers is None: - headers = instance._attrs[HEADERS] = {} - headers[self.name] = value - instance.set_headers(headers) - - -@six.add_metaclass(abc.ABCMeta) -class Resource(collections.MutableMapping): - - #: Singular form of key for resource. - resource_key = None - #: Common name for resource. - resource_name = None - #: Plural form of key for resource. - resources_key = None - - #: Attribute key associated with the id for this resource. - id_attribute = 'id' - #: Attribute key associated with the name for this resource. - name_attribute = 'name' - #: Attribute key associated with 'location' from response headers - location = header('location') - - #: The base part of the url for this resource. - base_path = '' - - #: The service associated with this resource to find the service URL. - service = None - - #: Allow create operation for this resource. - allow_create = False - #: Allow retrieve/get operation for this resource. - allow_retrieve = False - #: Allow update operation for this resource. - allow_update = False - #: Allow delete operation for this resource. - allow_delete = False - #: Allow list operation for this resource. - allow_list = False - #: Allow head operation for this resource. - allow_head = False - - patch_update = False - - def __init__(self, attrs=None, loaded=False): - """Construct a Resource to interact with a service's REST API. - - The Resource class offers two class methods to construct - resource objects, which are preferrable to entering through - this initializer. See :meth:`Resource.new` and - :meth:`Resource.existing`. - - :param dict attrs: The attributes to set when constructing - this Resource. - :param bool loaded: ``True`` if this Resource exists on - the server, ``False`` if it does not. - """ - self._attrs = {} if attrs is None else attrs.copy() - self._dirty = set() if loaded else set(self._attrs.keys()) - self.update_attrs(self._attrs) - self._loaded = loaded - - def __repr__(self): - return "%s.%s(attrs=%s, loaded=%s)" % (self.__module__, - self.__class__.__name__, - self._attrs, self._loaded) - - @classmethod - def get_resource_name(cls): - if cls.resource_name: - return cls.resource_name - if cls.resource_key: - return cls.resource_key - return cls().__class__.__name__ - - ## - # CONSTRUCTORS - ## - - @classmethod - def new(cls, **kwargs): - """Create a new instance of this resource. - - Internally set flags such that it is marked as not present on the - server. - - :param dict kwargs: Each of the named arguments will be set as - attributes on the resulting Resource object. - """ - return cls(kwargs, loaded=False) - - @classmethod - def existing(cls, **kwargs): - """Create an instance of an existing remote resource. - - It is marked as an exact replication of a resource present on a server. - - :param dict kwargs: Each of the named arguments will be set as - attributes on the resulting Resource object. - """ - return cls(kwargs, loaded=True) - - @classmethod - def _from_attr(cls, attribute, value): - # This method is useful in the higher level, in cases where operations - # need to depend on having Resource objects, but the API is flexible - # in taking text values which represent those objects. - if isinstance(value, cls): - return value - elif isinstance(value, six.string_types): - return cls.new(**{attribute: value}) - else: - raise ValueError("value must be %s instance or %s" % ( - cls.__name__, attribute)) - - @classmethod - def from_id(cls, value): - """Create an instance from an ID or return an existing instance. - - New instances are created with :meth:`~openstack.resource.Resource.new` - - :param value: If ``value`` is an instance of this Resource type, - it is returned. - If ``value`` is an ID which an instance of this - Resource type can be created with, one is created - and returned. - - :rtype: :class:`~openstack.resource.Resource` or the - appropriate subclass. - :raises: :exc:`ValueError` if ``value`` is not an instance of - this Resource type or a valid ``id``. - """ - return cls._from_attr(cls.id_attribute, value) - - @classmethod - def from_name(cls, value): - """Create an instance from a name or return an existing instance. - - New instances are created with :meth:`~openstack.resource.Resource.new` - - :param value: If ``value`` is an instance of this Resource type, - it is returned. - If ``value`` is a name which an instance of this - Resource type can be created with, one is created - and returned. - - :rtype: :class:`~openstack.resource.Resource` or the - appropriate subclass. - :raises: :exc:`ValueError` if ``value`` is not an instance of - this Resource type or a valid ``name``. - """ - return cls._from_attr(cls.name_attribute, value) - - ## - # MUTABLE MAPPING IMPLEMENTATION - ## - - def __getitem__(self, name): - return self._attrs[name] - - def __setitem__(self, name, value): - try: - orig = self._attrs[name] - except KeyError: - changed = True - else: - changed = orig != value - - if changed: - self._attrs[name] = value - self._dirty.add(name) - - def __delitem__(self, name): - del self._attrs[name] - self._dirty.add(name) - - def __len__(self): - return len(self._attrs) - - def __iter__(self): - return iter(self._attrs) - - ## - # BASE PROPERTIES/OPERATIONS - ## - - @property - def id(self): - """The identifier associated with this resource. - - The true value of the ``id`` property comes from the - attribute set as :data:`id_attribute`. For example, - a container's name may be the appropirate identifier, - so ``id_attribute = "name"`` would be set on the - :class:`Resource`, and ``Resource.name`` would be - conveniently accessible through ``id``. - """ - return self._attrs.get(self.id_attribute, None) - - @id.deleter - def id(self): - del self._attrs[self.id_attribute] - - @property - def name(self): - """The name associated with this resource. - - The true value of the ``name`` property comes from the - attribute set as :data:`name_attribute`. - """ - return self._attrs.get(self.name_attribute, None) - - @name.setter - def name(self, value): - self._attrs[self.name_attribute] = value - - @name.deleter - def name(self): - del self._attrs[self.name_attribute] - - @property - def is_dirty(self): - """True if the resource needs to be updated to the remote.""" - return len(self._dirty) > 0 - - def _reset_dirty(self): - self._dirty = set() - - def _update_attrs_from_response(self, resp, include_headers=False): - resp_headers = resp.pop(HEADERS, None) - self._attrs.update(resp) - self.update_attrs(self._attrs) - if include_headers and (resp_headers is not None): - self.set_headers(resp_headers) - - def update_attrs(self, *args, **kwargs): - """Update the attributes on this resource - - Note that this is implemented because Resource.update overrides - the update method we would get from the MutableMapping base class. - - :params args: A dictionary of attributes to be updated. - :params kwargs: Named arguments to be set on this instance. - When a key corresponds to a resource.prop, - it will be set via resource.prop.__set__. - - :rtype: None - """ - ignore_none = kwargs.pop("ignore_none", False) - - # ensure setters are called for type coercion - for key, value in itertools.chain(dict(*args).items(), kwargs.items()): - if key != self.id_attribute: # id property is read only - - # Don't allow None values to override a key unless we've - # explicitly specified they can. Proxy methods have default - # None arguments that we don't want to override any values - # that may have been passed in on Resource instances. - if not all([ignore_none, value is None]): - if key != "id": - setattr(self, key, value) - self[key] = value - - def get_headers(self): - if HEADERS in self._attrs: - return self._attrs[HEADERS] - return {} - - def set_headers(self, values): - self._attrs[HEADERS] = values - self._dirty.add(HEADERS) - - def to_dict(self): - attrs = copy.deepcopy(self._attrs) - headers = attrs.pop(HEADERS, {}) - attrs.update(headers) - return attrs - - ## - # CRUD OPERATIONS - ## - - @staticmethod - def get_id(value): - """If a value is a Resource, return the canonical ID.""" - if isinstance(value, Resource): - return value.id - else: - return value - - @staticmethod - def convert_ids(attrs): - """Return an attribute dictionary suitable for create/update - - As some attributes may be Resource types, their ``id`` attribute - needs to be put in the Resource instance's place in order - to be properly serialized and understood by the server. - """ - if attrs is None: - return - - converted = attrs.copy() - for key, value in converted.items(): - if isinstance(value, Resource): - converted[key] = value.id - - return converted - - @classmethod - def _get_create_body(cls, attrs): - if cls.resource_key: - return {cls.resource_key: attrs} - else: - return attrs - - @classmethod - def _get_url(cls, path_args=None, resource_id=None): - if path_args: - url = cls.base_path % path_args - else: - url = cls.base_path - if resource_id is not None: - url = utils.urljoin(url, resource_id) - return url - - @classmethod - def create_by_id(cls, session, attrs, resource_id=None, path_args=None): - """Create a remote resource from its attributes. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param dict attrs: The attributes to be sent in the body - of the request. - :param resource_id: This resource's identifier, if needed by - the request. The default is ``None``. - :param dict path_args: A dictionary of arguments to construct - a compound URL. - See `How path_args are used`_ for details. - - :return: A ``dict`` representing the response body. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_create` is not set to ``True``. - """ - if not cls.allow_create: - raise exceptions.MethodNotSupported(cls, 'create') - - # Convert attributes from Resource types into their ids. - attrs = cls.convert_ids(attrs) - headers = attrs.pop(HEADERS, None) - - body = cls._get_create_body(attrs) - - url = cls._get_url(path_args, resource_id) - args = {'json': body} - if headers: - args[HEADERS] = headers - if resource_id: - resp = session.put(url, endpoint_filter=cls.service, **args) - else: - resp = session.post(url, endpoint_filter=cls.service, **args) - resp_headers = resp.headers - resp = resp.json() - - if cls.resource_key: - resp = resp[cls.resource_key] - if resp_headers: - resp[HEADERS] = copy.deepcopy(resp_headers) - - return resp - - def create(self, session): - """Create a remote resource from this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - - :return: This :class:`Resource` instance. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_create` is not set to ``True``. - """ - resp = self.create_by_id(session, self._attrs, self.id, path_args=self) - self._update_attrs_from_response(resp, include_headers=True) - self._reset_dirty() - return self - - @classmethod - def get_data_by_id(cls, session, resource_id, path_args=None, args=None, - include_headers=False): - """Get the attributes of a remote resource from an id. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource_id: This resource's identifier, if needed by - the request. - :param dict path_args: A dictionary of arguments to construct - a compound URL. - See `How path_args are used`_ for details. - :param dict args: A dictionary of query parameters to be appended to - the compound URL. - :param bool include_headers: ``True`` if header data should be - included in the response body, - ``False`` if not. - - :return: A ``dict`` representing the response body. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_retrieve` is not set to ``True``. - """ - if not cls.allow_retrieve: - raise exceptions.MethodNotSupported(cls, 'retrieve') - - url = cls._get_url(path_args, resource_id) - if args: - url = '?'.join([url, url_parse.urlencode(args)]) - response = session.get(url, endpoint_filter=cls.service) - body = response.json() - - if cls.resource_key: - body = body[cls.resource_key] - - if include_headers: - body[HEADERS] = response.headers - - return body - - @classmethod - def get_by_id(cls, session, resource_id, path_args=None, - include_headers=False): - """Get an object representing a remote resource from an id. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource_id: This resource's identifier, if needed by - the request. - :param dict path_args: A dictionary of arguments to construct - a compound URL. - See `How path_args are used`_ for details. - :param bool include_headers: ``True`` if header data should be - included in the response body, - ``False`` if not. - - :return: A :class:`Resource` object representing the - response body. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_retrieve` is not set to ``True``. - """ - body = cls.get_data_by_id(session, resource_id, path_args=path_args, - include_headers=include_headers) - return cls.existing(**body) - - def get(self, session, include_headers=False, args=None): - """Get the remote resource associated with this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param bool include_headers: ``True`` if header data should be - included in the response body, - ``False`` if not. - :param dict args: A dictionary of query parameters to be appended to - the compound URL. - :return: This :class:`Resource` instance. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_retrieve` is not set to ``True``. - """ - body = self.get_data_by_id(session, self.id, path_args=self, args=args, - include_headers=include_headers) - self._update_attrs_from_response(body, include_headers) - self._loaded = True - return self - - @classmethod - def head_data_by_id(cls, session, resource_id, path_args=None): - """Get a dictionary representing the headers of a remote resource. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource_id: This resource's identifier, if needed by - the request. - :param dict path_args: A dictionary of arguments to construct - a compound URL. - See `How path_args are used`_ for details. - - :return: A ``dict`` containing the headers. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_head` is not set to ``True``. - """ - if not cls.allow_head: - raise exceptions.MethodNotSupported(cls, 'head') - - url = cls._get_url(path_args, resource_id) - - headers = {'Accept': ''} - resp = session.head(url, endpoint_filter=cls.service, headers=headers) - - return {HEADERS: resp.headers} - - @classmethod - def head_by_id(cls, session, resource_id, path_args=None): - """Get an object representing the headers of a remote resource. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource_id: This resource's identifier, if needed by - the request. - :param dict path_args: A dictionary of arguments to construct - a compound URL. - See `How path_args are used`_ for details. - - :return: A :class:`Resource` representing the headers. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_head` is not set to ``True``. - """ - data = cls.head_data_by_id(session, resource_id, path_args=path_args) - return cls.existing(**data) - - def head(self, session): - """Get the remote resource headers associated with this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - - :return: This :class:`Resource` instance. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_head` is not set to ``True``. - """ - data = self.head_data_by_id(session, self.id, path_args=self) - self._attrs.update(data) - self._loaded = True - return self - - @classmethod - def update_by_id(cls, session, resource_id, attrs, path_args=None): - """Update a remote resource with the given attributes. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource_id: This resource's identifier, if needed by - the request. - :param dict attrs: The attributes to be sent in the body - of the request. - :param dict path_args: A dictionary of arguments to construct - a compound URL. - See `How path_args are used`_ for details. - - :return: A ``dict`` representing the response body. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_update` is not set to ``True``. - """ - if not cls.allow_update: - raise exceptions.MethodNotSupported(cls, 'update') - - # Convert attributes from Resource types into their ids. - attrs = cls.convert_ids(attrs) - if attrs and cls.id_attribute in attrs: - del attrs[cls.id_attribute] - headers = attrs.pop(HEADERS, None) - - body = cls._get_create_body(attrs) - - url = cls._get_url(path_args, resource_id) - args = {'json': body} - if headers: - args[HEADERS] = headers - if cls.patch_update: - resp = session.patch(url, endpoint_filter=cls.service, **args) - else: - resp = session.put(url, endpoint_filter=cls.service, **args) - resp_headers = resp.headers - resp = resp.json() - - if cls.resource_key and cls.resource_key in resp.keys(): - resp = resp[cls.resource_key] - if resp_headers: - resp[HEADERS] = resp_headers - - return resp - - def update(self, session): - """Update the remote resource associated with this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - - :return: This :class:`Resource` instance. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_update` is not set to ``True``. - """ - if not self.is_dirty: - return - - dirty_attrs = dict((k, self._attrs[k]) for k in self._dirty) - resp = self.update_by_id(session, self.id, dirty_attrs, path_args=self) - - try: - resp_id = resp.pop(self.id_attribute) - except KeyError: - pass - else: - assert resp_id == self.id - self._update_attrs_from_response(resp, include_headers=True) - self._reset_dirty() - return self - - @classmethod - def delete_by_id(cls, session, resource_id, path_args=None): - """Delete a remote resource with the given id. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource_id: This resource's identifier, if needed by - the request. - :param dict path_args: A dictionary of arguments to construct - a compound URL. - See `How path_args are used`_ for details. - - :return: ``None`` - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_delete` is not set to ``True``. - """ - if not cls.allow_delete: - raise exceptions.MethodNotSupported(cls, 'delete') - - url = cls._get_url(path_args, resource_id) - headers = {'Accept': ''} - session.delete(url, endpoint_filter=cls.service, headers=headers) - - def delete(self, session): - """Delete the remote resource associated with this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - - :return: ``None`` - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_update` is not set to ``True``. - """ - self.delete_by_id(session, self.id, path_args=self) - - @classmethod - def list(cls, session, path_args=None, paginated=False, params=None): - """This method is a generator which yields resource objects. - - This resource object list generator handles pagination and takes query - params for response filtering. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param dict path_args: A dictionary of arguments to construct - a compound URL. - See `How path_args are used`_ for details. - :param bool paginated: ``True`` if a GET to this resource returns - a paginated series of responses, or ``False`` - if a GET returns only one page of data. - **When paginated is False only one - page of data will be returned regardless - of the API's support of pagination.** - :param dict params: Query parameters to be passed into the underlying - :meth:`~openstack.session.Session.get` method. - Values that the server may support include `limit` - and `marker`. - - :return: A generator of :class:`Resource` objects. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_list` is not set to ``True``. - """ - if not cls.allow_list: - raise exceptions.MethodNotSupported(cls, 'list') - - more_data = True - params = {} if params is None else params - url = cls._get_url(path_args) - headers = {'Accept': 'application/json'} - while more_data: - resp = session.get(url, endpoint_filter=cls.service, - headers=headers, params=params) - resp = resp.json() - if cls.resources_key: - resp = resp[cls.resources_key] - - if not resp: - more_data = False - - # Keep track of how many items we've yielded. If we yielded - # less than our limit, we don't need to do an extra request - # to get back an empty data set, which acts as a sentinel. - yielded = 0 - new_marker = None - for data in resp: - value = cls.existing(**data) - new_marker = value.id - yielded += 1 - yield value - - if not paginated: - return - if 'limit' in params and yielded < params['limit']: - return - params['limit'] = yielded - params['marker'] = new_marker - - @classmethod - def find(cls, session, name_or_id, path_args=None, ignore_missing=True): - """Find a resource by its name or id. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param name_or_id: This resource's identifier, if needed by - the request. The default is ``None``. - :param dict path_args: A dictionary of arguments to construct - a compound URL. - See `How path_args are used`_ for details. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - - :return: The :class:`Resource` object matching the given name or id - or None if nothing matches. - :raises: :class:`openstack.exceptions.DuplicateResource` if more - than one resource is found for this request. - :raises: :class:`openstack.exceptions.ResourceNotFound` if nothing - is found and ignore_missing is ``False``. - """ - # Only return one matching resource. - def get_one_match(results, the_id, the_name): - the_result = None - for item in results: - maybe_result = cls.existing(**item) - - id_value, name_value = None, None - if the_id is not None: - id_value = getattr(maybe_result, the_id, None) - if the_name is not None: - name_value = getattr(maybe_result, the_name, None) - - if (id_value == name_or_id) or (name_value == name_or_id): - # Only allow one resource to be found. If we already - # found a match, raise an exception to show it. - if the_result is None: - the_result = maybe_result - else: - msg = "More than one %s exists with the name '%s'." - msg = (msg % (cls.get_resource_name(), name_or_id)) - raise exceptions.DuplicateResource(msg) - - return the_result - - # Try to short-circuit by looking directly for a matching ID. - try: - if cls.allow_retrieve: - return cls.get_by_id(session, name_or_id, path_args=path_args) - except exceptions.NotFoundException: - pass - - data = cls.list(session, path_args=path_args) - - result = get_one_match(data, cls.id_attribute, cls.name_attribute) - if result is not None: - return result - - if ignore_missing: - return None - raise exceptions.ResourceNotFound( - "No %s found for %s" % (cls.__name__, name_or_id)) - - -def wait_for_status(session, resource, status, failures, interval, wait): - """Wait for the resource to be in a particular status. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource: The resource to wait on to reach the status. The resource - must have a status attribute. - :type resource: :class:`~openstack.resource.Resource` - :param status: Desired status of the resource. - :param list failures: Statuses that would indicate the transition - failed such as 'ERROR'. - :param interval: Number of seconds to wait between checks. - :param wait: Maximum number of seconds to wait for transition. - - :return: Method returns self on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` transition - to status failed to occur in wait seconds. - :raises: :class:`~openstack.exceptions.ResourceFailure` resource - transitioned to one of the failure states. - :raises: :class:`~AttributeError` if the resource does not have a status - attribute - """ - if resource.status == status: - return resource - - total_sleep = 0 - if failures is None: - failures = [] - - while total_sleep < wait: - resource.get(session) - if resource.status == status: - return resource - if resource.status in failures: - msg = ("Resource %s transitioned to failure state %s" % - (resource.id, resource.status)) - raise exceptions.ResourceFailure(msg) - time.sleep(interval) - total_sleep += interval - msg = "Timeout waiting for %s to transition to %s" % (resource.id, status) - raise exceptions.ResourceTimeout(msg) - - -def wait_for_delete(session, resource, interval, wait): - """Wait for the resource to be deleted. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource: The resource to wait on to be deleted. - :type resource: :class:`~openstack.resource.Resource` - :param interval: Number of seconds to wait between checks. - :param wait: Maximum number of seconds to wait for the delete. - - :return: Method returns self on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` transition - to status failed to occur in wait seconds. - """ - total_sleep = 0 - while total_sleep < wait: - try: - resource.get(session) - except exceptions.NotFoundException: - return resource - time.sleep(interval) - total_sleep += interval - msg = "Timeout waiting for %s delete" % (resource.id) - raise exceptions.ResourceTimeout(msg) diff --git a/openstack/resource2.py b/openstack/resource2.py deleted file mode 100644 index 7d8b0403..00000000 --- a/openstack/resource2.py +++ /dev/null @@ -1,893 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -The :class:`~openstack.resource.Resource` class is a base -class that represent a remote resource. The attributes that -comprise a request or response for this resource are specified -as class members on the Resource subclass where their values -are of a component type, including :class:`~openstack.resource2.Body`, -:class:`~openstack.resource2.Header`, and :class:`~openstack.resource2.URI`. - -For update management, :class:`~openstack.resource2.Resource` employs -a series of :class:`~openstack.resource2._ComponentManager` instances -to look after the attributes of that particular component type. This is -particularly useful for Body and Header types, so that only the values -necessary are sent in requests to the server. - -When making requests, each of the managers are looked at to gather the -necessary URI, body, and header data to build a request to be sent -via keystoneauth's sessions. Responses from keystoneauth are then -converted into this Resource class' appropriate components and types -and then returned to the caller. -""" - -import collections -import itertools -import time - -from openstack import exceptions -from openstack import format -from openstack import utils - - -class _BaseComponent(object): - - # The name this component is being tracked as in the Resource - key = None - - def __init__(self, name, type=None, default=None, alternate_id=False): - """A typed descriptor for a component that makes up a Resource - - :param name: The name this component exists as on the server - :param type: The type this component is expected to be by the server. - By default this is None, meaning any value you specify - will work. If you specify type=dict and then set a - component to a string, __set__ will fail, for example. - :param default: Typically None, but any other default can be set. - :param alternate_id: When `True`, this property is known - internally as a value that can be sent - with requests that require an ID but - when `id` is not a name the Resource has. - This is a relatively uncommon case, and this - setting should only be used once per Resource. - """ - self.name = name - self.type = type - self.default = default - self.alternate_id = alternate_id - - def __get__(self, instance, owner): - if instance is None: - return None - - attributes = getattr(instance, self.key) - - try: - value = attributes[self.name] - except KeyError: - return self.default - - # self.type() should not be called on None objects. - if value is None: - return None - - if self.type and not isinstance(value, self.type): - if issubclass(self.type, format.Formatter): - value = self.type.deserialize(value) - else: - value = self.type(value) - - return value - - def __set__(self, instance, value): - if (self.type and not isinstance(value, self.type) and - value != self.default): - if issubclass(self.type, format.Formatter): - value = self.type.serialize(value) - else: - value = str(self.type(value)) # validate to fail fast - - attributes = getattr(instance, self.key) - attributes[self.name] = value - - def __delete__(self, instance): - try: - attributes = getattr(instance, self.key) - del attributes[self.name] - except KeyError: - pass - - -class Body(_BaseComponent): - """Body attributes""" - - key = "_body" - - -class Header(_BaseComponent): - """Header attributes""" - - key = "_header" - - -class URI(_BaseComponent): - """URI attributes""" - - key = "_uri" - - -class _ComponentManager(collections.MutableMapping): - """Storage of a component type""" - - def __init__(self, attributes=None, synchronized=False): - self.attributes = dict() if attributes is None else attributes.copy() - self._dirty = set() if synchronized else set(self.attributes.keys()) - - def __getitem__(self, key): - return self.attributes[key] - - def __setitem__(self, key, value): - try: - orig = self.attributes[key] - except KeyError: - changed = True - else: - changed = orig != value - - if changed: - self.attributes[key] = value - self._dirty.add(key) - - def __delitem__(self, key): - del self.attributes[key] - self._dirty.add(key) - - def __iter__(self): - return iter(self.attributes) - - def __len__(self): - return len(self.attributes) - - @property - def dirty(self): - """Return a dict of modified attributes""" - return dict((key, self.attributes.get(key, None)) - for key in self._dirty) - - def clean(self): - """Signal that the resource no longer has modified attributes""" - self._dirty = set() - - -class _Request(object): - """Prepared components that go into a KSA request""" - - def __init__(self, uri, body, headers): - self.uri = uri - self.body = body - self.headers = headers - - -class QueryParameters(object): - - def __init__(self, *names, **mappings): - """Create a dict of accepted query parameters - - :param names: List of strings containing client-side query parameter - names. Each name in the list maps directly to the name - expected by the server. - - :param mappings: Key-value pairs where the key is the client-side - name we'll accept here and the value is the name - the server expects, e.g, changes_since=changes-since - - By default, both limit and marker are included in the initial mapping - as they're the most common query parameters used for listing resources. - """ - self._mapping = {"limit": "limit", "marker": "marker"} - self._mapping.update(dict({name: name for name in names}, **mappings)) - - def _transpose(self, query): - """Transpose the keys in query based on the mapping - - :param dict query: Collection of key-value pairs where each key is the - client-side parameter name to be transposed to its - server side name. - """ - result = {} - for key, value in self._mapping.items(): - if key in query: - result[value] = query[key] - return result - - -class Resource(object): - - #: Singular form of key for resource. - resource_key = None - #: Plural form of key for resource. - resources_key = None - - #: The ID of this resource. - id = Body("id") - #: The name of this resource. - name = Body("name") - #: The location of this resource. - location = Header("Location") - - #: Mapping of accepted query parameter names. - _query_mapping = QueryParameters() - - #: The base part of the URI for this resource. - base_path = "" - - #: The service associated with this resource to find the service URL. - service = None - - #: Allow create operation for this resource. - allow_create = False - #: Allow get operation for this resource. - allow_get = False - #: Allow update operation for this resource. - allow_update = False - #: Allow delete operation for this resource. - allow_delete = False - #: Allow list operation for this resource. - allow_list = False - #: Allow head operation for this resource. - allow_head = False - #: Use PATCH for update operations on this resource. - patch_update = False - #: Use PUT for create operations on this resource. - put_create = False - - def __init__(self, _synchronized=False, **attrs): - """The base resource - - :param bool _synchronized: This is not intended to be used directly. - See :meth:`~openstack.resource2.Resource.new` and - :meth:`~openstack.resource2.Resource.existing`. - """ - - # NOTE: _collect_attrs modifies **attrs in place, removing - # items as they match up with any of the body, header, - # or uri mappings. - body, header, uri = self._collect_attrs(attrs) - # TODO(briancurtin): at this point if attrs has anything left - # they're not being set anywhere. Log this? Raise exception? - # How strict should we be here? Should strict be an option? - - self._body = _ComponentManager(attributes=body, - synchronized=_synchronized) - self._header = _ComponentManager(attributes=header, - synchronized=_synchronized) - self._uri = _ComponentManager(attributes=uri, - synchronized=_synchronized) - - def __repr__(self): - pairs = ["%s=%s" % (k, v) for k, v in dict(itertools.chain( - self._body.attributes.items(), - self._header.attributes.items(), - self._uri.attributes.items())).items()] - args = ", ".join(pairs) - - return "%s.%s(%s)" % ( - self.__module__, self.__class__.__name__, args) - - def __eq__(self, comparand): - """Return True if another resource has the same contents""" - return all([self._body.attributes == comparand._body.attributes, - self._header.attributes == comparand._header.attributes, - self._uri.attributes == comparand._uri.attributes]) - - def __getattribute__(self, name): - """Return an attribute on this instance - - This is mostly a pass-through except for a specialization on - the 'id' name, as this can exist under a different name via the - `alternate_id` argument to resource.Body. - """ - if name == "id": - if name in self._body: - return self._body[name] - else: - try: - return self._body[self._alternate_id()] - except KeyError: - return None - else: - return object.__getattribute__(self, name) - - def _update(self, **attrs): - """Given attributes, update them on this instance - - This is intended to be used from within the proxy - layer when updating instances that may have already - been created. - """ - body, header, uri = self._collect_attrs(attrs) - - self._body.update(body) - self._header.update(header) - self._uri.update(uri) - - def _collect_attrs(self, attrs): - """Given attributes, return a dict per type of attribute - - This method splits up **attrs into separate dictionaries - that correspond to the relevant body, header, and uri - attributes that exist on this class. - """ - body = self._consume_attrs(self._body_mapping(), attrs) - header = self._consume_attrs(self._header_mapping(), attrs) - uri = self._consume_attrs(self._uri_mapping(), attrs) - - return body, header, uri - - def _consume_attrs(self, mapping, attrs): - """Given a mapping and attributes, return relevant matches - - This method finds keys in attrs that exist in the mapping, then - both transposes them to their server-side equivalent key name - to be returned, and finally pops them out of attrs. This allows - us to only calculate their place and existence in a particular - type of Resource component one time, rather than looking at the - same source dict several times. - """ - relevant_attrs = {} - consumed_keys = [] - for key in attrs: - if key in mapping: - # Convert client-side key names into server-side. - relevant_attrs[mapping[key]] = attrs[key] - consumed_keys.append(key) - elif key in mapping.values(): - # Server-side names can be stored directly. - relevant_attrs[key] = attrs[key] - consumed_keys.append(key) - - for key in consumed_keys: - attrs.pop(key) - - return relevant_attrs - - @classmethod - def _get_mapping(cls, component): - """Return a dict of attributes of a given component on the class""" - mapping = {} - # Since we're looking at class definitions we need to include - # subclasses, so check the whole MRO. - for klass in cls.__mro__: - for key, value in klass.__dict__.items(): - if isinstance(value, component): - # Make sure base classes don't end up overwriting - # mappings we've found previously in subclasses. - if key not in mapping: - mapping[key] = value.name - return mapping - - @classmethod - def _body_mapping(cls): - """Return all Body members of this class""" - return cls._get_mapping(Body) - - @classmethod - def _header_mapping(cls): - """Return all Header members of this class""" - return cls._get_mapping(Header) - - @classmethod - def _uri_mapping(cls): - """Return all URI members of this class""" - return cls._get_mapping(URI) - - @classmethod - def _alternate_id(cls): - """Return the name of any value known as an alternate_id - - NOTE: This will only ever return the first such alternate_id. - Only one alternate_id should be specified. - - Returns an empty string if no name exists, as this method is - consumed by _get_id and passed to getattr. - """ - for value in cls.__dict__.values(): - if isinstance(value, Body): - if value.alternate_id: - return value.name - return "" - - @staticmethod - def _get_id(value): - """If a value is a Resource, return the canonical ID - - This will return either the value specified by `id` or - `alternate_id` in that order if `value` is a Resource. - If `value` is anything other than a Resource, likely to - be a string already representing an ID, it is returned. - """ - if isinstance(value, Resource): - return value.id - else: - return value - - @classmethod - def new(cls, **kwargs): - """Create a new instance of this resource. - - When creating the instance set the ``_synchronized`` parameter - of :class:`Resource` to ``False`` to indicate that the resource does - not yet exist on the server side. This marks all attributes passed - in ``**kwargs`` as "dirty" on the resource, and thusly tracked - as necessary in subsequent calls such as :meth:`update`. - - :param dict kwargs: Each of the named arguments will be set as - attributes on the resulting Resource object. - """ - return cls(_synchronized=False, **kwargs) - - @classmethod - def existing(cls, **kwargs): - """Create an instance of an existing remote resource. - - When creating the instance set the ``_synchronized`` parameter - of :class:`Resource` to ``True`` to indicate that it represents the - state of an existing server-side resource. As such, all attributes - passed in ``**kwargs`` are considered "clean", such that an immediate - :meth:`update` call would not generate a body of attributes to be - modified on the server. - - :param dict kwargs: Each of the named arguments will be set as - attributes on the resulting Resource object. - """ - return cls(_synchronized=True, **kwargs) - - def to_dict(self, body=True, headers=True, ignore_none=False): - """Return a dictionary of this resource's contents - - :param bool body: Include the :class:`~openstack.resource2.Body` - attributes in the returned dictionary. - :param bool headers: Include the :class:`~openstack.resource2.Header` - attributes in the returned dictionary. - :param bool ignore_none: When True, exclude key/value pairs where - the value is None. This will exclude - attributes that the server hasn't returned. - - :return: A dictionary of key/value pairs where keys are named - as they exist as attributes of this class. - """ - mapping = {} - - components = [] - if body: - components.append(Body) - if headers: - components.append(Header) - if not components: - raise ValueError( - "At least one of `body` or `headers` must be True") - - # isinstance stricly requires this to be a tuple - components = tuple(components) - - # NOTE: This is similar to the implementation in _get_mapping - # but is slightly different in that we're looking at an instance - # and we're mapping names on this class to their actual stored - # values. - # Since we're looking at class definitions we need to include - # subclasses, so check the whole MRO. - for klass in self.__class__.__mro__: - for key, value in klass.__dict__.items(): - if isinstance(value, components): - # Make sure base classes don't end up overwriting - # mappings we've found previously in subclasses. - if key not in mapping: - value = getattr(self, key, None) - if ignore_none and value is None: - continue - mapping[key] = value - - return mapping - - def _prepare_request(self, requires_id=True, prepend_key=False): - """Prepare a request to be sent to the server - - Create operations don't require an ID, but all others do, - so only try to append an ID when it's needed with - requires_id. Create and update operations sometimes require - their bodies to be contained within an dict -- if the - instance contains a resource_key and prepend_key=True, - the body will be wrapped in a dict with that key. - - Return a _Request object that contains the constructed URI - as well a body and headers that are ready to send. - Only dirty body and header contents will be returned. - """ - body = self._body.dirty - if prepend_key and self.resource_key is not None: - body = {self.resource_key: body} - - headers = self._header.dirty - - uri = self.base_path % self._uri.attributes - if requires_id: - if self.id is None: - raise exceptions.InvalidRequest( - "Request requires an ID but none was found") - - uri = utils.urljoin(uri, self.id) - - return _Request(uri, body, headers) - - def _filter_component(self, component, mapping): - """Filter the keys in component based on a mapping - - This method converts a dict of server-side data to contain - only the appropriate keys for attributes on this instance. - """ - return {k: v for k, v in component.items() if k in mapping.values()} - - def _translate_response(self, response, has_body=True): - """Given a KSA response, inflate this instance with its data - - DELETE operations don't return a body, so only try to work - with a body when has_body is True. - - This method updates attributes that correspond to headers - and body on this instance and clears the dirty set. - """ - if has_body: - body = response.json() - if self.resource_key and self.resource_key in body: - body = body[self.resource_key] - - body = self._filter_component(body, self._body_mapping()) - self._body.attributes.update(body) - self._body.clean() - - headers = self._filter_component(response.headers, - self._header_mapping()) - self._header.attributes.update(headers) - self._header.clean() - - def create(self, session, prepend_key=True): - """Create a remote resource based on this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param prepend_key: A boolean indicating whether the resource_key - should be prepended in a resource creation - request. Default to True. - - :return: This :class:`Resource` instance. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_create` is not set to ``True``. - """ - if not self.allow_create: - raise exceptions.MethodNotSupported(self, "create") - - if self.put_create: - request = self._prepare_request(requires_id=True, - prepend_key=prepend_key) - response = session.put(request.uri, endpoint_filter=self.service, - json=request.body, headers=request.headers) - else: - request = self._prepare_request(requires_id=False, - prepend_key=prepend_key) - response = session.post(request.uri, endpoint_filter=self.service, - json=request.body, headers=request.headers) - - self._translate_response(response) - return self - - def get(self, session, requires_id=True): - """Get a remote resource based on this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param boolean requires_id: A boolean indicating whether resource ID - should be part of the requested URI. - :return: This :class:`Resource` instance. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_get` is not set to ``True``. - """ - if not self.allow_get: - raise exceptions.MethodNotSupported(self, "get") - - request = self._prepare_request(requires_id=requires_id) - response = session.get(request.uri, endpoint_filter=self.service) - - self._translate_response(response) - return self - - def head(self, session): - """Get headers from a remote resource based on this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - - :return: This :class:`Resource` instance. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_head` is not set to ``True``. - """ - if not self.allow_head: - raise exceptions.MethodNotSupported(self, "head") - - request = self._prepare_request() - - response = session.head(request.uri, endpoint_filter=self.service, - headers={"Accept": ""}) - - self._translate_response(response) - return self - - def update(self, session, prepend_key=True, has_body=True): - """Update the remote resource based on this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param prepend_key: A boolean indicating whether the resource_key - should be prepended in a resource update request. - Default to True. - - :return: This :class:`Resource` instance. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_update` is not set to ``True``. - """ - # The id cannot be dirty for an update - self._body._dirty.discard("id") - - # Only try to update if we actually have anything to update. - if not any([self._body.dirty, self._header.dirty]): - return self - - if not self.allow_update: - raise exceptions.MethodNotSupported(self, "update") - - request = self._prepare_request(prepend_key=prepend_key) - - if self.patch_update: - response = session.patch(request.uri, endpoint_filter=self.service, - json=request.body, - headers=request.headers) - else: - response = session.put(request.uri, endpoint_filter=self.service, - json=request.body, headers=request.headers) - - self._translate_response(response, has_body=has_body) - return self - - def delete(self, session): - """Delete the remote resource based on this instance. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - - :return: This :class:`Resource` instance. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_update` is not set to ``True``. - """ - if not self.allow_delete: - raise exceptions.MethodNotSupported(self, "delete") - - request = self._prepare_request() - - response = session.delete(request.uri, endpoint_filter=self.service, - headers={"Accept": ""}) - - self._translate_response(response, has_body=False) - return self - - @classmethod - def list(cls, session, paginated=False, **params): - """This method is a generator which yields resource objects. - - This resource object list generator handles pagination and takes query - params for response filtering. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param bool paginated: ``True`` if a GET to this resource returns - a paginated series of responses, or ``False`` - if a GET returns only one page of data. - **When paginated is False only one - page of data will be returned regardless - of the API's support of pagination.** - :param dict params: These keyword arguments are passed through the - :meth:`~openstack.resource2.QueryParamter._transpose` method - to find if any of them match expected query parameters to be - sent in the *params* argument to - :meth:`~openstack.session.Session.get`. They are additionally - checked against the - :data:`~openstack.resource2.Resource.base_path` format string - to see if any path fragments need to be filled in by the contents - of this argument. - - :return: A generator of :class:`Resource` objects. - :raises: :exc:`~openstack.exceptions.MethodNotSupported` if - :data:`Resource.allow_list` is not set to ``True``. - """ - if not cls.allow_list: - raise exceptions.MethodNotSupported(cls, "list") - - more_data = True - query_params = cls._query_mapping._transpose(params) - uri = cls.base_path % params - - while more_data: - resp = session.get(uri, endpoint_filter=cls.service, - headers={"Accept": "application/json"}, - params=query_params) - resp = resp.json() - if cls.resources_key: - resp = resp[cls.resources_key] - - if not resp: - more_data = False - - # Keep track of how many items we've yielded. If we yielded - # less than our limit, we don't need to do an extra request - # to get back an empty data set, which acts as a sentinel. - yielded = 0 - new_marker = None - for data in resp: - # Do not allow keys called "self" through. Glance chose - # to name a key "self", so we need to pop it out because - # we can't send it through cls.existing and into the - # Resource initializer. "self" is already the first - # argument and is practically a reserved word. - data.pop("self", None) - - value = cls.existing(**data) - new_marker = value.id - yielded += 1 - yield value - - if not paginated: - return - if "limit" in query_params and yielded < query_params["limit"]: - return - query_params["limit"] = yielded - query_params["marker"] = new_marker - - @classmethod - def _get_one_match(cls, name_or_id, results): - """Given a list of results, return the match""" - the_result = None - for maybe_result in results: - id_value = cls._get_id(maybe_result) - name_value = maybe_result.name - - if (id_value == name_or_id) or (name_value == name_or_id): - # Only allow one resource to be found. If we already - # found a match, raise an exception to show it. - if the_result is None: - the_result = maybe_result - else: - msg = "More than one %s exists with the name '%s'." - msg = (msg % (cls.__name__, name_or_id)) - raise exceptions.DuplicateResource(msg) - - return the_result - - @classmethod - def find(cls, session, name_or_id, ignore_missing=True, **params): - """Find a resource by its name or id. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param name_or_id: This resource's identifier, if needed by - the request. The default is ``None``. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :param dict params: Any additional parameters to be passed into - underlying methods, such as to - :meth:`~openstack.resource2.Resource.existing` - in order to pass on URI parameters. - - :return: The :class:`Resource` object matching the given name or id - or None if nothing matches. - :raises: :class:`openstack.exceptions.DuplicateResource` if more - than one resource is found for this request. - :raises: :class:`openstack.exceptions.ResourceNotFound` if nothing - is found and ignore_missing is ``False``. - """ - # Try to short-circuit by looking directly for a matching ID. - try: - match = cls.existing(id=name_or_id, **params) - return match.get(session) - except exceptions.NotFoundException: - pass - - data = cls.list(session, **params) - - result = cls._get_one_match(name_or_id, data) - if result is not None: - return result - - if ignore_missing: - return None - raise exceptions.ResourceNotFound( - "No %s found for %s" % (cls.__name__, name_or_id)) - - -def wait_for_status(session, resource, status, failures, interval, wait): - """Wait for the resource to be in a particular status. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource: The resource to wait on to reach the status. The resource - must have a status attribute. - :type resource: :class:`~openstack.resource.Resource` - :param status: Desired status of the resource. - :param list failures: Statuses that would indicate the transition - failed such as 'ERROR'. - :param interval: Number of seconds to wait between checks. - :param wait: Maximum number of seconds to wait for transition. - - :return: Method returns self on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` transition - to status failed to occur in wait seconds. - :raises: :class:`~openstack.exceptions.ResourceFailure` resource - transitioned to one of the failure states. - :raises: :class:`~AttributeError` if the resource does not have a status - attribute - """ - if resource.status == status: - return resource - - total_sleep = 0 - if failures is None: - failures = [] - - while total_sleep < wait: - resource.get(session) - if resource.status == status: - return resource - if resource.status in failures: - msg = ("Resource %s transitioned to failure state %s" % - (resource.id, resource.status)) - raise exceptions.ResourceFailure(msg) - time.sleep(interval) - total_sleep += interval - msg = "Timeout waiting for %s to transition to %s" % (resource.id, status) - raise exceptions.ResourceTimeout(msg) - - -def wait_for_delete(session, resource, interval, wait): - """Wait for the resource to be deleted. - - :param session: The session to use for making this request. - :type session: :class:`~openstack.session.Session` - :param resource: The resource to wait on to be deleted. - :type resource: :class:`~openstack.resource.Resource` - :param interval: Number of seconds to wait between checks. - :param wait: Maximum number of seconds to wait for the delete. - - :return: Method returns self on success. - :raises: :class:`~openstack.exceptions.ResourceTimeout` transition - to status failed to occur in wait seconds. - """ - total_sleep = 0 - while total_sleep < wait: - try: - resource.get(session) - except exceptions.NotFoundException: - return resource - time.sleep(interval) - total_sleep += interval - msg = "Timeout waiting for %s delete" % (resource.id) - raise exceptions.ResourceTimeout(msg) diff --git a/openstack/service_filter.py b/openstack/service_filter.py deleted file mode 100644 index 95bc2aa1..00000000 --- a/openstack/service_filter.py +++ /dev/null @@ -1,191 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -The :class:`~openstack.service_filter.ServiceFilter` is the base class -for service identifiers and user service preferences. Each -:class:`~openstack.resource.Resource` has a service identifier to -associate the resource with a service. An example of a service identifier -would be ``openstack.compute.compute_service.ComputeService``. -The preferences are stored in the -:class:`~openstack.profile.Profile` object. -The service preference and the service identifier are joined to create a -filter to match a service. - -Examples --------- - -The :class:`~openstack.service_filter.ServiceFilter` class can be built -with a service type, interface, region, name, and version. - -Create a service filter -~~~~~~~~~~~~~~~~~~~~~~~ - -Create a compute service and service preference. Join the services -and match:: - - from openstack import service_filter - from openstack.compute import compute_service - default = compute_service.ComputeService() - preference = service_filter.ServiceFilter('compute', version='v2') - result = preference.join(default) - matches = (result.match_service_type('compute') and - result.match_service_name('Hal9000') and - result.match_region('DiscoveryOne') and - result.match_interface('public')) - print(str(result)) - print("matches=" + str(matches)) - -The resulting output from the code:: - - service_type=compute,interface=public,version=v2 - matches=True -""" - - -class ValidVersion(object): - - def __init__(self, module, path=None): - """" Valid service version. - - :param string module: Module associated with version. - :param string path: URL path version. - """ - self.module = module - self.path = path or module - - -class ServiceFilter(dict): - UNVERSIONED = '' - PUBLIC = 'public' - INTERNAL = 'internal' - ADMIN = 'admin' - valid_versions = [] - - def __init__(self, service_type, interface=PUBLIC, region=None, - service_name=None, version=None, api_version=None, - requires_project_id=False): - """Create a service identifier. - - :param string service_type: The desired type of service. - :param string interface: The exposure of the endpoint. Should be - `public` (default), `internal` or `admin`. - :param string region: The desired region (optional). - :param string service_name: Name of the service - :param string version: Version of service to use. - :param string api_version: Microversion of service supported. - :param bool requires_project_id: True if this service's endpoint - expects project id to be included. - """ - self['service_type'] = service_type.lower() - self['interface'] = interface - self['region_name'] = region - self['service_name'] = service_name - self['version'] = version - self['api_version'] = api_version - self['requires_project_id'] = requires_project_id - - @property - def service_type(self): - return self['service_type'] - - @property - def interface(self): - return self['interface'] - - @interface.setter - def interface(self, value): - self['interface'] = value - - @property - def region(self): - return self['region_name'] - - @region.setter - def region(self, value): - self['region_name'] = value - - @property - def service_name(self): - return self['service_name'] - - @service_name.setter - def service_name(self, value): - self['service_name'] = value - - @property - def version(self): - return self['version'] - - @version.setter - def version(self, value): - self['version'] = value - - @property - def api_version(self): - return self['api_version'] - - @api_version.setter - def api_version(self, value): - self['api_version'] = value - - @property - def requires_project_id(self): - return self['requires_project_id'] - - @requires_project_id.setter - def requires_project_id(self, value): - self['requires_project_id'] = value - - @property - def path(self): - return self['path'] - - @path.setter - def path(self, value): - self['path'] = value - - def get_path(self, version=None): - if not self.version: - self.version = version - return self.get('path', self._get_valid_version().path) - - def get_filter(self): - filter = dict(self) - del filter['version'] - return filter - - def _get_valid_version(self): - if self.valid_versions: - if self.version: - for valid in self.valid_versions: - # NOTE(thowe): should support fuzzy match e.g: v2.1==v2 - if self.version.startswith(valid.module): - return valid - return self.valid_versions[0] - return ValidVersion('') - - def get_module(self): - """Get the full module name associated with the service.""" - module = self.__class__.__module__.split('.') - module = ".".join(module[:-1]) - module = module + "." + self._get_valid_version().module - return module - - def get_service_module(self): - """Get the module version of the service name. - - This would often be the same as the service type except in cases like - object store where the service type is `object-store` and the module - is `object_store`. - """ - return self.__class__.__module__.split('.')[-2] diff --git a/openstack/session.py b/openstack/session.py deleted file mode 100644 index f3a55e90..00000000 --- a/openstack/session.py +++ /dev/null @@ -1,347 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -The :class:`~openstack.session.Session` overrides -:class:`~keystoneauth1.session.Session` to provide end point filtering and -mapping KSA exceptions to SDK exceptions. - -""" -from collections import namedtuple -import logging - -try: - from itertools import accumulate -except ImportError: - # itertools.accumulate was added to Python 3.2, and since we have to - # support Python 2 for some reason, we include this equivalent from - # the 3.x docs. While it's stated that it's a rough equivalent, it's - # good enough for the purposes we're using it for. - # https://docs.python.org/dev/library/itertools.html#itertools.accumulate - def accumulate(iterable, func=None): - """Return running totals""" - # accumulate([1,2,3,4,5]) --> 1 3 6 10 15 - # accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120 - it = iter(iterable) - try: - total = next(it) - except StopIteration: - return - yield total - for element in it: - total = func(total, element) - yield total - -from keystoneauth1 import exceptions as _exceptions -from keystoneauth1 import session as _session - -from openstack import exceptions -from openstack import utils -from openstack import version as openstack_version - -from six.moves.urllib import parse - -DEFAULT_USER_AGENT = "openstacksdk/%s" % openstack_version.__version__ -API_REQUEST_HEADER = "openstack-api-version" - -Version = namedtuple("Version", ["major", "minor"]) - -_logger = logging.getLogger(__name__) - - -def map_exceptions(func): - def map_exceptions_wrapper(*args, **kwargs): - try: - return func(*args, **kwargs) - except _exceptions.HttpError as e: - raise exceptions.from_exception(e) - except _exceptions.ClientException as e: - raise exceptions.SDKException(message=e.message, cause=e) - - return map_exceptions_wrapper - - -class Session(_session.Session): - - def __init__(self, profile, user_agent=None, **kwargs): - """Create a new Keystone auth session with a profile. - - :param profile: If the user has any special profiles such as the - service name, region, version or interface, they may be provided - in the profile object. If no profiles are provided, the - services that appear first in the service catalog will be used. - :param user_agent: A User-Agent header string to use for the - request. If not provided, a default of - :attr:`~openstack.session.DEFAULT_USER_AGENT` - is used, which contains the openstacksdk version - When a non-None value is passed, it will be - prepended to the default. - :type profile: :class:`~openstack.profile.Profile` - """ - if user_agent is not None: - self.user_agent = "%s %s" % (user_agent, DEFAULT_USER_AGENT) - else: - self.user_agent = DEFAULT_USER_AGENT - - self.profile = profile - api_version_header = self._get_api_requests() - self.endpoint_cache = {} - - super(Session, self).__init__(user_agent=self.user_agent, - additional_headers=api_version_header, - **kwargs) - - def _get_api_requests(self): - """Get API micro-version requests. - - :param profile: A profile object that contains customizations about - service name, region, version, interface or - api_version. - :return: A standard header string if there is any specialization in - API microversion, or None if no such request exists. - """ - if self.profile is None: - return None - - req = [] - for svc in self.profile.get_services(): - if svc.service_type and svc.api_version: - req.append(" ".join([svc.service_type, svc.api_version])) - if req: - return {API_REQUEST_HEADER: ",".join(req)} - - return None - - class _Endpoint(object): - - def __init__(self, uri, versions, - needs_project_id=False, project_id=None): - self.uri = uri - self.versions = versions - self.needs_project_id = needs_project_id - self.project_id = project_id - - def __eq__(self, other): - return all([self.uri == other.uri, - self.versions == other.versions, - self.needs_project_id == other.needs_project_id, - self.project_id == other.project_id]) - - def _parse_versions_response(self, uri): - """Look for a "versions" JSON response at `uri` - - Return versions if we get them, otherwise return None. - """ - _logger.debug("Looking for versions at %s", uri) - - try: - response = self.get(uri) - except exceptions.HttpException: - return None - - try: - response_body = response.json() - except Exception: - # This could raise a number of things, all of which are bad. - # ValueError, JSONDecodeError, etc. Rather than pick and choose - # a bunch of things that might happen, catch 'em all. - return None - - if "versions" in response_body: - versions = response_body["versions"] - # Normalize the version response. Identity nests the versions - # a level deeper than others, inside of a "values" dictionary. - if "values" in versions: - versions = versions["values"] - return self._Endpoint(uri, versions) - - return None - - def _get_endpoint_versions(self, service_type, endpoint): - """Get available endpoints from the remote service - - Take the endpoint that the Service Catalog gives us as a base - and then work from there. In most cases, the path-less 'root' - of the URI is the base of the service which contains the versions. - In other cases, we need to discover it by trying the paths that - eminate from that root. Generally this is achieved in one roundtrip - request/response, but depending on how the service is installed, - it may require multiple requests. - """ - parts = parse.urlparse(endpoint) - - just_root = "://".join([parts.scheme, parts.netloc]) - - # If we need to try using a portion of the parts, - # the project id won't be one worth asking for so remove it. - # However, we do need to know that the project id was - # previously there, so keep it. - project_id = self.get_project_id() - # Domain scope token don't include project id - project_id_location = parts.path.find(project_id) if project_id else -1 - if project_id_location > -1: - usable_path = parts.path[slice(0, project_id_location)] - needs_project_id = True - else: - usable_path = parts.path - needs_project_id = False - - # Generate a series of paths that might contain our version - # information. This will build successively longer paths from - # the split, so /nova/v2 would return "", "/nova", - # "/nova/v2" out of it. Based on what we've normally seen, - # the match will be found early on within those. - paths = accumulate(usable_path.split("/"), - func=lambda *fragments: "/".join(fragments)) - - result = None - - # If we have paths, try them from the root outwards. - # NOTE: Both the body of the for loop and the else clause - # cover the request for `just_root`. The else clause is explicit - # in only testing it because there are no path parts. In the for - # loop, it gets requested in the first iteration. - for path in paths: - response = self._parse_versions_response(just_root + path) - if response is not None: - result = response - break - else: - # If we didn't have paths, root is all we can do anyway. - response = self._parse_versions_response(just_root) - if response is not None: - result = response - - if result is not None: - if needs_project_id: - result.needs_project_id = True - result.project_id = project_id - - return result - - raise exceptions.EndpointNotFound( - "Unable to parse endpoints for %s" % service_type) - - def _parse_version(self, version): - """Parse the version and return major and minor components - - If the version was given with a leading "v", e.g., "v3", strip - that off to just numerals. - """ - version_num = version[version.find("v") + 1:] - components = version_num.split(".") - if len(components) == 1: - # The minor version of a v2 ends up being -1 so that we can - # loop through versions taking the highest available match - # while also working around a direct match for 2.0. - rv = Version(int(components[0]), -1) - elif len(components) == 2: - rv = Version(*[int(component) for component in components]) - else: - raise ValueError("Unable to parse version string %s" % version) - - return rv - - def _get_version_match(self, endpoint, profile_version, service_type): - """Return the best matching version - - Look through each version trying to find the best match for - the version specified in this profile. - * The best match will only ever be found within the same - major version, meaning a v2 profile will never match if - only v3 is available on the server. - * The search for the best match is fuzzy if needed. - * If the profile specifies v2 and the server has - v2.0, v2.1, and v2.2, the match will be v2.2. - * When an exact major/minor is specified, e.g., v2.0, - it will only match v2.0. - """ - - match_version = None - - for version in endpoint.versions: - api_version = self._parse_version(version["id"]) - if profile_version.major != api_version.major: - continue - - if profile_version.minor <= api_version.minor: - for link in version["links"]: - if link["rel"] == "self": - resp_link = link['href'] - match_version = parse.urlsplit(resp_link).path - - # Only break out of the loop on an exact match, - # otherwise keep trying. - if profile_version.minor == api_version.minor: - break - - if match_version is None: - raise exceptions.EndpointNotFound( - "Unable to determine endpoint for %s" % service_type) - - # Make sure the root endpoint has no overlap with match_version - root_parts = parse.urlsplit(endpoint.uri) - match_version = match_version.replace(root_parts.path, "", 1) - match = utils.urljoin(endpoint.uri, match_version) - - # For services that require the project id in the request URI, - # add them in here. - if endpoint.needs_project_id: - match = utils.urljoin(match, endpoint.project_id) - - return match - - def get_endpoint(self, auth=None, interface=None, service_type=None, - **kwargs): - """Override get endpoint to automate endpoint filtering - - This method uses the service catalog to find the root URI of - each service and then gets all available versions directly - from the service, not from the service catalog. - - Endpoints are cached per service type and interface combination - so that they're only requested from the remote service once - per instance of this class. - """ - key = (service_type, interface) - if key in self.endpoint_cache: - return self.endpoint_cache[key] - - filt = self.profile.get_filter(service_type) - if filt.interface is None: - filt.interface = interface - sc_endpoint = super(Session, self).get_endpoint(auth, - **filt.get_filter()) - - # Object Storage is, of course, different. Just use what we get - # back from the service catalog as not only does it not offer - # a list of supported versions, it appends an "AUTH_" prefix to - # the project id so we'd have to special case that as well. - if service_type == "object-store": - self.endpoint_cache[key] = sc_endpoint - return sc_endpoint - - endpoint = self._get_endpoint_versions(service_type, sc_endpoint) - - profile_version = self._parse_version(filt.version) - match = self._get_version_match(endpoint, profile_version, - service_type) - - _logger.debug("Using %s as %s %s endpoint", - match, interface, service_type) - - self.endpoint_cache[key] = match - return match - - @map_exceptions - def request(self, *args, **kwargs): - return super(Session, self).request(*args, **kwargs) diff --git a/openstack/telemetry/__init__.py b/openstack/telemetry/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/telemetry/alarm/__init__.py b/openstack/telemetry/alarm/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/telemetry/alarm/alarm_service.py b/openstack/telemetry/alarm/alarm_service.py deleted file mode 100644 index a23cc3a6..00000000 --- a/openstack/telemetry/alarm/alarm_service.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class AlarmService(service_filter.ServiceFilter): - """The alarm service.""" - - valid_versions = [service_filter.ValidVersion('v2')] - - def __init__(self, version=None): - """Create an alarm service.""" - super(AlarmService, self).__init__(service_type='alarming', - version=version) diff --git a/openstack/telemetry/alarm/v2/__init__.py b/openstack/telemetry/alarm/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/telemetry/alarm/v2/_proxy.py b/openstack/telemetry/alarm/v2/_proxy.py deleted file mode 100644 index abadcd26..00000000 --- a/openstack/telemetry/alarm/v2/_proxy.py +++ /dev/null @@ -1,129 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import proxy -from openstack.telemetry.alarm.v2 import alarm as _alarm -from openstack.telemetry.alarm.v2 import alarm_change as _alarm_change - - -class Proxy(proxy.BaseProxy): - """.. caution:: This API is a work in progress and is subject to change.""" - - def create_alarm(self, **attrs): - """Create a new alarm from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.telemetry.v2.alarm.Alarm`, - comprised of the properties on the Alarm class. - - :returns: The results of alarm creation - :rtype: :class:`~openstack.telemetry.v2.alarm.Alarm` - """ - return self._create(_alarm.Alarm, **attrs) - - def delete_alarm(self, alarm, ignore_missing=True): - """Delete an alarm - - :param alarm: The value can be either the ID of an alarm or a - :class:`~openstack.telemetry.v2.alarm.Alarm` instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the alarm does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent alarm. - - :returns: ``None`` - """ - self._delete(_alarm.Alarm, alarm, ignore_missing=ignore_missing) - - def find_alarm(self, name_or_id, ignore_missing=True): - """Find a single alarm - - :param name_or_id: The name or ID of a alarm. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.telemetry.v2.alarm.Alarm` or None - """ - return self._find(_alarm.Alarm, name_or_id, - ignore_missing=ignore_missing) - - def get_alarm(self, alarm): - """Get a single alarm - - :param alarm: The value can be the ID of an alarm or a - :class:`~openstack.telemetry.v2.alarm.Alarm` instance. - - :returns: One :class:`~openstack.telemetry.v2.alarm.Alarm` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_alarm.Alarm, alarm) - - def alarms(self, **query): - """Return a generator of alarms - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of alarm objects - :rtype: :class:`~openstack.telemetry.v2.alarm.Alarm` - """ - # TODO(Qiming): Check the alarm service API docs/code to verify if - # the parameters need a change. - return self._list(_alarm.Alarm, paginated=False, **query) - - def update_alarm(self, alarm, **attrs): - """Update a alarm - - :param alarm: Either the id of a alarm or a - :class:`~openstack.telemetry.v2.alarm.Alarm` instance. - :attrs kwargs: The attributes to update on the alarm represented - by ``value``. - - :returns: The updated alarm - :rtype: :class:`~openstack.telemetry.v2.alarm.Alarm` - """ - return self._update(_alarm.Alarm, alarm, **attrs) - - def find_alarm_change(self, name_or_id, ignore_missing=True): - """Find a single alarm change - - :param name_or_id: The name or ID of a alarm change. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.telemetry.v2.alarm_change.AlarmChange` - or None - """ - return self._find(_alarm_change.AlarmChange, name_or_id, - ignore_missing=ignore_missing) - - def alarm_changes(self, alarm, **query): - """Return a generator of alarm changes - - :param alarm: Alarm resource or id for alarm. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of alarm change objects - :rtype: :class:`~openstack.telemetry.v2.alarm_change.AlarmChange` - """ - # TODO(Qiming): Check the alarm service API docs/code to verify if - # the parameters need a change. - alarm_id = _alarm.Alarm.from_id(alarm).id - return self._list(_alarm_change.AlarmChange, paginated=False, - path_args={'alarm_id': alarm_id}, **query) diff --git a/openstack/telemetry/alarm/v2/alarm.py b/openstack/telemetry/alarm/v2/alarm.py deleted file mode 100644 index 095d44ab..00000000 --- a/openstack/telemetry/alarm/v2/alarm.py +++ /dev/null @@ -1,91 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import resource -from openstack.telemetry.alarm import alarm_service -from openstack import utils - - -class Alarm(resource.Resource): - """.. caution:: This API is a work in progress and is subject to change.""" - id_attribute = 'alarm_id' - base_path = '/alarms' - service = alarm_service.AlarmService() - - # Supported Operations - allow_create = True - allow_retrieve = True - allow_update = True - allow_delete = True - allow_list = True - - # Properties - #: The actions to do when alarm state changes to alarm - alarm_actions = resource.prop('alarm_actions') - #: The ID of the alarm - alarm_id = resource.prop('alarm_id') - # TODO(briancurtin): undocumented - combination_rule = resource.prop('combination_rule') - #: The description of the alarm - description = resource.prop('description') - #: ``True`` if this alarm is enabled. *Type: bool* - is_enabled = resource.prop('enabled', type=bool) - #: The actions to do when alarm state changes to insufficient data - insufficient_data_actions = resource.prop('insufficient_data_actions') - #: The actions should be re-triggered on each evaluation cycle. - #: *Type: bool* - is_repeat_actions = resource.prop('repeat_actions', type=bool) - #: The name for the alarm - name = resource.prop('name') - #: The actions to do when alarm state change to ok - ok_actions = resource.prop('ok_actions') - #: The ID of the project that owns the alarm - project_id = resource.prop('project_id') - #: The severity of the alarm - severity = resource.prop('severity') - #: The state off the alarm - state = resource.prop('state') - #: The timestamp of the last alarm state change. - #: *Type: ISO 8601 formatted string* - state_changed_at = resource.prop('state_timestamp') - # TODO(briancurtin): undocumented - threshold_rule = resource.prop('threshold_rule', type=dict) - #: Describe time constraints for the alarm - time_constraints = resource.prop('time_constraints') - #: Explicit type specifier to select which rule to follow - type = resource.prop('type') - #: The timestamp of the last alarm definition update. - #: *Type: ISO 8601 formatted string* - updated_at = resource.prop('timestamp') - #: The ID of the user who created the alarm - user_id = resource.prop('user_id') - - def change_state(self, session, next_state): - """Set the state of an alarm. - - :param next_state: The valid values can be one of: ``ok``, ``alarm``, - ``insufficient data``. - """ - url = utils.urljoin(self.base_path, self.id, 'state') - resp = session.put(url, endpoint_filter=self.service, json=next_state) - return resp.json() - - def check_state(self, session): - """Retrieve the current state of an alarm from the service. - - The properties of the alarm are not modified. - """ - url = utils.urljoin(self.base_path, self.id, 'state') - resp = session.get(url, endpoint_filter=self.service) - resp = resp.json() - current_state = resp.replace('\"', '') - return current_state diff --git a/openstack/telemetry/alarm/v2/alarm_change.py b/openstack/telemetry/alarm/v2/alarm_change.py deleted file mode 100644 index ecc3e42d..00000000 --- a/openstack/telemetry/alarm/v2/alarm_change.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import resource -from openstack.telemetry.alarm import alarm_service - - -class AlarmChange(resource.Resource): - """.. caution:: This API is a work in progress and is subject to change.""" - id_attribute = 'event_id' - resource_key = 'alarm_change' - base_path = '/alarms/%(alarm_id)s/history' - service = alarm_service.AlarmService() - - # Supported Operations - allow_list = True - - # Properties - #: The ID of the alarm - alarm_id = resource.prop('alarm_id') - #: Data describing the change - detail = resource.prop('detail') - #: The ID of the change event - event_id = resource.prop('event_id') - #: The project ID on behalf of which the change is being made - on_behalf_of_id = resource.prop('on_behalf_of') - #: The project ID of the initiating identity - project_id = resource.prop('project_id') - #: The time/date of the alarm change. - #: *Type: ISO 8601 formatted string* - triggered_at = resource.prop('timestamp') - #: The type of change - type = resource.prop('type') - #: The user ID of the initiating identity - user_id = resource.prop('user_id') - - @classmethod - def list(cls, session, limit=None, marker=None, path_args=None, - paginated=False, **params): - url = cls._get_url(path_args) - resp = session.get(url, endpoint_filter=cls.service, params=params) - for item in resp.json(): - yield cls.existing(**item) diff --git a/openstack/telemetry/telemetry_service.py b/openstack/telemetry/telemetry_service.py deleted file mode 100644 index 6b0a9cc9..00000000 --- a/openstack/telemetry/telemetry_service.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class TelemetryService(service_filter.ServiceFilter): - """The telemetry service.""" - - valid_versions = [service_filter.ValidVersion('v2')] - - def __init__(self, version=None): - """Create a telemetry service.""" - super(TelemetryService, self).__init__(service_type='metering', - version=version) diff --git a/openstack/telemetry/v2/__init__.py b/openstack/telemetry/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/telemetry/v2/_proxy.py b/openstack/telemetry/v2/_proxy.py deleted file mode 100644 index 054becca..00000000 --- a/openstack/telemetry/v2/_proxy.py +++ /dev/null @@ -1,167 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import proxy2 -from openstack.telemetry.v2 import capability -from openstack.telemetry.v2 import meter as _meter -from openstack.telemetry.v2 import resource as _resource -from openstack.telemetry.v2 import sample -from openstack.telemetry.v2 import statistics - - -class Proxy(proxy2.BaseProxy): - """.. caution:: This API is a work in progress and is subject to change.""" - - def find_capability(self, name_or_id, ignore_missing=True): - """Find a single capability - - :param name_or_id: The name or ID of a capability. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.telemetry.v2.capability.Capability` - or None - """ - return self._find(capability.Capability, name_or_id, - ignore_missing=ignore_missing) - - def capabilities(self, **query): - """Return a generator of capabilities - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of capability objects - :rtype: :class:`~openstack.telemetry.v2.capability.Capability` - """ - return self._list(capability.Capability, paginated=False, **query) - - def find_meter(self, name_or_id, ignore_missing=True): - """Find a single meter - - :param name_or_id: The name or ID of a meter. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.telemetry.v2.meter.Meter` or None - """ - return self._find(_meter.Meter, name_or_id, - ignore_missing=ignore_missing) - - def meters(self, **query): - """Return a generator of meters - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of meter objects - :rtype: :class:`~openstack.telemetry.v2.meter.Meter` - """ - return self._list(_meter.Meter, paginated=False, **query) - - def find_resource(self, name_or_id, ignore_missing=True): - """Find a single resource - - :param name_or_id: The name or ID of a resource. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.telemetry.v2.resource.Resource` or - None - """ - return self._find(_resource.Resource, name_or_id, - ignore_missing=ignore_missing) - - def get_resource(self, resource): - """Get a single resource - - :param resource: The value can be the ID of a resource or a - :class:`~openstack.telemetry.v2.resource.Resource` - instance. - - :returns: One :class:`~openstack.telemetry.v2.resource.Resource` - :raises: :class:`~openstack.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_resource.Resource, resource) - - def resources(self, **query): - """Return a generator of resources - - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of resource objects - :rtype: :class:`~openstack.telemetry.v2.resource.Resource` - """ - return self._list(_resource.Resource, paginated=False, **query) - - def find_sample(self, name_or_id, ignore_missing=True): - """Find a single sample - - :param name_or_id: The name or ID of a sample. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.telemetry.v2.sample.Sample` or None - """ - return self._find(sample.Sample, name_or_id, - ignore_missing=ignore_missing) - - def samples(self, meter, **query): - """Return a generator of samples - - :param value: Meter resource or name for a meter. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of sample objects - :rtype: :class:`~openstack.telemetry.v2.sample.Sample` - """ - return self._list(sample.Sample, paginated=False, - counter_name=meter, **query) - - def find_statistics(self, name_or_id, ignore_missing=True): - """Find a single statistics - - :param name_or_id: The name or ID of a statistics. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.telemetry.v2.statistics.Statistics` - or None - """ - return self._find(statistics.Statistics, name_or_id, - ignore_missing=ignore_missing) - - def statistics(self, meter, **query): - """Return a generator of statistics - - :param meter: Meter resource or name for a meter. - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. - - :returns: A generator of statistics objects - :rtype: :class:`~openstack.telemetry.v2.statistics.Statistics` - """ - return self._list(statistics.Statistics, paginated=False, - meter_name=meter, **query) diff --git a/openstack/telemetry/v2/capability.py b/openstack/telemetry/v2/capability.py deleted file mode 100644 index be93db84..00000000 --- a/openstack/telemetry/v2/capability.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from openstack import resource2 as resource -from openstack.telemetry import telemetry_service - - -class Capability(resource.Resource): - """.. caution:: This API is a work in progress and is subject to change.""" - resource_key = 'capability' - resources_key = 'capabilities' - base_path = '/capabilities' - service = telemetry_service.TelemetryService() - - # Supported Operations - allow_list = True - - # Properties - is_enabled = resource.Body('enabled', type=bool) - - @classmethod - def list(cls, session, paginated=False, **params): - resp = session.get(cls.base_path, endpoint_filter=cls.service, - params=params) - resp = resp.json() - for key, value in resp['api'].items(): - yield cls.existing(id=key, enabled=value) diff --git a/openstack/telemetry/v2/meter.py b/openstack/telemetry/v2/meter.py deleted file mode 100644 index 9e7e9504..00000000 --- a/openstack/telemetry/v2/meter.py +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import resource2 as resource -from openstack.telemetry import telemetry_service - - -class Meter(resource.Resource): - """.. caution:: This API is a work in progress and is subject to change.""" - resource_key = 'meter' - base_path = '/meters' - service = telemetry_service.TelemetryService() - - # Supported Operations - allow_list = True - - # Properties - #: The ID of the meter - meter_id = resource.Body('meter_id', alternate_id=True) - #: The unique name for the meter - name = resource.Body('name') - #: The ID of the project that owns the resource - project_id = resource.Body('project_id') - #: The ID of the resource for which the measurements are taken - resource_id = resource.Body('resource_id') - #: The name of the source where the meter comes from - source = resource.Body('source') - #: The meter type - type = resource.Body('type') - #: The unit of measure - unit = resource.Body('unit') - #: The ID of the user who last triggered an update to the resource - user_id = resource.Body('user_id') diff --git a/openstack/telemetry/v2/resource.py b/openstack/telemetry/v2/resource.py deleted file mode 100644 index f359a391..00000000 --- a/openstack/telemetry/v2/resource.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import resource2 as resource -from openstack.telemetry import telemetry_service - - -class Resource(resource.Resource): - """.. caution:: This API is a work in progress and is subject to change.""" - base_path = '/resources' - service = telemetry_service.TelemetryService() - - # Supported Operations - allow_get = True - allow_list = True - - # Properties - #: UTC date & time not later than the first sample known - #: for this resource. - first_sample_at = resource.Body('first_sample_timestamp') - #: UTC date & time not earlier than the last sample known - #: for this resource. - last_sample_at = resource.Body('last_sample_timestamp') - #: A list containing a self link and associated meter links - links = resource.Body('links') - #: Arbitrary metadata associated with the resource - metadata = resource.Body('metadata') - #: The ID of the owning project - project_id = resource.Body('project_id') - #: The ID for the resource - resource_id = resource.Body('resource_id', alternate_id=True) - #: The name of the source where the resource comes from - source = resource.Body('source') - #: The ID of the user who created the resource or updated it last - user_id = resource.Body('user_id') diff --git a/openstack/telemetry/v2/sample.py b/openstack/telemetry/v2/sample.py deleted file mode 100644 index 0ff47f28..00000000 --- a/openstack/telemetry/v2/sample.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import resource2 as resource -from openstack.telemetry import telemetry_service - - -class Sample(resource.Resource): - """.. caution:: This API is a work in progress and is subject to change.""" - base_path = '/meters/%(counter_name)s' - service = telemetry_service.TelemetryService() - - # Supported Operations - allow_get = True - allow_list = True - - # Properties - #: When the sample has been generated. - generated_at = resource.Body('timestamp') - #: The message ID - message_id = resource.Body('message_id', alternate_id=True) - #: Arbitrary metadata associated with the sample - metadata = resource.Body('metadata') - #: The meter name this sample is for - counter_name = resource.Body('counter_name') - #: The meter name this sample is for - counter_type = resource.Body('counter_type') - #: The ID of the project this sample was taken for - project_id = resource.Body('project_id') - #: When the sample has been recorded. - recorded_at = resource.Body('recorded_at') - #: The ID of the resource this sample was taken for - resource_id = resource.Body('resource_id') - #: The name of the source that identifies where the sample comes from - source = resource.Body('source') - #: The meter type - type = resource.Body('type') - #: The unit of measure - unit = resource.Body('unit') - #: The ID of the user this sample was taken for - user_id = resource.Body('user_id') - #: The metered value - volume = resource.Body('volume') diff --git a/openstack/telemetry/v2/statistics.py b/openstack/telemetry/v2/statistics.py deleted file mode 100644 index a295d514..00000000 --- a/openstack/telemetry/v2/statistics.py +++ /dev/null @@ -1,62 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import resource2 as resource -from openstack.telemetry import telemetry_service - - -class Statistics(resource.Resource): - """.. caution:: This API is a work in progress and is subject to change.""" - resource_key = 'statistics' - base_path = '/meters/%(meter_name)s/statistics' - service = telemetry_service.TelemetryService() - - # Supported Operations - allow_list = True - - # Properties - #: The selectable aggregate value(s) - aggregate = resource.Body('aggregate') - #: The average of all of the volume values seen in the data - avg = resource.Body('avg') - #: The number of samples seen - count = resource.Body('count') - #: The difference, in seconds, between the oldest and newest timestamp - duration = resource.Body('duration') - #: UTC date and time of the oldest timestamp, or the query end time. - duration_end_at = resource.Body('duration_end') - #: UTC date and time of the earliest timestamp, or the query start time. - duration_start_at = resource.Body('duration_start') - #: Dictionary of field names for group, if groupby statistics are requested - group_by = resource.Body('groupby') - #: The maximum volume seen in the data - max = resource.Body('max') - #: The minimum volume seen in the data - min = resource.Body('min') - #: The difference, in seconds, between the period start and end - period = resource.Body('period') - #: UTC date and time of the period end. - period_end_at = resource.Body('period_end') - #: UTC date and time of the period start. - period_start_at = resource.Body('period_start') - #: The total of all of the volume values seen in the data - sum = resource.Body('sum') - #: The unit type of the data set - #: TODO(Qiming): This is still incorrect - unit = resource.Body('unit', alternate_id=True) - - @classmethod - def list(cls, session, paginated=False, **params): - url = cls.base_path % {'meter_name': params.pop('meter_name')} - resp = session.get(url, endpoint_filter=cls.service, params=params) - for stat in resp.json(): - yield cls.existing(**stat) diff --git a/openstack/tests/__init__.py b/openstack/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/examples/__init__.py b/openstack/tests/examples/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/examples/test_compute.py b/openstack/tests/examples/test_compute.py deleted file mode 100644 index c13337ef..00000000 --- a/openstack/tests/examples/test_compute.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from examples.compute import create -from examples.compute import delete -from examples.compute import find as compute_find -from examples.compute import list as compute_list -from examples import connect -from examples.network import find as network_find -from examples.network import list as network_list - - -class TestCompute(unittest.TestCase): - """Test the compute examples - - The purpose of these tests is to ensure the examples run without erring - out. - """ - - @classmethod - def setUpClass(cls): - cls.conn = connect.create_connection_from_config() - - def test_compute(self): - compute_list.list_servers(self.conn) - compute_list.list_images(self.conn) - compute_list.list_flavors(self.conn) - compute_list.list_keypairs(self.conn) - network_list.list_networks(self.conn) - - compute_find.find_image(self.conn) - compute_find.find_flavor(self.conn) - compute_find.find_keypair(self.conn) - network_find.find_network(self.conn) - - create.create_server(self.conn) - - delete.delete_keypair(self.conn) - delete.delete_server(self.conn) diff --git a/openstack/tests/examples/test_identity.py b/openstack/tests/examples/test_identity.py deleted file mode 100644 index f55dbe53..00000000 --- a/openstack/tests/examples/test_identity.py +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from examples import connect -from examples.identity import list as identity_list - - -class TestIdentity(unittest.TestCase): - """Test the identity examples - - The purpose of these tests is to ensure the examples run without erring - out. - """ - - @classmethod - def setUpClass(cls): - cls.conn = connect.create_connection_from_config() - - def test_identity(self): - identity_list.list_users(self.conn) - identity_list.list_credentials(self.conn) - identity_list.list_projects(self.conn) - identity_list.list_domains(self.conn) - identity_list.list_groups(self.conn) - identity_list.list_services(self.conn) - identity_list.list_endpoints(self.conn) - identity_list.list_regions(self.conn) diff --git a/openstack/tests/examples/test_image.py b/openstack/tests/examples/test_image.py deleted file mode 100644 index db027e9b..00000000 --- a/openstack/tests/examples/test_image.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from examples import connect -from examples.image import create as image_create -from examples.image import delete as image_delete -from examples.image import list as image_list - - -class TestImage(unittest.TestCase): - """Test the image examples - - The purpose of these tests is to ensure the examples run without erring - out. - """ - - @classmethod - def setUpClass(cls): - cls.conn = connect.create_connection_from_config() - - def test_image(self): - image_list.list_images(self.conn) - - image_create.upload_image(self.conn) - - image_delete.delete_image(self.conn) diff --git a/openstack/tests/examples/test_network.py b/openstack/tests/examples/test_network.py deleted file mode 100644 index 0e09f39b..00000000 --- a/openstack/tests/examples/test_network.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from examples import connect -from examples.network import create as network_create -from examples.network import delete as network_delete -from examples.network import find as network_find -from examples.network import list as network_list - - -class TestNetwork(unittest.TestCase): - """Test the network examples - - The purpose of these tests is to ensure the examples run without erring - out. - """ - - @classmethod - def setUpClass(cls): - cls.conn = connect.create_connection_from_config() - - def test_network(self): - network_list.list_networks(self.conn) - network_list.list_subnets(self.conn) - network_list.list_ports(self.conn) - network_list.list_security_groups(self.conn) - network_list.list_routers(self.conn) - - network_find.find_network(self.conn) - - network_create.create_network(self.conn) - network_delete.delete_network(self.conn) diff --git a/openstack/tests/functional/__init__.py b/openstack/tests/functional/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/base.py b/openstack/tests/functional/base.py deleted file mode 100644 index 9eb4eba4..00000000 --- a/openstack/tests/functional/base.py +++ /dev/null @@ -1,83 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import os -import os_client_config -import time -import unittest - -from keystoneauth1 import exceptions as _exceptions -from openstack import connection - - -#: Defines the OpenStack Client Config (OCC) cloud key in your OCC config -#: file, typically in $HOME/.config/openstack/clouds.yaml. That configuration -#: will determine where the functional tests will be run and what resource -#: defaults will be used to run the functional tests. -TEST_CLOUD = os.getenv('OS_CLOUD', 'devstack-admin') - - -class Opts(object): - def __init__(self, cloud_name='devstack-admin', debug=False): - self.cloud = cloud_name - self.debug = debug - - -def _get_resource_value(resource_key, default): - try: - return cloud.config['functional'][resource_key] - except KeyError: - return default - -opts = Opts(cloud_name=TEST_CLOUD) -occ = os_client_config.OpenStackConfig() -cloud = occ.get_one_cloud(opts.cloud, argparse=opts) - -IMAGE_NAME = _get_resource_value('image_name', 'cirros-0.3.5-x86_64-disk') -FLAVOR_NAME = _get_resource_value('flavor_name', 'm1.small') - - -def service_exists(**kwargs): - """Decorator function to check whether a service exists - - Usage: - @unittest.skipUnless(base.service_exists(service_type="metering"), - "Metering service does not exist") - class TestMeter(base.BaseFunctionalTest): - ... - - :param kwargs: The kwargs needed to filter an endpoint. - :returns: True if the service exists, otherwise False. - """ - try: - conn = connection.from_config(cloud_name=TEST_CLOUD) - conn.session.get_endpoint(**kwargs) - - return True - except _exceptions.EndpointNotFound: - return False - - -class BaseFunctionalTest(unittest.TestCase): - - @classmethod - def setUpClass(cls): - cls.conn = connection.from_config(cloud_name=TEST_CLOUD) - - @classmethod - def assertIs(cls, expected, actual): - if expected != actual: - raise Exception(expected + ' != ' + actual) - - @classmethod - def linger_for_delete(cls): - time.sleep(40) diff --git a/openstack/tests/functional/block_store/__init__.py b/openstack/tests/functional/block_store/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/block_store/v2/__init__.py b/openstack/tests/functional/block_store/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/block_store/v2/test_snapshot.py b/openstack/tests/functional/block_store/v2/test_snapshot.py deleted file mode 100644 index fd474764..00000000 --- a/openstack/tests/functional/block_store/v2/test_snapshot.py +++ /dev/null @@ -1,68 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.block_store.v2 import snapshot as _snapshot -from openstack.block_store.v2 import volume as _volume -from openstack.tests.functional import base - - -class TestSnapshot(base.BaseFunctionalTest): - - SNAPSHOT_NAME = uuid.uuid4().hex - SNAPSHOT_ID = None - VOLUME_NAME = uuid.uuid4().hex - VOLUME_ID = None - - @classmethod - def setUpClass(cls): - super(TestSnapshot, cls).setUpClass() - volume = cls.conn.block_store.create_volume( - name=cls.VOLUME_NAME, - size=1) - cls.conn.block_store.wait_for_status(volume, - status='available', - failures=['error'], - interval=2, - wait=120) - assert isinstance(volume, _volume.Volume) - cls.assertIs(cls.VOLUME_NAME, volume.name) - cls.VOLUME_ID = volume.id - snapshot = cls.conn.block_store.create_snapshot( - name=cls.SNAPSHOT_NAME, - volume_id=cls.VOLUME_ID) - cls.conn.block_store.wait_for_status(snapshot, - status='available', - failures=['error'], - interval=2, - wait=120) - assert isinstance(snapshot, _snapshot.Snapshot) - cls.assertIs(cls.SNAPSHOT_NAME, snapshot.name) - cls.SNAPSHOT_ID = snapshot.id - - @classmethod - def tearDownClass(cls): - snapshot = cls.conn.block_store.get_snapshot(cls.SNAPSHOT_ID) - sot = cls.conn.block_store.delete_snapshot(snapshot, - ignore_missing=False) - cls.conn.block_store.wait_for_delete(snapshot, - interval=2, - wait=120) - cls.assertIs(None, sot) - sot = cls.conn.block_store.delete_volume(cls.VOLUME_ID, - ignore_missing=False) - cls.assertIs(None, sot) - - def test_get(self): - sot = self.conn.block_store.get_snapshot(self.SNAPSHOT_ID) - self.assertEqual(self.SNAPSHOT_NAME, sot.name) diff --git a/openstack/tests/functional/block_store/v2/test_type.py b/openstack/tests/functional/block_store/v2/test_type.py deleted file mode 100644 index 428389ad..00000000 --- a/openstack/tests/functional/block_store/v2/test_type.py +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.block_store.v2 import type as _type -from openstack.tests.functional import base - - -class TestType(base.BaseFunctionalTest): - - TYPE_NAME = uuid.uuid4().hex - TYPE_ID = None - - @classmethod - def setUpClass(cls): - super(TestType, cls).setUpClass() - sot = cls.conn.block_store.create_type(name=cls.TYPE_NAME) - assert isinstance(sot, _type.Type) - cls.assertIs(cls.TYPE_NAME, sot.name) - cls.TYPE_ID = sot.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.block_store.delete_type(cls.TYPE_ID, - ignore_missing=False) - cls.assertIs(None, sot) - - def test_get(self): - sot = self.conn.block_store.get_type(self.TYPE_ID) - self.assertEqual(self.TYPE_NAME, sot.name) diff --git a/openstack/tests/functional/block_store/v2/test_volume.py b/openstack/tests/functional/block_store/v2/test_volume.py deleted file mode 100644 index c8d70ba5..00000000 --- a/openstack/tests/functional/block_store/v2/test_volume.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.block_store.v2 import volume as _volume -from openstack.tests.functional import base - - -class TestVolume(base.BaseFunctionalTest): - - VOLUME_NAME = uuid.uuid4().hex - VOLUME_ID = None - - @classmethod - def setUpClass(cls): - super(TestVolume, cls).setUpClass() - volume = cls.conn.block_store.create_volume( - name=cls.VOLUME_NAME, - size=1) - cls.conn.block_store.wait_for_status(volume, - status='available', - failures=['error'], - interval=2, - wait=120) - assert isinstance(volume, _volume.Volume) - cls.assertIs(cls.VOLUME_NAME, volume.name) - cls.VOLUME_ID = volume.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.block_store.delete_volume(cls.VOLUME_ID, - ignore_missing=False) - cls.assertIs(None, sot) - - def test_get(self): - sot = self.conn.block_store.get_volume(self.VOLUME_ID) - self.assertEqual(self.VOLUME_NAME, sot.name) diff --git a/openstack/tests/functional/compute/__init__.py b/openstack/tests/functional/compute/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/compute/v2/__init__.py b/openstack/tests/functional/compute/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/compute/v2/test_extension.py b/openstack/tests/functional/compute/v2/test_extension.py deleted file mode 100644 index c60ead51..00000000 --- a/openstack/tests/functional/compute/v2/test_extension.py +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six - -from openstack.tests.functional import base - - -class TestExtension(base.BaseFunctionalTest): - - def test_list(self): - extensions = list(self.conn.compute.extensions()) - self.assertGreater(len(extensions), 0) - - for ext in extensions: - self.assertIsInstance(ext.name, six.string_types) - self.assertIsInstance(ext.namespace, six.string_types) - self.assertIsInstance(ext.alias, six.string_types) diff --git a/openstack/tests/functional/compute/v2/test_flavor.py b/openstack/tests/functional/compute/v2/test_flavor.py deleted file mode 100644 index ec3f0bed..00000000 --- a/openstack/tests/functional/compute/v2/test_flavor.py +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six - -from openstack import exceptions -from openstack.tests.functional import base - - -class TestFlavor(base.BaseFunctionalTest): - - @classmethod - def setUpClass(cls): - super(TestFlavor, cls).setUpClass() - - cls.one_flavor = list(cls.conn.compute.flavors())[0] - - def test_flavors(self): - flavors = list(self.conn.compute.flavors()) - self.assertGreater(len(flavors), 0) - - for flavor in flavors: - self.assertIsInstance(flavor.id, six.string_types) - self.assertIsInstance(flavor.name, six.string_types) - self.assertIsInstance(flavor.disk, int) - self.assertIsInstance(flavor.ram, int) - self.assertIsInstance(flavor.vcpus, int) - - def test_find_flavors_by_id(self): - rslt = self.conn.compute.find_flavor(self.one_flavor.id) - self.assertEqual(rslt.id, self.one_flavor.id) - - def test_find_flavors_by_name(self): - rslt = self.conn.compute.find_flavor(self.one_flavor.name) - self.assertEqual(rslt.name, self.one_flavor.name) - - def test_find_flavors_no_match_ignore_true(self): - rslt = self.conn.compute.find_flavor("not a flavor", - ignore_missing=True) - self.assertIsNone(rslt) - - def test_find_flavors_no_match_ignore_false(self): - self.assertRaises(exceptions.ResourceNotFound, - self.conn.compute.find_flavor, - "not a flavor", ignore_missing=False) diff --git a/openstack/tests/functional/compute/v2/test_image.py b/openstack/tests/functional/compute/v2/test_image.py deleted file mode 100644 index d71f30d7..00000000 --- a/openstack/tests/functional/compute/v2/test_image.py +++ /dev/null @@ -1,110 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six - -from openstack.tests.functional import base -from openstack.tests.functional.image.v2.test_image import TEST_IMAGE_NAME - - -class TestImage(base.BaseFunctionalTest): - - def test_images(self): - images = list(self.conn.compute.images()) - self.assertGreater(len(images), 0) - for image in images: - self.assertIsInstance(image.id, six.string_types) - - def _get_non_test_image(self): - images = self.conn.compute.images() - image = next(images) - - if image.name == TEST_IMAGE_NAME: - image = next(images) - - return image - - def test_find_image(self): - image = self._get_non_test_image() - self.assertIsNotNone(image) - sot = self.conn.compute.find_image(image.id) - self.assertEqual(image.id, sot.id) - self.assertEqual(image.name, sot.name) - - def test_get_image(self): - image = self._get_non_test_image() - self.assertIsNotNone(image) - sot = self.conn.compute.get_image(image.id) - self.assertEqual(image.id, sot.id) - self.assertEqual(image.name, sot.name) - self.assertIsNotNone(image.links) - self.assertIsNotNone(image.min_disk) - self.assertIsNotNone(image.min_ram) - self.assertIsNotNone(image.metadata) - self.assertIsNotNone(image.progress) - self.assertIsNotNone(image.status) - - def test_image_metadata(self): - image = self._get_non_test_image() - - # delete pre-existing metadata - self.conn.compute.delete_image_metadata(image, image.metadata.keys()) - image = self.conn.compute.get_image_metadata(image) - self.assertFalse(image.metadata) - - # get metadata - image = self.conn.compute.get_image_metadata(image) - self.assertFalse(image.metadata) - - # set no metadata - self.conn.compute.set_image_metadata(image) - image = self.conn.compute.get_image_metadata(image) - self.assertFalse(image.metadata) - - # set empty metadata - self.conn.compute.set_image_metadata(image, k0='') - image = self.conn.compute.get_image_metadata(image) - self.assertIn('k0', image.metadata) - self.assertEqual('', image.metadata['k0']) - - # set metadata - self.conn.compute.set_image_metadata(image, k1='v1') - image = self.conn.compute.get_image_metadata(image) - self.assertTrue(image.metadata) - self.assertEqual(2, len(image.metadata)) - self.assertIn('k1', image.metadata) - self.assertEqual('v1', image.metadata['k1']) - - # set more metadata - self.conn.compute.set_image_metadata(image, k2='v2') - image = self.conn.compute.get_image_metadata(image) - self.assertTrue(image.metadata) - self.assertEqual(3, len(image.metadata)) - self.assertIn('k1', image.metadata) - self.assertEqual('v1', image.metadata['k1']) - self.assertIn('k2', image.metadata) - self.assertEqual('v2', image.metadata['k2']) - - # update metadata - self.conn.compute.set_image_metadata(image, k1='v1.1') - image = self.conn.compute.get_image_metadata(image) - self.assertTrue(image.metadata) - self.assertEqual(3, len(image.metadata)) - self.assertIn('k1', image.metadata) - self.assertEqual('v1.1', image.metadata['k1']) - self.assertIn('k2', image.metadata) - self.assertEqual('v2', image.metadata['k2']) - - # delete metadata - self.conn.compute.delete_image_metadata(image, image.metadata.keys()) - image = self.conn.compute.get_image_metadata(image) - self.assertFalse(image.metadata) diff --git a/openstack/tests/functional/compute/v2/test_keypair.py b/openstack/tests/functional/compute/v2/test_keypair.py deleted file mode 100644 index 3b2f2f63..00000000 --- a/openstack/tests/functional/compute/v2/test_keypair.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.compute.v2 import keypair -from openstack.tests.functional import base - - -class TestKeypair(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - ID = None - - @classmethod - def setUpClass(cls): - super(TestKeypair, cls).setUpClass() - sot = cls.conn.compute.create_keypair(name=cls.NAME) - assert isinstance(sot, keypair.Keypair) - cls.assertIs(cls.NAME, sot.name) - cls._keypair = sot - cls.ID = sot.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.compute.delete_keypair(cls._keypair) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.compute.find_keypair(self.NAME) - self.assertEqual(self.ID, sot.id) - - def test_get(self): - sot = self.conn.compute.get_keypair(self.NAME) - self.assertEqual(self.NAME, sot.name) - self.assertEqual(self.ID, sot.id) - - def test_list(self): - names = [o.name for o in self.conn.compute.keypairs()] - self.assertIn(self.NAME, names) diff --git a/openstack/tests/functional/compute/v2/test_limits.py b/openstack/tests/functional/compute/v2/test_limits.py deleted file mode 100644 index 8291b1c8..00000000 --- a/openstack/tests/functional/compute/v2/test_limits.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.tests.functional import base - - -class TestLimits(base.BaseFunctionalTest): - - def test_limits(self): - sot = self.conn.compute.get_limits() - self.assertIsNotNone('maxTotalInstances', sot.absolute) - self.assertIsNotNone('maxTotalRAMSize', sot.absolute) - self.assertIsNotNone('maxTotalKeypairs', sot.absolute) - self.assertIsNotNone('maxSecurityGroups', sot.absolute) - self.assertIsNotNone('maxSecurityGroupRules', sot.absolute) diff --git a/openstack/tests/functional/compute/v2/test_server.py b/openstack/tests/functional/compute/v2/test_server.py deleted file mode 100644 index 795e8180..00000000 --- a/openstack/tests/functional/compute/v2/test_server.py +++ /dev/null @@ -1,129 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.compute.v2 import server -from openstack.tests.functional import base -from openstack.tests.functional.network.v2 import test_network - - -class TestServer(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - server = None - network = None - subnet = None - cidr = '10.99.99.0/16' - - @classmethod - def setUpClass(cls): - super(TestServer, cls).setUpClass() - flavor = cls.conn.compute.find_flavor(base.FLAVOR_NAME, - ignore_missing=False) - image = cls.conn.compute.find_image(base.IMAGE_NAME, - ignore_missing=False) - cls.network, cls.subnet = test_network.create_network(cls.conn, - cls.NAME, - cls.cidr) - if not cls.network: - # We can't call TestCase.fail from within the setUpClass - # classmethod, but we need to raise some exception in order - # to get this setup to fail and thusly fail the entire class. - raise Exception("Unable to create network for TestServer") - - sot = cls.conn.compute.create_server( - name=cls.NAME, flavor_id=flavor.id, image_id=image.id, - networks=[{"uuid": cls.network.id}]) - cls.conn.compute.wait_for_server(sot) - assert isinstance(sot, server.Server) - cls.assertIs(cls.NAME, sot.name) - cls.server = sot - - @classmethod - def tearDownClass(cls): - sot = cls.conn.compute.delete_server(cls.server.id) - cls.assertIs(None, sot) - # Need to wait for the stack to go away before network delete - cls.conn.compute.wait_for_delete(cls.server) - cls.linger_for_delete() - test_network.delete_network(cls.conn, cls.network, cls.subnet) - - def test_find(self): - sot = self.conn.compute.find_server(self.NAME) - self.assertEqual(self.server.id, sot.id) - - def test_get(self): - sot = self.conn.compute.get_server(self.server.id) - self.assertEqual(self.NAME, sot.name) - self.assertEqual(self.server.id, sot.id) - - def test_list(self): - names = [o.name for o in self.conn.compute.servers()] - self.assertIn(self.NAME, names) - - def test_server_metadata(self): - test_server = self.conn.compute.get_server(self.server.id) - - # get metadata - test_server = self.conn.compute.get_server_metadata(test_server) - self.assertFalse(test_server.metadata) - - # set no metadata - self.conn.compute.set_server_metadata(test_server) - test_server = self.conn.compute.get_server_metadata(test_server) - self.assertFalse(test_server.metadata) - - # set empty metadata - self.conn.compute.set_server_metadata(test_server, k0='') - server = self.conn.compute.get_server_metadata(test_server) - self.assertTrue(server.metadata) - - # set metadata - self.conn.compute.set_server_metadata(test_server, k1='v1') - test_server = self.conn.compute.get_server_metadata(test_server) - self.assertTrue(test_server.metadata) - self.assertEqual(2, len(test_server.metadata)) - self.assertIn('k0', test_server.metadata) - self.assertEqual('', test_server.metadata['k0']) - self.assertIn('k1', test_server.metadata) - self.assertEqual('v1', test_server.metadata['k1']) - - # set more metadata - self.conn.compute.set_server_metadata(test_server, k2='v2') - test_server = self.conn.compute.get_server_metadata(test_server) - self.assertTrue(test_server.metadata) - self.assertEqual(3, len(test_server.metadata)) - self.assertIn('k0', test_server.metadata) - self.assertEqual('', test_server.metadata['k0']) - self.assertIn('k1', test_server.metadata) - self.assertEqual('v1', test_server.metadata['k1']) - self.assertIn('k2', test_server.metadata) - self.assertEqual('v2', test_server.metadata['k2']) - - # update metadata - self.conn.compute.set_server_metadata(test_server, k1='v1.1') - test_server = self.conn.compute.get_server_metadata(test_server) - self.assertTrue(test_server.metadata) - self.assertEqual(3, len(test_server.metadata)) - self.assertIn('k0', test_server.metadata) - self.assertEqual('', test_server.metadata['k0']) - self.assertIn('k1', test_server.metadata) - self.assertEqual('v1.1', test_server.metadata['k1']) - self.assertIn('k2', test_server.metadata) - self.assertEqual('v2', test_server.metadata['k2']) - - # delete metadata - self.conn.compute.delete_server_metadata( - test_server, test_server.metadata.keys()) - test_server = self.conn.compute.get_server_metadata(test_server) - self.assertFalse(test_server.metadata) diff --git a/openstack/tests/functional/image/__init__.py b/openstack/tests/functional/image/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/image/v2/__init__.py b/openstack/tests/functional/image/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/image/v2/test_image.py b/openstack/tests/functional/image/v2/test_image.py deleted file mode 100644 index 3008097a..00000000 --- a/openstack/tests/functional/image/v2/test_image.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import connection -from openstack.tests.functional import base - -TEST_IMAGE_NAME = 'Test Image' - - -class TestImage(base.BaseFunctionalTest): - - class ImageOpts(object): - def __init__(self): - self.image_api_version = '2' - - @classmethod - def setUpClass(cls): - opts = cls.ImageOpts() - cls.conn = connection.from_config(cloud_name=base.TEST_CLOUD, - options=opts) - - cls.img = cls.conn.image.upload_image( - name=TEST_IMAGE_NAME, - disk_format='raw', - container_format='bare', - properties='{"description": "This is not an image"}', - data=open('CONTRIBUTING.rst', 'r') - ) - - @classmethod - def tearDownClass(cls): - cls.conn.image.delete_image(cls.img) - - def test_get_image(self): - img2 = self.conn.image.get_image(self.img) - self.assertEqual(self.img, img2) diff --git a/openstack/tests/functional/load_balancer/__init__.py b/openstack/tests/functional/load_balancer/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/load_balancer/v2/__init__.py b/openstack/tests/functional/load_balancer/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/load_balancer/v2/test_load_balancer.py b/openstack/tests/functional/load_balancer/v2/test_load_balancer.py deleted file mode 100644 index acf95349..00000000 --- a/openstack/tests/functional/load_balancer/v2/test_load_balancer.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest -import uuid - -from openstack.load_balancer.v2 import load_balancer -from openstack.tests.functional import base - - -@unittest.skipUnless(base.service_exists(service_type='load_balancer'), - 'Load-balancing service does not exist') -class TestLoadBalancer(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - ID = None - VIP_SUBNET_ID = uuid.uuid4().hex - - @classmethod - def setUpClass(cls): - super(TestLoadBalancer, cls).setUpClass() - test_lb = cls.conn.load_balancer.create_load_balancer( - name=cls.NAME, vip_subnet_id=cls.VIP_SUBNET_ID) - assert isinstance(test_lb, load_balancer.LoadBalancer) - cls.assertIs(cls.NAME, test_lb.name) - cls.ID = test_lb.id - - @classmethod - def tearDownClass(cls): - test_lb = cls.conn.load_balancer.delete_load_balancer( - cls.ID, ignore_missing=False) - cls.assertIs(None, test_lb) - - def test_find(self): - test_lb = self.conn.load_balancer.find_load_balancer(self.NAME) - self.assertEqual(self.ID, test_lb.id) - - def test_get(self): - test_lb = self.conn.load_balancer.get_load_balancer(self.ID) - self.assertEqual(self.NAME, test_lb.name) - self.assertEqual(self.ID, test_lb.id) - self.assertEqual(self.VIP_SUBNET_ID, test_lb.vip_subnet_id) - - def test_list(self): - names = [lb.name for lb in self.conn.load_balancer.load_balancers()] - self.assertIn(self.NAME, names) diff --git a/openstack/tests/functional/network/__init__.py b/openstack/tests/functional/network/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/network/v2/__init__.py b/openstack/tests/functional/network/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/network/v2/test_address_scope.py b/openstack/tests/functional/network/v2/test_address_scope.py deleted file mode 100644 index 223f1573..00000000 --- a/openstack/tests/functional/network/v2/test_address_scope.py +++ /dev/null @@ -1,62 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import address_scope as _address_scope -from openstack.tests.functional import base - - -class TestAddressScope(base.BaseFunctionalTest): - - ADDRESS_SCOPE_ID = None - ADDRESS_SCOPE_NAME = uuid.uuid4().hex - ADDRESS_SCOPE_NAME_UPDATED = uuid.uuid4().hex - IS_SHARED = False - IP_VERSION = 4 - - @classmethod - def setUpClass(cls): - super(TestAddressScope, cls).setUpClass() - address_scope = cls.conn.network.create_address_scope( - ip_version=cls.IP_VERSION, - name=cls.ADDRESS_SCOPE_NAME, - shared=cls.IS_SHARED, - ) - assert isinstance(address_scope, _address_scope.AddressScope) - cls.assertIs(cls.ADDRESS_SCOPE_NAME, address_scope.name) - cls.ADDRESS_SCOPE_ID = address_scope.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_address_scope(cls.ADDRESS_SCOPE_ID) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_address_scope(self.ADDRESS_SCOPE_NAME) - self.assertEqual(self.ADDRESS_SCOPE_ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_address_scope(self.ADDRESS_SCOPE_ID) - self.assertEqual(self.ADDRESS_SCOPE_NAME, sot.name) - self.assertEqual(self.IS_SHARED, sot.is_shared) - self.assertEqual(self.IP_VERSION, sot.ip_version) - - def test_list(self): - names = [o.name for o in self.conn.network.address_scopes()] - self.assertIn(self.ADDRESS_SCOPE_NAME, names) - - def test_update(self): - sot = self.conn.network.update_address_scope( - self.ADDRESS_SCOPE_ID, - name=self.ADDRESS_SCOPE_NAME_UPDATED) - self.assertEqual(self.ADDRESS_SCOPE_NAME_UPDATED, sot.name) diff --git a/openstack/tests/functional/network/v2/test_agent.py b/openstack/tests/functional/network/v2/test_agent.py deleted file mode 100644 index 2cc96525..00000000 --- a/openstack/tests/functional/network/v2/test_agent.py +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import agent -from openstack.tests.functional import base - - -class TestAgent(base.BaseFunctionalTest): - - AGENT = None - DESC = 'test descrition' - - def validate_uuid(self, s): - try: - uuid.UUID(s) - except Exception: - return False - return True - - @classmethod - def setUpClass(cls): - super(TestAgent, cls).setUpClass() - agent_list = list(cls.conn.network.agents()) - cls.AGENT = agent_list[0] - assert isinstance(cls.AGENT, agent.Agent) - - def test_list(self): - agent_list = list(self.conn.network.agents()) - self.AGENT = agent_list[0] - assert isinstance(self.AGENT, agent.Agent) - self.assertTrue(self.validate_uuid(self.AGENT.id)) - - def test_get(self): - sot = self.conn.network.get_agent(self.AGENT.id) - self.assertEqual(self.AGENT.id, sot.id) - - def test_update(self): - sot = self.conn.network.update_agent(self.AGENT.id, - description=self.DESC) - self.assertEqual(self.DESC, sot.description) diff --git a/openstack/tests/functional/network/v2/test_agent_add_remove_network.py b/openstack/tests/functional/network/v2/test_agent_add_remove_network.py deleted file mode 100644 index cae3dddb..00000000 --- a/openstack/tests/functional/network/v2/test_agent_add_remove_network.py +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import network -from openstack.tests.functional import base - - -class TestAgentNetworks(base.BaseFunctionalTest): - - NETWORK_NAME = 'network-' + uuid.uuid4().hex - NETWORK_ID = None - AGENT = None - AGENT_ID = None - - @classmethod - def setUpClass(cls): - super(TestAgentNetworks, cls).setUpClass() - - net = cls.conn.network.create_network(name=cls.NETWORK_NAME) - assert isinstance(net, network.Network) - cls.NETWORK_ID = net.id - agent_list = list(cls.conn.network.agents()) - agents = [agent for agent in agent_list - if agent.agent_type == 'DHCP agent'] - cls.AGENT = agents[0] - cls.AGENT_ID = cls.AGENT.id - - @classmethod - def tearDownClass(cls): - cls.conn.network.delete_network(cls.NETWORK_ID) - - def test_add_agent_to_network(self): - net = self.AGENT.add_agent_to_network(self.conn.session, - network_id=self.NETWORK_ID) - self._verify_add(net) - - def test_remove_agent_from_network(self): - net = self.AGENT.remove_agent_from_network(self.conn.session, - network_id=self.NETWORK_ID) - self._verify_remove(net) - - def _verify_add(self, network): - net = self.conn.network.dhcp_agent_hosting_networks(self.AGENT_ID) - net_ids = [n.id for n in net] - self.assertIn(self.NETWORK_ID, net_ids) - - def _verify_remove(self, network): - net = self.conn.network.dhcp_agent_hosting_networks(self.AGENT_ID) - net_ids = [n.id for n in net] - self.assertNotIn(self.NETWORK_ID, net_ids) diff --git a/openstack/tests/functional/network/v2/test_agent_add_remove_router.py b/openstack/tests/functional/network/v2/test_agent_add_remove_router.py deleted file mode 100644 index ee3b4346..00000000 --- a/openstack/tests/functional/network/v2/test_agent_add_remove_router.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import router -from openstack.tests.functional import base - - -class TestAgentRouters(base.BaseFunctionalTest): - - ROUTER_NAME = 'router-name-' + uuid.uuid4().hex - ROUTER = None - AGENT = None - - @classmethod - def setUpClass(cls): - super(TestAgentRouters, cls).setUpClass() - - cls.ROUTER = cls.conn.network.create_router(name=cls.ROUTER_NAME) - assert isinstance(cls.ROUTER, router.Router) - agent_list = list(cls.conn.network.agents()) - agents = [agent for agent in agent_list - if agent.agent_type == 'L3 agent'] - cls.AGENT = agents[0] - - @classmethod - def tearDownClass(cls): - cls.conn.network.delete_router(cls.ROUTER) - - def test_add_router_to_agent(self): - self.conn.network.add_router_to_agent(self.AGENT, self.ROUTER) - rots = self.conn.network.agent_hosted_routers(self.AGENT) - routers = [router.id for router in rots] - self.assertIn(self.ROUTER.id, routers) - - def test_remove_router_from_agent(self): - self.conn.network.remove_router_from_agent(self.AGENT, self.ROUTER) - rots = self.conn.network.agent_hosted_routers(self.AGENT) - routers = [router.id for router in rots] - self.assertNotIn(self.ROUTER.id, routers) diff --git a/openstack/tests/functional/network/v2/test_auto_allocated_topology.py b/openstack/tests/functional/network/v2/test_auto_allocated_topology.py deleted file mode 100644 index 629957b8..00000000 --- a/openstack/tests/functional/network/v2/test_auto_allocated_topology.py +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.tests.functional import base - - -class TestAutoAllocatedTopology(base.BaseFunctionalTest): - - NETWORK_NAME = 'auto_allocated_network' - NETWORK_ID = None - PROJECT_ID = None - - @classmethod - def setUpClass(cls): - super(TestAutoAllocatedTopology, cls).setUpClass() - projects = [o.project_id for o in cls.conn.network.networks()] - cls.PROJECT_ID = projects[0] - - @classmethod - def tearDownClass(cls): - res = cls.conn.network.delete_auto_allocated_topology(cls.PROJECT_ID) - cls.assertIs(None, res) - - def test_dry_run_option_pass(self): - # Dry run will only pass if there is a public network - networks = self.conn.network.networks() - self._set_network_external(networks) - - # Dry run option will return "dry-run=pass" in the 'id' resource - top = self.conn.network.validate_auto_allocated_topology( - self.PROJECT_ID) - self.assertEqual(self.PROJECT_ID, top.project) - self.assertEqual('dry-run=pass', top.id) - - def test_show_no_project_option(self): - top = self.conn.network.get_auto_allocated_topology() - project = self.conn.session.get_project_id() - network = self.conn.network.get_network(top.id) - self.assertEqual(top.project_id, project) - self.assertEqual(top.id, network.id) - - def test_show_project_option(self): - top = self.conn.network.get_auto_allocated_topology(self.PROJECT_ID) - network = self.conn.network.get_network(top.id) - self.assertEqual(top.project_id, network.project_id) - self.assertEqual(top.id, network.id) - self.assertEqual(network.name, 'auto_allocated_network') - - def _set_network_external(self, networks): - for network in networks: - if network.name == 'public': - self.conn.network.update_network(network, is_default=True) diff --git a/openstack/tests/functional/network/v2/test_availability_zone.py b/openstack/tests/functional/network/v2/test_availability_zone.py deleted file mode 100644 index 64fc1910..00000000 --- a/openstack/tests/functional/network/v2/test_availability_zone.py +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six - -from openstack.tests.functional import base - - -class TestAvailabilityZone(base.BaseFunctionalTest): - - def test_list(self): - availability_zones = list(self.conn.network.availability_zones()) - self.assertGreater(len(availability_zones), 0) - - for az in availability_zones: - self.assertIsInstance(az.name, six.string_types) - self.assertIsInstance(az.resource, six.string_types) - self.assertIsInstance(az.state, six.string_types) diff --git a/openstack/tests/functional/network/v2/test_dvr_router.py b/openstack/tests/functional/network/v2/test_dvr_router.py deleted file mode 100644 index e93231f1..00000000 --- a/openstack/tests/functional/network/v2/test_dvr_router.py +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import router -from openstack.tests.functional import base - - -class TestDVRRouter(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - UPDATE_NAME = uuid.uuid4().hex - ID = None - - @classmethod - def setUpClass(cls): - super(TestDVRRouter, cls).setUpClass() - sot = cls.conn.network.create_router(name=cls.NAME, distributed=True) - assert isinstance(sot, router.Router) - cls.assertIs(cls.NAME, sot.name) - cls.ID = sot.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_router(cls.ID, ignore_missing=False) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_router(self.NAME) - self.assertEqual(self.ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_router(self.ID) - self.assertEqual(self.NAME, sot.name) - self.assertEqual(self.ID, sot.id) - self.assertTrue(sot.is_distributed) - - def test_list(self): - names = [o.name for o in self.conn.network.routers()] - self.assertIn(self.NAME, names) - dvr = [o.is_distributed for o in self.conn.network.routers()] - self.assertTrue(dvr) - - def test_update(self): - sot = self.conn.network.update_router(self.ID, name=self.UPDATE_NAME) - self.assertEqual(self.UPDATE_NAME, sot.name) diff --git a/openstack/tests/functional/network/v2/test_extension.py b/openstack/tests/functional/network/v2/test_extension.py deleted file mode 100644 index 98134cb6..00000000 --- a/openstack/tests/functional/network/v2/test_extension.py +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six - -from openstack.tests.functional import base - - -class TestExtension(base.BaseFunctionalTest): - - def test_list(self): - extensions = list(self.conn.network.extensions()) - self.assertGreater(len(extensions), 0) - - for ext in extensions: - self.assertIsInstance(ext.name, six.string_types) - self.assertIsInstance(ext.alias, six.string_types) - - def test_find(self): - extension = self.conn.network.find_extension('external-net') - self.assertEqual('Neutron external network', extension.name) diff --git a/openstack/tests/functional/network/v2/test_flavor.py b/openstack/tests/functional/network/v2/test_flavor.py deleted file mode 100644 index ad486e9e..00000000 --- a/openstack/tests/functional/network/v2/test_flavor.py +++ /dev/null @@ -1,81 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import flavor -from openstack.tests.functional import base - - -class TestFlavor(base.BaseFunctionalTest): - - FLAVOR_NAME = uuid.uuid4().hex - UPDATE_NAME = "UPDATED-NAME" - SERVICE_TYPE = "FLAVORS" - ID = None - - SERVICE_PROFILE_DESCRIPTION = "DESCRIPTION" - METAINFO = "FlAVOR_PROFILE_METAINFO" - - @classmethod - def setUpClass(cls): - super(TestFlavor, cls).setUpClass() - flavors = cls.conn.network.create_flavor(name=cls.FLAVOR_NAME, - service_type=cls.SERVICE_TYPE) - assert isinstance(flavors, flavor.Flavor) - cls.assertIs(cls.FLAVOR_NAME, flavors.name) - cls.assertIs(cls.SERVICE_TYPE, flavors.service_type) - - cls.ID = flavors.id - - cls.service_profiles = cls.conn.network.create_service_profile( - description=cls.SERVICE_PROFILE_DESCRIPTION, - metainfo=cls.METAINFO,) - - @classmethod - def tearDownClass(cls): - flavors = cls.conn.network.delete_flavor(cls.ID, ignore_missing=True) - cls.assertIs(None, flavors) - - service_profiles = cls.conn.network.delete_service_profile( - cls.ID, ignore_missing=True) - cls.assertIs(None, service_profiles) - - def test_find(self): - flavors = self.conn.network.find_flavor(self.FLAVOR_NAME) - self.assertEqual(self.ID, flavors.id) - - def test_get(self): - flavors = self.conn.network.get_flavor(self.ID) - self.assertEqual(self.FLAVOR_NAME, flavors.name) - self.assertEqual(self.ID, flavors.id) - - def test_list(self): - names = [f.name for f in self.conn.network.flavors()] - self.assertIn(self.FLAVOR_NAME, names) - - def test_update(self): - flavor = self.conn.network.update_flavor(self.ID, - name=self.UPDATE_NAME) - self.assertEqual(self.UPDATE_NAME, flavor.name) - - def test_associate_flavor_with_service_profile(self): - response = \ - self.conn.network.associate_flavor_with_service_profile( - self.ID, self.service_profiles.id) - self.assertIsNotNone(response) - - def test_disassociate_flavor_from_service_profile(self): - response = \ - self.conn.network.disassociate_flavor_from_service_profile( - self.ID, self.service_profiles.id) - self.assertIsNone(response) diff --git a/openstack/tests/functional/network/v2/test_floating_ip.py b/openstack/tests/functional/network/v2/test_floating_ip.py deleted file mode 100644 index b2274ce5..00000000 --- a/openstack/tests/functional/network/v2/test_floating_ip.py +++ /dev/null @@ -1,151 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import floating_ip -from openstack.network.v2 import network -from openstack.network.v2 import port -from openstack.network.v2 import router -from openstack.network.v2 import subnet -from openstack.tests.functional import base - - -class TestFloatingIP(base.BaseFunctionalTest): - - ROT_NAME = uuid.uuid4().hex - EXT_NET_NAME = uuid.uuid4().hex - EXT_SUB_NAME = uuid.uuid4().hex - INT_NET_NAME = uuid.uuid4().hex - INT_SUB_NAME = uuid.uuid4().hex - IPV4 = 4 - EXT_CIDR = "10.100.0.0/24" - INT_CIDR = "10.101.0.0/24" - EXT_NET_ID = None - INT_NET_ID = None - EXT_SUB_ID = None - INT_SUB_ID = None - ROT_ID = None - PORT_ID = None - FIP = None - - @classmethod - def setUpClass(cls): - super(TestFloatingIP, cls).setUpClass() - # Create Exeternal Network - args = {'router:external': True} - net = cls._create_network(cls.EXT_NET_NAME, **args) - cls.EXT_NET_ID = net.id - sub = cls._create_subnet(cls.EXT_SUB_NAME, cls.EXT_NET_ID, - cls.EXT_CIDR) - cls.EXT_SUB_ID = sub.id - # Create Internal Network - net = cls._create_network(cls.INT_NET_NAME) - cls.INT_NET_ID = net.id - sub = cls._create_subnet(cls.INT_SUB_NAME, cls.INT_NET_ID, - cls.INT_CIDR) - cls.INT_SUB_ID = sub.id - # Create Router - args = {'external_gateway_info': {'network_id': cls.EXT_NET_ID}} - sot = cls.conn.network.create_router(name=cls.ROT_NAME, **args) - assert isinstance(sot, router.Router) - cls.assertIs(cls.ROT_NAME, sot.name) - cls.ROT_ID = sot.id - cls.ROT = sot - # Add Router's Interface to Internal Network - sot = cls.ROT.add_interface(cls.conn.session, subnet_id=cls.INT_SUB_ID) - cls.assertIs(sot['subnet_id'], cls.INT_SUB_ID) - # Create Port in Internal Network - prt = cls.conn.network.create_port(network_id=cls.INT_NET_ID) - assert isinstance(prt, port.Port) - cls.PORT_ID = prt.id - # Create Floating IP. - fip = cls.conn.network.create_ip(floating_network_id=cls.EXT_NET_ID) - assert isinstance(fip, floating_ip.FloatingIP) - cls.FIP = fip - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_ip(cls.FIP.id, ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_port(cls.PORT_ID, ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.ROT.remove_interface(cls.conn.session, - subnet_id=cls.INT_SUB_ID) - cls.assertIs(sot['subnet_id'], cls.INT_SUB_ID) - sot = cls.conn.network.delete_router(cls.ROT_ID, ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_subnet(cls.EXT_SUB_ID, - ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_network(cls.EXT_NET_ID, - ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_subnet(cls.INT_SUB_ID, - ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_network(cls.INT_NET_ID, - ignore_missing=False) - cls.assertIs(None, sot) - - @classmethod - def _create_network(cls, name, **args): - cls.name = name - net = cls.conn.network.create_network(name=name, **args) - assert isinstance(net, network.Network) - cls.assertIs(cls.name, net.name) - return net - - @classmethod - def _create_subnet(cls, name, net_id, cidr): - cls.name = name - cls.net_id = net_id - cls.cidr = cidr - sub = cls.conn.network.create_subnet(name=cls.name, - ip_version=cls.IPV4, - network_id=cls.net_id, - cidr=cls.cidr) - assert isinstance(sub, subnet.Subnet) - cls.assertIs(cls.name, sub.name) - return sub - - def test_find_by_id(self): - sot = self.conn.network.find_ip(self.FIP.id) - self.assertEqual(self.FIP.id, sot.id) - - def test_find_by_ip_address(self): - sot = self.conn.network.find_ip(self.FIP.floating_ip_address) - self.assertEqual(self.FIP.floating_ip_address, sot.floating_ip_address) - self.assertEqual(self.FIP.floating_ip_address, sot.name) - - def test_find_available_ip(self): - sot = self.conn.network.find_available_ip() - self.assertIsNotNone(sot.id) - self.assertIsNone(sot.port_id) - - def test_get(self): - sot = self.conn.network.get_ip(self.FIP.id) - self.assertEqual(self.EXT_NET_ID, sot.floating_network_id) - self.assertEqual(self.FIP.id, sot.id) - self.assertEqual(self.FIP.floating_ip_address, sot.floating_ip_address) - self.assertEqual(self.FIP.fixed_ip_address, sot.fixed_ip_address) - self.assertEqual(self.FIP.port_id, sot.port_id) - self.assertEqual(self.FIP.router_id, sot.router_id) - - def test_list(self): - ids = [o.id for o in self.conn.network.ips()] - self.assertIn(self.FIP.id, ids) - - def test_update(self): - sot = self.conn.network.update_ip(self.FIP.id, port_id=self.PORT_ID) - self.assertEqual(self.PORT_ID, sot.port_id) - self.assertEqual(self.FIP.id, sot.id) diff --git a/openstack/tests/functional/network/v2/test_network.py b/openstack/tests/functional/network/v2/test_network.py deleted file mode 100644 index 6a959d71..00000000 --- a/openstack/tests/functional/network/v2/test_network.py +++ /dev/null @@ -1,70 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import network -from openstack.tests.functional import base - - -def create_network(conn, name, cidr): - try: - network = conn.network.create_network(name=name) - subnet = conn.network.create_subnet( - name=name, - ip_version=4, - network_id=network.id, - cidr=cidr) - return (network, subnet) - except Exception as e: - print(str(e)) - pass - return (None, None) - - -def delete_network(conn, network, subnet): - if subnet: - conn.network.delete_subnet(subnet) - if network: - conn.network.delete_network(network) - - -class TestNetwork(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - ID = None - - @classmethod - def setUpClass(cls): - super(TestNetwork, cls).setUpClass() - sot = cls.conn.network.create_network(name=cls.NAME) - assert isinstance(sot, network.Network) - cls.assertIs(cls.NAME, sot.name) - cls.ID = sot.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_network(cls.ID, ignore_missing=False) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_network(self.NAME) - self.assertEqual(self.ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_network(self.ID) - self.assertEqual(self.NAME, sot.name) - self.assertEqual(self.ID, sot.id) - - def test_list(self): - names = [o.name for o in self.conn.network.networks()] - self.assertIn(self.NAME, names) diff --git a/openstack/tests/functional/network/v2/test_network_ip_availability.py b/openstack/tests/functional/network/v2/test_network_ip_availability.py deleted file mode 100644 index cfd814b6..00000000 --- a/openstack/tests/functional/network/v2/test_network_ip_availability.py +++ /dev/null @@ -1,74 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import network -from openstack.network.v2 import port -from openstack.network.v2 import subnet -from openstack.tests.functional import base - - -class TestNetworkIPAvailability(base.BaseFunctionalTest): - - NET_NAME = uuid.uuid4().hex - SUB_NAME = uuid.uuid4().hex - PORT_NAME = uuid.uuid4().hex - UPDATE_NAME = uuid.uuid4().hex - IPV4 = 4 - CIDR = "10.100.0.0/24" - NET_ID = None - SUB_ID = None - PORT_ID = None - - @classmethod - def setUpClass(cls): - super(TestNetworkIPAvailability, cls).setUpClass() - net = cls.conn.network.create_network(name=cls.NET_NAME) - assert isinstance(net, network.Network) - cls.assertIs(cls.NET_NAME, net.name) - cls.NET_ID = net.id - sub = cls.conn.network.create_subnet(name=cls.SUB_NAME, - ip_version=cls.IPV4, - network_id=cls.NET_ID, - cidr=cls.CIDR) - assert isinstance(sub, subnet.Subnet) - cls.assertIs(cls.SUB_NAME, sub.name) - cls.SUB_ID = sub.id - prt = cls.conn.network.create_port(name=cls.PORT_NAME, - network_id=cls.NET_ID) - assert isinstance(prt, port.Port) - cls.assertIs(cls.PORT_NAME, prt.name) - cls.PORT_ID = prt.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_port(cls.PORT_ID) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_subnet(cls.SUB_ID) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_network(cls.NET_ID) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_network_ip_availability(self.NET_ID) - self.assertEqual(self.NET_ID, sot.network_id) - - def test_get(self): - sot = self.conn.network.get_network_ip_availability(self.NET_ID) - self.assertEqual(self.NET_ID, sot.network_id) - self.assertEqual(self.NET_NAME, sot.network_name) - - def test_list(self): - ids = [o.network_id for o in - self.conn.network.network_ip_availabilities()] - self.assertIn(self.NET_ID, ids) diff --git a/openstack/tests/functional/network/v2/test_port.py b/openstack/tests/functional/network/v2/test_port.py deleted file mode 100644 index 7409c794..00000000 --- a/openstack/tests/functional/network/v2/test_port.py +++ /dev/null @@ -1,79 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import network -from openstack.network.v2 import port -from openstack.network.v2 import subnet -from openstack.tests.functional import base - - -class TestPort(base.BaseFunctionalTest): - - NET_NAME = uuid.uuid4().hex - SUB_NAME = uuid.uuid4().hex - PORT_NAME = uuid.uuid4().hex - UPDATE_NAME = uuid.uuid4().hex - IPV4 = 4 - CIDR = "10.100.0.0/24" - NET_ID = None - SUB_ID = None - PORT_ID = None - - @classmethod - def setUpClass(cls): - super(TestPort, cls).setUpClass() - net = cls.conn.network.create_network(name=cls.NET_NAME) - assert isinstance(net, network.Network) - cls.assertIs(cls.NET_NAME, net.name) - cls.NET_ID = net.id - sub = cls.conn.network.create_subnet(name=cls.SUB_NAME, - ip_version=cls.IPV4, - network_id=cls.NET_ID, - cidr=cls.CIDR) - assert isinstance(sub, subnet.Subnet) - cls.assertIs(cls.SUB_NAME, sub.name) - cls.SUB_ID = sub.id - prt = cls.conn.network.create_port(name=cls.PORT_NAME, - network_id=cls.NET_ID) - assert isinstance(prt, port.Port) - cls.assertIs(cls.PORT_NAME, prt.name) - cls.PORT_ID = prt.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_port(cls.PORT_ID, ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_subnet(cls.SUB_ID, ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_network(cls.NET_ID, ignore_missing=False) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_port(self.PORT_NAME) - self.assertEqual(self.PORT_ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_port(self.PORT_ID) - self.assertEqual(self.PORT_ID, sot.id) - self.assertEqual(self.PORT_NAME, sot.name) - self.assertEqual(self.NET_ID, sot.network_id) - - def test_list(self): - ids = [o.id for o in self.conn.network.ports()] - self.assertIn(self.PORT_ID, ids) - - def test_update(self): - sot = self.conn.network.update_port(self.PORT_ID, - name=self.UPDATE_NAME) - self.assertEqual(self.UPDATE_NAME, sot.name) diff --git a/openstack/tests/functional/network/v2/test_qos_bandwidth_limit_rule.py b/openstack/tests/functional/network/v2/test_qos_bandwidth_limit_rule.py deleted file mode 100644 index 6d8a9253..00000000 --- a/openstack/tests/functional/network/v2/test_qos_bandwidth_limit_rule.py +++ /dev/null @@ -1,98 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import (qos_bandwidth_limit_rule as - _qos_bandwidth_limit_rule) -from openstack.tests.functional import base - - -class TestQoSBandwidthLimitRule(base.BaseFunctionalTest): - - QOS_POLICY_ID = None - QOS_POLICY_NAME = uuid.uuid4().hex - QOS_IS_SHARED = False - QOS_POLICY_DESCRIPTION = "QoS policy description" - RULE_ID = uuid.uuid4().hex - RULE_MAX_KBPS = 1500 - RULE_MAX_KBPS_NEW = 1800 - RULE_MAX_BURST_KBPS = 1100 - RULE_MAX_BURST_KBPS_NEW = 1300 - RULE_DIRECTION = 'egress' - RULE_DIRECTION_NEW = 'ingress' - - @classmethod - def setUpClass(cls): - super(TestQoSBandwidthLimitRule, cls).setUpClass() - qos_policy = cls.conn.network.create_qos_policy( - description=cls.QOS_POLICY_DESCRIPTION, - name=cls.QOS_POLICY_NAME, - shared=cls.QOS_IS_SHARED, - ) - cls.QOS_POLICY_ID = qos_policy.id - qos_rule = cls.conn.network.create_qos_bandwidth_limit_rule( - cls.QOS_POLICY_ID, max_kbps=cls.RULE_MAX_KBPS, - max_burst_kbps=cls.RULE_MAX_BURST_KBPS, - direction=cls.RULE_DIRECTION, - ) - assert isinstance(qos_rule, - _qos_bandwidth_limit_rule.QoSBandwidthLimitRule) - cls.assertIs(cls.RULE_MAX_KBPS, qos_rule.max_kbps) - cls.assertIs(cls.RULE_MAX_BURST_KBPS, qos_rule.max_burst_kbps) - cls.assertIs(cls.RULE_DIRECTION, qos_rule.direction) - cls.RULE_ID = qos_rule.id - - @classmethod - def tearDownClass(cls): - rule = cls.conn.network.delete_qos_minimum_bandwidth_rule( - cls.RULE_ID, - cls.QOS_POLICY_ID) - qos_policy = cls.conn.network.delete_qos_policy(cls.QOS_POLICY_ID) - cls.assertIs(None, rule) - cls.assertIs(None, qos_policy) - - def test_find(self): - sot = self.conn.network.find_qos_bandwidth_limit_rule( - self.RULE_ID, - self.QOS_POLICY_ID) - self.assertEqual(self.RULE_ID, sot.id) - self.assertEqual(self.RULE_MAX_KBPS, sot.max_kbps) - self.assertEqual(self.RULE_MAX_BURST_KBPS, sot.max_burst_kbps) - self.assertEqual(self.RULE_DIRECTION, sot.direction) - - def test_get(self): - sot = self.conn.network.get_qos_bandwidth_limit_rule( - self.RULE_ID, - self.QOS_POLICY_ID) - self.assertEqual(self.RULE_ID, sot.id) - self.assertEqual(self.QOS_POLICY_ID, sot.qos_policy_id) - self.assertEqual(self.RULE_MAX_KBPS, sot.max_kbps) - self.assertEqual(self.RULE_MAX_BURST_KBPS, sot.max_burst_kbps) - self.assertEqual(self.RULE_DIRECTION, sot.direction) - - def test_list(self): - rule_ids = [o.id for o in - self.conn.network.qos_bandwidth_limit_rules( - self.QOS_POLICY_ID)] - self.assertIn(self.RULE_ID, rule_ids) - - def test_update(self): - sot = self.conn.network.update_qos_bandwidth_limit_rule( - self.RULE_ID, - self.QOS_POLICY_ID, - max_kbps=self.RULE_MAX_KBPS_NEW, - max_burst_kbps=self.RULE_MAX_BURST_KBPS_NEW, - direction=self.RULE_DIRECTION_NEW) - self.assertEqual(self.RULE_MAX_KBPS_NEW, sot.max_kbps) - self.assertEqual(self.RULE_MAX_BURST_KBPS_NEW, sot.max_burst_kbps) - self.assertEqual(self.RULE_DIRECTION_NEW, sot.direction) diff --git a/openstack/tests/functional/network/v2/test_qos_dscp_marking_rule.py b/openstack/tests/functional/network/v2/test_qos_dscp_marking_rule.py deleted file mode 100644 index 3930587c..00000000 --- a/openstack/tests/functional/network/v2/test_qos_dscp_marking_rule.py +++ /dev/null @@ -1,81 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import (qos_dscp_marking_rule as - _qos_dscp_marking_rule) -from openstack.tests.functional import base - - -class TestQoSDSCPMarkingRule(base.BaseFunctionalTest): - - QOS_POLICY_ID = None - QOS_POLICY_NAME = uuid.uuid4().hex - QOS_IS_SHARED = False - QOS_POLICY_DESCRIPTION = "QoS policy description" - RULE_ID = uuid.uuid4().hex - RULE_DSCP_MARK = 36 - RULE_DSCP_MARK_NEW = 40 - - @classmethod - def setUpClass(cls): - super(TestQoSDSCPMarkingRule, cls).setUpClass() - qos_policy = cls.conn.network.create_qos_policy( - description=cls.QOS_POLICY_DESCRIPTION, - name=cls.QOS_POLICY_NAME, - shared=cls.QOS_IS_SHARED, - ) - cls.QOS_POLICY_ID = qos_policy.id - qos_rule = cls.conn.network.create_qos_dscp_marking_rule( - cls.QOS_POLICY_ID, dscp_mark=cls.RULE_DSCP_MARK, - ) - assert isinstance(qos_rule, _qos_dscp_marking_rule.QoSDSCPMarkingRule) - cls.assertIs(cls.RULE_DSCP_MARK, qos_rule.dscp_mark) - cls.RULE_ID = qos_rule.id - - @classmethod - def tearDownClass(cls): - rule = cls.conn.network.delete_qos_minimum_bandwidth_rule( - cls.RULE_ID, - cls.QOS_POLICY_ID) - qos_policy = cls.conn.network.delete_qos_policy(cls.QOS_POLICY_ID) - cls.assertIs(None, rule) - cls.assertIs(None, qos_policy) - - def test_find(self): - sot = self.conn.network.find_qos_dscp_marking_rule( - self.RULE_ID, - self.QOS_POLICY_ID) - self.assertEqual(self.RULE_ID, sot.id) - self.assertEqual(self.RULE_DSCP_MARK, sot.dscp_mark) - - def test_get(self): - sot = self.conn.network.get_qos_dscp_marking_rule( - self.RULE_ID, - self.QOS_POLICY_ID) - self.assertEqual(self.RULE_ID, sot.id) - self.assertEqual(self.QOS_POLICY_ID, sot.qos_policy_id) - self.assertEqual(self.RULE_DSCP_MARK, sot.dscp_mark) - - def test_list(self): - rule_ids = [o.id for o in - self.conn.network.qos_dscp_marking_rules( - self.QOS_POLICY_ID)] - self.assertIn(self.RULE_ID, rule_ids) - - def test_update(self): - sot = self.conn.network.update_qos_dscp_marking_rule( - self.RULE_ID, - self.QOS_POLICY_ID, - dscp_mark=self.RULE_DSCP_MARK_NEW) - self.assertEqual(self.RULE_DSCP_MARK_NEW, sot.dscp_mark) diff --git a/openstack/tests/functional/network/v2/test_qos_minimum_bandwidth_rule.py b/openstack/tests/functional/network/v2/test_qos_minimum_bandwidth_rule.py deleted file mode 100644 index 035121ca..00000000 --- a/openstack/tests/functional/network/v2/test_qos_minimum_bandwidth_rule.py +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import (qos_minimum_bandwidth_rule as - _qos_minimum_bandwidth_rule) -from openstack.tests.functional import base - - -class TestQoSMinimumBandwidthRule(base.BaseFunctionalTest): - - QOS_POLICY_ID = None - QOS_POLICY_NAME = uuid.uuid4().hex - QOS_IS_SHARED = False - QOS_POLICY_DESCRIPTION = "QoS policy description" - RULE_ID = None - RULE_MIN_KBPS = 1200 - RULE_MIN_KBPS_NEW = 1800 - RULE_DIRECTION = 'egress' - - @classmethod - def setUpClass(cls): - super(TestQoSMinimumBandwidthRule, cls).setUpClass() - qos_policy = cls.conn.network.create_qos_policy( - description=cls.QOS_POLICY_DESCRIPTION, - name=cls.QOS_POLICY_NAME, - shared=cls.QOS_IS_SHARED, - ) - cls.QOS_POLICY_ID = qos_policy.id - qos_min_bw_rule = cls.conn.network.create_qos_minimum_bandwidth_rule( - cls.QOS_POLICY_ID, direction=cls.RULE_DIRECTION, - min_kbps=cls.RULE_MIN_KBPS, - ) - assert isinstance(qos_min_bw_rule, - _qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule) - cls.assertIs(cls.RULE_MIN_KBPS, qos_min_bw_rule.min_kbps) - cls.assertIs(cls.RULE_DIRECTION, qos_min_bw_rule.direction) - cls.RULE_ID = qos_min_bw_rule.id - - @classmethod - def tearDownClass(cls): - rule = cls.conn.network.delete_qos_minimum_bandwidth_rule( - cls.RULE_ID, - cls.QOS_POLICY_ID) - qos_policy = cls.conn.network.delete_qos_policy(cls.QOS_POLICY_ID) - cls.assertIs(None, rule) - cls.assertIs(None, qos_policy) - - def test_find(self): - sot = self.conn.network.find_qos_minimum_bandwidth_rule( - self.RULE_ID, - self.QOS_POLICY_ID) - self.assertEqual(self.RULE_ID, sot.id) - self.assertEqual(self.RULE_DIRECTION, sot.direction) - self.assertEqual(self.RULE_MIN_KBPS, sot.min_kbps) - - def test_get(self): - sot = self.conn.network.get_qos_minimum_bandwidth_rule( - self.RULE_ID, - self.QOS_POLICY_ID) - self.assertEqual(self.RULE_ID, sot.id) - self.assertEqual(self.QOS_POLICY_ID, sot.qos_policy_id) - self.assertEqual(self.RULE_DIRECTION, sot.direction) - self.assertEqual(self.RULE_MIN_KBPS, sot.min_kbps) - - def test_list(self): - rule_ids = [o.id for o in - self.conn.network.qos_minimum_bandwidth_rules( - self.QOS_POLICY_ID)] - self.assertIn(self.RULE_ID, rule_ids) - - def test_update(self): - sot = self.conn.network.update_qos_minimum_bandwidth_rule( - self.RULE_ID, - self.QOS_POLICY_ID, - min_kbps=self.RULE_MIN_KBPS_NEW) - self.assertEqual(self.RULE_MIN_KBPS_NEW, sot.min_kbps) diff --git a/openstack/tests/functional/network/v2/test_qos_policy.py b/openstack/tests/functional/network/v2/test_qos_policy.py deleted file mode 100644 index 9643015b..00000000 --- a/openstack/tests/functional/network/v2/test_qos_policy.py +++ /dev/null @@ -1,67 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import qos_policy as _qos_policy -from openstack.tests.functional import base - - -class TestQoSPolicy(base.BaseFunctionalTest): - - QOS_POLICY_ID = None - QOS_POLICY_NAME = uuid.uuid4().hex - QOS_POLICY_NAME_UPDATED = uuid.uuid4().hex - IS_SHARED = False - IS_DEFAULT = False - RULES = [] - QOS_POLICY_DESCRIPTION = "QoS policy description" - - @classmethod - def setUpClass(cls): - super(TestQoSPolicy, cls).setUpClass() - qos = cls.conn.network.create_qos_policy( - description=cls.QOS_POLICY_DESCRIPTION, - name=cls.QOS_POLICY_NAME, - shared=cls.IS_SHARED, - is_default=cls.IS_DEFAULT, - ) - assert isinstance(qos, _qos_policy.QoSPolicy) - cls.assertIs(cls.QOS_POLICY_NAME, qos.name) - cls.QOS_POLICY_ID = qos.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_qos_policy(cls.QOS_POLICY_ID) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_qos_policy(self.QOS_POLICY_NAME) - self.assertEqual(self.QOS_POLICY_ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_qos_policy(self.QOS_POLICY_ID) - self.assertEqual(self.QOS_POLICY_NAME, sot.name) - self.assertEqual(self.IS_SHARED, sot.is_shared) - self.assertEqual(self.RULES, sot.rules) - self.assertEqual(self.QOS_POLICY_DESCRIPTION, sot.description) - self.assertEqual(self.IS_DEFAULT, sot.is_default) - - def test_list(self): - names = [o.name for o in self.conn.network.qos_policies()] - self.assertIn(self.QOS_POLICY_NAME, names) - - def test_update(self): - sot = self.conn.network.update_qos_policy( - self.QOS_POLICY_ID, - name=self.QOS_POLICY_NAME_UPDATED) - self.assertEqual(self.QOS_POLICY_NAME_UPDATED, sot.name) diff --git a/openstack/tests/functional/network/v2/test_qos_rule_type.py b/openstack/tests/functional/network/v2/test_qos_rule_type.py deleted file mode 100644 index 96c545da..00000000 --- a/openstack/tests/functional/network/v2/test_qos_rule_type.py +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six - -from openstack.tests.functional import base - - -class TestQoSRuleType(base.BaseFunctionalTest): - - def test_list(self): - rule_types = list(self.conn.network.qos_rule_types()) - self.assertGreater(len(rule_types), 0) - - for rule_type in rule_types: - self.assertIsInstance(rule_type.type, six.string_types) diff --git a/openstack/tests/functional/network/v2/test_quota.py b/openstack/tests/functional/network/v2/test_quota.py deleted file mode 100644 index 9fa10045..00000000 --- a/openstack/tests/functional/network/v2/test_quota.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.tests.functional import base - - -class TestQuota(base.BaseFunctionalTest): - - def test_list(self): - for qot in self.conn.network.quotas(): - self.assertIsNotNone(qot.project_id) - self.assertIsNotNone(qot.networks) - - def test_set(self): - attrs = {'networks': 123456789} - for project_quota in self.conn.network.quotas(): - self.conn.network.update_quota(project_quota, **attrs) - new_quota = self.conn.network.get_quota(project_quota.project_id) - self.assertEqual(123456789, new_quota.networks) diff --git a/openstack/tests/functional/network/v2/test_rbac_policy.py b/openstack/tests/functional/network/v2/test_rbac_policy.py deleted file mode 100644 index 1c28b886..00000000 --- a/openstack/tests/functional/network/v2/test_rbac_policy.py +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import network -from openstack.network.v2 import rbac_policy -from openstack.tests.functional import base - - -class TestRBACPolicy(base.BaseFunctionalTest): - - NET_NAME = 'net-' + uuid.uuid4().hex - UPDATE_NAME = uuid.uuid4().hex - ACTION = 'access_as_shared' - OBJ_TYPE = 'network' - TARGET_TENANT_ID = '*' - NET_ID = None - ID = None - - @classmethod - def setUpClass(cls): - super(TestRBACPolicy, cls).setUpClass() - net = cls.conn.network.create_network(name=cls.NET_NAME) - assert isinstance(net, network.Network) - cls.NET_ID = net.id - - sot = cls.conn.network.\ - create_rbac_policy(action=cls.ACTION, - object_type=cls.OBJ_TYPE, - target_tenant=cls.TARGET_TENANT_ID, - object_id=cls.NET_ID) - assert isinstance(sot, rbac_policy.RBACPolicy) - cls.ID = sot.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_rbac_policy(cls.ID, - ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_network(cls.NET_ID, - ignore_missing=False) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_rbac_policy(self.ID) - self.assertEqual(self.ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_rbac_policy(self.ID) - self.assertEqual(self.ID, sot.id) - - def test_list(self): - ids = [o.id for o in self.conn.network.rbac_policies()] - self.assertIn(self.ID, ids) diff --git a/openstack/tests/functional/network/v2/test_router.py b/openstack/tests/functional/network/v2/test_router.py deleted file mode 100644 index 1102c5da..00000000 --- a/openstack/tests/functional/network/v2/test_router.py +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import router -from openstack.tests.functional import base - - -class TestRouter(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - UPDATE_NAME = uuid.uuid4().hex - ID = None - - @classmethod - def setUpClass(cls): - super(TestRouter, cls).setUpClass() - sot = cls.conn.network.create_router(name=cls.NAME) - assert isinstance(sot, router.Router) - cls.assertIs(cls.NAME, sot.name) - cls.ID = sot.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_router(cls.ID, ignore_missing=False) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_router(self.NAME) - self.assertEqual(self.ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_router(self.ID) - self.assertEqual(self.NAME, sot.name) - self.assertEqual(self.ID, sot.id) - self.assertFalse(sot.is_ha) - - def test_list(self): - names = [o.name for o in self.conn.network.routers()] - self.assertIn(self.NAME, names) - ha = [o.is_ha for o in self.conn.network.routers()] - self.assertIn(False, ha) - - def test_update(self): - sot = self.conn.network.update_router(self.ID, name=self.UPDATE_NAME) - self.assertEqual(self.UPDATE_NAME, sot.name) diff --git a/openstack/tests/functional/network/v2/test_router_add_remove_interface.py b/openstack/tests/functional/network/v2/test_router_add_remove_interface.py deleted file mode 100644 index 27072dd3..00000000 --- a/openstack/tests/functional/network/v2/test_router_add_remove_interface.py +++ /dev/null @@ -1,75 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import network -from openstack.network.v2 import router -from openstack.network.v2 import subnet -from openstack.tests.functional import base - - -class TestRouterInterface(base.BaseFunctionalTest): - - ROUTER_NAME = uuid.uuid4().hex - NET_NAME = uuid.uuid4().hex - SUB_NAME = uuid.uuid4().hex - CIDR = "10.100.0.0/16" - IPV4 = 4 - ROUTER_ID = None - NET_ID = None - SUB_ID = None - ROT = None - - @classmethod - def setUpClass(cls): - super(TestRouterInterface, cls).setUpClass() - sot = cls.conn.network.create_router(name=cls.ROUTER_NAME) - assert isinstance(sot, router.Router) - cls.assertIs(cls.ROUTER_NAME, sot.name) - net = cls.conn.network.create_network(name=cls.NET_NAME) - assert isinstance(net, network.Network) - cls.assertIs(cls.NET_NAME, net.name) - sub = cls.conn.network.create_subnet(name=cls.SUB_NAME, - ip_version=cls.IPV4, - network_id=net.id, - cidr=cls.CIDR) - assert isinstance(sub, subnet.Subnet) - cls.assertIs(cls.SUB_NAME, sub.name) - cls.ROUTER_ID = sot.id - cls.ROT = sot - cls.NET_ID = net.id - cls.SUB_ID = sub.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_router(cls.ROUTER_ID, - ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_subnet(cls.SUB_ID, ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_network(cls.NET_ID, ignore_missing=False) - cls.assertIs(None, sot) - - def test_router_add_interface(self): - iface = self.ROT.add_interface(self.conn.session, - subnet_id=self.SUB_ID) - self._verification(iface) - - def test_router_remove_interface(self): - iface = self.ROT.remove_interface(self.conn.session, - subnet_id=self.SUB_ID) - self._verification(iface) - - def _verification(self, interface): - self.assertEqual(interface['subnet_id'], self.SUB_ID) - self.assertIn('port_id', interface) diff --git a/openstack/tests/functional/network/v2/test_security_group.py b/openstack/tests/functional/network/v2/test_security_group.py deleted file mode 100644 index cc9fa114..00000000 --- a/openstack/tests/functional/network/v2/test_security_group.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import security_group -from openstack.tests.functional import base - - -class TestSecurityGroup(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - ID = None - - @classmethod - def setUpClass(cls): - super(TestSecurityGroup, cls).setUpClass() - sot = cls.conn.network.create_security_group(name=cls.NAME) - assert isinstance(sot, security_group.SecurityGroup) - cls.assertIs(cls.NAME, sot.name) - cls.ID = sot.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_security_group(cls.ID, - ignore_missing=False) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_security_group(self.NAME) - self.assertEqual(self.ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_security_group(self.ID) - self.assertEqual(self.NAME, sot.name) - self.assertEqual(self.ID, sot.id) - - def test_list(self): - names = [o.name for o in self.conn.network.security_groups()] - self.assertIn(self.NAME, names) diff --git a/openstack/tests/functional/network/v2/test_security_group_rule.py b/openstack/tests/functional/network/v2/test_security_group_rule.py deleted file mode 100644 index f114fc4e..00000000 --- a/openstack/tests/functional/network/v2/test_security_group_rule.py +++ /dev/null @@ -1,69 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import security_group -from openstack.network.v2 import security_group_rule -from openstack.tests.functional import base - - -class TestSecurityGroupRule(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - IPV4 = 'IPv4' - PROTO = 'tcp' - PORT = 22 - DIR = 'ingress' - ID = None - RULE_ID = None - - @classmethod - def setUpClass(cls): - super(TestSecurityGroupRule, cls).setUpClass() - sot = cls.conn.network.create_security_group(name=cls.NAME) - assert isinstance(sot, security_group.SecurityGroup) - cls.assertIs(cls.NAME, sot.name) - cls.ID = sot.id - rul = cls.conn.network.create_security_group_rule( - direction=cls.DIR, ethertype=cls.IPV4, - port_range_max=cls.PORT, port_range_min=cls.PORT, - protocol=cls.PROTO, security_group_id=cls.ID) - assert isinstance(rul, security_group_rule.SecurityGroupRule) - cls.assertIs(cls.ID, rul.security_group_id) - cls.RULE_ID = rul.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_security_group_rule(cls.RULE_ID, - ignore_missing=False) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_security_group(cls.ID, - ignore_missing=False) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_security_group_rule(self.RULE_ID) - self.assertEqual(self.RULE_ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_security_group_rule(self.RULE_ID) - self.assertEqual(self.RULE_ID, sot.id) - self.assertEqual(self.DIR, sot.direction) - self.assertEqual(self.PROTO, sot.protocol) - self.assertEqual(self.PORT, sot.port_range_min) - self.assertEqual(self.PORT, sot.port_range_max) - self.assertEqual(self.ID, sot.security_group_id) - - def test_list(self): - ids = [o.id for o in self.conn.network.security_group_rules()] - self.assertIn(self.RULE_ID, ids) diff --git a/openstack/tests/functional/network/v2/test_segment.py b/openstack/tests/functional/network/v2/test_segment.py deleted file mode 100644 index 54200ded..00000000 --- a/openstack/tests/functional/network/v2/test_segment.py +++ /dev/null @@ -1,114 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import network -from openstack.network.v2 import segment -from openstack.tests.functional import base - - -class TestSegment(base.BaseFunctionalTest): - - NETWORK_NAME = uuid.uuid4().hex - NETWORK_TYPE = None - PHYSICAL_NETWORK = None - SEGMENTATION_ID = None - NETWORK_ID = None - SEGMENT_ID = None - SEGMENT_EXTENSION = None - - @classmethod - def setUpClass(cls): - super(TestSegment, cls).setUpClass() - - # NOTE(rtheis): The segment extension is not yet enabled by default. - # Skip the tests if not enabled. - cls.SEGMENT_EXTENSION = cls.conn.network.find_extension('segment') - - # Create a network to hold the segment. - net = cls.conn.network.create_network(name=cls.NETWORK_NAME) - assert isinstance(net, network.Network) - cls.assertIs(cls.NETWORK_NAME, net.name) - cls.NETWORK_ID = net.id - - if cls.SEGMENT_EXTENSION: - # Get the segment for the network. - for seg in cls.conn.network.segments(): - assert isinstance(seg, segment.Segment) - if cls.NETWORK_ID == seg.network_id: - cls.NETWORK_TYPE = seg.network_type - cls.PHYSICAL_NETWORK = seg.physical_network - cls.SEGMENTATION_ID = seg.segmentation_id - cls.SEGMENT_ID = seg.id - break - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_network(cls.NETWORK_ID, - ignore_missing=False) - cls.assertIs(None, sot) - - def test_create_delete(self): - if self.SEGMENT_EXTENSION: - sot = self.conn.network.create_segment( - description='test description', - name='test name', - network_id=self.NETWORK_ID, - network_type='geneve', - segmentation_id=2055, - ) - self.assertIsInstance(sot, segment.Segment) - del_sot = self.conn.network.delete_segment(sot.id) - self.assertEqual('test description', sot.description) - self.assertEqual('test name', sot.name) - self.assertEqual(self.NETWORK_ID, sot.network_id) - self.assertEqual('geneve', sot.network_type) - self.assertIsNone(sot.physical_network) - self.assertEqual(2055, sot.segmentation_id) - self.assertIsNone(del_sot) - else: - self.skipTest('Segment extension disabled') - - def test_find(self): - if self.SEGMENT_EXTENSION: - sot = self.conn.network.find_segment(self.SEGMENT_ID) - self.assertEqual(self.SEGMENT_ID, sot.id) - else: - self.skipTest('Segment extension disabled') - - def test_get(self): - if self.SEGMENT_EXTENSION: - sot = self.conn.network.get_segment(self.SEGMENT_ID) - self.assertEqual(self.SEGMENT_ID, sot.id) - self.assertIsNone(sot.name) - self.assertEqual(self.NETWORK_ID, sot.network_id) - self.assertEqual(self.NETWORK_TYPE, sot.network_type) - self.assertEqual(self.PHYSICAL_NETWORK, sot.physical_network) - self.assertEqual(self.SEGMENTATION_ID, sot.segmentation_id) - else: - self.skipTest('Segment extension disabled') - - def test_list(self): - if self.SEGMENT_EXTENSION: - ids = [o.id for o in self.conn.network.segments(name=None)] - self.assertIn(self.SEGMENT_ID, ids) - else: - self.skipTest('Segment extension disabled') - - def test_update(self): - if self.SEGMENT_EXTENSION: - sot = self.conn.network.update_segment(self.SEGMENT_ID, - description='update') - self.assertEqual('update', sot.description) - else: - self.skipTest('Segment extension disabled') diff --git a/openstack/tests/functional/network/v2/test_service_profile.py b/openstack/tests/functional/network/v2/test_service_profile.py deleted file mode 100644 index 9b9fd73f..00000000 --- a/openstack/tests/functional/network/v2/test_service_profile.py +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.network.v2 import service_profile as _service_profile -from openstack.tests.functional import base - - -class TestServiceProfile(base.BaseFunctionalTest): - - SERVICE_PROFILE_DESCRIPTION = "DESCRIPTION" - UPDATE_DESCRIPTION = "UPDATED-DESCRIPTION" - METAINFO = "FlAVOR_PROFILE_METAINFO" - ID = None - - @classmethod - def setUpClass(cls): - super(TestServiceProfile, cls).setUpClass() - service_profiles = cls.conn.network.create_service_profile( - description=cls.SERVICE_PROFILE_DESCRIPTION, - metainfo=cls.METAINFO,) - assert isinstance(service_profiles, _service_profile.ServiceProfile) - cls.assertIs(cls.SERVICE_PROFILE_DESCRIPTION, - service_profiles.description) - cls.assertIs(cls.METAINFO, service_profiles.meta_info) - - cls.ID = service_profiles.id - - @classmethod - def tearDownClass(cls): - service_profiles = cls.conn.network.delete_service_profile( - cls.ID, - ignore_missing=True) - cls.assertIs(None, service_profiles) - - def test_find(self): - service_profiles = self.conn.network.find_service_profile( - self.ID) - self.assertEqual(self.METAINFO, - service_profiles.meta_info) - - def test_get(self): - service_profiles = self.conn.network.get_service_profile(self.ID) - self.assertEqual(self.METAINFO, service_profiles.meta_info) - self.assertEqual(self.SERVICE_PROFILE_DESCRIPTION, - service_profiles.description) - - def test_update(self): - service_profiles = self.conn.network.update_service_profile( - self.ID, - description=self.UPDATE_DESCRIPTION) - self.assertEqual(self.UPDATE_DESCRIPTION, service_profiles.description) - - def test_list(self): - metainfos = [f.meta_info for f in self.conn.network.service_profiles()] - self.assertIn(self.METAINFO, metainfos) diff --git a/openstack/tests/functional/network/v2/test_service_provider.py b/openstack/tests/functional/network/v2/test_service_provider.py deleted file mode 100644 index fca659c0..00000000 --- a/openstack/tests/functional/network/v2/test_service_provider.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.tests.functional import base - - -class TestServiceProvider(base.BaseFunctionalTest): - def test_list(self): - providers = list(self.conn.network.service_providers()) - names = [o.name for o in providers] - service_types = [o.service_type for o in providers] - self.assertIn('ha', names) - self.assertIn('L3_ROUTER_NAT', service_types) diff --git a/openstack/tests/functional/network/v2/test_subnet.py b/openstack/tests/functional/network/v2/test_subnet.py deleted file mode 100644 index eb56a2bd..00000000 --- a/openstack/tests/functional/network/v2/test_subnet.py +++ /dev/null @@ -1,81 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import network -from openstack.network.v2 import subnet -from openstack.tests.functional import base - - -class TestSubnet(base.BaseFunctionalTest): - - NET_NAME = uuid.uuid4().hex - SUB_NAME = uuid.uuid4().hex - UPDATE_NAME = uuid.uuid4().hex - IPV4 = 4 - CIDR = "10.100.0.0/24" - DNS_SERVERS = ["8.8.4.4", "8.8.8.8"] - POOL = [{"start": "10.100.0.2", "end": "10.100.0.253"}] - ROUTES = [{"destination": "10.101.0.0/24", "nexthop": "10.100.0.254"}] - NET_ID = None - SUB_ID = None - - @classmethod - def setUpClass(cls): - super(TestSubnet, cls).setUpClass() - net = cls.conn.network.create_network(name=cls.NET_NAME) - assert isinstance(net, network.Network) - cls.assertIs(cls.NET_NAME, net.name) - cls.NET_ID = net.id - sub = cls.conn.network.create_subnet(name=cls.SUB_NAME, - ip_version=cls.IPV4, - network_id=cls.NET_ID, - cidr=cls.CIDR, - dns_nameservers=cls.DNS_SERVERS, - allocation_pools=cls.POOL, - host_routes=cls.ROUTES) - assert isinstance(sub, subnet.Subnet) - cls.assertIs(cls.SUB_NAME, sub.name) - cls.SUB_ID = sub.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_subnet(cls.SUB_ID) - cls.assertIs(None, sot) - sot = cls.conn.network.delete_network(cls.NET_ID, ignore_missing=False) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_subnet(self.SUB_NAME) - self.assertEqual(self.SUB_ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_subnet(self.SUB_ID) - self.assertEqual(self.SUB_NAME, sot.name) - self.assertEqual(self.SUB_ID, sot.id) - self.assertEqual(self.DNS_SERVERS, sot.dns_nameservers) - self.assertEqual(self.CIDR, sot.cidr) - self.assertEqual(self.POOL, sot.allocation_pools) - self.assertEqual(self.IPV4, sot.ip_version) - self.assertEqual(self.ROUTES, sot.host_routes) - self.assertEqual("10.100.0.1", sot.gateway_ip) - self.assertTrue(sot.is_dhcp_enabled) - - def test_list(self): - names = [o.name for o in self.conn.network.subnets()] - self.assertIn(self.SUB_NAME, names) - - def test_update(self): - sot = self.conn.network.update_subnet(self.SUB_ID, - name=self.UPDATE_NAME) - self.assertEqual(self.UPDATE_NAME, sot.name) diff --git a/openstack/tests/functional/network/v2/test_subnet_pool.py b/openstack/tests/functional/network/v2/test_subnet_pool.py deleted file mode 100644 index c06d850b..00000000 --- a/openstack/tests/functional/network/v2/test_subnet_pool.py +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -from openstack.network.v2 import subnet_pool as _subnet_pool -from openstack.tests.functional import base - - -class TestSubnetPool(base.BaseFunctionalTest): - - SUBNET_POOL_NAME = uuid.uuid4().hex - SUBNET_POOL_NAME_UPDATED = uuid.uuid4().hex - SUBNET_POOL_ID = None - MINIMUM_PREFIX_LENGTH = 8 - DEFAULT_PREFIX_LENGTH = 24 - MAXIMUM_PREFIX_LENGTH = 32 - DEFAULT_QUOTA = 24 - IS_SHARED = False - IP_VERSION = 4 - PREFIXES = ['10.100.0.0/24', '10.101.0.0/24'] - - @classmethod - def setUpClass(cls): - super(TestSubnetPool, cls).setUpClass() - subnet_pool = cls.conn.network.create_subnet_pool( - name=cls.SUBNET_POOL_NAME, - min_prefixlen=cls.MINIMUM_PREFIX_LENGTH, - default_prefixlen=cls.DEFAULT_PREFIX_LENGTH, - max_prefixlen=cls.MAXIMUM_PREFIX_LENGTH, - default_quota=cls.DEFAULT_QUOTA, - shared=cls.IS_SHARED, - prefixes=cls.PREFIXES) - assert isinstance(subnet_pool, _subnet_pool.SubnetPool) - cls.assertIs(cls.SUBNET_POOL_NAME, subnet_pool.name) - cls.SUBNET_POOL_ID = subnet_pool.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.network.delete_subnet_pool(cls.SUBNET_POOL_ID) - cls.assertIs(None, sot) - - def test_find(self): - sot = self.conn.network.find_subnet_pool(self.SUBNET_POOL_NAME) - self.assertEqual(self.SUBNET_POOL_ID, sot.id) - - def test_get(self): - sot = self.conn.network.get_subnet_pool(self.SUBNET_POOL_ID) - self.assertEqual(self.SUBNET_POOL_NAME, sot.name) - self.assertEqual(self.MINIMUM_PREFIX_LENGTH, - sot.minimum_prefix_length) - self.assertEqual(self.DEFAULT_PREFIX_LENGTH, - sot.default_prefix_length) - self.assertEqual(self.MAXIMUM_PREFIX_LENGTH, - sot.maximum_prefix_length) - self.assertEqual(self.DEFAULT_QUOTA, sot.default_quota) - self.assertEqual(self.IS_SHARED, sot.is_shared) - self.assertEqual(self.IP_VERSION, sot.ip_version) - self.assertEqual(self.PREFIXES, sot.prefixes) - - def test_list(self): - names = [o.name for o in self.conn.network.subnet_pools()] - self.assertIn(self.SUBNET_POOL_NAME, names) - - def test_update(self): - sot = self.conn.network.update_subnet_pool( - self.SUBNET_POOL_ID, - name=self.SUBNET_POOL_NAME_UPDATED) - self.assertEqual(self.SUBNET_POOL_NAME_UPDATED, sot.name) diff --git a/openstack/tests/functional/object_store/__init__.py b/openstack/tests/functional/object_store/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/object_store/v1/__init__.py b/openstack/tests/functional/object_store/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/object_store/v1/test_account.py b/openstack/tests/functional/object_store/v1/test_account.py deleted file mode 100644 index fe258db8..00000000 --- a/openstack/tests/functional/object_store/v1/test_account.py +++ /dev/null @@ -1,83 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from openstack.tests.functional import base - - -@unittest.skipUnless(base.service_exists(service_type='object-store'), - 'Object Storage service does not exist') -class TestAccount(base.BaseFunctionalTest): - - @classmethod - def tearDownClass(cls): - super(TestAccount, cls).tearDownClass() - account = cls.conn.object_store.get_account_metadata() - cls.conn.object_store.delete_account_metadata(account.metadata.keys()) - - def test_system_metadata(self): - account = self.conn.object_store.get_account_metadata() - self.assertGreaterEqual(account.account_bytes_used, 0) - self.assertGreaterEqual(account.account_container_count, 0) - self.assertGreaterEqual(account.account_object_count, 0) - - def test_custom_metadata(self): - # get custom metadata - account = self.conn.object_store.get_account_metadata() - self.assertFalse(account.metadata) - - # set no custom metadata - self.conn.object_store.set_account_metadata() - account = self.conn.object_store.get_account_metadata() - self.assertFalse(account.metadata) - - # set empty custom metadata - self.conn.object_store.set_account_metadata(k0='') - account = self.conn.object_store.get_account_metadata() - self.assertFalse(account.metadata) - - # set custom metadata - self.conn.object_store.set_account_metadata(k1='v1') - account = self.conn.object_store.get_account_metadata() - self.assertTrue(account.metadata) - self.assertEqual(1, len(account.metadata)) - self.assertIn('k1', account.metadata) - self.assertEqual('v1', account.metadata['k1']) - - # set more custom metadata - self.conn.object_store.set_account_metadata(k2='v2') - account = self.conn.object_store.get_account_metadata() - self.assertTrue(account.metadata) - self.assertEqual(2, len(account.metadata)) - self.assertIn('k1', account.metadata) - self.assertEqual('v1', account.metadata['k1']) - self.assertIn('k2', account.metadata) - self.assertEqual('v2', account.metadata['k2']) - - # update custom metadata - self.conn.object_store.set_account_metadata(k1='v1.1') - account = self.conn.object_store.get_account_metadata() - self.assertTrue(account.metadata) - self.assertEqual(2, len(account.metadata)) - self.assertIn('k1', account.metadata) - self.assertEqual('v1.1', account.metadata['k1']) - self.assertIn('k2', account.metadata) - self.assertEqual('v2', account.metadata['k2']) - - # unset custom metadata - self.conn.object_store.delete_account_metadata(['k1']) - account = self.conn.object_store.get_account_metadata() - self.assertTrue(account.metadata) - self.assertEqual(1, len(account.metadata)) - self.assertIn('k2', account.metadata) - self.assertEqual('v2', account.metadata['k2']) diff --git a/openstack/tests/functional/object_store/v1/test_container.py b/openstack/tests/functional/object_store/v1/test_container.py deleted file mode 100644 index 0a6dc754..00000000 --- a/openstack/tests/functional/object_store/v1/test_container.py +++ /dev/null @@ -1,137 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest -import uuid - -from openstack.object_store.v1 import container as _container -from openstack.tests.functional import base - - -@unittest.skipUnless(base.service_exists(service_type='object-store'), - 'Object Storage service does not exist') -class TestContainer(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - - @classmethod - def setUpClass(cls): - super(TestContainer, cls).setUpClass() - container = cls.conn.object_store.create_container(name=cls.NAME) - assert isinstance(container, _container.Container) - cls.assertIs(cls.NAME, container.name) - - @classmethod - def tearDownClass(cls): - result = cls.conn.object_store.delete_container(cls.NAME, - ignore_missing=False) - cls.assertIs(None, result) - - def test_list(self): - names = [o.name for o in self.conn.object_store.containers()] - self.assertIn(self.NAME, names) - - def test_system_metadata(self): - # get system metadata - container = self.conn.object_store.get_container_metadata(self.NAME) - self.assertEqual(0, container.object_count) - self.assertEqual(0, container.bytes_used) - - # set system metadata - container = self.conn.object_store.get_container_metadata(self.NAME) - self.assertIsNone(container.read_ACL) - self.assertIsNone(container.write_ACL) - self.conn.object_store.set_container_metadata( - container, read_ACL='.r:*', write_ACL='demo:demo') - container = self.conn.object_store.get_container_metadata(self.NAME) - self.assertEqual('.r:*', container.read_ACL) - self.assertEqual('demo:demo', container.write_ACL) - - # update system metadata - self.conn.object_store.set_container_metadata( - container, read_ACL='.r:demo') - container = self.conn.object_store.get_container_metadata(self.NAME) - self.assertEqual('.r:demo', container.read_ACL) - self.assertEqual('demo:demo', container.write_ACL) - - # set system metadata and custom metadata - self.conn.object_store.set_container_metadata( - container, k0='v0', sync_key='1234') - container = self.conn.object_store.get_container_metadata(self.NAME) - self.assertTrue(container.metadata) - self.assertIn('k0', container.metadata) - self.assertEqual('v0', container.metadata['k0']) - self.assertEqual('.r:demo', container.read_ACL) - self.assertEqual('demo:demo', container.write_ACL) - self.assertEqual('1234', container.sync_key) - - # unset system metadata - self.conn.object_store.delete_container_metadata(container, - ['sync_key']) - container = self.conn.object_store.get_container_metadata(self.NAME) - self.assertTrue(container.metadata) - self.assertIn('k0', container.metadata) - self.assertEqual('v0', container.metadata['k0']) - self.assertEqual('.r:demo', container.read_ACL) - self.assertEqual('demo:demo', container.write_ACL) - self.assertIsNone(container.sync_key) - - def test_custom_metadata(self): - # get custom metadata - container = self.conn.object_store.get_container_metadata(self.NAME) - self.assertFalse(container.metadata) - - # set no custom metadata - self.conn.object_store.set_container_metadata(container) - container = self.conn.object_store.get_container_metadata(container) - self.assertFalse(container.metadata) - - # set empty custom metadata - self.conn.object_store.set_container_metadata(container, k0='') - container = self.conn.object_store.get_container_metadata(container) - self.assertFalse(container.metadata) - - # set custom metadata - self.conn.object_store.set_container_metadata(container, k1='v1') - container = self.conn.object_store.get_container_metadata(container) - self.assertTrue(container.metadata) - self.assertEqual(1, len(container.metadata)) - self.assertIn('k1', container.metadata) - self.assertEqual('v1', container.metadata['k1']) - - # set more custom metadata by named container - self.conn.object_store.set_container_metadata(self.NAME, k2='v2') - container = self.conn.object_store.get_container_metadata(container) - self.assertTrue(container.metadata) - self.assertEqual(2, len(container.metadata)) - self.assertIn('k1', container.metadata) - self.assertEqual('v1', container.metadata['k1']) - self.assertIn('k2', container.metadata) - self.assertEqual('v2', container.metadata['k2']) - - # update metadata - self.conn.object_store.set_container_metadata(container, k1='v1.1') - container = self.conn.object_store.get_container_metadata(self.NAME) - self.assertTrue(container.metadata) - self.assertEqual(2, len(container.metadata)) - self.assertIn('k1', container.metadata) - self.assertEqual('v1.1', container.metadata['k1']) - self.assertIn('k2', container.metadata) - self.assertEqual('v2', container.metadata['k2']) - - # delete metadata - self.conn.object_store.delete_container_metadata(container, ['k1']) - container = self.conn.object_store.get_container_metadata(self.NAME) - self.assertTrue(container.metadata) - self.assertEqual(1, len(container.metadata)) - self.assertIn('k2', container.metadata) - self.assertEqual('v2', container.metadata['k2']) diff --git a/openstack/tests/functional/object_store/v1/test_obj.py b/openstack/tests/functional/object_store/v1/test_obj.py deleted file mode 100644 index ace53ced..00000000 --- a/openstack/tests/functional/object_store/v1/test_obj.py +++ /dev/null @@ -1,146 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest -import uuid - -from openstack.tests.functional import base - - -@unittest.skipUnless(base.service_exists(service_type='object-store'), - 'Object Storage service does not exist') -class TestObject(base.BaseFunctionalTest): - - FOLDER = uuid.uuid4().hex - FILE = uuid.uuid4().hex - DATA = 'abc' - - @classmethod - def setUpClass(cls): - super(TestObject, cls).setUpClass() - cls.conn.object_store.create_container(name=cls.FOLDER) - cls.sot = cls.conn.object_store.upload_object( - container=cls.FOLDER, name=cls.FILE, data=cls.DATA) - - @classmethod - def tearDownClass(cls): - super(TestObject, cls).tearDownClass() - cls.conn.object_store.delete_object(cls.sot, ignore_missing=False) - cls.conn.object_store.delete_container(cls.FOLDER) - - def test_list(self): - names = [o.name for o - in self.conn.object_store.objects(container=self.FOLDER)] - self.assertIn(self.FILE, names) - - def test_get_object(self): - result = self.conn.object_store.get_object( - self.FILE, container=self.FOLDER) - self.assertEqual(self.DATA, result) - result = self.conn.object_store.get_object(self.sot) - self.assertEqual(self.DATA, result) - - def test_system_metadata(self): - # get system metadata - obj = self.conn.object_store.get_object_metadata( - self.FILE, container=self.FOLDER) - self.assertGreaterEqual(0, obj.bytes) - self.assertIsNotNone(obj.etag) - - # set system metadata - obj = self.conn.object_store.get_object_metadata( - self.FILE, container=self.FOLDER) - self.assertIsNone(obj.content_disposition) - self.assertIsNone(obj.content_encoding) - self.conn.object_store.set_object_metadata( - obj, content_disposition='attachment', content_encoding='gzip') - obj = self.conn.object_store.get_object_metadata(obj) - self.assertEqual('attachment', obj.content_disposition) - self.assertEqual('gzip', obj.content_encoding) - - # update system metadata - self.conn.object_store.set_object_metadata( - obj, content_encoding='deflate') - obj = self.conn.object_store.get_object_metadata(obj) - self.assertEqual('attachment', obj.content_disposition) - self.assertEqual('deflate', obj.content_encoding) - - # set custom metadata - self.conn.object_store.set_object_metadata(obj, k0='v0') - obj = self.conn.object_store.get_object_metadata(obj) - self.assertIn('k0', obj.metadata) - self.assertEqual('v0', obj.metadata['k0']) - self.assertEqual('attachment', obj.content_disposition) - self.assertEqual('deflate', obj.content_encoding) - - # unset more system metadata - self.conn.object_store.delete_object_metadata( - obj, keys=['content_disposition']) - obj = self.conn.object_store.get_object_metadata(obj) - self.assertIn('k0', obj.metadata) - self.assertEqual('v0', obj.metadata['k0']) - self.assertIsNone(obj.content_disposition) - self.assertEqual('deflate', obj.content_encoding) - self.assertIsNone(obj.delete_at) - - def test_custom_metadata(self): - # get custom metadata - obj = self.conn.object_store.get_object_metadata( - self.FILE, container=self.FOLDER) - self.assertFalse(obj.metadata) - - # set no custom metadata - self.conn.object_store.set_object_metadata(obj) - obj = self.conn.object_store.get_object_metadata(obj) - self.assertFalse(obj.metadata) - - # set empty custom metadata - self.conn.object_store.set_object_metadata(obj, k0='') - obj = self.conn.object_store.get_object_metadata(obj) - self.assertFalse(obj.metadata) - - # set custom metadata - self.conn.object_store.set_object_metadata(obj, k1='v1') - obj = self.conn.object_store.get_object_metadata(obj) - self.assertTrue(obj.metadata) - self.assertEqual(1, len(obj.metadata)) - self.assertIn('k1', obj.metadata) - self.assertEqual('v1', obj.metadata['k1']) - - # set more custom metadata by named object and container - self.conn.object_store.set_object_metadata(self.FILE, self.FOLDER, - k2='v2') - obj = self.conn.object_store.get_object_metadata(obj) - self.assertTrue(obj.metadata) - self.assertEqual(2, len(obj.metadata)) - self.assertIn('k1', obj.metadata) - self.assertEqual('v1', obj.metadata['k1']) - self.assertIn('k2', obj.metadata) - self.assertEqual('v2', obj.metadata['k2']) - - # update custom metadata - self.conn.object_store.set_object_metadata(obj, k1='v1.1') - obj = self.conn.object_store.get_object_metadata(obj) - self.assertTrue(obj.metadata) - self.assertEqual(2, len(obj.metadata)) - self.assertIn('k1', obj.metadata) - self.assertEqual('v1.1', obj.metadata['k1']) - self.assertIn('k2', obj.metadata) - self.assertEqual('v2', obj.metadata['k2']) - - # unset custom metadata - self.conn.object_store.delete_object_metadata(obj, keys=['k1']) - obj = self.conn.object_store.get_object_metadata(obj) - self.assertTrue(obj.metadata) - self.assertEqual(1, len(obj.metadata)) - self.assertIn('k2', obj.metadata) - self.assertEqual('v2', obj.metadata['k2']) diff --git a/openstack/tests/functional/orchestration/__init__.py b/openstack/tests/functional/orchestration/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/orchestration/v1/__init__.py b/openstack/tests/functional/orchestration/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/orchestration/v1/hello_world.yaml b/openstack/tests/functional/orchestration/v1/hello_world.yaml deleted file mode 100644 index 71b1f7f4..00000000 --- a/openstack/tests/functional/orchestration/v1/hello_world.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# -# Minimal HOT template defining a single compute server. -# -heat_template_version: 2013-05-23 - -description: > - Minimal HOT template for stack - -parameters: - key_name: - type: string - description: Name of an existing key pair to use for the server - constraints: - - custom_constraint: nova.keypair - flavor: - type: string - description: Flavor for the server to be created - default: m1.small - constraints: - - custom_constraint: nova.flavor - image: - type: string - description: Image ID or image name to use for the server - constraints: - - custom_constraint: glance.image - network: - type: string - description: Network used by the server - -resources: - server: - type: OS::Nova::Server - properties: - key_name: { get_param: key_name } - image: { get_param: image } - flavor: { get_param: flavor } - networks: [{network: {get_param: network} }] - -outputs: - server_networks: - description: The networks of the deployed server - value: { get_attr: [server, networks] } diff --git a/openstack/tests/functional/orchestration/v1/test_stack.py b/openstack/tests/functional/orchestration/v1/test_stack.py deleted file mode 100644 index 73dc1933..00000000 --- a/openstack/tests/functional/orchestration/v1/test_stack.py +++ /dev/null @@ -1,77 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from openstack import exceptions -from openstack.orchestration.v1 import stack -from openstack.tests.functional import base -from openstack.tests.functional.network.v2 import test_network - - -@unittest.skip("bug/1525005") -@unittest.skipUnless(base.service_exists(service_type='orchestration'), - 'Orchestration service does not exist') -class TestStack(base.BaseFunctionalTest): - - NAME = 'test_stack' - stack = None - network = None - subnet = None - cidr = '10.99.99.0/16' - - @classmethod - def setUpClass(cls): - super(TestStack, cls).setUpClass() - if cls.conn.compute.find_keypair(cls.NAME) is None: - cls.conn.compute.create_keypair(name=cls.NAME) - image = next(cls.conn.image.images()) - tname = "openstack/tests/functional/orchestration/v1/hello_world.yaml" - with open(tname) as f: - template = f.read() - cls.network, cls.subnet = test_network.create_network(cls.conn, - cls.NAME, - cls.cidr) - parameters = { - 'image': image.id, - 'key_name': cls.NAME, - 'network': cls.network.id, - } - sot = cls.conn.orchestration.create_stack( - name=cls.NAME, - parameters=parameters, - template=template, - ) - assert isinstance(sot, stack.Stack) - cls.assertIs(True, (sot.id is not None)) - cls.stack = sot - cls.assertIs(cls.NAME, sot.name) - cls.conn.orchestration.wait_for_status( - sot, status='CREATE_COMPLETE', failures=['CREATE_FAILED']) - - @classmethod - def tearDownClass(cls): - super(TestStack, cls).tearDownClass() - cls.conn.orchestration.delete_stack(cls.stack, ignore_missing=False) - cls.conn.compute.delete_keypair(cls.NAME) - # Need to wait for the stack to go away before network delete - try: - cls.conn.orchestration.wait_for_status( - cls.stack, 'DELETE_COMPLETE') - except exceptions.NotFoundException: - pass - cls.linger_for_delete() - test_network.delete_network(cls.conn, cls.network, cls.subnet) - - def test_list(self): - names = [o.name for o in self.conn.orchestration.stacks()] - self.assertIn(self.NAME, names) diff --git a/openstack/tests/functional/telemetry/__init__.py b/openstack/tests/functional/telemetry/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/telemetry/alarm/__init__.py b/openstack/tests/functional/telemetry/alarm/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/telemetry/alarm/v2/__init__.py b/openstack/tests/functional/telemetry/alarm/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/telemetry/alarm/v2/test_alarm.py b/openstack/tests/functional/telemetry/alarm/v2/test_alarm.py deleted file mode 100644 index 3c6c0dd9..00000000 --- a/openstack/tests/functional/telemetry/alarm/v2/test_alarm.py +++ /dev/null @@ -1,58 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest -import uuid - -from openstack.telemetry.alarm.v2 import alarm -from openstack.tests.functional import base - - -@unittest.skip("bug/1524468") -@unittest.skipUnless(base.service_exists(service_type="alarming"), - "Alarming service does not exist") -@unittest.skipUnless(base.service_exists(service_type="metering"), - "Metering service does not exist") -class TestAlarm(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - ID = None - - @classmethod - def setUpClass(cls): - super(TestAlarm, cls).setUpClass() - meter = next(cls.conn.telemetry.meters()) - sot = cls.conn.alarm.create_alarm( - name=cls.NAME, - type='threshold', - threshold_rule={ - 'meter_name': meter.name, - 'threshold': 1.1, - }, - ) - assert isinstance(sot, alarm.Alarm) - cls.assertIs(cls.NAME, sot.name) - cls.ID = sot.id - - @classmethod - def tearDownClass(cls): - sot = cls.conn.alarm.delete_alarm(cls.ID, ignore_missing=False) - cls.assertIs(None, sot) - - def test_get(self): - sot = self.conn.alarm.get_alarm(self.ID) - self.assertEqual(self.NAME, sot.name) - self.assertEqual(self.ID, sot.id) - - def test_list(self): - names = [o.name for o in self.conn.alarm.alarms()] - self.assertIn(self.NAME, names) diff --git a/openstack/tests/functional/telemetry/alarm/v2/test_alarm_change.py b/openstack/tests/functional/telemetry/alarm/v2/test_alarm_change.py deleted file mode 100644 index f1b94d41..00000000 --- a/openstack/tests/functional/telemetry/alarm/v2/test_alarm_change.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest -import uuid - -from openstack.tests.functional import base - - -@unittest.skip("bug/1524468") -@unittest.skipUnless(base.service_exists(service_type="metering"), - "Metering service does not exist") -@unittest.skipUnless(base.service_exists(service_type="alarming"), - "Alarming service does not exist") -class TestAlarmChange(base.BaseFunctionalTest): - - NAME = uuid.uuid4().hex - alarm = None - - @classmethod - def setUpClass(cls): - super(TestAlarmChange, cls).setUpClass() - meter = next(cls.conn.telemetry.meters()) - alarm = cls.conn.alarm.create_alarm( - name=cls.NAME, - type='threshold', - threshold_rule={ - 'meter_name': meter.name, - 'threshold': 1.1, - }, - ) - cls.alarm = alarm - - @classmethod - def tearDownClass(cls): - cls.conn.alarm.delete_alarm(cls.alarm, ignore_missing=False) - - def test_list(self): - change = next(self.conn.alarm.alarm_changes(self.alarm)) - self.assertEqual(self.alarm.id, change.alarm_id) - self.assertEqual('creation', change.type) diff --git a/openstack/tests/functional/telemetry/v2/__init__.py b/openstack/tests/functional/telemetry/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/functional/telemetry/v2/test_capability.py b/openstack/tests/functional/telemetry/v2/test_capability.py deleted file mode 100644 index 8db9d4e6..00000000 --- a/openstack/tests/functional/telemetry/v2/test_capability.py +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from openstack.tests.functional import base - - -@unittest.skipUnless(base.service_exists(service_type="metering"), - "Metering service does not exist") -class TestCapability(base.BaseFunctionalTest): - - def test_list(self): - ids = [o.id for o in self.conn.telemetry.capabilities()] - self.assertIn('resources:query:simple', ids) - self.assertIn('meters:query:simple', ids) - self.assertIn('statistics:query:simple', ids) - self.assertIn('samples:query:simple', ids) diff --git a/openstack/tests/functional/telemetry/v2/test_meter.py b/openstack/tests/functional/telemetry/v2/test_meter.py deleted file mode 100644 index c06495ef..00000000 --- a/openstack/tests/functional/telemetry/v2/test_meter.py +++ /dev/null @@ -1,32 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest -import uuid - -from openstack.tests.functional import base - - -@unittest.skipUnless(base.service_exists(service_type="metering"), - "Metering service does not exist") -class TestMeter(base.BaseFunctionalTest): - - def test_list(self): - # TODO(thowe): Remove this in favor of create_meter call. - # Since we do not have a create meter method at the moment - # make sure there is some data in there - name = uuid.uuid4().hex - tainer = self.conn.object_store.create_container(name=name) - self.conn.object_store.delete_container(tainer) - - names = set([o.name for o in self.conn.telemetry.meters()]) - self.assertIn('storage.objects.incoming.bytes', names) diff --git a/openstack/tests/functional/telemetry/v2/test_resource.py b/openstack/tests/functional/telemetry/v2/test_resource.py deleted file mode 100644 index 0ec768a5..00000000 --- a/openstack/tests/functional/telemetry/v2/test_resource.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from openstack.tests.functional import base - - -@unittest.skipUnless(base.service_exists(service_type="metering"), - "Metering service does not exist") -class TestResource(base.BaseFunctionalTest): - - def test_list(self): - ids = [o.resource_id for o in self.conn.telemetry.resources()] - self.assertNotEqual(0, len(ids)) diff --git a/openstack/tests/functional/telemetry/v2/test_sample.py b/openstack/tests/functional/telemetry/v2/test_sample.py deleted file mode 100644 index 49c209ec..00000000 --- a/openstack/tests/functional/telemetry/v2/test_sample.py +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from openstack.telemetry.v2 import sample -from openstack.tests.functional import base - - -@unittest.skipUnless(base.service_exists(service_type="metering"), - "Metering service does not exist") -class TestSample(base.BaseFunctionalTest): - - def test_list(self): - for meter in self.conn.telemetry.meters(): - for sot in self.conn.telemetry.samples(meter): - assert isinstance(sot, sample.Sample) diff --git a/openstack/tests/functional/telemetry/v2/test_statistics.py b/openstack/tests/functional/telemetry/v2/test_statistics.py deleted file mode 100644 index 7db97135..00000000 --- a/openstack/tests/functional/telemetry/v2/test_statistics.py +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import unittest - -from openstack.tests.functional import base - - -@unittest.skipUnless(base.service_exists(service_type="metering"), - "Metering service does not exist") -class TestStatistics(base.BaseFunctionalTest): - - def test_list(self): - for met in self.conn.telemetry.meters(): - for stat in self.conn.telemetry.statistics(met): - self.assertTrue(stat.period_end_at is not None) - break diff --git a/openstack/tests/unit/__init__.py b/openstack/tests/unit/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/bare_metal/__init__.py b/openstack/tests/unit/bare_metal/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/bare_metal/test_bare_metal_service.py b/openstack/tests/unit/bare_metal/test_bare_metal_service.py deleted file mode 100644 index 0a7f0058..00000000 --- a/openstack/tests/unit/bare_metal/test_bare_metal_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.bare_metal import bare_metal_service - - -class TestBareMetalService(testtools.TestCase): - - def test_service(self): - sot = bare_metal_service.BareMetalService() - self.assertEqual('baremetal', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v1', sot.valid_versions[0].module) - self.assertEqual('v1', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/bare_metal/test_version.py b/openstack/tests/unit/bare_metal/test_version.py deleted file mode 100644 index 38aff792..00000000 --- a/openstack/tests/unit/bare_metal/test_version.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.bare_metal import version - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'status': '3', - 'updated': '4', -} - - -class TestVersion(testtools.TestCase): - - def test_basic(self): - sot = version.Version() - self.assertEqual('version', sot.resource_key) - self.assertEqual('versions', sot.resources_key) - self.assertEqual('/', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertFalse(sot.allow_head) - self.assertFalse(sot.patch_update) - self.assertFalse(sot.put_create) - - def test_make_it(self): - sot = version.Version(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['updated'], sot.updated) diff --git a/openstack/tests/unit/bare_metal/v1/__init__.py b/openstack/tests/unit/bare_metal/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/bare_metal/v1/test_chassis.py b/openstack/tests/unit/bare_metal/v1/test_chassis.py deleted file mode 100644 index eab6c7a9..00000000 --- a/openstack/tests/unit/bare_metal/v1/test_chassis.py +++ /dev/null @@ -1,94 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.bare_metal.v1 import chassis - -FAKE = { - "created_at": "2016-08-18T22:28:48.165105+00:00", - "description": "Sample chassis", - "extra": {}, - "links": [ - { - "href": "http://127.0.0.1:6385/v1/chassis/ID", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/chassis/ID", - "rel": "bookmark" - } - ], - "nodes": [ - { - "href": "http://127.0.0.1:6385/v1/chassis/ID/nodes", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/chassis/ID/nodes", - "rel": "bookmark" - } - ], - "updated_at": None, - "uuid": "dff29d23-1ded-43b4-8ae1-5eebb3e30de1" -} - - -class TestChassis(testtools.TestCase): - - def test_basic(self): - sot = chassis.Chassis() - self.assertIsNone(sot.resource_key) - self.assertEqual('chassis', sot.resources_key) - self.assertEqual('/chassis', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_instantiate(self): - sot = chassis.Chassis(**FAKE) - self.assertEqual(FAKE['uuid'], sot.id) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['description'], sot.description) - self.assertEqual(FAKE['extra'], sot.extra) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['nodes'], sot.nodes) - self.assertEqual(FAKE['updated_at'], sot.updated_at) - - -class TestChassisDetail(testtools.TestCase): - - def test_basic(self): - sot = chassis.ChassisDetail() - self.assertIsNone(sot.resource_key) - self.assertEqual('chassis', sot.resources_key) - self.assertEqual('/chassis/detail', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = chassis.ChassisDetail(**FAKE) - self.assertEqual(FAKE['uuid'], sot.id) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['description'], sot.description) - self.assertEqual(FAKE['extra'], sot.extra) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['nodes'], sot.nodes) - self.assertEqual(FAKE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/bare_metal/v1/test_driver.py b/openstack/tests/unit/bare_metal/v1/test_driver.py deleted file mode 100644 index 36ce7dc1..00000000 --- a/openstack/tests/unit/bare_metal/v1/test_driver.py +++ /dev/null @@ -1,66 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.bare_metal.v1 import driver - -FAKE = { - "hosts": [ - "897ab1dad809" - ], - "links": [ - { - "href": "http://127.0.0.1:6385/v1/drivers/agent_ipmitool", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/drivers/agent_ipmitool", - "rel": "bookmark" - } - ], - "name": "agent_ipmitool", - "properties": [ - { - "href": - "http://127.0.0.1:6385/v1/drivers/agent_ipmitool/properties", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/drivers/agent_ipmitool/properties", - "rel": "bookmark" - } - ] -} - - -class TestDriver(testtools.TestCase): - - def test_basic(self): - sot = driver.Driver() - self.assertIsNone(sot.resource_key) - self.assertEqual('drivers', sot.resources_key) - self.assertEqual('/drivers', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = driver.Driver(**FAKE) - self.assertEqual(FAKE['name'], sot.id) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['hosts'], sot.hosts) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['properties'], sot.properties) diff --git a/openstack/tests/unit/bare_metal/v1/test_node.py b/openstack/tests/unit/bare_metal/v1/test_node.py deleted file mode 100644 index ddbf2512..00000000 --- a/openstack/tests/unit/bare_metal/v1/test_node.py +++ /dev/null @@ -1,198 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.bare_metal.v1 import node - -# NOTE: Sample data from api-ref doc -FAKE = { - "chassis_uuid": "1", # NOTE: missed in api-ref sample - "clean_step": {}, - "console_enabled": False, - "created_at": "2016-08-18T22:28:48.643434+00:00", - "driver": "agent_ipmitool", - "driver_info": { - "ipmi_password": "******", - "ipmi_username": "ADMIN" - }, - "driver_internal_info": {}, - "extra": {}, - "inspection_finished_at": None, - "inspection_started_at": None, - "instance_info": {}, - "instance_uuid": None, - "last_error": None, - "links": [ - { - "href": "http://127.0.0.1:6385/v1/nodes/", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/nodes/", - "rel": "bookmark" - } - ], - "maintenance": False, - "maintenance_reason": None, - "name": "test_node", - "network_interface": "flat", - "portgroups": [ - { - "href": "http://127.0.0.1:6385/v1/nodes//portgroups", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/nodes//portgroups", - "rel": "bookmark" - } - ], - "ports": [ - { - "href": "http://127.0.0.1:6385/v1/nodes//ports", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/nodes//ports", - "rel": "bookmark" - } - ], - "power_state": None, - "properties": {}, - "provision_state": "enroll", - "provision_updated_at": None, - "raid_config": {}, - "reservation": None, - "resource_class": None, - "states": [ - { - "href": "http://127.0.0.1:6385/v1/nodes//states", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/nodes//states", - "rel": "bookmark" - } - ], - "target_power_state": None, - "target_provision_state": None, - "target_raid_config": {}, - "updated_at": None, - "uuid": "6d85703a-565d-469a-96ce-30b6de53079d" -} - - -class TestNode(testtools.TestCase): - - def test_basic(self): - sot = node.Node() - self.assertIsNone(sot.resource_key) - self.assertEqual('nodes', sot.resources_key) - self.assertEqual('/nodes', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_instantiate(self): - sot = node.Node(**FAKE) - - self.assertEqual(FAKE['uuid'], sot.id) - self.assertEqual(FAKE['name'], sot.name) - - self.assertEqual(FAKE['chassis_uuid'], sot.chassis_id) - self.assertEqual(FAKE['clean_step'], sot.clean_step) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['driver'], sot.driver) - self.assertEqual(FAKE['driver_info'], sot.driver_info) - self.assertEqual(FAKE['driver_internal_info'], - sot.driver_internal_info) - self.assertEqual(FAKE['extra'], sot.extra) - self.assertEqual(FAKE['instance_info'], sot.instance_info) - self.assertEqual(FAKE['instance_uuid'], sot.instance_id) - self.assertEqual(FAKE['console_enabled'], sot.is_console_enabled) - self.assertEqual(FAKE['maintenance'], sot.is_maintenance) - self.assertEqual(FAKE['last_error'], sot.last_error) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['maintenance_reason'], sot.maintenance_reason) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['network_interface'], sot.network_interface) - self.assertEqual(FAKE['ports'], sot.ports) - self.assertEqual(FAKE['portgroups'], sot.port_groups) - self.assertEqual(FAKE['power_state'], sot.power_state) - self.assertEqual(FAKE['properties'], sot.properties) - self.assertEqual(FAKE['provision_state'], sot.provision_state) - self.assertEqual(FAKE['raid_config'], sot.raid_config) - self.assertEqual(FAKE['reservation'], sot.reservation) - self.assertEqual(FAKE['resource_class'], sot.resource_class) - self.assertEqual(FAKE['states'], sot.states) - self.assertEqual(FAKE['target_provision_state'], - sot.target_provision_state) - self.assertEqual(FAKE['target_power_state'], sot.target_power_state) - self.assertEqual(FAKE['target_raid_config'], sot.target_raid_config) - self.assertEqual(FAKE['updated_at'], sot.updated_at) - - -class TestNodeDetail(testtools.TestCase): - - def test_basic(self): - sot = node.NodeDetail() - self.assertIsNone(sot.resource_key) - self.assertEqual('nodes', sot.resources_key) - self.assertEqual('/nodes/detail', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = node.NodeDetail(**FAKE) - - self.assertEqual(FAKE['uuid'], sot.id) - self.assertEqual(FAKE['name'], sot.name) - - self.assertEqual(FAKE['chassis_uuid'], sot.chassis_id) - self.assertEqual(FAKE['clean_step'], sot.clean_step) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['driver'], sot.driver) - self.assertEqual(FAKE['driver_info'], sot.driver_info) - self.assertEqual(FAKE['driver_internal_info'], - sot.driver_internal_info) - self.assertEqual(FAKE['extra'], sot.extra) - self.assertEqual(FAKE['instance_info'], sot.instance_info) - self.assertEqual(FAKE['instance_uuid'], sot.instance_id) - self.assertEqual(FAKE['console_enabled'], sot.is_console_enabled) - self.assertEqual(FAKE['maintenance'], sot.is_maintenance) - self.assertEqual(FAKE['last_error'], sot.last_error) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['maintenance_reason'], sot.maintenance_reason) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['network_interface'], sot.network_interface) - self.assertEqual(FAKE['ports'], sot.ports) - self.assertEqual(FAKE['portgroups'], sot.port_groups) - self.assertEqual(FAKE['power_state'], sot.power_state) - self.assertEqual(FAKE['properties'], sot.properties) - self.assertEqual(FAKE['provision_state'], sot.provision_state) - self.assertEqual(FAKE['raid_config'], sot.raid_config) - self.assertEqual(FAKE['reservation'], sot.reservation) - self.assertEqual(FAKE['resource_class'], sot.resource_class) - self.assertEqual(FAKE['states'], sot.states) - self.assertEqual(FAKE['target_provision_state'], - sot.target_provision_state) - self.assertEqual(FAKE['target_power_state'], sot.target_power_state) - self.assertEqual(FAKE['target_raid_config'], sot.target_raid_config) - self.assertEqual(FAKE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/bare_metal/v1/test_port.py b/openstack/tests/unit/bare_metal/v1/test_port.py deleted file mode 100644 index c58b6f93..00000000 --- a/openstack/tests/unit/bare_metal/v1/test_port.py +++ /dev/null @@ -1,103 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.bare_metal.v1 import port - -FAKE = { - "address": "11:11:11:11:11:11", - "created_at": "2016-08-18T22:28:49.946416+00:00", - "extra": {}, - "internal_info": {}, - "links": [ - { - "href": "http://127.0.0.1:6385/v1/ports/", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/ports/", - "rel": "bookmark" - } - ], - "local_link_connection": { - "port_id": "Ethernet3/1", - "switch_id": "0a:1b:2c:3d:4e:5f", - "switch_info": "switch1" - }, - "node_uuid": "6d85703a-565d-469a-96ce-30b6de53079d", - "portgroup_uuid": "e43c722c-248e-4c6e-8ce8-0d8ff129387a", - "pxe_enabled": True, - "updated_at": None, - "uuid": "d2b30520-907d-46c8-bfee-c5586e6fb3a1" -} - - -class TestPort(testtools.TestCase): - - def test_basic(self): - sot = port.Port() - self.assertIsNone(sot.resource_key) - self.assertEqual('ports', sot.resources_key) - self.assertEqual('/ports', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_instantiate(self): - sot = port.PortDetail(**FAKE) - self.assertEqual(FAKE['uuid'], sot.id) - self.assertEqual(FAKE['address'], sot.address) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['extra'], sot.extra) - self.assertEqual(FAKE['internal_info'], sot.internal_info) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['local_link_connection'], - sot.local_link_connection) - self.assertEqual(FAKE['node_uuid'], sot.node_id) - self.assertEqual(FAKE['portgroup_uuid'], sot.port_group_id) - self.assertEqual(FAKE['pxe_enabled'], sot.is_pxe_enabled) - self.assertEqual(FAKE['updated_at'], sot.updated_at) - - -class TestPortDetail(testtools.TestCase): - - def test_basic(self): - sot = port.PortDetail() - self.assertIsNone(sot.resource_key) - self.assertEqual('ports', sot.resources_key) - self.assertEqual('/ports/detail', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = port.PortDetail(**FAKE) - self.assertEqual(FAKE['uuid'], sot.id) - self.assertEqual(FAKE['address'], sot.address) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['extra'], sot.extra) - self.assertEqual(FAKE['internal_info'], sot.internal_info) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['local_link_connection'], - sot.local_link_connection) - self.assertEqual(FAKE['node_uuid'], sot.node_id) - self.assertEqual(FAKE['portgroup_uuid'], sot.port_group_id) - self.assertEqual(FAKE['pxe_enabled'], sot.is_pxe_enabled) - self.assertEqual(FAKE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/bare_metal/v1/test_port_group.py b/openstack/tests/unit/bare_metal/v1/test_port_group.py deleted file mode 100644 index ea1cfd06..00000000 --- a/openstack/tests/unit/bare_metal/v1/test_port_group.py +++ /dev/null @@ -1,108 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.bare_metal.v1 import port_group - -FAKE = { - "address": "11:11:11:11:11:11", - "created_at": "2016-08-18T22:28:48.165105+00:00", - "extra": {}, - "internal_info": {}, - "links": [ - { - "href": "http://127.0.0.1:6385/v1/portgroups/", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/portgroups/", - "rel": "bookmark" - } - ], - "name": "test_portgroup", - "node_uuid": "6d85703a-565d-469a-96ce-30b6de53079d", - "ports": [ - { - "href": "http://127.0.0.1:6385/v1/portgroups//ports", - "rel": "self" - }, - { - "href": "http://127.0.0.1:6385/portgroups//ports", - "rel": "bookmark" - } - ], - "standalone_ports_supported": True, - "updated_at": None, - "uuid": "e43c722c-248e-4c6e-8ce8-0d8ff129387a", -} - - -class TestPortGroup(testtools.TestCase): - - def test_basic(self): - sot = port_group.PortGroup() - self.assertIsNone(sot.resource_key) - self.assertEqual('portgroups', sot.resources_key) - self.assertEqual('/portgroups', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_instantiate(self): - sot = port_group.PortGroup(**FAKE) - self.assertEqual(FAKE['uuid'], sot.id) - self.assertEqual(FAKE['address'], sot.address) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['extra'], sot.extra) - self.assertEqual(FAKE['internal_info'], sot.internal_info) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['node_uuid'], sot.node_id) - self.assertEqual(FAKE['ports'], sot.ports) - self.assertEqual(FAKE['standalone_ports_supported'], - sot.is_standalone_ports_supported) - self.assertEqual(FAKE['updated_at'], sot.updated_at) - - -class TestPortGroupDetail(testtools.TestCase): - - def test_basic(self): - sot = port_group.PortGroupDetail() - self.assertIsNone(sot.resource_key) - self.assertEqual('portgroups', sot.resources_key) - self.assertEqual('/portgroups/detail', sot.base_path) - self.assertEqual('baremetal', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = port_group.PortGroupDetail(**FAKE) - self.assertEqual(FAKE['uuid'], sot.id) - self.assertEqual(FAKE['address'], sot.address) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['extra'], sot.extra) - self.assertEqual(FAKE['internal_info'], sot.internal_info) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['node_uuid'], sot.node_id) - self.assertEqual(FAKE['ports'], sot.ports) - self.assertEqual(FAKE['standalone_ports_supported'], - sot.is_standalone_ports_supported) - self.assertEqual(FAKE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/bare_metal/v1/test_proxy.py b/openstack/tests/unit/bare_metal/v1/test_proxy.py deleted file mode 100644 index 34212a6a..00000000 --- a/openstack/tests/unit/bare_metal/v1/test_proxy.py +++ /dev/null @@ -1,164 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import deprecation - -from openstack.bare_metal.v1 import _proxy -from openstack.bare_metal.v1 import chassis -from openstack.bare_metal.v1 import driver -from openstack.bare_metal.v1 import node -from openstack.bare_metal.v1 import port -from openstack.bare_metal.v1 import port_group -from openstack.tests.unit import test_proxy_base2 - - -class TestBareMetalProxy(test_proxy_base2.TestProxyBase): - - def setUp(self): - super(TestBareMetalProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_drivers(self): - self.verify_list(self.proxy.drivers, driver.Driver, paginated=False) - - def test_get_driver(self): - self.verify_get(self.proxy.get_driver, driver.Driver) - - def test_chassis_detailed(self): - self.verify_list(self.proxy.chassis, chassis.ChassisDetail, - paginated=True, - method_kwargs={"details": True, "query": 1}, - expected_kwargs={"query": 1}) - - def test_chassis_not_detailed(self): - self.verify_list(self.proxy.chassis, chassis.Chassis, - paginated=True, - method_kwargs={"details": False, "query": 1}, - expected_kwargs={"query": 1}) - - def test_create_chassis(self): - self.verify_create(self.proxy.create_chassis, chassis.Chassis) - - def test_find_chassis(self): - self.verify_find(self.proxy.find_chassis, chassis.Chassis) - - def test_get_chassis(self): - self.verify_get(self.proxy.get_chassis, chassis.Chassis) - - def test_update_chassis(self): - self.verify_update(self.proxy.update_chassis, chassis.Chassis) - - def test_delete_chassis(self): - self.verify_delete(self.proxy.delete_chassis, chassis.Chassis, False) - - def test_delete_chassis_ignore(self): - self.verify_delete(self.proxy.delete_chassis, chassis.Chassis, True) - - def test_nodes_detailed(self): - self.verify_list(self.proxy.nodes, node.NodeDetail, - paginated=True, - method_kwargs={"details": True, "query": 1}, - expected_kwargs={"query": 1}) - - def test_nodes_not_detailed(self): - self.verify_list(self.proxy.nodes, node.Node, - paginated=True, - method_kwargs={"details": False, "query": 1}, - expected_kwargs={"query": 1}) - - def test_create_node(self): - self.verify_create(self.proxy.create_node, node.Node) - - def test_find_node(self): - self.verify_find(self.proxy.find_node, node.Node) - - def test_get_node(self): - self.verify_get(self.proxy.get_node, node.Node) - - def test_update_node(self): - self.verify_update(self.proxy.update_node, node.Node) - - def test_delete_node(self): - self.verify_delete(self.proxy.delete_node, node.Node, False) - - def test_delete_node_ignore(self): - self.verify_delete(self.proxy.delete_node, node.Node, True) - - def test_ports_detailed(self): - self.verify_list(self.proxy.ports, port.PortDetail, - paginated=True, - method_kwargs={"details": True, "query": 1}, - expected_kwargs={"query": 1}) - - def test_ports_not_detailed(self): - self.verify_list(self.proxy.ports, port.Port, - paginated=True, - method_kwargs={"details": False, "query": 1}, - expected_kwargs={"query": 1}) - - def test_create_port(self): - self.verify_create(self.proxy.create_port, port.Port) - - def test_find_port(self): - self.verify_find(self.proxy.find_port, port.Port) - - def test_get_port(self): - self.verify_get(self.proxy.get_port, port.Port) - - def test_update_port(self): - self.verify_update(self.proxy.update_port, port.Port) - - def test_delete_port(self): - self.verify_delete(self.proxy.delete_port, port.Port, False) - - def test_delete_port_ignore(self): - self.verify_delete(self.proxy.delete_port, port.Port, True) - - @deprecation.fail_if_not_removed - def test_portgroups_detailed(self): - self.verify_list(self.proxy.portgroups, port_group.PortGroupDetail, - paginated=True, - method_kwargs={"details": True, "query": 1}, - expected_kwargs={"query": 1}) - - @deprecation.fail_if_not_removed - def test_portgroups_not_detailed(self): - self.verify_list(self.proxy.portgroups, port_group.PortGroup, - paginated=True, - method_kwargs={"details": False, "query": 1}, - expected_kwargs={"query": 1}) - - @deprecation.fail_if_not_removed - def test_create_portgroup(self): - self.verify_create(self.proxy.create_portgroup, port_group.PortGroup) - - @deprecation.fail_if_not_removed - def test_find_portgroup(self): - self.verify_find(self.proxy.find_portgroup, port_group.PortGroup) - - @deprecation.fail_if_not_removed - def test_get_portgroup(self): - self.verify_get(self.proxy.get_portgroup, port_group.PortGroup) - - @deprecation.fail_if_not_removed - def test_update_portgroup(self): - self.verify_update(self.proxy.update_portgroup, port_group.PortGroup) - - @deprecation.fail_if_not_removed - def test_delete_portgroup(self): - self.verify_delete(self.proxy.delete_portgroup, port_group.PortGroup, - False) - - @deprecation.fail_if_not_removed - def test_delete_portgroup_ignore(self): - self.verify_delete(self.proxy.delete_portgroup, port_group.PortGroup, - True) diff --git a/openstack/tests/unit/base.py b/openstack/tests/unit/base.py deleted file mode 100644 index eae41c16..00000000 --- a/openstack/tests/unit/base.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2010-2011 OpenStack Foundation -# 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 os - -import fixtures -import testtools - -_TRUE_VALUES = ('true', '1', 'yes') - - -class TestCase(testtools.TestCase): - - """Test case base class for all unit tests.""" - - def setUp(self): - """Run before each test method to initialize test environment.""" - - super(TestCase, self).setUp() - test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0) - try: - test_timeout = int(test_timeout) - except ValueError: - # If timeout value is invalid do not set a timeout. - test_timeout = 0 - if test_timeout > 0: - self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) - - self.useFixture(fixtures.NestedTempfile()) - self.useFixture(fixtures.TempHomeDir()) - - if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES: - stdout = self.useFixture(fixtures.StringStream('stdout')).stream - self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) - if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES: - stderr = self.useFixture(fixtures.StringStream('stderr')).stream - self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) - - self.log_fixture = self.useFixture(fixtures.FakeLogger()) diff --git a/openstack/tests/unit/block_store/__init__.py b/openstack/tests/unit/block_store/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/block_store/test_block_store_service.py b/openstack/tests/unit/block_store/test_block_store_service.py deleted file mode 100644 index f02d12ac..00000000 --- a/openstack/tests/unit/block_store/test_block_store_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.block_store import block_store_service - - -class TestBlockStoreService(testtools.TestCase): - - def test_service(self): - sot = block_store_service.BlockStoreService() - self.assertEqual("volume", sot.service_type) - self.assertEqual("public", sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual("v2", sot.valid_versions[0].module) - self.assertEqual("v2", sot.valid_versions[0].path) diff --git a/openstack/tests/unit/block_store/v2/__init__.py b/openstack/tests/unit/block_store/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/block_store/v2/test_proxy.py b/openstack/tests/unit/block_store/v2/test_proxy.py deleted file mode 100644 index 4af3b4d8..00000000 --- a/openstack/tests/unit/block_store/v2/test_proxy.py +++ /dev/null @@ -1,88 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.block_store.v2 import _proxy -from openstack.block_store.v2 import snapshot -from openstack.block_store.v2 import type -from openstack.block_store.v2 import volume -from openstack.tests.unit import test_proxy_base2 - - -class TestVolumeProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestVolumeProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_snapshot_get(self): - self.verify_get(self.proxy.get_snapshot, snapshot.Snapshot) - - def test_snapshots_detailed(self): - self.verify_list(self.proxy.snapshots, snapshot.SnapshotDetail, - paginated=True, - method_kwargs={"details": True, "query": 1}, - expected_kwargs={"query": 1}) - - def test_snapshots_not_detailed(self): - self.verify_list(self.proxy.snapshots, snapshot.Snapshot, - paginated=True, - method_kwargs={"details": False, "query": 1}, - expected_kwargs={"query": 1}) - - def test_snapshot_create_attrs(self): - self.verify_create(self.proxy.create_snapshot, snapshot.Snapshot) - - def test_snapshot_delete(self): - self.verify_delete(self.proxy.delete_snapshot, - snapshot.Snapshot, False) - - def test_snapshot_delete_ignore(self): - self.verify_delete(self.proxy.delete_snapshot, - snapshot.Snapshot, True) - - def test_type_get(self): - self.verify_get(self.proxy.get_type, type.Type) - - def test_types(self): - self.verify_list(self.proxy.types, type.Type, paginated=False) - - def test_type_create_attrs(self): - self.verify_create(self.proxy.create_type, type.Type) - - def test_type_delete(self): - self.verify_delete(self.proxy.delete_type, type.Type, False) - - def test_type_delete_ignore(self): - self.verify_delete(self.proxy.delete_type, type.Type, True) - - def test_volume_get(self): - self.verify_get(self.proxy.get_volume, volume.Volume) - - def test_volumes_detailed(self): - self.verify_list(self.proxy.volumes, volume.VolumeDetail, - paginated=True, - method_kwargs={"details": True, "query": 1}, - expected_kwargs={"query": 1}) - - def test_volumes_not_detailed(self): - self.verify_list(self.proxy.volumes, volume.Volume, - paginated=True, - method_kwargs={"details": False, "query": 1}, - expected_kwargs={"query": 1}) - - def test_volume_create_attrs(self): - self.verify_create(self.proxy.create_volume, volume.Volume) - - def test_volume_delete(self): - self.verify_delete(self.proxy.delete_volume, volume.Volume, False) - - def test_volume_delete_ignore(self): - self.verify_delete(self.proxy.delete_volume, volume.Volume, True) diff --git a/openstack/tests/unit/block_store/v2/test_snapshot.py b/openstack/tests/unit/block_store/v2/test_snapshot.py deleted file mode 100644 index 79388489..00000000 --- a/openstack/tests/unit/block_store/v2/test_snapshot.py +++ /dev/null @@ -1,90 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.block_store.v2 import snapshot - -FAKE_ID = "ffa9bc5e-1172-4021-acaf-cdcd78a9584d" - -SNAPSHOT = { - "status": "creating", - "description": "Daily backup", - "created_at": "2015-03-09T12:14:57.233772", - "metadata": {}, - "volume_id": "5aa119a8-d25b-45a7-8d1b-88e127885635", - "size": 1, - "id": FAKE_ID, - "name": "snap-001", - "force": "true", -} - -DETAILS = { - "os-extended-snapshot-attributes:progress": "100%", - "os-extended-snapshot-attributes:project_id": - "0c2eba2c5af04d3f9e9d0d410b371fde" -} - -DETAILED_SNAPSHOT = SNAPSHOT.copy() -DETAILED_SNAPSHOT.update(**DETAILS) - - -class TestSnapshot(testtools.TestCase): - - def test_basic(self): - sot = snapshot.Snapshot(SNAPSHOT) - self.assertEqual("snapshot", sot.resource_key) - self.assertEqual("snapshots", sot.resources_key) - self.assertEqual("/snapshots", sot.base_path) - self.assertEqual("volume", sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - self.assertDictEqual({"name": "name", - "status": "status", - "all_tenants": "all_tenants", - "volume_id": "volume_id", - "limit": "limit", - "marker": "marker"}, - sot._query_mapping._mapping) - - def test_create_basic(self): - sot = snapshot.Snapshot(**SNAPSHOT) - self.assertEqual(SNAPSHOT["id"], sot.id) - self.assertEqual(SNAPSHOT["status"], sot.status) - self.assertEqual(SNAPSHOT["created_at"], sot.created_at) - self.assertEqual(SNAPSHOT["metadata"], sot.metadata) - self.assertEqual(SNAPSHOT["volume_id"], sot.volume_id) - self.assertEqual(SNAPSHOT["size"], sot.size) - self.assertEqual(SNAPSHOT["name"], sot.name) - self.assertTrue(sot.is_forced) - - -class TestSnapshotDetail(testtools.TestCase): - - def test_basic(self): - sot = snapshot.SnapshotDetail(DETAILED_SNAPSHOT) - self.assertIsInstance(sot, snapshot.Snapshot) - self.assertEqual("/snapshots/detail", sot.base_path) - - def test_create_detailed(self): - sot = snapshot.SnapshotDetail(**DETAILED_SNAPSHOT) - - self.assertEqual( - DETAILED_SNAPSHOT["os-extended-snapshot-attributes:progress"], - sot.progress) - self.assertEqual( - DETAILED_SNAPSHOT["os-extended-snapshot-attributes:project_id"], - sot.project_id) diff --git a/openstack/tests/unit/block_store/v2/test_type.py b/openstack/tests/unit/block_store/v2/test_type.py deleted file mode 100644 index d841b35c..00000000 --- a/openstack/tests/unit/block_store/v2/test_type.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.block_store.v2 import type - -FAKE_ID = "6685584b-1eac-4da6-b5c3-555430cf68ff" -TYPE = { - "extra_specs": { - "capabilities": "gpu" - }, - "id": FAKE_ID, - "name": "SSD" -} - - -class TestType(testtools.TestCase): - - def test_basic(self): - sot = type.Type(**TYPE) - self.assertEqual("volume_type", sot.resource_key) - self.assertEqual("volume_types", sot.resources_key) - self.assertEqual("/types", sot.base_path) - self.assertEqual("volume", sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertFalse(sot.allow_update) - - def test_new(self): - sot = type.Type.new(id=FAKE_ID) - self.assertEqual(FAKE_ID, sot.id) - - def test_create(self): - sot = type.Type(**TYPE) - self.assertEqual(TYPE["id"], sot.id) - self.assertEqual(TYPE["extra_specs"], sot.extra_specs) - self.assertEqual(TYPE["name"], sot.name) diff --git a/openstack/tests/unit/block_store/v2/test_volume.py b/openstack/tests/unit/block_store/v2/test_volume.py deleted file mode 100644 index 825cb910..00000000 --- a/openstack/tests/unit/block_store/v2/test_volume.py +++ /dev/null @@ -1,119 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -import testtools - -from openstack.block_store.v2 import volume - -FAKE_ID = "6685584b-1eac-4da6-b5c3-555430cf68ff" - -VOLUME = { - "status": "creating", - "name": "my_volume", - "attachments": [], - "availability_zone": "nova", - "bootable": "false", - "created_at": "2015-03-09T12:14:57.233772", - "description": "something", - "volume_type": "some_type", - "snapshot_id": "93c2e2aa-7744-4fd6-a31a-80c4726b08d7", - "source_volid": None, - "imageRef": "some_image", - "metadata": {}, - "id": FAKE_ID, - "size": 10 -} - -DETAILS = { - "os-vol-host-attr:host": "127.0.0.1", - "os-vol-tenant-attr:tenant_id": "some tenant", - "os-vol-mig-status-attr:migstat": "done", - "os-vol-mig-status-attr:name_id": "93c2e2aa-7744-4fd6-a31a-80c4726b08d7", - "replication_status": "nah", - "os-volume-replication:extended_status": "really nah", - "consistencygroup_id": "123asf-asdf123", - "os-volume-replication:driver_data": "ahasadfasdfasdfasdfsdf", - "snapshot_id": "93c2e2aa-7744-4fd6-a31a-80c4726b08d7", - "encrypted": "false", -} - -VOLUME_DETAIL = copy.copy(VOLUME) -VOLUME_DETAIL.update(DETAILS) - - -class TestVolume(testtools.TestCase): - - def test_basic(self): - sot = volume.Volume(VOLUME) - self.assertEqual("volume", sot.resource_key) - self.assertEqual("volumes", sot.resources_key) - self.assertEqual("/volumes", sot.base_path) - self.assertEqual("volume", sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - self.assertDictEqual({"name": "name", - "status": "status", - "all_tenants": "all_tenants", - "project_id": "project_id", - "limit": "limit", - "marker": "marker"}, - sot._query_mapping._mapping) - - def test_create(self): - sot = volume.Volume(**VOLUME) - self.assertEqual(VOLUME["id"], sot.id) - self.assertEqual(VOLUME["status"], sot.status) - self.assertEqual(VOLUME["attachments"], sot.attachments) - self.assertEqual(VOLUME["availability_zone"], sot.availability_zone) - self.assertFalse(sot.is_bootable) - self.assertEqual(VOLUME["created_at"], sot.created_at) - self.assertEqual(VOLUME["description"], sot.description) - self.assertEqual(VOLUME["volume_type"], sot.volume_type) - self.assertEqual(VOLUME["snapshot_id"], sot.snapshot_id) - self.assertEqual(VOLUME["source_volid"], sot.source_volume_id) - self.assertEqual(VOLUME["metadata"], sot.metadata) - self.assertEqual(VOLUME["size"], sot.size) - self.assertEqual(VOLUME["imageRef"], sot.image_id) - - -class TestVolumeDetail(testtools.TestCase): - - def test_basic(self): - sot = volume.VolumeDetail(VOLUME_DETAIL) - self.assertIsInstance(sot, volume.Volume) - self.assertEqual("/volumes/detail", sot.base_path) - - def test_create(self): - sot = volume.VolumeDetail(**VOLUME_DETAIL) - self.assertEqual(VOLUME_DETAIL["os-vol-host-attr:host"], sot.host) - self.assertEqual(VOLUME_DETAIL["os-vol-tenant-attr:tenant_id"], - sot.project_id) - self.assertEqual(VOLUME_DETAIL["os-vol-mig-status-attr:migstat"], - sot.migration_status) - self.assertEqual(VOLUME_DETAIL["os-vol-mig-status-attr:name_id"], - sot.migration_id) - self.assertEqual(VOLUME_DETAIL["replication_status"], - sot.replication_status) - self.assertEqual( - VOLUME_DETAIL["os-volume-replication:extended_status"], - sot.extended_replication_status) - self.assertEqual(VOLUME_DETAIL["consistencygroup_id"], - sot.consistency_group_id) - self.assertEqual(VOLUME_DETAIL["os-volume-replication:driver_data"], - sot.replication_driver_data) - self.assertFalse(sot.is_encrypted) diff --git a/openstack/tests/unit/cluster/__init__.py b/openstack/tests/unit/cluster/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/cluster/test_cluster_service.py b/openstack/tests/unit/cluster/test_cluster_service.py deleted file mode 100644 index 0d7532a6..00000000 --- a/openstack/tests/unit/cluster/test_cluster_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster import cluster_service - - -class TestClusterService(testtools.TestCase): - - def test_service(self): - sot = cluster_service.ClusterService() - self.assertEqual('clustering', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v1', sot.valid_versions[0].module) - self.assertEqual('v1', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/cluster/test_version.py b/openstack/tests/unit/cluster/test_version.py deleted file mode 100644 index c9b0a5bd..00000000 --- a/openstack/tests/unit/cluster/test_version.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster import version - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'status': '3', -} - - -class TestVersion(testtools.TestCase): - - def test_basic(self): - sot = version.Version() - self.assertEqual('version', sot.resource_key) - self.assertEqual('versions', sot.resources_key) - self.assertEqual('/', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = version.Version(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['status'], sot.status) diff --git a/openstack/tests/unit/cluster/v1/__init__.py b/openstack/tests/unit/cluster/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/cluster/v1/test_action.py b/openstack/tests/unit/cluster/v1/test_action.py deleted file mode 100644 index 01777952..00000000 --- a/openstack/tests/unit/cluster/v1/test_action.py +++ /dev/null @@ -1,82 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import action - - -FAKE_ID = '633bd3c6-520b-420f-8e6a-dc2a47022b53' -FAKE_NAME = 'node_create_c3783474' - -FAKE = { - 'id': FAKE_ID, - 'name': FAKE_NAME, - 'target': 'c378e474-d091-43a3-b083-e19719291358', - 'action': 'NODE_CREATE', - 'cause': 'RPC Request', - 'owner': None, - 'user': '3747afc360b64702a53bdd64dc1b8976', - 'project': '42d9e9663331431f97b75e25136307ff', - 'domain': '204ccccd267b40aea871750116b5b184', - 'interval': -1, - 'start_time': 1453414055.48672, - 'end_time': 1453414055.48672, - 'timeout': 3600, - 'status': 'SUCCEEDED', - 'status_reason': 'Action completed successfully.', - 'inputs': {}, - 'outputs': {}, - 'depends_on': [], - 'depended_by': [], - 'created_at': '2015-10-10T12:46:36.000000', - 'updated_at': '2016-10-10T12:46:36.000000', -} - - -class TestAction(testtools.TestCase): - - def setUp(self): - super(TestAction, self).setUp() - - def test_basic(self): - sot = action.Action() - self.assertEqual('action', sot.resource_key) - self.assertEqual('actions', sot.resources_key) - self.assertEqual('/actions', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = action.Action(**FAKE) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['target'], sot.target_id) - self.assertEqual(FAKE['action'], sot.action) - self.assertEqual(FAKE['cause'], sot.cause) - self.assertEqual(FAKE['owner'], sot.owner_id) - self.assertEqual(FAKE['user'], sot.user_id) - self.assertEqual(FAKE['project'], sot.project_id) - self.assertEqual(FAKE['domain'], sot.domain_id) - self.assertEqual(FAKE['interval'], sot.interval) - self.assertEqual(FAKE['start_time'], sot.start_at) - self.assertEqual(FAKE['end_time'], sot.end_at) - self.assertEqual(FAKE['timeout'], sot.timeout) - self.assertEqual(FAKE['status'], sot.status) - self.assertEqual(FAKE['status_reason'], sot.status_reason) - self.assertEqual(FAKE['inputs'], sot.inputs) - self.assertEqual(FAKE['outputs'], sot.outputs) - self.assertEqual(FAKE['depends_on'], sot.depends_on) - self.assertEqual(FAKE['depended_by'], sot.depended_by) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/cluster/v1/test_build_info.py b/openstack/tests/unit/cluster/v1/test_build_info.py deleted file mode 100644 index ab695c02..00000000 --- a/openstack/tests/unit/cluster/v1/test_build_info.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import build_info - - -FAKE = { - 'api': { - 'revision': '1.0.0', - }, - 'engine': { - 'revision': '1.0.0', - } -} - - -class TestBuildInfo(testtools.TestCase): - - def setUp(self): - super(TestBuildInfo, self).setUp() - - def test_basic(self): - sot = build_info.BuildInfo() - self.assertEqual('/build-info', sot.base_path) - self.assertEqual('build_info', sot.resource_key) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_get) - - def test_instantiate(self): - sot = build_info.BuildInfo(**FAKE) - self.assertEqual(FAKE['api'], sot.api) - self.assertEqual(FAKE['engine'], sot.engine) diff --git a/openstack/tests/unit/cluster/v1/test_cluster.py b/openstack/tests/unit/cluster/v1/test_cluster.py deleted file mode 100644 index 5c1de631..00000000 --- a/openstack/tests/unit/cluster/v1/test_cluster.py +++ /dev/null @@ -1,309 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.cluster.v1 import cluster - - -FAKE_ID = '092d0955-2645-461a-b8fa-6a44655cdb2c' -FAKE_NAME = 'test_cluster' - -FAKE = { - 'id': 'IDENTIFIER', - 'config': {'key1': 'value1', 'key2': 'value2'}, - 'desired_capacity': 1, - 'max_size': 3, - 'min_size': 0, - 'name': FAKE_NAME, - 'profile_id': 'myserver', - 'profile_only': True, - 'metadata': {}, - 'dependents': {}, - 'timeout': None, - 'init_at': '2015-10-10T12:46:36.000000', - 'created_at': '2015-10-10T12:46:36.000000', - 'updated_at': '2016-10-10T12:46:36.000000', -} - -FAKE_CREATE_RESP = { - 'cluster': { - 'action': 'a679c926-908f-49e7-a822-06ca371e64e1', - 'init_at': '2015-10-10T12:46:36.000000', - 'created_at': '2015-10-10T12:46:36.000000', - 'updated_at': '2016-10-10T12:46:36.000000', - 'data': {}, - 'desired_capacity': 1, - 'domain': None, - 'id': FAKE_ID, - 'init_time': None, - 'max_size': 3, - 'metadata': {}, - 'min_size': 0, - 'name': 'test_cluster', - 'nodes': [], - 'policies': [], - 'profile_id': '560a8f9d-7596-4a32-85e8-03645fa7be13', - 'profile_name': 'myserver', - 'project': '333acb15a43242f4a609a27cb097a8f2', - 'status': 'INIT', - 'status_reason': 'Initializing', - 'timeout': None, - 'user': '6d600911ff764e54b309ce734c89595e', - 'dependents': {}, - } -} - - -class TestCluster(testtools.TestCase): - - def setUp(self): - super(TestCluster, self).setUp() - - def test_basic(self): - sot = cluster.Cluster() - self.assertEqual('cluster', sot.resource_key) - self.assertEqual('clusters', sot.resources_key) - self.assertEqual('/clusters', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = cluster.Cluster(**FAKE) - - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['name'], sot.name) - - self.assertEqual(FAKE['profile_id'], sot.profile_id) - - self.assertEqual(FAKE['min_size'], sot.min_size) - self.assertEqual(FAKE['max_size'], sot.max_size) - self.assertEqual(FAKE['desired_capacity'], sot.desired_capacity) - - self.assertEqual(FAKE['config'], sot.config) - self.assertEqual(FAKE['timeout'], sot.timeout) - self.assertEqual(FAKE['metadata'], sot.metadata) - - self.assertEqual(FAKE['init_at'], sot.init_at) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['updated_at'], sot.updated_at) - self.assertEqual(FAKE['dependents'], sot.dependents) - self.assertTrue(sot.is_profile_only) - - self.assertDictEqual({"limit": "limit", - "marker": "marker", - "name": "name", - "status": "status", - "sort": "sort", - "global_project": "global_project"}, - sot._query_mapping._mapping) - - def test_scale_in(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.scale_in(sess, 3)) - url = 'clusters/%s/actions' % sot.id - body = {'scale_in': {'count': 3}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_scale_out(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.scale_out(sess, 3)) - url = 'clusters/%s/actions' % sot.id - body = {'scale_out': {'count': 3}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_resize(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.resize(sess, foo='bar', zoo=5)) - url = 'clusters/%s/actions' % sot.id - body = {'resize': {'foo': 'bar', 'zoo': 5}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_add_nodes(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.add_nodes(sess, ['node-33'])) - url = 'clusters/%s/actions' % sot.id - body = {'add_nodes': {'nodes': ['node-33']}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_del_nodes(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.del_nodes(sess, ['node-11'])) - url = 'clusters/%s/actions' % sot.id - body = {'del_nodes': {'nodes': ['node-11']}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_del_nodes_with_params(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - params = { - 'destroy_after_deletion': True, - } - self.assertEqual('', sot.del_nodes(sess, ['node-11'], **params)) - url = 'clusters/%s/actions' % sot.id - body = { - 'del_nodes': { - 'nodes': ['node-11'], - 'destroy_after_deletion': True, - } - } - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_replace_nodes(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.replace_nodes(sess, {'node-22': 'node-44'})) - url = 'clusters/%s/actions' % sot.id - body = {'replace_nodes': {'nodes': {'node-22': 'node-44'}}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_policy_attach(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - params = { - 'enabled': True, - } - self.assertEqual('', sot.policy_attach(sess, 'POLICY', **params)) - - url = 'clusters/%s/actions' % sot.id - body = { - 'policy_attach': { - 'policy_id': 'POLICY', - 'enabled': True, - } - } - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_policy_detach(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.policy_detach(sess, 'POLICY')) - - url = 'clusters/%s/actions' % sot.id - body = {'policy_detach': {'policy_id': 'POLICY'}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_policy_update(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - params = { - 'enabled': False - } - self.assertEqual('', sot.policy_update(sess, 'POLICY', **params)) - - url = 'clusters/%s/actions' % sot.id - body = { - 'policy_update': { - 'policy_id': 'POLICY', - 'enabled': False - } - } - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_check(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.check(sess)) - url = 'clusters/%s/actions' % sot.id - body = {'check': {}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_recover(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.recover(sess)) - url = 'clusters/%s/actions' % sot.id - body = {'recover': {}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_operation(self): - sot = cluster.Cluster(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.op(sess, 'dance', style='tango')) - url = 'clusters/%s/ops' % sot.id - body = {'dance': {'style': 'tango'}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) diff --git a/openstack/tests/unit/cluster/v1/test_cluster_attr.py b/openstack/tests/unit/cluster/v1/test_cluster_attr.py deleted file mode 100644 index cded9ef8..00000000 --- a/openstack/tests/unit/cluster/v1/test_cluster_attr.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import cluster_attr as ca - - -FAKE = { - 'cluster_id': '633bd3c6-520b-420f-8e6a-dc2a47022b53', - 'path': 'path.to.attr', - 'id': 'c378e474-d091-43a3-b083-e19719291358', - 'value': 'fake value', -} - - -class TestClusterAttr(testtools.TestCase): - - def setUp(self): - super(TestClusterAttr, self).setUp() - - def test_basic(self): - sot = ca.ClusterAttr() - self.assertEqual('cluster_attributes', sot.resources_key) - self.assertEqual('/clusters/%(cluster_id)s/attrs/%(path)s', - sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = ca.ClusterAttr(**FAKE) - self.assertEqual(FAKE['cluster_id'], sot.cluster_id) - self.assertEqual(FAKE['path'], sot.path) - self.assertEqual(FAKE['id'], sot.node_id) - self.assertEqual(FAKE['value'], sot.attr_value) diff --git a/openstack/tests/unit/cluster/v1/test_cluster_policy.py b/openstack/tests/unit/cluster/v1/test_cluster_policy.py deleted file mode 100644 index a4126977..00000000 --- a/openstack/tests/unit/cluster/v1/test_cluster_policy.py +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import cluster_policy - - -FAKE = { - 'cluster_id': '99e39f4b-1990-4237-a556-1518f0f0c9e7', - 'cluster_name': 'test_cluster', - 'data': {'purpose': 'unknown'}, - 'enabled': True, - 'policy_id': 'ac5415bd-f522-4160-8be0-f8853e4bc332', - 'policy_name': 'dp01', - 'policy_type': 'senlin.poicy.deletion-1.0', -} - - -class TestClusterPolicy(testtools.TestCase): - - def setUp(self): - super(TestClusterPolicy, self).setUp() - - def test_basic(self): - sot = cluster_policy.ClusterPolicy() - self.assertEqual('cluster_policy', sot.resource_key) - self.assertEqual('cluster_policies', sot.resources_key) - self.assertEqual('/clusters/%(cluster_id)s/policies', - sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_list) - - self.assertDictEqual({"policy_name": "policy_name", - "policy_type": "policy_type", - "is_enabled": "enabled", - "sort": "sort", - "limit": "limit", - "marker": "marker"}, - sot._query_mapping._mapping) - - def test_instantiate(self): - sot = cluster_policy.ClusterPolicy(**FAKE) - self.assertEqual(FAKE['policy_id'], sot.id) - self.assertEqual(FAKE['cluster_id'], sot.cluster_id) - self.assertEqual(FAKE['cluster_name'], sot.cluster_name) - self.assertEqual(FAKE['data'], sot.data) - self.assertTrue(sot.is_enabled) - self.assertEqual(FAKE['policy_id'], sot.policy_id) - self.assertEqual(FAKE['policy_name'], sot.policy_name) - self.assertEqual(FAKE['policy_type'], sot.policy_type) diff --git a/openstack/tests/unit/cluster/v1/test_event.py b/openstack/tests/unit/cluster/v1/test_event.py deleted file mode 100644 index 0d482b97..00000000 --- a/openstack/tests/unit/cluster/v1/test_event.py +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import event - - -FAKE = { - 'action': 'NODE_CREATE', - 'cluster_id': None, - 'id': 'ffaed25e-46f5-4089-8e20-b3b4722fd597', - 'level': '20', - 'oid': 'efff1c11-2ada-47da-bedd-2c9af4fd099a', - 'oname': 'node_create_b4a49016', - 'otype': 'NODEACTION', - 'project': '42d9e9663331431f97b75e25136307ff', - 'status': 'START', - 'status_reason': 'The action was abandoned.', - 'timestamp': '2016-10-10T12:46:36.000000', - 'user': '5e5bf8027826429c96af157f68dc9072' -} - - -class TestEvent(testtools.TestCase): - - def setUp(self): - super(TestEvent, self).setUp() - - def test_basic(self): - sot = event.Event() - self.assertEqual('event', sot.resource_key) - self.assertEqual('events', sot.resources_key) - self.assertEqual('/events', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = event.Event(**FAKE) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['action'], sot.action) - self.assertEqual(FAKE['cluster_id'], sot.cluster_id) - self.assertEqual(FAKE['level'], sot.level) - self.assertEqual(FAKE['oid'], sot.obj_id) - self.assertEqual(FAKE['oname'], sot.obj_name) - self.assertEqual(FAKE['otype'], sot.obj_type) - self.assertEqual(FAKE['project'], sot.project_id) - self.assertEqual(FAKE['status'], sot.status) - self.assertEqual(FAKE['status_reason'], sot.status_reason) - self.assertEqual(FAKE['timestamp'], sot.generated_at) - self.assertEqual(FAKE['user'], sot.user_id) diff --git a/openstack/tests/unit/cluster/v1/test_node.py b/openstack/tests/unit/cluster/v1/test_node.py deleted file mode 100644 index 9ffa543e..00000000 --- a/openstack/tests/unit/cluster/v1/test_node.py +++ /dev/null @@ -1,147 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.cluster.v1 import node - - -FAKE_ID = '123d0955-0099-aabb-b8fa-6a44655ceeff' -FAKE_NAME = 'test_node' - -FAKE = { - 'id': FAKE_ID, - 'cluster_id': 'clusterA', - 'metadata': {'key1': 'value1'}, - 'name': FAKE_NAME, - 'profile_id': 'myserver', - 'domain': '204ccccd267b40aea871750116b5b184', - 'user': '3747afc360b64702a53bdd64dc1b8976', - 'project': '42d9e9663331431f97b75e25136307ff', - 'index': 1, - 'role': 'master', - 'dependents': {}, - 'created_at': '2015-10-10T12:46:36.000000', - 'updated_at': '2016-10-10T12:46:36.000000', - 'init_at': '2015-10-10T12:46:36.000000', -} - - -class TestNode(testtools.TestCase): - - def test_basic(self): - sot = node.Node() - self.assertEqual('node', sot.resource_key) - self.assertEqual('nodes', sot.resources_key) - self.assertEqual('/nodes', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = node.Node(**FAKE) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['profile_id'], sot.profile_id) - self.assertEqual(FAKE['cluster_id'], sot.cluster_id) - self.assertEqual(FAKE['user'], sot.user_id) - self.assertEqual(FAKE['project'], sot.project_id) - self.assertEqual(FAKE['domain'], sot.domain_id) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['index'], sot.index) - self.assertEqual(FAKE['role'], sot.role) - self.assertEqual(FAKE['metadata'], sot.metadata) - self.assertEqual(FAKE['init_at'], sot.init_at) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['updated_at'], sot.updated_at) - self.assertEqual(FAKE['dependents'], sot.dependents) - - def test_check(self): - sot = node.Node(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.check(sess)) - url = 'nodes/%s/actions' % sot.id - body = {'check': {}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_recover(self): - sot = node.Node(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.recover(sess)) - url = 'nodes/%s/actions' % sot.id - body = {'recover': {}} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json=body) - - def test_operation(self): - sot = node.Node(**FAKE) - - resp = mock.Mock() - resp.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - self.assertEqual('', sot.op(sess, 'dance', style='tango')) - url = 'nodes/%s/ops' % sot.id - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - json={'dance': {'style': 'tango'}}) - - def test_adopt_preview(self): - sot = node.Node.new() - resp = mock.Mock() - resp.headers = {} - resp.json = mock.Mock(return_value={"foo": "bar"}) - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - - res = sot.adopt(sess, True, param="value") - self.assertEqual({"foo": "bar"}, res) - sess.post.assert_called_once_with("nodes/adopt-preview", - endpoint_filter=sot.service, - json={"param": "value"}) - - def test_adopt(self): - sot = node.Node.new() - resp = mock.Mock() - resp.headers = {} - resp.json = mock.Mock(return_value={"foo": "bar"}) - sess = mock.Mock() - sess.post = mock.Mock(return_value=resp) - - res = sot.adopt(sess, False, param="value") - self.assertEqual(sot, res) - sess.post.assert_called_once_with("nodes/adopt", - endpoint_filter=sot.service, - json={"param": "value"}) - - -class TestNodeDetail(testtools.TestCase): - - def test_basic(self): - sot = node.NodeDetail() - self.assertEqual('/nodes/%(node_id)s?show_details=True', sot.base_path) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) diff --git a/openstack/tests/unit/cluster/v1/test_policy.py b/openstack/tests/unit/cluster/v1/test_policy.py deleted file mode 100644 index 7a9b18fa..00000000 --- a/openstack/tests/unit/cluster/v1/test_policy.py +++ /dev/null @@ -1,89 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import policy - - -FAKE_ID = 'ac5415bd-f522-4160-8be0-f8853e4bc332' -FAKE_NAME = 'test_policy' - -FAKE = { - 'id': FAKE_ID, - 'name': FAKE_NAME, - 'spec': { - 'type': 'senlin.policy.deletion', - 'version': '1.0', - 'properties': { - 'criteria': 'OLDEST_FIRST', - 'grace_period': 60, - 'reduce_desired_capacity': False, - 'destroy_after_deletion': True, - } - }, - 'project': '42d9e9663331431f97b75e25136307ff', - 'domain': '204ccccd267b40aea871750116b5b184', - 'user': '3747afc360b64702a53bdd64dc1b8976', - 'type': 'senlin.policy.deletion-1.0', - 'created_at': '2015-10-10T12:46:36.000000', - 'updated_at': '2016-10-10T12:46:36.000000', - 'data': {}, -} - - -class TestPolicy(testtools.TestCase): - - def setUp(self): - super(TestPolicy, self).setUp() - - def test_basic(self): - sot = policy.Policy() - self.assertEqual('policy', sot.resource_key) - self.assertEqual('policies', sot.resources_key) - self.assertEqual('/policies', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = policy.Policy(**FAKE) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['spec'], sot.spec) - self.assertEqual(FAKE['project'], sot.project_id) - self.assertEqual(FAKE['domain'], sot.domain_id) - self.assertEqual(FAKE['user'], sot.user_id) - self.assertEqual(FAKE['data'], sot.data) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['updated_at'], sot.updated_at) - - -class TestPolicyValidate(testtools.TestCase): - - def setUp(self): - super(TestPolicyValidate, self).setUp() - - def test_basic(self): - sot = policy.PolicyValidate() - self.assertEqual('policy', sot.resource_key) - self.assertEqual('policies', sot.resources_key) - self.assertEqual('/policies/validate', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) diff --git a/openstack/tests/unit/cluster/v1/test_policy_type.py b/openstack/tests/unit/cluster/v1/test_policy_type.py deleted file mode 100644 index fd20733a..00000000 --- a/openstack/tests/unit/cluster/v1/test_policy_type.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import policy_type - - -FAKE = { - 'name': 'FAKE_POLICY_TYPE', - 'schema': { - 'foo': 'bar' - }, - 'support_status': { - '1.0': [{ - 'status': 'supported', - 'since': '2016.10' - }] - } -} - - -class TestPolicyType(testtools.TestCase): - - def test_basic(self): - sot = policy_type.PolicyType() - self.assertEqual('policy_type', sot.resource_key) - self.assertEqual('policy_types', sot.resources_key) - self.assertEqual('/policy-types', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = policy_type.PolicyType(**FAKE) - self.assertEqual(FAKE['name'], sot._get_id(sot)) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['schema'], sot.schema) - self.assertEqual(FAKE['support_status'], sot.support_status) diff --git a/openstack/tests/unit/cluster/v1/test_profile.py b/openstack/tests/unit/cluster/v1/test_profile.py deleted file mode 100644 index 7a65bf6f..00000000 --- a/openstack/tests/unit/cluster/v1/test_profile.py +++ /dev/null @@ -1,92 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import profile - - -FAKE_ID = '9b127538-a675-4271-ab9b-f24f54cfe173' -FAKE_NAME = 'test_profile' - -FAKE = { - 'metadata': {}, - 'name': FAKE_NAME, - 'id': FAKE_ID, - 'spec': { - 'type': 'os.nova.server', - 'version': 1.0, - 'properties': { - 'flavor': 1, - 'image': 'cirros-0.3.2-x86_64-uec', - 'key_name': 'oskey', - 'name': 'cirros_server' - } - }, - 'project': '42d9e9663331431f97b75e25136307ff', - 'domain': '204ccccd267b40aea871750116b5b184', - 'user': '3747afc360b64702a53bdd64dc1b8976', - 'type': 'os.nova.server', - 'created_at': '2015-10-10T12:46:36.000000', - 'updated_at': '2016-10-10T12:46:36.000000', -} - - -class TestProfile(testtools.TestCase): - - def setUp(self): - super(TestProfile, self).setUp() - - def test_basic(self): - sot = profile.Profile() - self.assertEqual('profile', sot.resource_key) - self.assertEqual('profiles', sot.resources_key) - self.assertEqual('/profiles', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_instantiate(self): - sot = profile.Profile(**FAKE) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['metadata'], sot.metadata) - self.assertEqual(FAKE['spec'], sot.spec) - self.assertEqual(FAKE['project'], sot.project_id) - self.assertEqual(FAKE['domain'], sot.domain_id) - self.assertEqual(FAKE['user'], sot.user_id) - self.assertEqual(FAKE['type'], sot.type) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['updated_at'], sot.updated_at) - - -class TestProfileValidate(testtools.TestCase): - - def setUp(self): - super(TestProfileValidate, self).setUp() - - def test_basic(self): - sot = profile.ProfileValidate() - self.assertEqual('profile', sot.resource_key) - self.assertEqual('profiles', sot.resources_key) - self.assertEqual('/profiles/validate', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - self.assertFalse(sot.patch_update) diff --git a/openstack/tests/unit/cluster/v1/test_profile_type.py b/openstack/tests/unit/cluster/v1/test_profile_type.py deleted file mode 100644 index d494a8e5..00000000 --- a/openstack/tests/unit/cluster/v1/test_profile_type.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import profile_type - - -FAKE = { - 'name': 'FAKE_PROFILE_TYPE', - 'schema': { - 'foo': 'bar' - }, - 'support_status': { - '1.0': [{ - 'status': 'supported', - 'since': '2016.10', - }] - } -} - - -class TestProfileType(testtools.TestCase): - - def test_basic(self): - sot = profile_type.ProfileType() - self.assertEqual('profile_type', sot.resource_key) - self.assertEqual('profile_types', sot.resources_key) - self.assertEqual('/profile-types', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = profile_type.ProfileType(**FAKE) - self.assertEqual(FAKE['name'], sot._get_id(sot)) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['schema'], sot.schema) - self.assertEqual(FAKE['support_status'], sot.support_status) diff --git a/openstack/tests/unit/cluster/v1/test_proxy.py b/openstack/tests/unit/cluster/v1/test_proxy.py deleted file mode 100644 index ec6b55c3..00000000 --- a/openstack/tests/unit/cluster/v1/test_proxy.py +++ /dev/null @@ -1,568 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import deprecation -import mock - -from openstack.cluster.v1 import _proxy -from openstack.cluster.v1 import action -from openstack.cluster.v1 import build_info -from openstack.cluster.v1 import cluster -from openstack.cluster.v1 import cluster_attr -from openstack.cluster.v1 import cluster_policy -from openstack.cluster.v1 import event -from openstack.cluster.v1 import node -from openstack.cluster.v1 import policy -from openstack.cluster.v1 import policy_type -from openstack.cluster.v1 import profile -from openstack.cluster.v1 import profile_type -from openstack.cluster.v1 import receiver -from openstack.cluster.v1 import service -from openstack import proxy2 as proxy_base -from openstack.tests.unit import test_proxy_base2 - - -class TestClusterProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestClusterProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_build_info_get(self): - self.verify_get(self.proxy.get_build_info, build_info.BuildInfo, - ignore_value=True, - expected_kwargs={'requires_id': False}) - - def test_profile_types(self): - self.verify_list(self.proxy.profile_types, - profile_type.ProfileType, - paginated=False) - - def test_profile_type_get(self): - self.verify_get(self.proxy.get_profile_type, - profile_type.ProfileType) - - def test_policy_types(self): - self.verify_list(self.proxy.policy_types, policy_type.PolicyType, - paginated=False) - - def test_policy_type_get(self): - self.verify_get(self.proxy.get_policy_type, policy_type.PolicyType) - - def test_profile_create(self): - self.verify_create(self.proxy.create_profile, profile.Profile) - - def test_profile_validate(self): - self.verify_create(self.proxy.validate_profile, - profile.ProfileValidate) - - def test_profile_delete(self): - self.verify_delete(self.proxy.delete_profile, profile.Profile, False) - - def test_profile_delete_ignore(self): - self.verify_delete(self.proxy.delete_profile, profile.Profile, True) - - def test_profile_find(self): - self.verify_find(self.proxy.find_profile, profile.Profile) - - def test_profile_get(self): - self.verify_get(self.proxy.get_profile, profile.Profile) - - def test_profiles(self): - self.verify_list(self.proxy.profiles, profile.Profile, - paginated=True, - method_kwargs={'limit': 2}, - expected_kwargs={'limit': 2}) - - def test_profile_update(self): - self.verify_update(self.proxy.update_profile, profile.Profile) - - def test_cluster_create(self): - self.verify_create(self.proxy.create_cluster, cluster.Cluster) - - def test_cluster_delete(self): - self.verify_delete(self.proxy.delete_cluster, cluster.Cluster, False) - - def test_cluster_delete_ignore(self): - self.verify_delete(self.proxy.delete_cluster, cluster.Cluster, True) - - def test_cluster_find(self): - self.verify_find(self.proxy.find_cluster, cluster.Cluster) - - def test_cluster_get(self): - self.verify_get(self.proxy.get_cluster, cluster.Cluster) - - def test_clusters(self): - self.verify_list(self.proxy.clusters, cluster.Cluster, - paginated=True, - method_kwargs={'limit': 2}, - expected_kwargs={'limit': 2}) - - def test_cluster_update(self): - self.verify_update(self.proxy.update_cluster, cluster.Cluster) - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_find') - def test_cluster_add_nodes(self, mock_find): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_find.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.add_nodes", - self.proxy.cluster_add_nodes, - method_args=["FAKE_CLUSTER", ["node1"]], - expected_args=[["node1"]]) - mock_find.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER", - ignore_missing=False) - - @deprecation.fail_if_not_removed - def test_cluster_add_nodes_with_obj(self): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - self._verify("openstack.cluster.v1.cluster.Cluster.add_nodes", - self.proxy.cluster_add_nodes, - method_args=[mock_cluster, ["node1"]], - expected_args=[["node1"]]) - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_find') - def test_cluster_del_nodes(self, mock_find): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_find.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.del_nodes", - self.proxy.cluster_del_nodes, - method_args=["FAKE_CLUSTER", ["node1"]], - expected_args=[["node1"]]) - mock_find.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER", - ignore_missing=False) - - @deprecation.fail_if_not_removed - def test_cluster_del_nodes_with_obj(self): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - self._verify("openstack.cluster.v1.cluster.Cluster.del_nodes", - self.proxy.cluster_del_nodes, - method_args=[mock_cluster, ["node1"]], - method_kwargs={"key": "value"}, - expected_args=[["node1"]], - expected_kwargs={"key": "value"}) - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_find') - def test_cluster_replace_nodes(self, mock_find): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_find.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.replace_nodes", - self.proxy.cluster_replace_nodes, - method_args=["FAKE_CLUSTER", {"node1": "node2"}], - expected_args=[{"node1": "node2"}]) - mock_find.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER", - ignore_missing=False) - - @deprecation.fail_if_not_removed - def test_cluster_replace_nodes_with_obj(self): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - self._verify("openstack.cluster.v1.cluster.Cluster.replace_nodes", - self.proxy.cluster_replace_nodes, - method_args=[mock_cluster, {"node1": "node2"}], - expected_args=[{"node1": "node2"}]) - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_find') - def test_cluster_scale_out(self, mock_find): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_find.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.scale_out", - self.proxy.cluster_scale_out, - method_args=["FAKE_CLUSTER", 3], - expected_args=[3]) - mock_find.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER", - ignore_missing=False) - - @deprecation.fail_if_not_removed - def test_cluster_scale_out_with_obj(self): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - self._verify("openstack.cluster.v1.cluster.Cluster.scale_out", - self.proxy.cluster_scale_out, - method_args=[mock_cluster, 5], - expected_args=[5]) - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_find') - def test_cluster_scale_in(self, mock_find): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_find.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.scale_in", - self.proxy.cluster_scale_in, - method_args=["FAKE_CLUSTER", 3], - expected_args=[3]) - mock_find.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER", - ignore_missing=False) - - @deprecation.fail_if_not_removed - def test_cluster_scale_in_with_obj(self): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - self._verify("openstack.cluster.v1.cluster.Cluster.scale_in", - self.proxy.cluster_scale_in, - method_args=[mock_cluster, 5], - expected_args=[5]) - - def test_services(self): - self.verify_list(self.proxy.services, - service.Service, - paginated=False) - - @mock.patch.object(proxy_base.BaseProxy, '_find') - def test_cluster_resize(self, mock_find): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_find.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.resize", - self.proxy.cluster_resize, - method_args=["FAKE_CLUSTER"], - method_kwargs={'k1': 'v1', 'k2': 'v2'}, - expected_kwargs={'k1': 'v1', 'k2': 'v2'}) - mock_find.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER", - ignore_missing=False) - - def test_cluster_resize_with_obj(self): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - self._verify("openstack.cluster.v1.cluster.Cluster.resize", - self.proxy.cluster_resize, - method_args=[mock_cluster], - method_kwargs={'k1': 'v1', 'k2': 'v2'}, - expected_kwargs={'k1': 'v1', 'k2': 'v2'}) - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_find') - def test_cluster_attach_policy(self, mock_find): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_find.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.policy_attach", - self.proxy.cluster_attach_policy, - method_args=["FAKE_CLUSTER", "FAKE_POLICY"], - method_kwargs={"k1": "v1", "k2": "v2"}, - expected_args=["FAKE_POLICY"], - expected_kwargs={"k1": "v1", 'k2': "v2"}) - mock_find.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER", - ignore_missing=False) - - @deprecation.fail_if_not_removed - def test_cluster_attach_policy_with_obj(self): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - self._verify("openstack.cluster.v1.cluster.Cluster.policy_attach", - self.proxy.cluster_attach_policy, - method_args=[mock_cluster, "FAKE_POLICY"], - method_kwargs={"k1": "v1", "k2": "v2"}, - expected_args=["FAKE_POLICY"], - expected_kwargs={"k1": "v1", 'k2': "v2"}) - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_find') - def test_cluster_detach_policy(self, mock_find): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_find.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.policy_detach", - self.proxy.cluster_detach_policy, - method_args=["FAKE_CLUSTER", "FAKE_POLICY"], - expected_args=["FAKE_POLICY"]) - mock_find.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER", - ignore_missing=False) - - @deprecation.fail_if_not_removed - def test_cluster_detach_policy_with_obj(self): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - self._verify("openstack.cluster.v1.cluster.Cluster.policy_detach", - self.proxy.cluster_detach_policy, - method_args=[mock_cluster, "FAKE_POLICY"], - expected_args=["FAKE_POLICY"]) - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_find') - def test_cluster_update_policy(self, mock_find): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_find.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.policy_update", - self.proxy.cluster_update_policy, - method_args=["FAKE_CLUSTER", "FAKE_POLICY"], - method_kwargs={"k1": "v1", "k2": "v2"}, - expected_args=["FAKE_POLICY"], - expected_kwargs={"k1": "v1", 'k2': "v2"}) - mock_find.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER", - ignore_missing=False) - - @deprecation.fail_if_not_removed - def test_cluster_update_policy_with_obj(self): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - self._verify("openstack.cluster.v1.cluster.Cluster.policy_update", - self.proxy.cluster_update_policy, - method_args=[mock_cluster, "FAKE_POLICY"], - method_kwargs={"k1": "v1", "k2": "v2"}, - expected_args=["FAKE_POLICY"], - expected_kwargs={"k1": "v1", 'k2': "v2"}) - - def test_collect_cluster_attrs(self): - self.verify_list(self.proxy.collect_cluster_attrs, - cluster_attr.ClusterAttr, paginated=False, - method_args=['FAKE_ID', 'path.to.attr'], - expected_kwargs={'cluster_id': 'FAKE_ID', - 'path': 'path.to.attr'}) - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_cluster_check(self, mock_get): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_get.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.check", - self.proxy.check_cluster, - method_args=["FAKE_CLUSTER"]) - mock_get.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER") - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_cluster_recover(self, mock_get): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_get.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.recover", - self.proxy.recover_cluster, - method_args=["FAKE_CLUSTER"]) - mock_get.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER") - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_cluster_operation(self, mock_get): - mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - mock_get.return_value = mock_cluster - self._verify("openstack.cluster.v1.cluster.Cluster.op", - self.proxy.cluster_operation, - method_args=["FAKE_CLUSTER", "dance"], - expected_args=["dance"]) - mock_get.assert_called_once_with(cluster.Cluster, "FAKE_CLUSTER") - - def test_node_create(self): - self.verify_create(self.proxy.create_node, node.Node) - - def test_node_delete(self): - self.verify_delete(self.proxy.delete_node, node.Node, False) - - def test_node_delete_ignore(self): - self.verify_delete(self.proxy.delete_node, node.Node, True) - - def test_node_find(self): - self.verify_find(self.proxy.find_node, node.Node) - - def test_node_get(self): - self.verify_get(self.proxy.get_node, node.Node) - - def test_node_get_with_details(self): - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_node, - method_args=['NODE_ID'], - method_kwargs={'details': True}, - expected_args=[node.NodeDetail], - expected_kwargs={'node_id': 'NODE_ID', - 'requires_id': False}) - - def test_nodes(self): - self.verify_list(self.proxy.nodes, node.Node, - paginated=True, - method_kwargs={'limit': 2}, - expected_kwargs={'limit': 2}) - - def test_node_update(self): - self.verify_update(self.proxy.update_node, node.Node) - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_node_check(self, mock_get): - mock_node = node.Node.new(id='FAKE_NODE') - mock_get.return_value = mock_node - self._verify("openstack.cluster.v1.node.Node.check", - self.proxy.check_node, - method_args=["FAKE_NODE"]) - mock_get.assert_called_once_with(node.Node, "FAKE_NODE") - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_node_recover(self, mock_get): - mock_node = node.Node.new(id='FAKE_NODE') - mock_get.return_value = mock_node - self._verify("openstack.cluster.v1.node.Node.recover", - self.proxy.recover_node, - method_args=["FAKE_NODE"]) - mock_get.assert_called_once_with(node.Node, "FAKE_NODE") - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_node_adopt(self, mock_get): - mock_node = node.Node.new() - mock_get.return_value = mock_node - self._verify("openstack.cluster.v1.node.Node.adopt", - self.proxy.adopt_node, - method_kwargs={"preview": False, "foo": "bar"}, - expected_kwargs={"preview": False, "foo": "bar"}) - - mock_get.assert_called_once_with(node.Node, None) - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_node_adopt_preview(self, mock_get): - mock_node = node.Node.new() - mock_get.return_value = mock_node - self._verify("openstack.cluster.v1.node.Node.adopt", - self.proxy.adopt_node, - method_kwargs={"preview": True, "foo": "bar"}, - expected_kwargs={"preview": True, "foo": "bar"}) - - mock_get.assert_called_once_with(node.Node, None) - - @deprecation.fail_if_not_removed - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_node_operation(self, mock_get): - mock_node = node.Node.new(id='FAKE_CLUSTER') - mock_get.return_value = mock_node - self._verify("openstack.cluster.v1.node.Node.op", - self.proxy.node_operation, - method_args=["FAKE_NODE", "dance"], - expected_args=["dance"]) - mock_get.assert_called_once_with(node.Node, "FAKE_NODE") - - def test_policy_create(self): - self.verify_create(self.proxy.create_policy, policy.Policy) - - def test_policy_validate(self): - self.verify_create(self.proxy.validate_policy, policy.PolicyValidate) - - def test_policy_delete(self): - self.verify_delete(self.proxy.delete_policy, policy.Policy, False) - - def test_policy_delete_ignore(self): - self.verify_delete(self.proxy.delete_policy, policy.Policy, True) - - def test_policy_find(self): - self.verify_find(self.proxy.find_policy, policy.Policy) - - def test_policy_get(self): - self.verify_get(self.proxy.get_policy, policy.Policy) - - def test_policies(self): - self.verify_list(self.proxy.policies, policy.Policy, - paginated=True, - method_kwargs={'limit': 2}, - expected_kwargs={'limit': 2}) - - def test_policy_update(self): - self.verify_update(self.proxy.update_policy, policy.Policy) - - def test_cluster_policies(self): - self.verify_list(self.proxy.cluster_policies, - cluster_policy.ClusterPolicy, - paginated=False, method_args=["FAKE_CLUSTER"], - expected_kwargs={"cluster_id": "FAKE_CLUSTER"}) - - def test_get_cluster_policy(self): - fake_policy = cluster_policy.ClusterPolicy.new(id="FAKE_POLICY") - fake_cluster = cluster.Cluster.new(id='FAKE_CLUSTER') - - # ClusterPolicy object as input - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_cluster_policy, - method_args=[fake_policy, "FAKE_CLUSTER"], - expected_args=[cluster_policy.ClusterPolicy, - fake_policy], - expected_kwargs={'cluster_id': 'FAKE_CLUSTER'}, - expected_result=fake_policy) - - # Policy ID as input - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_cluster_policy, - method_args=["FAKE_POLICY", "FAKE_CLUSTER"], - expected_args=[cluster_policy.ClusterPolicy, - "FAKE_POLICY"], - expected_kwargs={"cluster_id": "FAKE_CLUSTER"}) - - # Cluster object as input - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_cluster_policy, - method_args=["FAKE_POLICY", fake_cluster], - expected_args=[cluster_policy.ClusterPolicy, - "FAKE_POLICY"], - expected_kwargs={"cluster_id": fake_cluster}) - - def test_receiver_create(self): - self.verify_create(self.proxy.create_receiver, receiver.Receiver) - - def test_receiver_update(self): - self.verify_update(self.proxy.update_receiver, receiver.Receiver) - - def test_receiver_delete(self): - self.verify_delete(self.proxy.delete_receiver, receiver.Receiver, - False) - - def test_receiver_delete_ignore(self): - self.verify_delete(self.proxy.delete_receiver, receiver.Receiver, True) - - def test_receiver_find(self): - self.verify_find(self.proxy.find_receiver, receiver.Receiver) - - def test_receiver_get(self): - self.verify_get(self.proxy.get_receiver, receiver.Receiver) - - def test_receivers(self): - self.verify_list(self.proxy.receivers, receiver.Receiver, - paginated=True, - method_kwargs={'limit': 2}, - expected_kwargs={'limit': 2}) - - def test_action_get(self): - self.verify_get(self.proxy.get_action, action.Action) - - def test_actions(self): - self.verify_list(self.proxy.actions, action.Action, - paginated=True, - method_kwargs={'limit': 2}, - expected_kwargs={'limit': 2}) - - def test_event_get(self): - self.verify_get(self.proxy.get_event, event.Event) - - def test_events(self): - self.verify_list(self.proxy.events, event.Event, - paginated=True, - method_kwargs={'limit': 2}, - expected_kwargs={'limit': 2}) - - @mock.patch("openstack.resource2.wait_for_status") - def test_wait_for(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - - self.proxy.wait_for_status(mock_resource, 'ACTIVE') - - mock_wait.assert_called_once_with(self.session, mock_resource, - 'ACTIVE', [], 2, 120) - - @mock.patch("openstack.resource2.wait_for_status") - def test_wait_for_params(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - - self.proxy.wait_for_status(mock_resource, 'ACTIVE', ['ERROR'], 1, 2) - - mock_wait.assert_called_once_with(self.session, mock_resource, - 'ACTIVE', ['ERROR'], 1, 2) - - @mock.patch("openstack.resource2.wait_for_delete") - def test_wait_for_delete(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - - self.proxy.wait_for_delete(mock_resource) - - mock_wait.assert_called_once_with(self.session, mock_resource, 2, 120) - - @mock.patch("openstack.resource2.wait_for_delete") - def test_wait_for_delete_params(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - - self.proxy.wait_for_delete(mock_resource, 1, 2) - - mock_wait.assert_called_once_with(self.session, mock_resource, 1, 2) diff --git a/openstack/tests/unit/cluster/v1/test_receiver.py b/openstack/tests/unit/cluster/v1/test_receiver.py deleted file mode 100644 index bac16f00..00000000 --- a/openstack/tests/unit/cluster/v1/test_receiver.py +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.cluster.v1 import receiver - - -FAKE_ID = 'ae63a10b-4a90-452c-aef1-113a0b255ee3' -FAKE_NAME = 'test_receiver' - -FAKE = { - 'id': FAKE_ID, - 'name': FAKE_NAME, - 'type': 'webhook', - 'cluster_id': 'FAKE_CLUSTER', - 'action': 'CLUSTER_RESIZE', - 'created_at': '2015-10-10T12:46:36.000000', - 'updated_at': '2016-10-10T12:46:36.000000', - 'actor': {}, - 'params': { - 'adjustment_type': 'CHANGE_IN_CAPACITY', - 'adjustment': 2 - }, - 'channel': { - 'alarm_url': 'http://host:port/webhooks/AN_ID/trigger?V=1', - }, - 'user': 'FAKE_USER', - 'project': 'FAKE_PROJECT', - 'domain': '', -} - - -class TestReceiver(testtools.TestCase): - - def setUp(self): - super(TestReceiver, self).setUp() - - def test_basic(self): - sot = receiver.Receiver() - self.assertEqual('receiver', sot.resource_key) - self.assertEqual('receivers', sot.resources_key) - self.assertEqual('/receivers', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_instantiate(self): - sot = receiver.Receiver(**FAKE) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['type'], sot.type) - self.assertEqual(FAKE['cluster_id'], sot.cluster_id) - self.assertEqual(FAKE['action'], sot.action) - self.assertEqual(FAKE['params'], sot.params) - self.assertEqual(FAKE['created_at'], sot.created_at) - self.assertEqual(FAKE['updated_at'], sot.updated_at) - self.assertEqual(FAKE['user'], sot.user_id) - self.assertEqual(FAKE['project'], sot.project_id) - self.assertEqual(FAKE['domain'], sot.domain_id) - self.assertEqual(FAKE['channel'], sot.channel) diff --git a/openstack/tests/unit/cluster/v1/test_service.py b/openstack/tests/unit/cluster/v1/test_service.py deleted file mode 100644 index 20b3b1b5..00000000 --- a/openstack/tests/unit/cluster/v1/test_service.py +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.cluster.v1 import service - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'binary': 'senlin-engine', - 'host': 'host1', - 'status': 'enabled', - 'state': 'up', - 'disabled_reason': None, - 'updated_at': '2016-10-10T12:46:36.000000', -} - - -class TestService(testtools.TestCase): - - def setUp(self): - super(TestService, self).setUp() - self.resp = mock.Mock() - self.resp.body = None - self.resp.json = mock.Mock(return_value=self.resp.body) - self.sess = mock.Mock() - self.sess.put = mock.Mock(return_value=self.resp) - - def test_basic(self): - sot = service.Service() - self.assertEqual('service', sot.resource_key) - self.assertEqual('services', sot.resources_key) - self.assertEqual('/services', sot.base_path) - self.assertEqual('clustering', sot.service.service_type) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = service.Service(**EXAMPLE) - self.assertEqual(EXAMPLE['host'], sot.host) - self.assertEqual(EXAMPLE['binary'], sot.binary) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['state'], sot.state) - self.assertEqual(EXAMPLE['disabled_reason'], sot.disabled_reason) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/compute/__init__.py b/openstack/tests/unit/compute/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/compute/test_compute_service.py b/openstack/tests/unit/compute/test_compute_service.py deleted file mode 100644 index 3c5b26c8..00000000 --- a/openstack/tests/unit/compute/test_compute_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute import compute_service - - -class TestComputeService(testtools.TestCase): - - def test_service(self): - sot = compute_service.ComputeService() - self.assertEqual('compute', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v2', sot.valid_versions[0].module) - self.assertEqual('v2', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/compute/test_version.py b/openstack/tests/unit/compute/test_version.py deleted file mode 100644 index 0940b2cf..00000000 --- a/openstack/tests/unit/compute/test_version.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute import version - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'status': '3', - 'updated': '4', -} - - -class TestVersion(testtools.TestCase): - - def test_basic(self): - sot = version.Version() - self.assertEqual('version', sot.resource_key) - self.assertEqual('versions', sot.resources_key) - self.assertEqual('/', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = version.Version(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['updated'], sot.updated) diff --git a/openstack/tests/unit/compute/v2/__init__.py b/openstack/tests/unit/compute/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/compute/v2/test_availability_zone.py b/openstack/tests/unit/compute/v2/test_availability_zone.py deleted file mode 100644 index 4d4abe09..00000000 --- a/openstack/tests/unit/compute/v2/test_availability_zone.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute.v2 import availability_zone as az - -IDENTIFIER = 'IDENTIFIER' -BASIC_EXAMPLE = { - 'id': IDENTIFIER, - 'zoneState': 'available', - 'hosts': 'host1', - 'zoneName': 'zone1' -} - - -class TestAvailabilityZone(testtools.TestCase): - - def test_basic(self): - sot = az.AvailabilityZone() - self.assertEqual('availabilityZoneInfo', sot.resources_key) - self.assertEqual('/os-availability-zone', sot.base_path) - self.assertTrue(sot.allow_list) - self.assertEqual('compute', sot.service.service_type) - - def test_basic_detail(self): - sot = az.AvailabilityZoneDetail() - self.assertEqual('availabilityZoneInfo', sot.resources_key) - self.assertEqual('/os-availability-zone/detail', sot.base_path) - self.assertTrue(sot.allow_list) - self.assertEqual('compute', sot.service.service_type) - - def test_make_basic(self): - sot = az.AvailabilityZone(**BASIC_EXAMPLE) - self.assertEqual(BASIC_EXAMPLE['id'], sot.id) - self.assertEqual(BASIC_EXAMPLE['zoneState'], sot.state) - self.assertEqual(BASIC_EXAMPLE['hosts'], sot.hosts) - self.assertEqual(BASIC_EXAMPLE['zoneName'], sot.name) diff --git a/openstack/tests/unit/compute/v2/test_extension.py b/openstack/tests/unit/compute/v2/test_extension.py deleted file mode 100644 index 8d59084b..00000000 --- a/openstack/tests/unit/compute/v2/test_extension.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute.v2 import extension - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'alias': '1', - 'description': '2', - 'links': '3', - 'name': '4', - 'namespace': '5', - 'updated': '2015-03-09T12:14:57.233772', -} - - -class TestExtension(testtools.TestCase): - - def test_basic(self): - sot = extension.Extension() - self.assertEqual('extension', sot.resource_key) - self.assertEqual('extensions', sot.resources_key) - self.assertEqual('/extensions', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = extension.Extension(**EXAMPLE) - self.assertEqual(EXAMPLE['alias'], sot.alias) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['namespace'], sot.namespace) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) diff --git a/openstack/tests/unit/compute/v2/test_flavor.py b/openstack/tests/unit/compute/v2/test_flavor.py deleted file mode 100644 index dba4a4aa..00000000 --- a/openstack/tests/unit/compute/v2/test_flavor.py +++ /dev/null @@ -1,82 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute.v2 import flavor - -IDENTIFIER = 'IDENTIFIER' -BASIC_EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'name': '3', - 'disk': 4, - 'os-flavor-access:is_public': True, - 'ram': 6, - 'vcpus': 7, - 'swap': 8, - 'OS-FLV-EXT-DATA:ephemeral': 9, - 'OS-FLV-DISABLED:disabled': False, - 'rxtx_factor': 11.0 -} - - -class TestFlavor(testtools.TestCase): - - def test_basic(self): - sot = flavor.Flavor() - self.assertEqual('flavor', sot.resource_key) - self.assertEqual('flavors', sot.resources_key) - self.assertEqual('/flavors', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertFalse(sot.allow_update) - - self.assertDictEqual({"sort_key": "sort_key", - "sort_dir": "sort_dir", - "min_disk": "minDisk", - "min_ram": "minRam", - "limit": "limit", - "marker": "marker"}, - sot._query_mapping._mapping) - - def test_make_basic(self): - sot = flavor.Flavor(**BASIC_EXAMPLE) - self.assertEqual(BASIC_EXAMPLE['id'], sot.id) - self.assertEqual(BASIC_EXAMPLE['links'], sot.links) - self.assertEqual(BASIC_EXAMPLE['name'], sot.name) - self.assertEqual(BASIC_EXAMPLE['disk'], sot.disk) - self.assertEqual(BASIC_EXAMPLE['os-flavor-access:is_public'], - sot.is_public) - self.assertEqual(BASIC_EXAMPLE['ram'], sot.ram) - self.assertEqual(BASIC_EXAMPLE['vcpus'], sot.vcpus) - self.assertEqual(BASIC_EXAMPLE['swap'], sot.swap) - self.assertEqual(BASIC_EXAMPLE['OS-FLV-EXT-DATA:ephemeral'], - sot.ephemeral) - self.assertEqual(BASIC_EXAMPLE['OS-FLV-DISABLED:disabled'], - sot.is_disabled) - self.assertEqual(BASIC_EXAMPLE['rxtx_factor'], sot.rxtx_factor) - - def test_detail(self): - sot = flavor.FlavorDetail() - self.assertEqual('flavor', sot.resource_key) - self.assertEqual('flavors', sot.resources_key) - self.assertEqual('/flavors/detail', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) diff --git a/openstack/tests/unit/compute/v2/test_hypervisor.py b/openstack/tests/unit/compute/v2/test_hypervisor.py deleted file mode 100644 index 04829c08..00000000 --- a/openstack/tests/unit/compute/v2/test_hypervisor.py +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute.v2 import hypervisor - -EXAMPLE = { - "status": "enabled", - "service": { - "host": "fake-mini", - "disabled_reason": None, - "id": 6 - }, - "vcpus_used": 0, - "hypervisor_type": "QEMU", - "local_gb_used": 0, - "vcpus": 8, - "hypervisor_hostname": "fake-mini", - "memory_mb_used": 512, - "memory_mb": 7980, - "current_workload": 0, - "state": "up", - "host_ip": "23.253.248.171", - "cpu_info": "some cpu info", - "running_vms": 0, - "free_disk_gb": 157, - "hypervisor_version": 2000000, - "disk_available_least": 140, - "local_gb": 157, - "free_ram_mb": 7468, - "id": 1 -} - - -class TestHypervisor(testtools.TestCase): - - def test_basic(self): - sot = hypervisor.Hypervisor() - self.assertEqual('hypervisor', sot.resource_key) - self.assertEqual('hypervisors', sot.resources_key) - self.assertEqual('/os-hypervisors', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = hypervisor.Hypervisor(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['hypervisor_hostname'], sot.name) - self.assertEqual(EXAMPLE['state'], sot.state) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['service'], sot.service_details) - self.assertEqual(EXAMPLE['vcpus_used'], sot.vcpus_used) - self.assertEqual(EXAMPLE['hypervisor_type'], sot.hypervisor_type) - self.assertEqual(EXAMPLE['local_gb_used'], sot.local_disk_used) - self.assertEqual(EXAMPLE['vcpus'], sot.vcpus) - self.assertEqual(EXAMPLE['vcpus_used'], sot.vcpus_used) - self.assertEqual(EXAMPLE['memory_mb_used'], sot.memory_used) - self.assertEqual(EXAMPLE['memory_mb'], sot.memory_size) - self.assertEqual(EXAMPLE['current_workload'], sot.current_workload) - self.assertEqual(EXAMPLE['host_ip'], sot.host_ip) - self.assertEqual(EXAMPLE['cpu_info'], sot.cpu_info) - self.assertEqual(EXAMPLE['running_vms'], sot.running_vms) - self.assertEqual(EXAMPLE['free_disk_gb'], sot.local_disk_free) - self.assertEqual(EXAMPLE['hypervisor_version'], sot.hypervisor_version) - self.assertEqual(EXAMPLE['disk_available_least'], sot.disk_available) - self.assertEqual(EXAMPLE['local_gb'], sot.local_disk_size) - self.assertEqual(EXAMPLE['free_ram_mb'], sot.memory_free) diff --git a/openstack/tests/unit/compute/v2/test_image.py b/openstack/tests/unit/compute/v2/test_image.py deleted file mode 100644 index 8e848a23..00000000 --- a/openstack/tests/unit/compute/v2/test_image.py +++ /dev/null @@ -1,94 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute.v2 import image - -IDENTIFIER = 'IDENTIFIER' -BASIC_EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'name': '3', -} - -DETAILS = { - 'created': '2015-03-09T12:14:57.233772', - 'metadata': {'key': '2'}, - 'minDisk': 3, - 'minRam': 4, - 'progress': 5, - 'status': '6', - 'updated': '2015-03-09T12:15:57.233772', - 'OS-EXT-IMG-SIZE:size': 8 -} - -DETAIL_EXAMPLE = BASIC_EXAMPLE.copy() -DETAIL_EXAMPLE.update(DETAILS) - - -class TestImage(testtools.TestCase): - - def test_basic(self): - sot = image.Image() - self.assertEqual('image', sot.resource_key) - self.assertEqual('images', sot.resources_key) - self.assertEqual('/images', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - self.assertDictEqual({"server": "server", - "name": "name", - "status": "status", - "type": "type", - "min_disk": "minDisk", - "min_ram": "minRam", - "changes_since": "changes-since", - "limit": "limit", - "marker": "marker"}, - sot._query_mapping._mapping) - - def test_make_basic(self): - sot = image.Image(**BASIC_EXAMPLE) - self.assertEqual(BASIC_EXAMPLE['id'], sot.id) - self.assertEqual(BASIC_EXAMPLE['links'], sot.links) - self.assertEqual(BASIC_EXAMPLE['name'], sot.name) - - def test_detail(self): - sot = image.ImageDetail() - self.assertEqual('image', sot.resource_key) - self.assertEqual('images', sot.resources_key) - self.assertEqual('/images/detail', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_detail(self): - sot = image.ImageDetail(**DETAIL_EXAMPLE) - self.assertEqual(DETAIL_EXAMPLE['created'], sot.created_at) - self.assertEqual(DETAIL_EXAMPLE['id'], sot.id) - self.assertEqual(DETAIL_EXAMPLE['links'], sot.links) - self.assertEqual(DETAIL_EXAMPLE['metadata'], sot.metadata) - self.assertEqual(DETAIL_EXAMPLE['minDisk'], sot.min_disk) - self.assertEqual(DETAIL_EXAMPLE['minRam'], sot.min_ram) - self.assertEqual(DETAIL_EXAMPLE['name'], sot.name) - self.assertEqual(DETAIL_EXAMPLE['progress'], sot.progress) - self.assertEqual(DETAIL_EXAMPLE['status'], sot.status) - self.assertEqual(DETAIL_EXAMPLE['updated'], sot.updated_at) - self.assertEqual(DETAIL_EXAMPLE['OS-EXT-IMG-SIZE:size'], sot.size) diff --git a/openstack/tests/unit/compute/v2/test_keypair.py b/openstack/tests/unit/compute/v2/test_keypair.py deleted file mode 100644 index 3fb3dbcb..00000000 --- a/openstack/tests/unit/compute/v2/test_keypair.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute.v2 import keypair - -EXAMPLE = { - 'fingerprint': '1', - 'name': '2', - 'public_key': '3', - 'private_key': '3', -} - - -class TestKeypair(testtools.TestCase): - - def test_basic(self): - sot = keypair.Keypair() - self.assertEqual('keypair', sot.resource_key) - self.assertEqual('keypairs', sot.resources_key) - self.assertEqual('/os-keypairs', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = keypair.Keypair(**EXAMPLE) - self.assertEqual(EXAMPLE['fingerprint'], sot.fingerprint) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['public_key'], sot.public_key) - self.assertEqual(EXAMPLE['private_key'], sot.private_key) diff --git a/openstack/tests/unit/compute/v2/test_limits.py b/openstack/tests/unit/compute/v2/test_limits.py deleted file mode 100644 index e3134916..00000000 --- a/openstack/tests/unit/compute/v2/test_limits.py +++ /dev/null @@ -1,195 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.compute.v2 import limits - -ABSOLUTE_LIMITS = { - "maxImageMeta": 128, - "maxPersonality": 5, - "maxPersonalitySize": 10240, - "maxSecurityGroupRules": 20, - "maxSecurityGroups": 10, - "maxServerMeta": 128, - "maxTotalCores": 20, - "maxTotalFloatingIps": 10, - "maxTotalInstances": 10, - "maxTotalKeypairs": 100, - "maxTotalRAMSize": 51200, - "maxServerGroups": 10, - "maxServerGroupMembers": 10, - "totalFloatingIpsUsed": 1, - "totalSecurityGroupsUsed": 2, - "totalRAMUsed": 4, - "totalInstancesUsed": 5, - "totalServerGroupsUsed": 6, - "totalCoresUsed": 7 -} - -RATE_LIMIT = { - "limit": [ - { - "next-available": "2012-11-27T17:22:18Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "POST" - }, - ], - "regex": ".*", - "uri": "*" -} - -LIMITS_BODY = { - "limits": { - "absolute": ABSOLUTE_LIMITS, - "rate": [RATE_LIMIT] - } -} - - -class TestAbsoluteLimits(testtools.TestCase): - - def test_basic(self): - sot = limits.AbsoluteLimits() - self.assertIsNone(sot.resource_key) - self.assertIsNone(sot.resources_key) - self.assertEqual("", sot.base_path) - self.assertIsNone(sot.service) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = limits.AbsoluteLimits(**ABSOLUTE_LIMITS) - self.assertEqual(ABSOLUTE_LIMITS["maxImageMeta"], sot.image_meta) - self.assertEqual(ABSOLUTE_LIMITS["maxPersonality"], sot.personality) - self.assertEqual(ABSOLUTE_LIMITS["maxPersonalitySize"], - sot.personality_size) - self.assertEqual(ABSOLUTE_LIMITS["maxSecurityGroupRules"], - sot.security_group_rules) - self.assertEqual(ABSOLUTE_LIMITS["maxSecurityGroups"], - sot.security_groups) - self.assertEqual(ABSOLUTE_LIMITS["maxServerMeta"], sot.server_meta) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalCores"], sot.total_cores) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalFloatingIps"], - sot.floating_ips) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalInstances"], - sot.instances) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalKeypairs"], - sot.keypairs) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalRAMSize"], - sot.total_ram) - self.assertEqual(ABSOLUTE_LIMITS["maxServerGroups"], sot.server_groups) - self.assertEqual(ABSOLUTE_LIMITS["maxServerGroupMembers"], - sot.server_group_members) - self.assertEqual(ABSOLUTE_LIMITS["totalFloatingIpsUsed"], - sot.floating_ips_used) - self.assertEqual(ABSOLUTE_LIMITS["totalSecurityGroupsUsed"], - sot.security_groups_used) - self.assertEqual(ABSOLUTE_LIMITS["totalRAMUsed"], sot.total_ram_used) - self.assertEqual(ABSOLUTE_LIMITS["totalInstancesUsed"], - sot.instances_used) - self.assertEqual(ABSOLUTE_LIMITS["totalServerGroupsUsed"], - sot.server_groups_used) - self.assertEqual(ABSOLUTE_LIMITS["totalCoresUsed"], - sot.total_cores_used) - - -class TestRateLimit(testtools.TestCase): - - def test_basic(self): - sot = limits.RateLimit() - self.assertIsNone(sot.resource_key) - self.assertIsNone(sot.resources_key) - self.assertEqual("", sot.base_path) - self.assertIsNone(sot.service) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = limits.RateLimit(**RATE_LIMIT) - self.assertEqual(RATE_LIMIT["regex"], sot.regex) - self.assertEqual(RATE_LIMIT["uri"], sot.uri) - self.assertEqual(RATE_LIMIT["limit"], sot.limits) - - -class TestLimits(testtools.TestCase): - - def test_basic(self): - sot = limits.Limits() - self.assertEqual("limits", sot.resource_key) - self.assertEqual("/limits", sot.base_path) - self.assertEqual("compute", sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_get(self): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - resp.json.return_value = LIMITS_BODY - - sot = limits.Limits().get(sess) - - self.assertEqual(ABSOLUTE_LIMITS["maxImageMeta"], - sot.absolute.image_meta) - self.assertEqual(ABSOLUTE_LIMITS["maxPersonality"], - sot.absolute.personality) - self.assertEqual(ABSOLUTE_LIMITS["maxPersonalitySize"], - sot.absolute.personality_size) - self.assertEqual(ABSOLUTE_LIMITS["maxSecurityGroupRules"], - sot.absolute.security_group_rules) - self.assertEqual(ABSOLUTE_LIMITS["maxSecurityGroups"], - sot.absolute.security_groups) - self.assertEqual(ABSOLUTE_LIMITS["maxServerMeta"], - sot.absolute.server_meta) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalCores"], - sot.absolute.total_cores) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalFloatingIps"], - sot.absolute.floating_ips) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalInstances"], - sot.absolute.instances) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalKeypairs"], - sot.absolute.keypairs) - self.assertEqual(ABSOLUTE_LIMITS["maxTotalRAMSize"], - sot.absolute.total_ram) - self.assertEqual(ABSOLUTE_LIMITS["maxServerGroups"], - sot.absolute.server_groups) - self.assertEqual(ABSOLUTE_LIMITS["maxServerGroupMembers"], - sot.absolute.server_group_members) - self.assertEqual(ABSOLUTE_LIMITS["totalFloatingIpsUsed"], - sot.absolute.floating_ips_used) - self.assertEqual(ABSOLUTE_LIMITS["totalSecurityGroupsUsed"], - sot.absolute.security_groups_used) - self.assertEqual(ABSOLUTE_LIMITS["totalRAMUsed"], - sot.absolute.total_ram_used) - self.assertEqual(ABSOLUTE_LIMITS["totalInstancesUsed"], - sot.absolute.instances_used) - self.assertEqual(ABSOLUTE_LIMITS["totalServerGroupsUsed"], - sot.absolute.server_groups_used) - self.assertEqual(ABSOLUTE_LIMITS["totalCoresUsed"], - sot.absolute.total_cores_used) - - self.assertEqual(RATE_LIMIT["uri"], sot.rate[0].uri) - self.assertEqual(RATE_LIMIT["regex"], sot.rate[0].regex) - self.assertEqual(RATE_LIMIT["limit"], sot.rate[0].limits) diff --git a/openstack/tests/unit/compute/v2/test_metadata.py b/openstack/tests/unit/compute/v2/test_metadata.py deleted file mode 100644 index 458f931b..00000000 --- a/openstack/tests/unit/compute/v2/test_metadata.py +++ /dev/null @@ -1,86 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.compute.v2 import server - -IDENTIFIER = 'IDENTIFIER' - -# NOTE: The implementation for metadata is done via a mixin class that both -# the server and image resources inherit from. Currently this test class -# uses the Server resource to test it. Ideally it would be parameterized -# to run with both Server and Image when the tooling for subtests starts -# working. - - -class TestMetadata(testtools.TestCase): - - def setUp(self): - super(TestMetadata, self).setUp() - self.metadata_result = {"metadata": {"go": "cubs", "boo": "sox"}} - self.meta_result = {"meta": {"oh": "yeah"}} - - def test_get_all_metadata_Server(self): - self._test_get_all_metadata(server.Server(id=IDENTIFIER)) - - def test_get_all_metadata_ServerDetail(self): - # This is tested explicitly so we know ServerDetail items are - # properly having /detail stripped out of their base_path. - self._test_get_all_metadata(server.ServerDetail(id=IDENTIFIER)) - - def _test_get_all_metadata(self, sot): - response = mock.Mock() - response.json.return_value = self.metadata_result - sess = mock.Mock() - sess.get.return_value = response - - result = sot.get_metadata(sess) - - self.assertEqual(result, self.metadata_result["metadata"]) - sess.get.assert_called_once_with("servers/IDENTIFIER/metadata", - headers={}, - endpoint_filter=sot.service) - - def test_set_metadata(self): - response = mock.Mock() - response.json.return_value = self.metadata_result - sess = mock.Mock() - sess.post.return_value = response - - sot = server.Server(id=IDENTIFIER) - - set_meta = {"lol": "rofl"} - - result = sot.set_metadata(sess, **set_meta) - - self.assertEqual(result, self.metadata_result["metadata"]) - sess.post.assert_called_once_with("servers/IDENTIFIER/metadata", - endpoint_filter=sot.service, - headers={}, - json={"metadata": set_meta}) - - def test_delete_metadata(self): - sess = mock.Mock() - sess.delete.return_value = None - - sot = server.Server(id=IDENTIFIER) - - key = "hey" - - sot.delete_metadata(sess, [key]) - - sess.delete.assert_called_once_with( - "servers/IDENTIFIER/metadata/" + key, - headers={"Accept": ""}, - endpoint_filter=sot.service) diff --git a/openstack/tests/unit/compute/v2/test_proxy.py b/openstack/tests/unit/compute/v2/test_proxy.py deleted file mode 100644 index a608a261..00000000 --- a/openstack/tests/unit/compute/v2/test_proxy.py +++ /dev/null @@ -1,518 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.compute.v2 import _proxy -from openstack.compute.v2 import availability_zone as az -from openstack.compute.v2 import extension -from openstack.compute.v2 import flavor -from openstack.compute.v2 import hypervisor -from openstack.compute.v2 import image -from openstack.compute.v2 import keypair -from openstack.compute.v2 import limits -from openstack.compute.v2 import server -from openstack.compute.v2 import server_group -from openstack.compute.v2 import server_interface -from openstack.compute.v2 import server_ip -from openstack.compute.v2 import service -from openstack.tests.unit import test_proxy_base2 - - -class TestComputeProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestComputeProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_extension_find(self): - self.verify_find(self.proxy.find_extension, extension.Extension) - - def test_extensions(self): - self.verify_list_no_kwargs(self.proxy.extensions, extension.Extension, - paginated=False) - - def test_flavor_create(self): - self.verify_create(self.proxy.create_flavor, flavor.Flavor) - - def test_flavor_delete(self): - self.verify_delete(self.proxy.delete_flavor, flavor.Flavor, False) - - def test_flavor_delete_ignore(self): - self.verify_delete(self.proxy.delete_flavor, flavor.Flavor, True) - - def test_flavor_find(self): - self.verify_find(self.proxy.find_flavor, flavor.Flavor) - - def test_flavor_get(self): - self.verify_get(self.proxy.get_flavor, flavor.Flavor) - - def test_flavors_detailed(self): - self.verify_list(self.proxy.flavors, flavor.FlavorDetail, - paginated=True, - method_kwargs={"details": True, "query": 1}, - expected_kwargs={"query": 1}) - - def test_flavors_not_detailed(self): - self.verify_list(self.proxy.flavors, flavor.Flavor, - paginated=True, - method_kwargs={"details": False, "query": 1}, - expected_kwargs={"query": 1}) - - def test_image_delete(self): - self.verify_delete(self.proxy.delete_image, image.Image, False) - - def test_image_delete_ignore(self): - self.verify_delete(self.proxy.delete_image, image.Image, True) - - def test_image_find(self): - self.verify_find(self.proxy.find_image, image.Image) - - def test_image_get(self): - self.verify_get(self.proxy.get_image, image.Image) - - def test_images_detailed(self): - self.verify_list(self.proxy.images, image.ImageDetail, - paginated=True, - method_kwargs={"details": True, "query": 1}, - expected_kwargs={"query": 1}) - - def test_images_not_detailed(self): - self.verify_list(self.proxy.images, image.Image, - paginated=True, - method_kwargs={"details": False, "query": 1}, - expected_kwargs={"query": 1}) - - def test_keypair_create(self): - self.verify_create(self.proxy.create_keypair, keypair.Keypair) - - def test_keypair_delete(self): - self.verify_delete(self.proxy.delete_keypair, keypair.Keypair, False) - - def test_keypair_delete_ignore(self): - self.verify_delete(self.proxy.delete_keypair, keypair.Keypair, True) - - def test_keypair_find(self): - self.verify_find(self.proxy.find_keypair, keypair.Keypair) - - def test_keypair_get(self): - self.verify_get(self.proxy.get_keypair, keypair.Keypair) - - def test_keypairs(self): - self.verify_list_no_kwargs(self.proxy.keypairs, keypair.Keypair, - paginated=False) - - def test_limits_get(self): - self.verify_get(self.proxy.get_limits, limits.Limits, value=[]) - - def test_server_interface_create(self): - self.verify_create(self.proxy.create_server_interface, - server_interface.ServerInterface, - method_kwargs={"server": "test_id"}, - expected_kwargs={"server_id": "test_id"}) - - def test_server_interface_delete(self): - self.proxy._get_uri_attribute = lambda *args: args[1] - - interface_id = "test_interface_id" - server_id = "test_server_id" - test_interface = server_interface.ServerInterface(id=interface_id) - test_interface.server_id = server_id - - # Case1: ServerInterface instance is provided as value - self._verify2("openstack.proxy2.BaseProxy._delete", - self.proxy.delete_server_interface, - method_args=[test_interface], - method_kwargs={"server": server_id}, - expected_args=[server_interface.ServerInterface], - expected_kwargs={"server_id": server_id, - "port_id": interface_id, - "ignore_missing": True}) - - # Case2: ServerInterface ID is provided as value - self._verify2("openstack.proxy2.BaseProxy._delete", - self.proxy.delete_server_interface, - method_args=[interface_id], - method_kwargs={"server": server_id}, - expected_args=[server_interface.ServerInterface], - expected_kwargs={"server_id": server_id, - "port_id": interface_id, - "ignore_missing": True}) - - def test_server_interface_delete_ignore(self): - self.proxy._get_uri_attribute = lambda *args: args[1] - self.verify_delete(self.proxy.delete_server_interface, - server_interface.ServerInterface, True, - method_kwargs={"server": "test_id"}, - expected_args=[server_interface.ServerInterface], - expected_kwargs={"server_id": "test_id", - "port_id": "resource_or_id"}) - - def test_server_interface_get(self): - self.proxy._get_uri_attribute = lambda *args: args[1] - - interface_id = "test_interface_id" - server_id = "test_server_id" - test_interface = server_interface.ServerInterface(id=interface_id) - test_interface.server_id = server_id - - # Case1: ServerInterface instance is provided as value - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_server_interface, - method_args=[test_interface], - method_kwargs={"server": server_id}, - expected_args=[server_interface.ServerInterface], - expected_kwargs={"port_id": interface_id, - "server_id": server_id}) - - # Case2: ServerInterface ID is provided as value - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_server_interface, - method_args=[interface_id], - method_kwargs={"server": server_id}, - expected_args=[server_interface.ServerInterface], - expected_kwargs={"port_id": interface_id, - "server_id": server_id}) - - def test_server_interfaces(self): - self.verify_list(self.proxy.server_interfaces, - server_interface.ServerInterface, - paginated=False, method_args=["test_id"], - expected_kwargs={"server_id": "test_id"}) - - def test_server_ips_with_network_label(self): - self.verify_list(self.proxy.server_ips, server_ip.ServerIP, - paginated=False, method_args=["test_id"], - method_kwargs={"network_label": "test_label"}, - expected_kwargs={"server_id": "test_id", - "network_label": "test_label"}) - - def test_server_ips_without_network_label(self): - self.verify_list(self.proxy.server_ips, server_ip.ServerIP, - paginated=False, method_args=["test_id"], - expected_kwargs={"server_id": "test_id", - "network_label": None}) - - def test_server_create_attrs(self): - self.verify_create(self.proxy.create_server, server.Server) - - def test_server_delete(self): - self.verify_delete(self.proxy.delete_server, server.Server, False) - - def test_server_delete_ignore(self): - self.verify_delete(self.proxy.delete_server, server.Server, True) - - def test_server_force_delete(self): - self._verify("openstack.compute.v2.server.Server.force_delete", - self.proxy.delete_server, - method_args=["value", False, True]) - - def test_server_find(self): - self.verify_find(self.proxy.find_server, server.Server) - - def test_server_get(self): - self.verify_get(self.proxy.get_server, server.Server) - - def test_servers_detailed(self): - self.verify_list(self.proxy.servers, server.ServerDetail, - paginated=True, - method_kwargs={"details": True, - "changes_since": 1, "image": 2}, - expected_kwargs={"changes_since": 1, "image": 2}) - - def test_servers_not_detailed(self): - self.verify_list(self.proxy.servers, server.Server, - paginated=True, - method_kwargs={"details": False, - "changes_since": 1, "image": 2}, - expected_kwargs={"paginated": True, - "changes_since": 1, "image": 2}) - - def test_server_update(self): - self.verify_update(self.proxy.update_server, server.Server) - - def test_server_wait_for(self): - value = server.Server(id='1234') - self.verify_wait_for_status( - self.proxy.wait_for_server, - method_args=[value], - expected_args=[value, 'ACTIVE', ['ERROR'], 2, 120]) - - def test_server_resize(self): - self._verify("openstack.compute.v2.server.Server.resize", - self.proxy.resize_server, - method_args=["value", "test-flavor"], - expected_args=["test-flavor"]) - - def test_server_confirm_resize(self): - self._verify("openstack.compute.v2.server.Server.confirm_resize", - self.proxy.confirm_server_resize, - method_args=["value"]) - - def test_server_revert_resize(self): - self._verify("openstack.compute.v2.server.Server.revert_resize", - self.proxy.revert_server_resize, - method_args=["value"]) - - def test_server_rebuild(self): - id = 'test_image_id' - image_obj = image.Image(id='test_image_id') - - # Case1: image object is provided - # NOTE: Inside of Server.rebuild is where image_obj gets converted - # to an ID instead of object. - self._verify('openstack.compute.v2.server.Server.rebuild', - self.proxy.rebuild_server, - method_args=["value", "test_server", "test_pass"], - method_kwargs={"metadata": {"k1": "v1"}, - "image": image_obj}, - expected_args=["test_server", "test_pass"], - expected_kwargs={"metadata": {"k1": "v1"}, - "image": image_obj}) - - # Case2: image name or id is provided - self._verify('openstack.compute.v2.server.Server.rebuild', - self.proxy.rebuild_server, - method_args=["value", "test_server", "test_pass"], - method_kwargs={"metadata": {"k1": "v1"}, - "image": id}, - expected_args=["test_server", "test_pass"], - expected_kwargs={"metadata": {"k1": "v1"}, - "image": id}) - - def test_add_fixed_ip_to_server(self): - self._verify("openstack.compute.v2.server.Server.add_fixed_ip", - self.proxy.add_fixed_ip_to_server, - method_args=["value", "network-id"], - expected_args=["network-id"]) - - def test_fixed_ip_from_server(self): - self._verify("openstack.compute.v2.server.Server.remove_fixed_ip", - self.proxy.remove_fixed_ip_from_server, - method_args=["value", "address"], - expected_args=["address"]) - - def test_floating_ip_to_server(self): - self._verify("openstack.compute.v2.server.Server.add_floating_ip", - self.proxy.add_floating_ip_to_server, - method_args=["value", "floating-ip"], - expected_args=["floating-ip"], - expected_kwargs={'fixed_address': None}) - - def test_add_floating_ip_to_server_with_fixed_addr(self): - self._verify("openstack.compute.v2.server.Server.add_floating_ip", - self.proxy.add_floating_ip_to_server, - method_args=["value", "floating-ip", 'fixed-addr'], - expected_args=["floating-ip"], - expected_kwargs={'fixed_address': 'fixed-addr'}) - - def test_remove_floating_ip_from_server(self): - self._verify("openstack.compute.v2.server.Server.remove_floating_ip", - self.proxy.remove_floating_ip_from_server, - method_args=["value", "address"], - expected_args=["address"]) - - def test_server_backup(self): - self._verify("openstack.compute.v2.server.Server.backup", - self.proxy.backup_server, - method_args=["value", "name", "daily", 1], - expected_args=["name", "daily", 1]) - - def test_server_pause(self): - self._verify("openstack.compute.v2.server.Server.pause", - self.proxy.pause_server, - method_args=["value"]) - - def test_server_unpause(self): - self._verify("openstack.compute.v2.server.Server.unpause", - self.proxy.unpause_server, - method_args=["value"]) - - def test_server_suspend(self): - self._verify("openstack.compute.v2.server.Server.suspend", - self.proxy.suspend_server, - method_args=["value"]) - - def test_server_resume(self): - self._verify("openstack.compute.v2.server.Server.resume", - self.proxy.resume_server, - method_args=["value"]) - - def test_server_lock(self): - self._verify("openstack.compute.v2.server.Server.lock", - self.proxy.lock_server, - method_args=["value"]) - - def test_server_unlock(self): - self._verify("openstack.compute.v2.server.Server.unlock", - self.proxy.unlock_server, - method_args=["value"]) - - def test_server_rescue(self): - self._verify("openstack.compute.v2.server.Server.rescue", - self.proxy.rescue_server, - method_args=["value"], - expected_kwargs={"admin_pass": None, "image_ref": None}) - - def test_server_rescue_with_options(self): - self._verify("openstack.compute.v2.server.Server.rescue", - self.proxy.rescue_server, - method_args=["value", 'PASS', 'IMG'], - expected_kwargs={"admin_pass": 'PASS', - "image_ref": 'IMG'}) - - def test_server_unrescue(self): - self._verify("openstack.compute.v2.server.Server.unrescue", - self.proxy.unrescue_server, - method_args=["value"]) - - def test_server_evacuate(self): - self._verify("openstack.compute.v2.server.Server.evacuate", - self.proxy.evacuate_server, - method_args=["value"], - expected_kwargs={"host": None, "admin_pass": None, - "force": None}) - - def test_server_evacuate_with_options(self): - self._verify("openstack.compute.v2.server.Server.evacuate", - self.proxy.evacuate_server, - method_args=["value", 'HOST2', 'NEW_PASS', True], - expected_kwargs={"host": "HOST2", - "admin_pass": 'NEW_PASS', - "force": True}) - - def test_server_start(self): - self._verify("openstack.compute.v2.server.Server.start", - self.proxy.start_server, - method_args=["value"]) - - def test_server_stop(self): - self._verify("openstack.compute.v2.server.Server.stop", - self.proxy.stop_server, - method_args=["value"]) - - def test_server_shelve(self): - self._verify("openstack.compute.v2.server.Server.shelve", - self.proxy.shelve_server, - method_args=["value"]) - - def test_server_unshelve(self): - self._verify("openstack.compute.v2.server.Server.unshelve", - self.proxy.unshelve_server, - method_args=["value"]) - - def test_get_server_output(self): - self._verify("openstack.compute.v2.server.Server.get_console_output", - self.proxy.get_server_console_output, - method_args=["value"], - expected_kwargs={"length": None}) - - self._verify("openstack.compute.v2.server.Server.get_console_output", - self.proxy.get_server_console_output, - method_args=["value", 1], - expected_kwargs={"length": 1}) - - def test_availability_zones(self): - self.verify_list_no_kwargs(self.proxy.availability_zones, - az.AvailabilityZone, - paginated=False) - - def test_get_all_server_metadata(self): - self._verify2("openstack.compute.v2.server.Server.get_metadata", - self.proxy.get_server_metadata, - method_args=["value"], - method_result=server.Server(id="value", metadata={}), - expected_args=[self.session], - expected_result={}) - - def test_set_server_metadata(self): - kwargs = {"a": "1", "b": "2"} - id = "an_id" - self._verify2("openstack.compute.v2.server.Server.set_metadata", - self.proxy.set_server_metadata, - method_args=[id], - method_kwargs=kwargs, - method_result=server.Server.existing(id=id, - metadata=kwargs), - expected_args=[self.session], - expected_kwargs=kwargs, - expected_result=kwargs) - - def test_delete_server_metadata(self): - self._verify2("openstack.compute.v2.server.Server.delete_metadata", - self.proxy.delete_server_metadata, - expected_result=None, - method_args=["value", "key"], - expected_args=[self.session, "key"]) - - def test_server_group_create(self): - self.verify_create(self.proxy.create_server_group, - server_group.ServerGroup) - - def test_server_group_delete(self): - self.verify_delete(self.proxy.delete_server_group, - server_group.ServerGroup, False) - - def test_server_group_delete_ignore(self): - self.verify_delete(self.proxy.delete_server_group, - server_group.ServerGroup, True) - - def test_server_group_find(self): - self.verify_find(self.proxy.find_server_group, - server_group.ServerGroup) - - def test_server_group_get(self): - self.verify_get(self.proxy.get_server_group, - server_group.ServerGroup) - - def test_server_groups(self): - self.verify_list(self.proxy.server_groups, server_group.ServerGroup, - paginated=False) - - def test_hypervisors(self): - self.verify_list_no_kwargs(self.proxy.hypervisors, - hypervisor.Hypervisor, - paginated=False) - - def test_find_hypervisor(self): - self.verify_find(self.proxy.find_hypervisor, - hypervisor.Hypervisor) - - def test_get_hypervisor(self): - self.verify_get(self.proxy.get_hypervisor, - hypervisor.Hypervisor) - - def test_services(self): - self.verify_list_no_kwargs(self.proxy.services, - service.Service, - paginated=False) - - def test_enable_service(self): - self._verify('openstack.compute.v2.service.Service.enable', - self.proxy.enable_service, - method_args=["value", "host1", "nova-compute"], - expected_args=["host1", "nova-compute"]) - - def test_disable_service(self): - self._verify('openstack.compute.v2.service.Service.disable', - self.proxy.disable_service, - method_args=["value", "host1", "nova-compute"], - expected_args=["host1", "nova-compute", None]) - - def test_force_service_down(self): - self._verify('openstack.compute.v2.service.Service.force_down', - self.proxy.force_service_down, - method_args=["value", "host1", "nova-compute"], - expected_args=["host1", "nova-compute"]) - - def test_live_migrate_server(self): - self._verify('openstack.compute.v2.server.Server.live_migrate', - self.proxy.live_migrate_server, - method_args=["value", "host1", "force"], - expected_args=["host1", "force"]) diff --git a/openstack/tests/unit/compute/v2/test_server.py b/openstack/tests/unit/compute/v2/test_server.py deleted file mode 100644 index 80f5fa93..00000000 --- a/openstack/tests/unit/compute/v2/test_server.py +++ /dev/null @@ -1,675 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.compute.v2 import server - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'accessIPv4': '1', - 'accessIPv6': '2', - 'addresses': {'region': '3'}, - 'config_drive': True, - 'created': '2015-03-09T12:14:57.233772', - 'flavorRef': '5', - 'flavor': {'id': 'FLAVOR_ID', 'links': {}}, - 'hostId': '6', - 'id': IDENTIFIER, - 'imageRef': '8', - 'image': {'id': 'IMAGE_ID', 'links': {}}, - 'links': '9', - 'metadata': {'key': '10'}, - 'networks': 'auto', - 'name': '11', - 'progress': 12, - 'tenant_id': '13', - 'status': '14', - 'updated': '2015-03-09T12:15:57.233772', - 'user_id': '16', - 'key_name': '17', - 'OS-DCF:diskConfig': '18', - 'OS-EXT-AZ:availability_zone': '19', - 'OS-EXT-STS:power_state': '20', - 'OS-EXT-STS:task_state': '21', - 'OS-EXT-STS:vm_state': '22', - 'os-extended-volumes:volumes_attached': '23', - 'OS-SRV-USG:launched_at': '2015-03-09T12:15:57.233772', - 'OS-SRV-USG:terminated_at': '2015-03-09T12:15:57.233772', - 'security_groups': '26', - 'adminPass': '27', - 'personality': '28', - 'block_device_mapping_v2': {'key': '29'}, - 'OS-EXT-SRV-ATTR:hypervisor_hostname': 'hypervisor.example.com', - 'OS-EXT-SRV-ATTR:instance_name': 'instance-00000001', - 'OS-SCH-HNT:scheduler_hints': {'key': '30'}, - 'OS-EXT-SRV-ATTR:user_data': '31' -} - - -class TestServer(testtools.TestCase): - - def setUp(self): - super(TestServer, self).setUp() - self.resp = mock.Mock() - self.resp.body = None - self.resp.json = mock.Mock(return_value=self.resp.body) - self.sess = mock.Mock() - self.sess.post = mock.Mock(return_value=self.resp) - - def test_basic(self): - sot = server.Server() - self.assertEqual('server', sot.resource_key) - self.assertEqual('servers', sot.resources_key) - self.assertEqual('/servers', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - self.assertDictEqual({"image": "image", - "flavor": "flavor", - "name": "name", - "status": "status", - "host": "host", - "all_tenants": "all_tenants", - "changes_since": "changes-since", - "limit": "limit", - "marker": "marker", - "sort_key": "sort_key", - "sort_dir": "sort_dir", - "reservation_id": "reservation_id", - "project_id": "project_id", - "tags": "tags", - "tags_any": "tags-any", - "not_tags": "not-tags", - "not_tags_any": "not-tags-any", - "is_deleted": "deleted", - "ipv4_address": "ip", - "ipv6_address": "ip6", - }, - sot._query_mapping._mapping) - - def test_make_it(self): - sot = server.Server(**EXAMPLE) - self.assertEqual(EXAMPLE['accessIPv4'], sot.access_ipv4) - self.assertEqual(EXAMPLE['accessIPv6'], sot.access_ipv6) - self.assertEqual(EXAMPLE['addresses'], sot.addresses) - self.assertEqual(EXAMPLE['created'], sot.created_at) - self.assertEqual(EXAMPLE['config_drive'], sot.has_config_drive) - self.assertEqual(EXAMPLE['flavorRef'], sot.flavor_id) - self.assertEqual(EXAMPLE['flavor'], sot.flavor) - self.assertEqual(EXAMPLE['hostId'], sot.host_id) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['imageRef'], sot.image_id) - self.assertEqual(EXAMPLE['image'], sot.image) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['metadata'], sot.metadata) - self.assertEqual(EXAMPLE['networks'], sot.networks) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['progress'], sot.progress) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) - self.assertEqual(EXAMPLE['user_id'], sot.user_id) - self.assertEqual(EXAMPLE['key_name'], sot.key_name) - self.assertEqual(EXAMPLE['OS-DCF:diskConfig'], sot.disk_config) - self.assertEqual(EXAMPLE['OS-EXT-AZ:availability_zone'], - sot.availability_zone) - self.assertEqual(EXAMPLE['OS-EXT-STS:power_state'], sot.power_state) - self.assertEqual(EXAMPLE['OS-EXT-STS:task_state'], sot.task_state) - self.assertEqual(EXAMPLE['OS-EXT-STS:vm_state'], sot.vm_state) - self.assertEqual(EXAMPLE['os-extended-volumes:volumes_attached'], - sot.attached_volumes) - self.assertEqual(EXAMPLE['OS-SRV-USG:launched_at'], sot.launched_at) - self.assertEqual(EXAMPLE['OS-SRV-USG:terminated_at'], - sot.terminated_at) - self.assertEqual(EXAMPLE['security_groups'], sot.security_groups) - self.assertEqual(EXAMPLE['adminPass'], sot.admin_password) - self.assertEqual(EXAMPLE['personality'], sot.personality) - self.assertEqual(EXAMPLE['block_device_mapping_v2'], - sot.block_device_mapping) - self.assertEqual(EXAMPLE['OS-EXT-SRV-ATTR:hypervisor_hostname'], - sot.hypervisor_hostname) - self.assertEqual(EXAMPLE['OS-EXT-SRV-ATTR:instance_name'], - sot.instance_name) - self.assertEqual(EXAMPLE['OS-SCH-HNT:scheduler_hints'], - sot.scheduler_hints) - self.assertEqual(EXAMPLE['OS-EXT-SRV-ATTR:user_data'], sot.user_data) - - def test_detail(self): - sot = server.ServerDetail() - self.assertEqual('server', sot.resource_key) - self.assertEqual('servers', sot.resources_key) - self.assertEqual('/servers/detail', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test__prepare_server(self): - zone = 1 - data = 2 - hints = {"hint": 3} - - sot = server.Server(id=1, availability_zone=zone, user_data=data, - scheduler_hints=hints) - request = sot._prepare_request() - - self.assertNotIn("OS-EXT-AZ:availability_zone", - request.body[sot.resource_key]) - self.assertEqual(request.body[sot.resource_key]["availability_zone"], - zone) - - self.assertNotIn("OS-EXT-SRV-ATTR:user_data", - request.body[sot.resource_key]) - self.assertEqual(request.body[sot.resource_key]["user_data"], - data) - - self.assertNotIn("OS-SCH-HNT:scheduler_hints", - request.body[sot.resource_key]) - self.assertEqual(request.body["OS-SCH-HNT:scheduler_hints"], hints) - - def test_change_password(self): - sot = server.Server(**EXAMPLE) - - self.assertIsNone(sot.change_password(self.sess, 'a')) - - url = 'servers/IDENTIFIER/action' - body = {"changePassword": {"adminPass": "a"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_reboot(self): - sot = server.Server(**EXAMPLE) - - self.assertIsNone(sot.reboot(self.sess, 'HARD')) - - url = 'servers/IDENTIFIER/action' - body = {"reboot": {"type": "HARD"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_force_delete(self): - sot = server.Server(**EXAMPLE) - - self.assertIsNone(sot.force_delete(self.sess)) - - url = 'servers/IDENTIFIER/action' - body = {'forceDelete': None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_rebuild(self): - sot = server.Server(**EXAMPLE) - # Let the translate pass through, that portion is tested elsewhere - sot._translate_response = lambda arg: arg - - result = sot.rebuild(self.sess, name='noo', admin_password='seekr3t', - image='http://image/1', access_ipv4="12.34.56.78", - access_ipv6="fe80::100", - metadata={"meta var": "meta val"}, - personality=[{"path": "/etc/motd", - "contents": "foo"}]) - - self.assertIsInstance(result, server.Server) - - url = 'servers/IDENTIFIER/action' - body = { - "rebuild": { - "name": "noo", - "imageRef": "http://image/1", - "adminPass": "seekr3t", - "accessIPv4": "12.34.56.78", - "accessIPv6": "fe80::100", - "metadata": {"meta var": "meta val"}, - "personality": [{"path": "/etc/motd", "contents": "foo"}], - "preserve_ephemeral": False - } - } - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_rebuild_minimal(self): - sot = server.Server(**EXAMPLE) - # Let the translate pass through, that portion is tested elsewhere - sot._translate_response = lambda arg: arg - - result = sot.rebuild(self.sess, name='nootoo', - admin_password='seekr3two', - image='http://image/2') - - self.assertIsInstance(result, server.Server) - - url = 'servers/IDENTIFIER/action' - body = { - "rebuild": { - "name": "nootoo", - "imageRef": "http://image/2", - "adminPass": "seekr3two", - "preserve_ephemeral": False - } - } - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_resize(self): - sot = server.Server(**EXAMPLE) - - self.assertIsNone(sot.resize(self.sess, '2')) - - url = 'servers/IDENTIFIER/action' - body = {"resize": {"flavorRef": "2"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_confirm_resize(self): - sot = server.Server(**EXAMPLE) - - self.assertIsNone(sot.confirm_resize(self.sess)) - - url = 'servers/IDENTIFIER/action' - body = {"confirmResize": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_revert_resize(self): - sot = server.Server(**EXAMPLE) - - self.assertIsNone(sot.revert_resize(self.sess)) - - url = 'servers/IDENTIFIER/action' - body = {"revertResize": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_create_image(self): - sot = server.Server(**EXAMPLE) - name = 'noo' - metadata = {'nu': 'image', 'created': 'today'} - - self.assertIsNone(sot.create_image(self.sess, name, metadata)) - - url = 'servers/IDENTIFIER/action' - body = {"createImage": {'name': name, 'metadata': metadata}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_create_image_minimal(self): - sot = server.Server(**EXAMPLE) - name = 'noo' - - self.assertIsNone(self.resp.body, sot.create_image(self.sess, name)) - - url = 'servers/IDENTIFIER/action' - body = {"createImage": {'name': name}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=dict(sot.service), json=body, headers=headers) - - def test_add_security_group(self): - sot = server.Server(**EXAMPLE) - - self.assertIsNone(sot.add_security_group(self.sess, "group")) - - url = 'servers/IDENTIFIER/action' - body = {"addSecurityGroup": {"name": "group"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_remove_security_group(self): - sot = server.Server(**EXAMPLE) - - self.assertIsNone(sot.remove_security_group(self.sess, "group")) - - url = 'servers/IDENTIFIER/action' - body = {"removeSecurityGroup": {"name": "group"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_reset_state(self): - sot = server.Server(**EXAMPLE) - - self.assertIsNone(sot.reset_state(self.sess, 'active')) - - url = 'servers/IDENTIFIER/action' - body = {"os-resetState": {"state": 'active'}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_add_fixed_ip(self): - sot = server.Server(**EXAMPLE) - - res = sot.add_fixed_ip(self.sess, "NETWORK-ID") - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"addFixedIp": {"networkId": "NETWORK-ID"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_remove_fixed_ip(self): - sot = server.Server(**EXAMPLE) - - res = sot.remove_fixed_ip(self.sess, "ADDRESS") - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"removeFixedIp": {"address": "ADDRESS"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_add_floating_ip(self): - sot = server.Server(**EXAMPLE) - - res = sot.add_floating_ip(self.sess, "FLOATING-IP") - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"addFloatingIp": {"address": "FLOATING-IP"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_add_floating_ip_with_fixed_addr(self): - sot = server.Server(**EXAMPLE) - - res = sot.add_floating_ip(self.sess, "FLOATING-IP", "FIXED-ADDR") - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"addFloatingIp": {"address": "FLOATING-IP", - "fixed_address": "FIXED-ADDR"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_remove_floating_ip(self): - sot = server.Server(**EXAMPLE) - - res = sot.remove_floating_ip(self.sess, "I-AM-FLOATING") - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"removeFloatingIp": {"address": "I-AM-FLOATING"}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_backup(self): - sot = server.Server(**EXAMPLE) - - res = sot.backup(self.sess, "name", "daily", 1) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"createBackup": {"name": "name", "backup_type": "daily", - "rotation": 1}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_pause(self): - sot = server.Server(**EXAMPLE) - - res = sot.pause(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"pause": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_unpause(self): - sot = server.Server(**EXAMPLE) - - res = sot.unpause(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"unpause": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_suspend(self): - sot = server.Server(**EXAMPLE) - - res = sot.suspend(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"suspend": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_resume(self): - sot = server.Server(**EXAMPLE) - - res = sot.resume(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"resume": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_lock(self): - sot = server.Server(**EXAMPLE) - - res = sot.lock(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"lock": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_unlock(self): - sot = server.Server(**EXAMPLE) - - res = sot.unlock(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"unlock": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_rescue(self): - sot = server.Server(**EXAMPLE) - - res = sot.rescue(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"rescue": {}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_rescue_with_options(self): - sot = server.Server(**EXAMPLE) - - res = sot.rescue(self.sess, admin_pass='SECRET', image_ref='IMG-ID') - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"rescue": {'adminPass': 'SECRET', - 'rescue_image_ref': 'IMG-ID'}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_unrescue(self): - sot = server.Server(**EXAMPLE) - - res = sot.unrescue(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"unrescue": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_evacuate(self): - sot = server.Server(**EXAMPLE) - - res = sot.evacuate(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"evacuate": {}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_evacuate_with_options(self): - sot = server.Server(**EXAMPLE) - - res = sot.evacuate(self.sess, host='HOST2', admin_pass='NEW_PASS', - force=True) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"evacuate": {'host': 'HOST2', 'adminPass': 'NEW_PASS', - 'force': True}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_start(self): - sot = server.Server(**EXAMPLE) - - res = sot.start(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"os-start": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_stop(self): - sot = server.Server(**EXAMPLE) - - res = sot.stop(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"os-stop": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_shelve(self): - sot = server.Server(**EXAMPLE) - - res = sot.shelve(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"shelve": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_unshelve(self): - sot = server.Server(**EXAMPLE) - - res = sot.unshelve(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"unshelve": None} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_migrate(self): - sot = server.Server(**EXAMPLE) - - res = sot.migrate(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {"migrate": None} - - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_get_console_output(self): - sot = server.Server(**EXAMPLE) - - res = sot.get_console_output(self.sess) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {'os-getConsoleOutput': {}} - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - res = sot.get_console_output(self.sess, length=1) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = {'os-getConsoleOutput': {'length': 1}} - - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) - - def test_live_migrate(self): - sot = server.Server(**EXAMPLE) - - res = sot.live_migrate(self.sess, host='HOST2', force=False) - - self.assertIsNone(res) - url = 'servers/IDENTIFIER/action' - body = { - "os-migrateLive": { - "host": 'HOST2', - "block_migration": "auto", - "force": False - } - } - - headers = {'Accept': ''} - self.sess.post.assert_called_with( - url, endpoint_filter=sot.service, json=body, headers=headers) diff --git a/openstack/tests/unit/compute/v2/test_server_group.py b/openstack/tests/unit/compute/v2/test_server_group.py deleted file mode 100644 index 3fabbfc1..00000000 --- a/openstack/tests/unit/compute/v2/test_server_group.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute.v2 import server_group - -EXAMPLE = { - 'id': 'IDENTIFIER', - 'name': 'test', - 'members': ['server1', 'server2'], - 'metadata': {'k': 'v'}, - 'policies': ['anti-affinity'], -} - - -class TestServerGroup(testtools.TestCase): - - def test_basic(self): - sot = server_group.ServerGroup() - self.assertEqual('server_group', sot.resource_key) - self.assertEqual('server_groups', sot.resources_key) - self.assertEqual('/os-server-groups', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - self.assertDictEqual({"all_projects": "all_projects", - "limit": "limit", "marker": "marker"}, - sot._query_mapping._mapping) - - def test_make_it(self): - sot = server_group.ServerGroup(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['members'], sot.member_ids) - self.assertEqual(EXAMPLE['metadata'], sot.metadata) - self.assertEqual(EXAMPLE['policies'], sot.policies) diff --git a/openstack/tests/unit/compute/v2/test_server_interface.py b/openstack/tests/unit/compute/v2/test_server_interface.py deleted file mode 100644 index 64467541..00000000 --- a/openstack/tests/unit/compute/v2/test_server_interface.py +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute.v2 import server_interface - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'fixed_ips': [ - { - 'ip_address': '192.168.1.1', - 'subnet_id': 'f8a6e8f8-c2ec-497c-9f23-da9616de54ef' - } - ], - 'mac_addr': '2', - 'net_id': '3', - 'port_id': '4', - 'port_state': '5', - 'server_id': '6', -} - - -class TestServerInterface(testtools.TestCase): - - def test_basic(self): - sot = server_interface.ServerInterface() - self.assertEqual('interfaceAttachment', sot.resource_key) - self.assertEqual('interfaceAttachments', sot.resources_key) - self.assertEqual('/servers/%(server_id)s/os-interface', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = server_interface.ServerInterface(**EXAMPLE) - self.assertEqual(EXAMPLE['fixed_ips'], sot.fixed_ips) - self.assertEqual(EXAMPLE['mac_addr'], sot.mac_addr) - self.assertEqual(EXAMPLE['net_id'], sot.net_id) - self.assertEqual(EXAMPLE['port_id'], sot.port_id) - self.assertEqual(EXAMPLE['port_state'], sot.port_state) - self.assertEqual(EXAMPLE['server_id'], sot.server_id) diff --git a/openstack/tests/unit/compute/v2/test_server_ip.py b/openstack/tests/unit/compute/v2/test_server_ip.py deleted file mode 100644 index 770b67a2..00000000 --- a/openstack/tests/unit/compute/v2/test_server_ip.py +++ /dev/null @@ -1,100 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.compute.v2 import server_ip - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'addr': '1', - 'network_label': '2', - 'version': '4', -} - - -class TestServerIP(testtools.TestCase): - - def test_basic(self): - sot = server_ip.ServerIP() - self.assertEqual('addresses', sot.resources_key) - self.assertEqual('/servers/%(server_id)s/ips', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = server_ip.ServerIP(**EXAMPLE) - self.assertEqual(EXAMPLE['addr'], sot.address) - self.assertEqual(EXAMPLE['network_label'], sot.network_label) - self.assertEqual(EXAMPLE['version'], sot.version) - - def test_list(self): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - resp.json.return_value = { - "addresses": {"label1": [{"version": 1, "addr": "a1"}, - {"version": 2, "addr": "a2"}], - "label2": [{"version": 3, "addr": "a3"}, - {"version": 4, "addr": "a4"}]}} - - ips = list(server_ip.ServerIP.list(sess, server_id=IDENTIFIER)) - - self.assertEqual(4, len(ips)) - ips = sorted(ips, key=lambda ip: ip.version) - - self.assertEqual(type(ips[0]), server_ip.ServerIP) - self.assertEqual(ips[0].network_label, "label1") - self.assertEqual(ips[0].address, "a1") - self.assertEqual(ips[0].version, 1) - self.assertEqual(type(ips[1]), server_ip.ServerIP) - self.assertEqual(ips[1].network_label, "label1") - self.assertEqual(ips[1].address, "a2") - self.assertEqual(ips[1].version, 2) - self.assertEqual(type(ips[2]), server_ip.ServerIP) - self.assertEqual(ips[2].network_label, "label2") - self.assertEqual(ips[2].address, "a3") - self.assertEqual(ips[2].version, 3) - self.assertEqual(type(ips[3]), server_ip.ServerIP) - self.assertEqual(ips[3].network_label, "label2") - self.assertEqual(ips[3].address, "a4") - self.assertEqual(ips[3].version, 4) - - def test_list_network_label(self): - label = "label1" - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - resp.json.return_value = {label: [{"version": 1, - "addr": "a1"}, - {"version": 2, - "addr": "a2"}]} - - ips = list(server_ip.ServerIP.list(sess, server_id=IDENTIFIER, - network_label=label)) - - self.assertEqual(2, len(ips)) - ips = sorted(ips, key=lambda ip: ip.version) - - self.assertEqual(type(ips[0]), server_ip.ServerIP) - self.assertEqual(ips[0].network_label, label) - self.assertEqual(ips[0].address, "a1") - self.assertEqual(ips[0].version, 1) - self.assertEqual(type(ips[1]), server_ip.ServerIP) - self.assertEqual(ips[1].network_label, label) - self.assertEqual(ips[1].address, "a2") - self.assertEqual(ips[1].version, 2) diff --git a/openstack/tests/unit/compute/v2/test_service.py b/openstack/tests/unit/compute/v2/test_service.py deleted file mode 100644 index 0872cf08..00000000 --- a/openstack/tests/unit/compute/v2/test_service.py +++ /dev/null @@ -1,116 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.compute.v2 import service - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'binary': 'nova-compute', - 'host': 'host1', - 'status': 'enabled', - 'state': 'up', - 'zone': 'nova' -} - - -class TestService(testtools.TestCase): - - def setUp(self): - super(TestService, self).setUp() - self.resp = mock.Mock() - self.resp.body = None - self.resp.json = mock.Mock(return_value=self.resp.body) - self.sess = mock.Mock() - self.sess.put = mock.Mock(return_value=self.resp) - - def test_basic(self): - sot = service.Service() - self.assertEqual('service', sot.resource_key) - self.assertEqual('services', sot.resources_key) - self.assertEqual('/os-services', sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_list) - self.assertFalse(sot.allow_get) - - def test_make_it(self): - sot = service.Service(**EXAMPLE) - self.assertEqual(EXAMPLE['host'], sot.host) - self.assertEqual(EXAMPLE['binary'], sot.binary) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['state'], sot.state) - self.assertEqual(EXAMPLE['zone'], sot.zone) - self.assertEqual(EXAMPLE['id'], sot.id) - - def test_force_down(self): - sot = service.Service(**EXAMPLE) - - res = sot.force_down(self.sess, 'host1', 'nova-compute') - self.assertIsNone(res.body) - - url = 'os-services/force-down' - body = { - 'binary': 'nova-compute', - 'host': 'host1', - 'forced_down': True, - } - self.sess.put.assert_called_with( - url, endpoint_filter=sot.service, json=body) - - def test_enable(self): - sot = service.Service(**EXAMPLE) - - res = sot.enable(self.sess, 'host1', 'nova-compute') - self.assertIsNone(res.body) - - url = 'os-services/enable' - body = { - 'binary': 'nova-compute', - 'host': 'host1', - } - self.sess.put.assert_called_with( - url, endpoint_filter=sot.service, json=body) - - def test_disable(self): - sot = service.Service(**EXAMPLE) - - res = sot.disable(self.sess, 'host1', 'nova-compute') - self.assertIsNone(res.body) - - url = 'os-services/disable' - body = { - 'binary': 'nova-compute', - 'host': 'host1', - } - self.sess.put.assert_called_with( - url, endpoint_filter=sot.service, json=body) - - def test_disable_with_reason(self): - sot = service.Service(**EXAMPLE) - reason = 'fencing' - - res = sot.disable(self.sess, 'host1', 'nova-compute', reason=reason) - - self.assertIsNone(res.body) - - url = 'os-services/disable-log-reason' - body = { - 'binary': 'nova-compute', - 'host': 'host1', - 'disabled_reason': reason - } - self.sess.put.assert_called_with( - url, endpoint_filter=sot.service, json=body) diff --git a/openstack/tests/unit/compute/v2/test_volume_attachment.py b/openstack/tests/unit/compute/v2/test_volume_attachment.py deleted file mode 100644 index 87d4cdbd..00000000 --- a/openstack/tests/unit/compute/v2/test_volume_attachment.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.compute.v2 import volume_attachment - -EXAMPLE = { - 'device': '1', - 'id': '2', - 'volume_id': '3', -} - - -class TestServerInterface(testtools.TestCase): - - def test_basic(self): - sot = volume_attachment.VolumeAttachment() - self.assertEqual('volumeAttachment', sot.resource_key) - self.assertEqual('volumeAttachments', sot.resources_key) - self.assertEqual('/servers/%(server_id)s/os-volume_attachments', - sot.base_path) - self.assertEqual('compute', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertDictEqual({"limit": "limit", - "offset": "offset", - "marker": "marker"}, - sot._query_mapping._mapping) - - def test_make_it(self): - sot = volume_attachment.VolumeAttachment(**EXAMPLE) - self.assertEqual(EXAMPLE['device'], sot.device) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['volume_id'], sot.volume_id) diff --git a/openstack/tests/unit/database/__init__.py b/openstack/tests/unit/database/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/database/test_database_service.py b/openstack/tests/unit/database/test_database_service.py deleted file mode 100644 index 6793acd4..00000000 --- a/openstack/tests/unit/database/test_database_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.database import database_service - - -class TestDatabaseService(testtools.TestCase): - - def test_service(self): - sot = database_service.DatabaseService() - self.assertEqual('database', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v1', sot.valid_versions[0].module) - self.assertEqual('v1', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/database/v1/__init__.py b/openstack/tests/unit/database/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/database/v1/test_database.py b/openstack/tests/unit/database/v1/test_database.py deleted file mode 100644 index 6f8cda2c..00000000 --- a/openstack/tests/unit/database/v1/test_database.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.database.v1 import database - - -IDENTIFIER = 'NAME' -INSTANCE_ID = 'INSTANCE_ID' -EXAMPLE = { - 'character_set': '1', - 'collate': '2', - 'instance_id': INSTANCE_ID, - 'name': IDENTIFIER, -} - - -class TestDatabase(testtools.TestCase): - - def test_basic(self): - sot = database.Database() - self.assertEqual('database', sot.resource_key) - self.assertEqual('databases', sot.resources_key) - path = '/instances/%(instance_id)s/databases' - self.assertEqual(path, sot.base_path) - self.assertEqual('database', sot.service.service_type) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - - def test_make_it(self): - sot = database.Database(**EXAMPLE) - self.assertEqual(IDENTIFIER, sot.id) - self.assertEqual(EXAMPLE['character_set'], sot.character_set) - self.assertEqual(EXAMPLE['collate'], sot.collate) - self.assertEqual(EXAMPLE['instance_id'], sot.instance_id) - self.assertEqual(IDENTIFIER, sot.name) - self.assertEqual(IDENTIFIER, sot.id) diff --git a/openstack/tests/unit/database/v1/test_flavor.py b/openstack/tests/unit/database/v1/test_flavor.py deleted file mode 100644 index a851e45d..00000000 --- a/openstack/tests/unit/database/v1/test_flavor.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.database.v1 import flavor - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': '1', - 'name': '2', - 'ram': '3', -} - - -class TestFlavor(testtools.TestCase): - - def test_basic(self): - sot = flavor.Flavor() - self.assertEqual('flavor', sot.resource_key) - self.assertEqual('flavors', sot.resources_key) - self.assertEqual('/flavors', sot.base_path) - self.assertEqual('database', sot.service.service_type) - self.assertTrue(sot.allow_list) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - - def test_make_it(self): - sot = flavor.Flavor(**EXAMPLE) - self.assertEqual(IDENTIFIER, sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['ram'], sot.ram) diff --git a/openstack/tests/unit/database/v1/test_instance.py b/openstack/tests/unit/database/v1/test_instance.py deleted file mode 100644 index a13bed7b..00000000 --- a/openstack/tests/unit/database/v1/test_instance.py +++ /dev/null @@ -1,130 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.database.v1 import instance - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'flavor': '1', - 'id': IDENTIFIER, - 'links': '3', - 'name': '4', - 'status': '5', - 'volume': '6', - 'datastore': {'7': 'seven'}, - 'region': '8', - 'hostname': '9', - 'created': '10', - 'updated': '11', -} - - -class TestInstance(testtools.TestCase): - - def test_basic(self): - sot = instance.Instance() - self.assertEqual('instance', sot.resource_key) - self.assertEqual('instances', sot.resources_key) - self.assertEqual('/instances', sot.base_path) - self.assertEqual('database', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = instance.Instance(**EXAMPLE) - self.assertEqual(EXAMPLE['flavor'], sot.flavor) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['volume'], sot.volume) - self.assertEqual(EXAMPLE['datastore'], sot.datastore) - self.assertEqual(EXAMPLE['region'], sot.region) - self.assertEqual(EXAMPLE['hostname'], sot.hostname) - self.assertEqual(EXAMPLE['created'], sot.created_at) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) - - def test_enable_root_user(self): - sot = instance.Instance(**EXAMPLE) - response = mock.Mock() - response.body = {'user': {'name': 'root', 'password': 'foo'}} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.post = mock.Mock(return_value=response) - - self.assertEqual(response.body['user'], sot.enable_root_user(sess)) - - url = ("instances/%s/root" % IDENTIFIER) - sess.post.assert_called_with(url, endpoint_filter=sot.service) - - def test_is_root_enabled(self): - sot = instance.Instance(**EXAMPLE) - response = mock.Mock() - response.body = {'rootEnabled': True} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.get = mock.Mock(return_value=response) - - self.assertTrue(sot.is_root_enabled(sess)) - - url = ("instances/%s/root" % IDENTIFIER) - sess.get.assert_called_with(url, endpoint_filter=sot.service) - - def test_action_restart(self): - sot = instance.Instance(**EXAMPLE) - response = mock.Mock() - response.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=response) - - self.assertIsNone(sot.restart(sess)) - - url = ("instances/%s/action" % IDENTIFIER) - body = {'restart': {}} - sess.post.assert_called_with(url, endpoint_filter=sot.service, - json=body) - - def test_action_resize(self): - sot = instance.Instance(**EXAMPLE) - response = mock.Mock() - response.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=response) - flavor = 'http://flavor/flav' - - self.assertIsNone(sot.resize(sess, flavor)) - - url = ("instances/%s/action" % IDENTIFIER) - body = {'resize': {'flavorRef': flavor}} - sess.post.assert_called_with(url, endpoint_filter=sot.service, - json=body) - - def test_action_resize_volume(self): - sot = instance.Instance(**EXAMPLE) - response = mock.Mock() - response.json = mock.Mock(return_value='') - sess = mock.Mock() - sess.post = mock.Mock(return_value=response) - size = 4 - - self.assertIsNone(sot.resize_volume(sess, size)) - - url = ("instances/%s/action" % IDENTIFIER) - body = {'resize': {'volume': size}} - sess.post.assert_called_with(url, endpoint_filter=sot.service, - json=body) diff --git a/openstack/tests/unit/database/v1/test_proxy.py b/openstack/tests/unit/database/v1/test_proxy.py deleted file mode 100644 index ff54e5b2..00000000 --- a/openstack/tests/unit/database/v1/test_proxy.py +++ /dev/null @@ -1,122 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.database.v1 import _proxy -from openstack.database.v1 import database -from openstack.database.v1 import flavor -from openstack.database.v1 import instance -from openstack.database.v1 import user -from openstack.tests.unit import test_proxy_base2 - - -class TestDatabaseProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestDatabaseProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_database_create_attrs(self): - self.verify_create(self.proxy.create_database, database.Database, - method_kwargs={"instance": "id"}, - expected_kwargs={"instance_id": "id"}) - - def test_database_delete(self): - self.verify_delete(self.proxy.delete_database, - database.Database, False, - input_path_args={"instance": "test_id"}, - expected_path_args={"instance_id": "test_id"}) - - def test_database_delete_ignore(self): - self.verify_delete(self.proxy.delete_database, - database.Database, True, - input_path_args={"instance": "test_id"}, - expected_path_args={"instance_id": "test_id"}) - - def test_database_find(self): - self._verify2('openstack.proxy2.BaseProxy._find', - self.proxy.find_database, - method_args=["db", "instance"], - expected_args=[database.Database, "db"], - expected_kwargs={"instance_id": "instance", - "ignore_missing": True}) - - def test_databases(self): - self.verify_list(self.proxy.databases, database.Database, - paginated=False, method_args=["id"], - expected_kwargs={"instance_id": "id"}) - - def test_database_get(self): - self.verify_get(self.proxy.get_database, database.Database) - - def test_flavor_find(self): - self.verify_find(self.proxy.find_flavor, flavor.Flavor) - - def test_flavor_get(self): - self.verify_get(self.proxy.get_flavor, flavor.Flavor) - - def test_flavors(self): - self.verify_list(self.proxy.flavors, flavor.Flavor, - paginated=False) - - def test_instance_create_attrs(self): - self.verify_create(self.proxy.create_instance, instance.Instance) - - def test_instance_delete(self): - self.verify_delete(self.proxy.delete_instance, - instance.Instance, False) - - def test_instance_delete_ignore(self): - self.verify_delete(self.proxy.delete_instance, - instance.Instance, True) - - def test_instance_find(self): - self.verify_find(self.proxy.find_instance, instance.Instance) - - def test_instance_get(self): - self.verify_get(self.proxy.get_instance, instance.Instance) - - def test_instances(self): - self.verify_list(self.proxy.instances, instance.Instance, - paginated=False) - - def test_instance_update(self): - self.verify_update(self.proxy.update_instance, instance.Instance) - - def test_user_create_attrs(self): - self.verify_create(self.proxy.create_user, user.User, - method_kwargs={"instance": "id"}, - expected_kwargs={"instance_id": "id"}) - - def test_user_delete(self): - self.verify_delete(self.proxy.delete_user, user.User, False, - input_path_args={"instance": "id"}, - expected_path_args={"instance_id": "id"}) - - def test_user_delete_ignore(self): - self.verify_delete(self.proxy.delete_user, user.User, True, - input_path_args={"instance": "id"}, - expected_path_args={"instance_id": "id"}) - - def test_user_find(self): - self._verify2('openstack.proxy2.BaseProxy._find', - self.proxy.find_user, - method_args=["user", "instance"], - expected_args=[user.User, "user"], - expected_kwargs={"instance_id": "instance", - "ignore_missing": True}) - - def test_users(self): - self.verify_list(self.proxy.users, user.User, paginated=False, - method_args=["test_instance"], - expected_kwargs={"instance_id": "test_instance"}) - - def test_user_get(self): - self.verify_get(self.proxy.get_user, user.User) diff --git a/openstack/tests/unit/database/v1/test_user.py b/openstack/tests/unit/database/v1/test_user.py deleted file mode 100644 index 884a906e..00000000 --- a/openstack/tests/unit/database/v1/test_user.py +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.database.v1 import user - -INSTANCE_ID = 'INSTANCE_ID' - -CREATING = { - 'databases': '1', - 'name': '2', - 'password': '3', -} - - -class TestUser(testtools.TestCase): - - def test_basic(self): - sot = user.User() - self.assertEqual('user', sot.resource_key) - self.assertEqual('users', sot.resources_key) - self.assertEqual('/instances/%(instance_id)s/users', sot.base_path) - self.assertEqual('database', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make(self): - sot = user.User(**CREATING) - self.assertEqual(CREATING['name'], sot.id) - self.assertEqual(CREATING['databases'], sot.databases) - self.assertEqual(CREATING['name'], sot.name) - self.assertEqual(CREATING['name'], sot.id) - self.assertEqual(CREATING['password'], sot.password) - - def test_create(self): - sot = user.User(instance_id=INSTANCE_ID, **CREATING) - result = sot._prepare_request() - self.assertEqual(result.body, {sot.resources_key: CREATING}) diff --git a/openstack/tests/unit/fakes.py b/openstack/tests/unit/fakes.py deleted file mode 100644 index f979ded5..00000000 --- a/openstack/tests/unit/fakes.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2010-2011 OpenStack Foundation -# 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 mock - - -class FakeTransport(mock.Mock): - RESPONSE = mock.Mock('200 OK') - - def __init__(self): - super(FakeTransport, self).__init__() - self.request = mock.Mock() - self.request.return_value = self.RESPONSE - - -class FakeAuthenticator(mock.Mock): - TOKEN = 'fake_token' - ENDPOINT = 'http://www.example.com/endpoint' - - def __init__(self): - super(FakeAuthenticator, self).__init__() - self.get_token = mock.Mock() - self.get_token.return_value = self.TOKEN - self.get_endpoint = mock.Mock() - self.get_endpoint.return_value = self.ENDPOINT diff --git a/openstack/tests/unit/identity/__init__.py b/openstack/tests/unit/identity/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/identity/test_identity_service.py b/openstack/tests/unit/identity/test_identity_service.py deleted file mode 100644 index dbfaea3d..00000000 --- a/openstack/tests/unit/identity/test_identity_service.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity import identity_service - - -class TestIdentityService(testtools.TestCase): - - def test_regular_service(self): - sot = identity_service.IdentityService() - self.assertEqual('identity', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(2, len(sot.valid_versions)) - self.assertEqual('v3', sot.valid_versions[0].module) - self.assertEqual('v3', sot.valid_versions[0].path) - self.assertEqual('v2', sot.valid_versions[1].module) - self.assertEqual('v2', sot.valid_versions[1].path) - - def test_admin_service(self): - sot = identity_service.AdminService() - self.assertEqual('identity', sot.service_type) - self.assertEqual('admin', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) diff --git a/openstack/tests/unit/identity/test_version.py b/openstack/tests/unit/identity/test_version.py deleted file mode 100644 index a3693f0d..00000000 --- a/openstack/tests/unit/identity/test_version.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.identity import version - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'media-types': '2', - 'status': '3', - 'updated': '4', -} - - -class TestVersion(testtools.TestCase): - - def test_basic(self): - sot = version.Version() - self.assertEqual('version', sot.resource_key) - self.assertEqual('versions', sot.resources_key) - self.assertEqual('/', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = version.Version(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['media-types'], sot.media_types) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['updated'], sot.updated) - - def test_list(self): - resp = mock.Mock() - resp.body = { - "versions": { - "values": [ - {"status": "stable", "updated": "a", "id": "v1.0"}, - {"status": "stable", "updated": "b", "id": "v1.1"}, - ] - } - } - resp.json = mock.Mock(return_value=resp.body) - session = mock.Mock() - session.get = mock.Mock(return_value=resp) - sot = version.Version(**EXAMPLE) - result = sot.list(session) - self.assertEqual(next(result).id, 'v1.0') - self.assertEqual(next(result).id, 'v1.1') - self.assertRaises(StopIteration, next, result) diff --git a/openstack/tests/unit/identity/v2/__init__.py b/openstack/tests/unit/identity/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/identity/v2/test_extension.py b/openstack/tests/unit/identity/v2/test_extension.py deleted file mode 100644 index 13d0d29b..00000000 --- a/openstack/tests/unit/identity/v2/test_extension.py +++ /dev/null @@ -1,69 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.identity.v2 import extension - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'alias': '1', - 'description': '2', - 'links': '3', - 'name': '4', - 'namespace': '5', - 'updated': '2015-03-09T12:14:57.233772', -} - - -class TestExtension(testtools.TestCase): - - def test_basic(self): - sot = extension.Extension() - self.assertEqual('extension', sot.resource_key) - self.assertEqual('extensions', sot.resources_key) - self.assertEqual('/extensions', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = extension.Extension(**EXAMPLE) - self.assertEqual(EXAMPLE['alias'], sot.alias) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['namespace'], sot.namespace) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) - - def test_list(self): - resp = mock.Mock() - resp.body = { - "extensions": { - "values": [ - {"name": "a"}, - {"name": "b"}, - ] - } - } - resp.json = mock.Mock(return_value=resp.body) - session = mock.Mock() - session.get = mock.Mock(return_value=resp) - sot = extension.Extension(**EXAMPLE) - result = sot.list(session) - self.assertEqual(next(result).name, 'a') - self.assertEqual(next(result).name, 'b') - self.assertRaises(StopIteration, next, result) diff --git a/openstack/tests/unit/identity/v2/test_proxy.py b/openstack/tests/unit/identity/v2/test_proxy.py deleted file mode 100644 index cbca1fd7..00000000 --- a/openstack/tests/unit/identity/v2/test_proxy.py +++ /dev/null @@ -1,86 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity.v2 import _proxy -from openstack.identity.v2 import role -from openstack.identity.v2 import tenant -from openstack.identity.v2 import user -from openstack.tests.unit import test_proxy_base2 as test_proxy_base - - -class TestIdentityProxy(test_proxy_base.TestProxyBase): - def setUp(self): - super(TestIdentityProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_role_create_attrs(self): - self.verify_create(self.proxy.create_role, role.Role) - - def test_role_delete(self): - self.verify_delete(self.proxy.delete_role, role.Role, False) - - def test_role_delete_ignore(self): - self.verify_delete(self.proxy.delete_role, role.Role, True) - - def test_role_find(self): - self.verify_find(self.proxy.find_role, role.Role) - - def test_role_get(self): - self.verify_get(self.proxy.get_role, role.Role) - - def test_roles(self): - self.verify_list(self.proxy.roles, role.Role) - - def test_role_update(self): - self.verify_update(self.proxy.update_role, role.Role) - - def test_tenant_create_attrs(self): - self.verify_create(self.proxy.create_tenant, tenant.Tenant) - - def test_tenant_delete(self): - self.verify_delete(self.proxy.delete_tenant, tenant.Tenant, False) - - def test_tenant_delete_ignore(self): - self.verify_delete(self.proxy.delete_tenant, tenant.Tenant, True) - - def test_tenant_find(self): - self.verify_find(self.proxy.find_tenant, tenant.Tenant) - - def test_tenant_get(self): - self.verify_get(self.proxy.get_tenant, tenant.Tenant) - - def test_tenants(self): - self.verify_list(self.proxy.tenants, tenant.Tenant, paginated=True) - - def test_tenant_update(self): - self.verify_update(self.proxy.update_tenant, tenant.Tenant) - - def test_user_create_attrs(self): - self.verify_create(self.proxy.create_user, user.User) - - def test_user_delete(self): - self.verify_delete(self.proxy.delete_user, user.User, False) - - def test_user_delete_ignore(self): - self.verify_delete(self.proxy.delete_user, user.User, True) - - def test_user_find(self): - self.verify_find(self.proxy.find_user, user.User) - - def test_user_get(self): - self.verify_get(self.proxy.get_user, user.User) - - def test_users(self): - self.verify_list(self.proxy.users, user.User) - - def test_user_update(self): - self.verify_update(self.proxy.update_user, user.User) diff --git a/openstack/tests/unit/identity/v2/test_role.py b/openstack/tests/unit/identity/v2/test_role.py deleted file mode 100644 index e1f67ba3..00000000 --- a/openstack/tests/unit/identity/v2/test_role.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v2 import role - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'enabled': 'True', - 'description': '1', - 'id': IDENTIFIER, - 'name': '3', -} - - -class TestRole(testtools.TestCase): - - def test_basic(self): - sot = role.Role() - self.assertEqual('role', sot.resource_key) - self.assertEqual('roles', sot.resources_key) - self.assertEqual('/OS-KSADM/roles', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = role.Role(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertTrue(sot.is_enabled) diff --git a/openstack/tests/unit/identity/v2/test_tenant.py b/openstack/tests/unit/identity/v2/test_tenant.py deleted file mode 100644 index b123ce40..00000000 --- a/openstack/tests/unit/identity/v2/test_tenant.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v2 import tenant - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'description': '1', - 'enabled': True, - 'id': '3', - 'name': '4', -} - - -class TestTenant(testtools.TestCase): - - def test_basic(self): - sot = tenant.Tenant() - self.assertEqual('tenant', sot.resource_key) - self.assertEqual('tenants', sot.resources_key) - self.assertEqual('/tenants', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = tenant.Tenant(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertTrue(sot.is_enabled) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) diff --git a/openstack/tests/unit/identity/v2/test_user.py b/openstack/tests/unit/identity/v2/test_user.py deleted file mode 100644 index 161b8bad..00000000 --- a/openstack/tests/unit/identity/v2/test_user.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v2 import user - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'email': '1', - 'enabled': True, - 'id': '3', - 'name': '4', -} - - -class TestUser(testtools.TestCase): - - def test_basic(self): - sot = user.User() - self.assertEqual('user', sot.resource_key) - self.assertEqual('users', sot.resources_key) - self.assertEqual('/users', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = user.User(**EXAMPLE) - self.assertEqual(EXAMPLE['email'], sot.email) - self.assertTrue(sot.is_enabled) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) diff --git a/openstack/tests/unit/identity/v3/__init__.py b/openstack/tests/unit/identity/v3/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/identity/v3/test_credential.py b/openstack/tests/unit/identity/v3/test_credential.py deleted file mode 100644 index 36066d9c..00000000 --- a/openstack/tests/unit/identity/v3/test_credential.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import credential - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'blob': '1', - 'id': IDENTIFIER, - 'project_id': '3', - 'type': '4', - 'user_id': '5', -} - - -class TestCredential(testtools.TestCase): - - def test_basic(self): - sot = credential.Credential() - self.assertEqual('credential', sot.resource_key) - self.assertEqual('credentials', sot.resources_key) - self.assertEqual('/credentials', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_make_it(self): - sot = credential.Credential(**EXAMPLE) - self.assertEqual(EXAMPLE['blob'], sot.blob) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['type'], sot.type) - self.assertEqual(EXAMPLE['user_id'], sot.user_id) diff --git a/openstack/tests/unit/identity/v3/test_domain.py b/openstack/tests/unit/identity/v3/test_domain.py deleted file mode 100644 index 07faa7fe..00000000 --- a/openstack/tests/unit/identity/v3/test_domain.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import domain - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'description': '1', - 'enabled': True, - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/identity/v3/domains/id'}, - 'name': '4', -} - - -class TestDomain(testtools.TestCase): - - def test_basic(self): - sot = domain.Domain() - self.assertEqual('domain', sot.resource_key) - self.assertEqual('domains', sot.resources_key) - self.assertEqual('/domains', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_make_it(self): - sot = domain.Domain(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertTrue(sot.is_enabled) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) diff --git a/openstack/tests/unit/identity/v3/test_endpoint.py b/openstack/tests/unit/identity/v3/test_endpoint.py deleted file mode 100644 index 44af7162..00000000 --- a/openstack/tests/unit/identity/v3/test_endpoint.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import endpoint - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'enabled': True, - 'id': IDENTIFIER, - 'interface': '3', - 'links': {'self': 'http://example.com/endpoint1'}, - 'region_id': '4', - 'service_id': '5', - 'url': '6', -} - - -class TestEndpoint(testtools.TestCase): - - def test_basic(self): - sot = endpoint.Endpoint() - self.assertEqual('endpoint', sot.resource_key) - self.assertEqual('endpoints', sot.resources_key) - self.assertEqual('/endpoints', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_make_it(self): - sot = endpoint.Endpoint(**EXAMPLE) - self.assertTrue(sot.is_enabled) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['interface'], sot.interface) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['region_id'], sot.region_id) - self.assertEqual(EXAMPLE['service_id'], sot.service_id) - self.assertEqual(EXAMPLE['url'], sot.url) diff --git a/openstack/tests/unit/identity/v3/test_group.py b/openstack/tests/unit/identity/v3/test_group.py deleted file mode 100644 index ff30c971..00000000 --- a/openstack/tests/unit/identity/v3/test_group.py +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import group - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'description': '1', - 'domain_id': '2', - 'id': IDENTIFIER, - 'name': '4', -} - - -class TestGroup(testtools.TestCase): - - def test_basic(self): - sot = group.Group() - self.assertEqual('group', sot.resource_key) - self.assertEqual('groups', sot.resources_key) - self.assertEqual('/groups', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_make_it(self): - sot = group.Group(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['domain_id'], sot.domain_id) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) diff --git a/openstack/tests/unit/identity/v3/test_policy.py b/openstack/tests/unit/identity/v3/test_policy.py deleted file mode 100644 index cdd8b71d..00000000 --- a/openstack/tests/unit/identity/v3/test_policy.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import policy - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'blob': '1', - 'id': IDENTIFIER, - 'links': {'self': 'a-pointer'}, - 'project_id': '2', - 'type': '3', - 'user_id': '4', -} - - -class TestPolicy(testtools.TestCase): - - def test_basic(self): - sot = policy.Policy() - self.assertEqual('policy', sot.resource_key) - self.assertEqual('policies', sot.resources_key) - self.assertEqual('/policies', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_make_it(self): - sot = policy.Policy(**EXAMPLE) - self.assertEqual(EXAMPLE['blob'], sot.blob) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['type'], sot.type) - self.assertEqual(EXAMPLE['user_id'], sot.user_id) diff --git a/openstack/tests/unit/identity/v3/test_project.py b/openstack/tests/unit/identity/v3/test_project.py deleted file mode 100644 index f88a0ae5..00000000 --- a/openstack/tests/unit/identity/v3/test_project.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import project - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'description': '1', - 'domain_id': '2', - 'enabled': True, - 'id': IDENTIFIER, - 'is_domain': False, - 'name': '5', - 'parent_id': '6', -} - - -class TestProject(testtools.TestCase): - - def test_basic(self): - sot = project.Project() - self.assertEqual('project', sot.resource_key) - self.assertEqual('projects', sot.resources_key) - self.assertEqual('/projects', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_make_it(self): - sot = project.Project(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['domain_id'], sot.domain_id) - self.assertFalse(sot.is_domain) - self.assertTrue(sot.is_enabled) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['parent_id'], sot.parent_id) diff --git a/openstack/tests/unit/identity/v3/test_proxy.py b/openstack/tests/unit/identity/v3/test_proxy.py deleted file mode 100644 index aff74726..00000000 --- a/openstack/tests/unit/identity/v3/test_proxy.py +++ /dev/null @@ -1,266 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.identity.v3 import _proxy -from openstack.identity.v3 import credential -from openstack.identity.v3 import domain -from openstack.identity.v3 import endpoint -from openstack.identity.v3 import group -from openstack.identity.v3 import policy -from openstack.identity.v3 import project -from openstack.identity.v3 import region -from openstack.identity.v3 import role -from openstack.identity.v3 import service -from openstack.identity.v3 import trust -from openstack.identity.v3 import user -from openstack.tests.unit import test_proxy_base2 - - -class TestIdentityProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestIdentityProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_credential_create_attrs(self): - self.verify_create(self.proxy.create_credential, - credential.Credential) - - def test_credential_delete(self): - self.verify_delete(self.proxy.delete_credential, - credential.Credential, False) - - def test_credential_delete_ignore(self): - self.verify_delete(self.proxy.delete_credential, - credential.Credential, True) - - def test_credential_find(self): - self.verify_find(self.proxy.find_credential, credential.Credential) - - def test_credential_get(self): - self.verify_get(self.proxy.get_credential, credential.Credential) - - def test_credentials(self): - self.verify_list(self.proxy.credentials, credential.Credential, - paginated=False) - - def test_credential_update(self): - self.verify_update(self.proxy.update_credential, credential.Credential) - - def test_domain_create_attrs(self): - self.verify_create(self.proxy.create_domain, domain.Domain) - - def test_domain_delete(self): - self.verify_delete(self.proxy.delete_domain, domain.Domain, False) - - def test_domain_delete_ignore(self): - self.verify_delete(self.proxy.delete_domain, domain.Domain, True) - - def test_domain_find(self): - self.verify_find(self.proxy.find_domain, domain.Domain) - - def test_domain_get(self): - self.verify_get(self.proxy.get_domain, domain.Domain) - - def test_domains(self): - self.verify_list(self.proxy.domains, domain.Domain, paginated=False) - - def test_domain_update(self): - self.verify_update(self.proxy.update_domain, domain.Domain) - - def test_endpoint_create_attrs(self): - self.verify_create(self.proxy.create_endpoint, endpoint.Endpoint) - - def test_endpoint_delete(self): - self.verify_delete(self.proxy.delete_endpoint, - endpoint.Endpoint, False) - - def test_endpoint_delete_ignore(self): - self.verify_delete(self.proxy.delete_endpoint, - endpoint.Endpoint, True) - - def test_endpoint_find(self): - self.verify_find(self.proxy.find_endpoint, endpoint.Endpoint) - - def test_endpoint_get(self): - self.verify_get(self.proxy.get_endpoint, endpoint.Endpoint) - - def test_endpoints(self): - self.verify_list(self.proxy.endpoints, endpoint.Endpoint, - paginated=False) - - def test_endpoint_update(self): - self.verify_update(self.proxy.update_endpoint, endpoint.Endpoint) - - def test_group_create_attrs(self): - self.verify_create(self.proxy.create_group, group.Group) - - def test_group_delete(self): - self.verify_delete(self.proxy.delete_group, group.Group, False) - - def test_group_delete_ignore(self): - self.verify_delete(self.proxy.delete_group, group.Group, True) - - def test_group_find(self): - self.verify_find(self.proxy.find_group, group.Group) - - def test_group_get(self): - self.verify_get(self.proxy.get_group, group.Group) - - def test_groups(self): - self.verify_list(self.proxy.groups, group.Group, paginated=False) - - def test_group_update(self): - self.verify_update(self.proxy.update_group, group.Group) - - def test_policy_create_attrs(self): - self.verify_create(self.proxy.create_policy, policy.Policy) - - def test_policy_delete(self): - self.verify_delete(self.proxy.delete_policy, policy.Policy, False) - - def test_policy_delete_ignore(self): - self.verify_delete(self.proxy.delete_policy, policy.Policy, True) - - def test_policy_find(self): - self.verify_find(self.proxy.find_policy, policy.Policy) - - def test_policy_get(self): - self.verify_get(self.proxy.get_policy, policy.Policy) - - def test_policies(self): - self.verify_list(self.proxy.policies, policy.Policy, paginated=False) - - def test_policy_update(self): - self.verify_update(self.proxy.update_policy, policy.Policy) - - def test_project_create_attrs(self): - self.verify_create(self.proxy.create_project, project.Project) - - def test_project_delete(self): - self.verify_delete(self.proxy.delete_project, project.Project, False) - - def test_project_delete_ignore(self): - self.verify_delete(self.proxy.delete_project, project.Project, True) - - def test_project_find(self): - self.verify_find(self.proxy.find_project, project.Project) - - def test_project_get(self): - self.verify_get(self.proxy.get_project, project.Project) - - def test_projects(self): - self.verify_list(self.proxy.projects, project.Project, paginated=False) - - def test_project_update(self): - self.verify_update(self.proxy.update_project, project.Project) - - def test_service_create_attrs(self): - self.verify_create(self.proxy.create_service, service.Service) - - def test_service_delete(self): - self.verify_delete(self.proxy.delete_service, service.Service, False) - - def test_service_delete_ignore(self): - self.verify_delete(self.proxy.delete_service, service.Service, True) - - def test_service_find(self): - self.verify_find(self.proxy.find_service, service.Service) - - def test_service_get(self): - self.verify_get(self.proxy.get_service, service.Service) - - def test_services(self): - self.verify_list(self.proxy.services, service.Service, paginated=False) - - def test_service_update(self): - self.verify_update(self.proxy.update_service, service.Service) - - def test_user_create_attrs(self): - self.verify_create(self.proxy.create_user, user.User) - - def test_user_delete(self): - self.verify_delete(self.proxy.delete_user, user.User, False) - - def test_user_delete_ignore(self): - self.verify_delete(self.proxy.delete_user, user.User, True) - - def test_user_find(self): - self.verify_find(self.proxy.find_user, user.User) - - def test_user_get(self): - self.verify_get(self.proxy.get_user, user.User) - - def test_users(self): - self.verify_list(self.proxy.users, user.User, paginated=False) - - def test_user_update(self): - self.verify_update(self.proxy.update_user, user.User) - - def test_trust_create_attrs(self): - self.verify_create(self.proxy.create_trust, trust.Trust) - - def test_trust_delete(self): - self.verify_delete(self.proxy.delete_trust, trust.Trust, False) - - def test_trust_delete_ignore(self): - self.verify_delete(self.proxy.delete_trust, trust.Trust, True) - - def test_trust_find(self): - self.verify_find(self.proxy.find_trust, trust.Trust) - - def test_trust_get(self): - self.verify_get(self.proxy.get_trust, trust.Trust) - - def test_trusts(self): - self.verify_list(self.proxy.trusts, trust.Trust, paginated=False) - - def test_region_create_attrs(self): - self.verify_create(self.proxy.create_region, region.Region) - - def test_region_delete(self): - self.verify_delete(self.proxy.delete_region, region.Region, False) - - def test_region_delete_ignore(self): - self.verify_delete(self.proxy.delete_region, region.Region, True) - - def test_region_find(self): - self.verify_find(self.proxy.find_region, region.Region) - - def test_region_get(self): - self.verify_get(self.proxy.get_region, region.Region) - - def test_regions(self): - self.verify_list(self.proxy.regions, region.Region, paginated=False) - - def test_region_update(self): - self.verify_update(self.proxy.update_region, region.Region) - - def test_role_create_attrs(self): - self.verify_create(self.proxy.create_role, role.Role) - - def test_role_delete(self): - self.verify_delete(self.proxy.delete_role, role.Role, False) - - def test_role_delete_ignore(self): - self.verify_delete(self.proxy.delete_role, role.Role, True) - - def test_role_find(self): - self.verify_find(self.proxy.find_role, role.Role) - - def test_role_get(self): - self.verify_get(self.proxy.get_role, role.Role) - - def test_roles(self): - self.verify_list(self.proxy.roles, role.Role, paginated=False) - - def test_role_update(self): - self.verify_update(self.proxy.update_role, role.Role) diff --git a/openstack/tests/unit/identity/v3/test_region.py b/openstack/tests/unit/identity/v3/test_region.py deleted file mode 100644 index 01711d0e..00000000 --- a/openstack/tests/unit/identity/v3/test_region.py +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import region - -IDENTIFIER = 'RegionOne' -EXAMPLE = { - 'description': '1', - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/region1'}, - 'parent_region_id': 'FAKE_PARENT', -} - - -class TestRegion(testtools.TestCase): - - def test_basic(self): - sot = region.Region() - self.assertEqual('region', sot.resource_key) - self.assertEqual('regions', sot.resources_key) - self.assertEqual('/regions', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_make_it(self): - sot = region.Region(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['parent_region_id'], sot.parent_region_id) diff --git a/openstack/tests/unit/identity/v3/test_role.py b/openstack/tests/unit/identity/v3/test_role.py deleted file mode 100644 index 8f9e9809..00000000 --- a/openstack/tests/unit/identity/v3/test_role.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import role - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/user1'}, - 'name': '2', -} - - -class TestRole(testtools.TestCase): - - def test_basic(self): - sot = role.Role() - self.assertEqual('role', sot.resource_key) - self.assertEqual('roles', sot.resources_key) - self.assertEqual('/roles', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = role.Role(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) diff --git a/openstack/tests/unit/identity/v3/test_role_assignment.py b/openstack/tests/unit/identity/v3/test_role_assignment.py deleted file mode 100644 index a0a1e505..00000000 --- a/openstack/tests/unit/identity/v3/test_role_assignment.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import role_assignment - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/user1'}, - 'scope': {'domain': {'id': '2'}}, - 'user': {'id': '3'}, - 'group': {'id': '4'} -} - - -class TestRoleAssignment(testtools.TestCase): - - def test_basic(self): - sot = role_assignment.RoleAssignment() - self.assertEqual('role_assignment', sot.resource_key) - self.assertEqual('role_assignments', sot.resources_key) - self.assertEqual('/role_assignments', - sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = role_assignment.RoleAssignment(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['scope'], sot.scope) - self.assertEqual(EXAMPLE['user'], sot.user) - self.assertEqual(EXAMPLE['group'], sot.group) diff --git a/openstack/tests/unit/identity/v3/test_role_domain_group_assignment.py b/openstack/tests/unit/identity/v3/test_role_domain_group_assignment.py deleted file mode 100644 index 5e0777d2..00000000 --- a/openstack/tests/unit/identity/v3/test_role_domain_group_assignment.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import role_domain_group_assignment - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/user1'}, - 'name': '2', - 'domain_id': '3', - 'group_id': '4' -} - - -class TestRoleDomainGroupAssignment(testtools.TestCase): - - def test_basic(self): - sot = role_domain_group_assignment.RoleDomainGroupAssignment() - self.assertEqual('role', sot.resource_key) - self.assertEqual('roles', sot.resources_key) - self.assertEqual('/domains/%(domain_id)s/groups/%(group_id)s/roles', - sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = \ - role_domain_group_assignment.RoleDomainGroupAssignment(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['domain_id'], sot.domain_id) - self.assertEqual(EXAMPLE['group_id'], sot.group_id) diff --git a/openstack/tests/unit/identity/v3/test_role_domain_user_assignment.py b/openstack/tests/unit/identity/v3/test_role_domain_user_assignment.py deleted file mode 100644 index cc7de8bd..00000000 --- a/openstack/tests/unit/identity/v3/test_role_domain_user_assignment.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import role_domain_user_assignment - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/user1'}, - 'name': '2', - 'domain_id': '3', - 'user_id': '4' -} - - -class TestRoleDomainUserAssignment(testtools.TestCase): - - def test_basic(self): - sot = role_domain_user_assignment.RoleDomainUserAssignment() - self.assertEqual('role', sot.resource_key) - self.assertEqual('roles', sot.resources_key) - self.assertEqual('/domains/%(domain_id)s/users/%(user_id)s/roles', - sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = \ - role_domain_user_assignment.RoleDomainUserAssignment(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['domain_id'], sot.domain_id) - self.assertEqual(EXAMPLE['user_id'], sot.user_id) diff --git a/openstack/tests/unit/identity/v3/test_role_project_group_assignment.py b/openstack/tests/unit/identity/v3/test_role_project_group_assignment.py deleted file mode 100644 index 81c96e7d..00000000 --- a/openstack/tests/unit/identity/v3/test_role_project_group_assignment.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import role_project_group_assignment - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/user1'}, - 'name': '2', - 'project_id': '3', - 'group_id': '4' -} - - -class TestRoleProjectGroupAssignment(testtools.TestCase): - - def test_basic(self): - sot = role_project_group_assignment.RoleProjectGroupAssignment() - self.assertEqual('role', sot.resource_key) - self.assertEqual('roles', sot.resources_key) - self.assertEqual('/projects/%(project_id)s/groups/%(group_id)s/roles', - sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = \ - role_project_group_assignment.RoleProjectGroupAssignment(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['group_id'], sot.group_id) diff --git a/openstack/tests/unit/identity/v3/test_role_project_user_assignment.py b/openstack/tests/unit/identity/v3/test_role_project_user_assignment.py deleted file mode 100644 index 5314c0bc..00000000 --- a/openstack/tests/unit/identity/v3/test_role_project_user_assignment.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import role_project_user_assignment - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/user1'}, - 'name': '2', - 'project_id': '3', - 'user_id': '4' -} - - -class TestRoleProjectUserAssignment(testtools.TestCase): - - def test_basic(self): - sot = role_project_user_assignment.RoleProjectUserAssignment() - self.assertEqual('role', sot.resource_key) - self.assertEqual('roles', sot.resources_key) - self.assertEqual('/projects/%(project_id)s/users/%(user_id)s/roles', - sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = \ - role_project_user_assignment.RoleProjectUserAssignment(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['user_id'], sot.user_id) diff --git a/openstack/tests/unit/identity/v3/test_service.py b/openstack/tests/unit/identity/v3/test_service.py deleted file mode 100644 index 848c847f..00000000 --- a/openstack/tests/unit/identity/v3/test_service.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import service - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'description': '1', - 'enabled': True, - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/service1'}, - 'name': '4', - 'type': '5', -} - - -class TestService(testtools.TestCase): - - def test_basic(self): - sot = service.Service() - self.assertEqual('service', sot.resource_key) - self.assertEqual('services', sot.resources_key) - self.assertEqual('/services', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_make_it(self): - sot = service.Service(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertTrue(sot.is_enabled) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['type'], sot.type) diff --git a/openstack/tests/unit/identity/v3/test_trust.py b/openstack/tests/unit/identity/v3/test_trust.py deleted file mode 100644 index de5c07c6..00000000 --- a/openstack/tests/unit/identity/v3/test_trust.py +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import trust - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'allow_redelegation': False, - 'expires_at': '2016-03-09T12:14:57.233772', - 'id': IDENTIFIER, - 'impersonation': True, - 'links': {'self': 'fake_link'}, - 'project_id': '1', - 'redelegated_trust_id': None, - 'redelegation_count': '0', - 'remaining_uses': 10, - 'role_links': {'self': 'other_fake_link'}, - 'trustee_user_id': '2', - 'trustor_user_id': '3', - 'roles': [{'name': 'test-role'}], -} - - -class TestTrust(testtools.TestCase): - - def test_basic(self): - sot = trust.Trust() - self.assertEqual('trust', sot.resource_key) - self.assertEqual('trusts', sot.resources_key) - self.assertEqual('/OS-TRUST/trusts', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = trust.Trust(**EXAMPLE) - self.assertEqual(EXAMPLE['allow_redelegation'], sot.allow_redelegation) - self.assertEqual(EXAMPLE['expires_at'], sot.expires_at) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertTrue(sot.is_impersonation) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['role_links'], sot.role_links) - self.assertEqual(EXAMPLE['redelegated_trust_id'], - sot.redelegated_trust_id) - self.assertEqual(EXAMPLE['remaining_uses'], sot.remaining_uses) - self.assertEqual(EXAMPLE['trustee_user_id'], sot.trustee_user_id) - self.assertEqual(EXAMPLE['trustor_user_id'], sot.trustor_user_id) - self.assertEqual(EXAMPLE['roles'], sot.roles) - self.assertEqual(EXAMPLE['redelegation_count'], sot.redelegation_count) diff --git a/openstack/tests/unit/identity/v3/test_user.py b/openstack/tests/unit/identity/v3/test_user.py deleted file mode 100644 index f0202b90..00000000 --- a/openstack/tests/unit/identity/v3/test_user.py +++ /dev/null @@ -1,60 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity.v3 import user - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'default_project_id': '1', - 'description': '2', - 'domain_id': '3', - 'email': '4', - 'enabled': True, - 'id': IDENTIFIER, - 'links': {'self': 'http://example.com/user1'}, - 'name': '6', - 'password': '7', - 'password_expires_at': '8', -} - - -class TestUser(testtools.TestCase): - - def test_basic(self): - sot = user.User() - self.assertEqual('user', sot.resource_key) - self.assertEqual('users', sot.resources_key) - self.assertEqual('/users', sot.base_path) - self.assertEqual('identity', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.patch_update) - - def test_make_it(self): - sot = user.User(**EXAMPLE) - self.assertEqual(EXAMPLE['default_project_id'], - sot.default_project_id) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['domain_id'], sot.domain_id) - self.assertEqual(EXAMPLE['email'], sot.email) - self.assertTrue(sot.is_enabled) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['password'], sot.password) - self.assertEqual(EXAMPLE['password_expires_at'], - sot.password_expires_at) diff --git a/openstack/tests/unit/image/__init__.py b/openstack/tests/unit/image/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/image/test_image_service.py b/openstack/tests/unit/image/test_image_service.py deleted file mode 100644 index adc64125..00000000 --- a/openstack/tests/unit/image/test_image_service.py +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.image import image_service - - -class TestImageService(testtools.TestCase): - - def test_service(self): - sot = image_service.ImageService() - self.assertEqual('image', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(2, len(sot.valid_versions)) - self.assertEqual('v2', sot.valid_versions[0].module) - self.assertEqual('v2', sot.valid_versions[0].path) - self.assertEqual('v1', sot.valid_versions[1].module) - self.assertEqual('v1', sot.valid_versions[1].path) diff --git a/openstack/tests/unit/image/v1/__init__.py b/openstack/tests/unit/image/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/image/v1/test_image.py b/openstack/tests/unit/image/v1/test_image.py deleted file mode 100644 index 4f0a4554..00000000 --- a/openstack/tests/unit/image/v1/test_image.py +++ /dev/null @@ -1,71 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.image.v1 import image - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'checksum': '1', - 'container_format': '2', - 'copy_from': '3', - 'disk_format': '4', - 'id': IDENTIFIER, - 'is_public': True, - 'location': '6', - 'min_disk': '7', - 'min_ram': '8', - 'name': '9', - 'owner': '10', - 'properties': '11', - 'protected': True, - 'size': '13', - 'status': '14', - 'created_at': '2015-03-09T12:14:57.233772', - 'updated_at': '2015-03-09T12:15:57.233772', -} - - -class TestImage(testtools.TestCase): - - def test_basic(self): - sot = image.Image() - self.assertEqual('image', sot.resource_key) - self.assertEqual('images', sot.resources_key) - self.assertEqual('/images', sot.base_path) - self.assertEqual('image', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = image.Image(**EXAMPLE) - self.assertEqual(EXAMPLE['checksum'], sot.checksum) - self.assertEqual(EXAMPLE['container_format'], sot.container_format) - self.assertEqual(EXAMPLE['copy_from'], sot.copy_from) - self.assertEqual(EXAMPLE['disk_format'], sot.disk_format) - self.assertEqual(IDENTIFIER, sot.id) - self.assertTrue(sot.is_public) - self.assertEqual(EXAMPLE['location'], sot.location) - self.assertEqual(EXAMPLE['min_disk'], sot.min_disk) - self.assertEqual(EXAMPLE['min_ram'], sot.min_ram) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['owner'], sot.owner_id) - self.assertEqual(EXAMPLE['properties'], sot.properties) - self.assertTrue(sot.is_protected) - self.assertEqual(EXAMPLE['size'], sot.size) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/image/v1/test_proxy.py b/openstack/tests/unit/image/v1/test_proxy.py deleted file mode 100644 index e0dbd679..00000000 --- a/openstack/tests/unit/image/v1/test_proxy.py +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.image.v1 import _proxy -from openstack.image.v1 import image -from openstack.tests.unit import test_proxy_base2 as test_proxy_base - - -class TestImageProxy(test_proxy_base.TestProxyBase): - def setUp(self): - super(TestImageProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_image_upload_attrs(self): - self.verify_create(self.proxy.upload_image, image.Image) - - def test_image_delete(self): - self.verify_delete(self.proxy.delete_image, image.Image, False) - - def test_image_delete_ignore(self): - self.verify_delete(self.proxy.delete_image, image.Image, True) - - def test_image_find(self): - self.verify_find(self.proxy.find_image, image.Image) - - def test_image_get(self): - self.verify_get(self.proxy.get_image, image.Image) - - def test_images(self): - self.verify_list(self.proxy.images, image.Image, paginated=True) - - def test_image_update(self): - self.verify_update(self.proxy.update_image, image.Image) diff --git a/openstack/tests/unit/image/v2/__init__.py b/openstack/tests/unit/image/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/image/v2/test_image.py b/openstack/tests/unit/image/v2/test_image.py deleted file mode 100644 index 2a3acf45..00000000 --- a/openstack/tests/unit/image/v2/test_image.py +++ /dev/null @@ -1,326 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import json - -import mock -import testtools - -from openstack import exceptions -from openstack.image.v2 import image - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'checksum': '1', - 'container_format': '2', - 'created_at': '2015-03-09T12:14:57.233772', - 'data': 'This is not an image', - 'disk_format': '4', - 'min_disk': 5, - 'name': '6', - 'owner': '7', - 'properties': {'a': 'z', 'b': 'y', }, - 'protected': False, - 'status': '8', - 'tags': ['g', 'h', 'i'], - 'updated_at': '2015-03-09T12:15:57.233772', - 'virtual_size': '10', - 'visibility': '11', - 'location': '12', - 'size': 13, - 'store': '14', - 'file': '15', - 'locations': ['15', '16'], - 'direct_url': '17', - 'path': '18', - 'value': '19', - 'url': '20', - 'metadata': {'21': '22'}, - 'architecture': '23', - 'hypervisor-type': '24', - 'instance_type_rxtx_factor': 25.1, - 'instance_uuid': '26', - 'img_config_drive': '27', - 'kernel_id': '28', - 'os_distro': '29', - 'os_version': '30', - 'os_secure_boot': '31', - 'ramdisk_id': '32', - 'vm_mode': '33', - 'hw_cpu_sockets': 34, - 'hw_cpu_cores': 35, - 'hw_cpu_threads': 36, - 'hw_disk_bus': '37', - 'hw_rng_model': '38', - 'hw_machine_type': '39', - 'hw_scsi_model': '40', - 'hw_serial_port_count': 41, - 'hw_video_model': '42', - 'hw_video_ram': 43, - 'hw_watchdog_action': '44', - 'os_command_line': '45', - 'hw_vif_model': '46', - 'hw_vif_multiqueue_enabled': True, - 'hw_boot_menu': True, - 'vmware_adaptertype': '47', - 'vmware_ostype': '48', - 'auto_disk_config': True, - 'os_type': '49', -} - - -class TestImage(testtools.TestCase): - - def setUp(self): - super(TestImage, self).setUp() - self.resp = mock.Mock() - self.resp.body = None - self.resp.json = mock.Mock(return_value=self.resp.body) - self.sess = mock.Mock() - self.sess.post = mock.Mock(return_value=self.resp) - - def test_basic(self): - sot = image.Image() - self.assertIsNone(sot.resource_key) - self.assertEqual('images', sot.resources_key) - self.assertEqual('/images', sot.base_path) - self.assertEqual('image', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = image.Image(**EXAMPLE) - self.assertEqual(IDENTIFIER, sot.id) - self.assertEqual(EXAMPLE['checksum'], sot.checksum) - self.assertEqual(EXAMPLE['container_format'], sot.container_format) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['disk_format'], sot.disk_format) - self.assertEqual(EXAMPLE['min_disk'], sot.min_disk) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['owner'], sot.owner_id) - self.assertEqual(EXAMPLE['properties'], sot.properties) - self.assertFalse(sot.is_protected) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['tags'], sot.tags) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) - self.assertEqual(EXAMPLE['virtual_size'], sot.virtual_size) - self.assertEqual(EXAMPLE['visibility'], sot.visibility) - self.assertEqual(EXAMPLE['size'], sot.size) - self.assertEqual(EXAMPLE['store'], sot.store) - self.assertEqual(EXAMPLE['file'], sot.file) - self.assertEqual(EXAMPLE['locations'], sot.locations) - self.assertEqual(EXAMPLE['direct_url'], sot.direct_url) - self.assertEqual(EXAMPLE['path'], sot.path) - self.assertEqual(EXAMPLE['value'], sot.value) - self.assertEqual(EXAMPLE['url'], sot.url) - self.assertEqual(EXAMPLE['metadata'], sot.metadata) - self.assertEqual(EXAMPLE['architecture'], sot.architecture) - self.assertEqual(EXAMPLE['hypervisor-type'], sot.hypervisor_type) - self.assertEqual(EXAMPLE['instance_type_rxtx_factor'], - sot.instance_type_rxtx_factor) - self.assertEqual(EXAMPLE['instance_uuid'], sot.instance_uuid) - self.assertEqual(EXAMPLE['img_config_drive'], sot.needs_config_drive) - self.assertEqual(EXAMPLE['kernel_id'], sot.kernel_id) - self.assertEqual(EXAMPLE['os_distro'], sot.os_distro) - self.assertEqual(EXAMPLE['os_version'], sot.os_version) - self.assertEqual(EXAMPLE['os_secure_boot'], sot.needs_secure_boot) - self.assertEqual(EXAMPLE['ramdisk_id'], sot.ramdisk_id) - self.assertEqual(EXAMPLE['vm_mode'], sot.vm_mode) - self.assertEqual(EXAMPLE['hw_cpu_sockets'], sot.hw_cpu_sockets) - self.assertEqual(EXAMPLE['hw_cpu_cores'], sot.hw_cpu_cores) - self.assertEqual(EXAMPLE['hw_cpu_threads'], sot.hw_cpu_threads) - self.assertEqual(EXAMPLE['hw_disk_bus'], sot.hw_disk_bus) - self.assertEqual(EXAMPLE['hw_rng_model'], sot.hw_rng_model) - self.assertEqual(EXAMPLE['hw_machine_type'], sot.hw_machine_type) - self.assertEqual(EXAMPLE['hw_scsi_model'], sot.hw_scsi_model) - self.assertEqual(EXAMPLE['hw_serial_port_count'], - sot.hw_serial_port_count) - self.assertEqual(EXAMPLE['hw_video_model'], sot.hw_video_model) - self.assertEqual(EXAMPLE['hw_video_ram'], sot.hw_video_ram) - self.assertEqual(EXAMPLE['hw_watchdog_action'], sot.hw_watchdog_action) - self.assertEqual(EXAMPLE['os_command_line'], sot.os_command_line) - self.assertEqual(EXAMPLE['hw_vif_model'], sot.hw_vif_model) - self.assertEqual(EXAMPLE['hw_vif_multiqueue_enabled'], - sot.is_hw_vif_multiqueue_enabled) - self.assertEqual(EXAMPLE['hw_boot_menu'], sot.is_hw_boot_menu_enabled) - self.assertEqual(EXAMPLE['vmware_adaptertype'], sot.vmware_adaptertype) - self.assertEqual(EXAMPLE['vmware_ostype'], sot.vmware_ostype) - self.assertEqual(EXAMPLE['auto_disk_config'], sot.has_auto_disk_config) - self.assertEqual(EXAMPLE['os_type'], sot.os_type) - - def test_deactivate(self): - sot = image.Image(**EXAMPLE) - self.assertIsNone(sot.deactivate(self.sess)) - self.sess.post.assert_called_with( - 'images/IDENTIFIER/actions/deactivate', - endpoint_filter=sot.service) - - def test_reactivate(self): - sot = image.Image(**EXAMPLE) - self.assertIsNone(sot.reactivate(self.sess)) - self.sess.post.assert_called_with( - 'images/IDENTIFIER/actions/reactivate', - endpoint_filter=sot.service) - - def test_add_tag(self): - sot = image.Image(**EXAMPLE) - tag = "lol" - - self.assertIsNone(sot.add_tag(self.sess, tag)) - self.sess.put.assert_called_with( - 'images/IDENTIFIER/tags/%s' % tag, - endpoint_filter=sot.service) - - def test_remove_tag(self): - sot = image.Image(**EXAMPLE) - tag = "lol" - - self.assertIsNone(sot.remove_tag(self.sess, tag)) - self.sess.delete.assert_called_with( - 'images/IDENTIFIER/tags/%s' % tag, - endpoint_filter=sot.service) - - def test_upload(self): - sot = image.Image(**EXAMPLE) - - self.assertIsNone(sot.upload(self.sess)) - self.sess.put.assert_called_with('images/IDENTIFIER/file', - endpoint_filter=sot.service, - data=sot.data, - headers={"Content-Type": - "application/octet-stream", - "Accept": ""}) - - def test_download_checksum_match(self): - sot = image.Image(**EXAMPLE) - - resp = mock.Mock() - resp.content = b"abc" - resp.headers = {"Content-MD5": "900150983cd24fb0d6963f7d28e17f72"} - self.sess.get.return_value = resp - - rv = sot.download(self.sess) - self.sess.get.assert_called_with('images/IDENTIFIER/file', - endpoint_filter=sot.service, - stream=False) - - self.assertEqual(rv, resp.content) - - def test_download_checksum_mismatch(self): - sot = image.Image(**EXAMPLE) - - resp = mock.Mock() - resp.content = b"abc" - resp.headers = {"Content-MD5": "the wrong checksum"} - self.sess.get.return_value = resp - - self.assertRaises(exceptions.InvalidResponse, sot.download, self.sess) - - def test_download_no_checksum_header(self): - sot = image.Image(**EXAMPLE) - - resp1 = mock.Mock() - resp1.content = b"abc" - resp1.headers = {"no_checksum_here": ""} - - resp2 = mock.Mock() - resp2.json = mock.Mock( - return_value={"checksum": "900150983cd24fb0d6963f7d28e17f72"}) - resp2.headers = {"": ""} - - self.sess.get.side_effect = [resp1, resp2] - - rv = sot.download(self.sess) - self.sess.get.assert_has_calls( - [mock.call('images/IDENTIFIER/file', endpoint_filter=sot.service, - stream=False), - mock.call('images/IDENTIFIER', endpoint_filter=sot.service)]) - - self.assertEqual(rv, resp1.content) - - def test_download_no_checksum_at_all2(self): - sot = image.Image(**EXAMPLE) - - resp1 = mock.Mock() - resp1.content = b"abc" - resp1.headers = {"no_checksum_here": ""} - - resp2 = mock.Mock() - resp2.json = mock.Mock(return_value={"checksum": None}) - resp2.headers = {"": ""} - - self.sess.get.side_effect = [resp1, resp2] - - with self.assertLogs(logger=image.__name__, level="WARNING") as log: - rv = sot.download(self.sess) - - self.assertEqual(len(log.records), 1, - "Too many warnings were logged") - self.assertEqual( - "Unable to verify the integrity of image IDENTIFIER", - log.records[0].msg) - - self.sess.get.assert_has_calls( - [mock.call('images/IDENTIFIER/file', endpoint_filter=sot.service, - stream=False), - mock.call('images/IDENTIFIER', endpoint_filter=sot.service)]) - - self.assertEqual(rv, resp1.content) - - def test_download_stream(self): - sot = image.Image(**EXAMPLE) - - resp = mock.Mock() - resp.content = b"abc" - resp.headers = {"Content-MD5": "900150983cd24fb0d6963f7d28e17f72"} - self.sess.get.return_value = resp - - rv = sot.download(self.sess, stream=True) - self.sess.get.assert_called_with('images/IDENTIFIER/file', - endpoint_filter=sot.service, - stream=True) - - self.assertEqual(rv, resp) - - def test_image_update(self): - sot = image.Image(**EXAMPLE) - # Let the translate pass through, that portion is tested elsewhere - sot._translate_response = mock.Mock() - - resp = mock.Mock() - resp.content = b"abc" - headers = { - 'Content-Type': 'application/openstack-images-v2.1-json-patch', - 'Accept': '', - } - resp.headers = headers - resp.status_code = 200 - self.sess.patch.return_value = resp - - value = ('[{"value": "fake_name", "op": "replace", "path": "/name"}, ' - '{"value": "fake_value", "op": "add", ' - '"path": "/new_property"}]') - fake_img = sot.to_dict() - fake_img['name'] = 'fake_name' - fake_img['new_property'] = 'fake_value' - - sot.update(self.sess, **fake_img) - url = 'images/' + IDENTIFIER - self.sess.patch.assert_called_once() - call = self.sess.patch.call_args - call_args, call_kwargs = call - self.assertEqual(url, call_args[0]) - self.assertEqual(json.loads(value), json.loads(call_kwargs['data'])) diff --git a/openstack/tests/unit/image/v2/test_member.py b/openstack/tests/unit/image/v2/test_member.py deleted file mode 100644 index 993639f5..00000000 --- a/openstack/tests/unit/image/v2/test_member.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.image.v2 import member - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'created_at': '2015-03-09T12:14:57.233772', - 'image_id': '2', - 'member_id': IDENTIFIER, - 'status': '4', - 'updated_at': '2015-03-09T12:15:57.233772', -} - - -class TestMember(testtools.TestCase): - def test_basic(self): - sot = member.Member() - self.assertIsNone(sot.resource_key) - self.assertEqual('members', sot.resources_key) - self.assertEqual('/images/%(image_id)s/members', sot.base_path) - self.assertEqual('image', sot.service.service_type) - self.assertEqual('member', sot._alternate_id()) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = member.Member(**EXAMPLE) - self.assertEqual(IDENTIFIER, sot.id) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['image_id'], sot.image_id) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/image/v2/test_proxy.py b/openstack/tests/unit/image/v2/test_proxy.py deleted file mode 100644 index 8bb060c7..00000000 --- a/openstack/tests/unit/image/v2/test_proxy.py +++ /dev/null @@ -1,156 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock - -from openstack import exceptions -from openstack.image.v2 import _proxy -from openstack.image.v2 import image -from openstack.image.v2 import member -from openstack.tests.unit.image.v2 import test_image as fake_image -from openstack.tests.unit import test_proxy_base2 - -EXAMPLE = fake_image.EXAMPLE - - -class TestImageProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestImageProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_image_create_no_args(self): - # container_format and disk_format are required args - self.assertRaises(exceptions.InvalidRequest, self.proxy.upload_image) - - def test_image_create(self): - # NOTE: This doesn't use any of the base class verify methods - # because it ends up making two separate calls to complete the - # operation. - created_image = mock.Mock(spec=image.Image(id="id")) - - self.proxy._create = mock.Mock() - self.proxy._create.return_value = created_image - - rv = self.proxy.upload_image(data="data", container_format="x", - disk_format="y", name="z") - - self.proxy._create.assert_called_with(image.Image, - container_format="x", - disk_format="y", - name="z") - created_image.upload.assert_called_with(self.session) - self.assertEqual(rv, created_image) - - def test_image_delete(self): - self.verify_delete(self.proxy.delete_image, image.Image, False) - - def test_image_delete_ignore(self): - self.verify_delete(self.proxy.delete_image, image.Image, True) - - @mock.patch("openstack.resource2.Resource._translate_response") - @mock.patch("openstack.proxy2.BaseProxy._get") - @mock.patch("openstack.image.v2.image.Image.update") - def test_image_update(self, mock_update_image, mock_get_image, - mock_transpose): - original_image = image.Image(**EXAMPLE) - mock_get_image.return_value = original_image - EXAMPLE['name'] = 'fake_name' - updated_image = image.Image(**EXAMPLE) - mock_update_image.return_value = updated_image.to_dict() - result = self.proxy.update_image(original_image, - **updated_image.to_dict()) - self.assertEqual('fake_name', result.get('name')) - - def test_image_get(self): - self.verify_get(self.proxy.get_image, image.Image) - - def test_images(self): - self.verify_list(self.proxy.images, image.Image, paginated=True) - - def test_add_tag(self): - self._verify("openstack.image.v2.image.Image.add_tag", - self.proxy.add_tag, - method_args=["image", "tag"], - expected_args=["tag"]) - - def test_remove_tag(self): - self._verify("openstack.image.v2.image.Image.remove_tag", - self.proxy.remove_tag, - method_args=["image", "tag"], - expected_args=["tag"]) - - def test_deactivate_image(self): - self._verify("openstack.image.v2.image.Image.deactivate", - self.proxy.deactivate_image, - method_args=["image"]) - - def test_reactivate_image(self): - self._verify("openstack.image.v2.image.Image.reactivate", - self.proxy.reactivate_image, - method_args=["image"]) - - def test_member_create(self): - self.verify_create(self.proxy.add_member, member.Member, - method_kwargs={"image": "test_id"}, - expected_kwargs={"image_id": "test_id"}) - - def test_member_delete(self): - self._verify2("openstack.proxy2.BaseProxy._delete", - self.proxy.remove_member, - method_args=["member_id"], - method_kwargs={"image": "image_id", - "ignore_missing": False}, - expected_args=[member.Member], - expected_kwargs={"member_id": "member_id", - "image_id": "image_id", - "ignore_missing": False}) - - def test_member_delete_ignore(self): - self._verify2("openstack.proxy2.BaseProxy._delete", - self.proxy.remove_member, - method_args=["member_id"], - method_kwargs={"image": "image_id"}, - expected_args=[member.Member], - expected_kwargs={"member_id": "member_id", - "image_id": "image_id", - "ignore_missing": True}) - - def test_member_update(self): - self._verify2("openstack.proxy2.BaseProxy._update", - self.proxy.update_member, - method_args=['member_id', 'image_id'], - expected_args=[member.Member], - expected_kwargs={'member_id': 'member_id', - 'image_id': 'image_id'}) - - def test_member_get(self): - self._verify2("openstack.proxy2.BaseProxy._get", - self.proxy.get_member, - method_args=['member_id'], - method_kwargs={"image": "image_id"}, - expected_args=[member.Member], - expected_kwargs={'member_id': 'member_id', - 'image_id': 'image_id'}) - - def test_member_find(self): - self._verify2("openstack.proxy2.BaseProxy._find", - self.proxy.find_member, - method_args=['member_id'], - method_kwargs={"image": "image_id"}, - expected_args=[member.Member, "member_id"], - expected_kwargs={'ignore_missing': True, - 'image_id': 'image_id'}) - - def test_members(self): - self.verify_list(self.proxy.members, member.Member, paginated=False, - method_args=('image_1',), - expected_kwargs={'image_id': 'image_1'}) diff --git a/openstack/tests/unit/key_manager/__init__.py b/openstack/tests/unit/key_manager/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/key_manager/test_key_management_service.py b/openstack/tests/unit/key_manager/test_key_management_service.py deleted file mode 100644 index b458daf7..00000000 --- a/openstack/tests/unit/key_manager/test_key_management_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.key_manager import key_manager_service - - -class TestKeyManagerService(testtools.TestCase): - - def test_service(self): - sot = key_manager_service.KeyManagerService() - self.assertEqual('key-manager', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v1', sot.valid_versions[0].module) - self.assertEqual('v1', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/key_manager/v1/__init__.py b/openstack/tests/unit/key_manager/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/key_manager/v1/test_container.py b/openstack/tests/unit/key_manager/v1/test_container.py deleted file mode 100644 index 98fe51b6..00000000 --- a/openstack/tests/unit/key_manager/v1/test_container.py +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.key_manager.v1 import container - -ID_VAL = "123" -IDENTIFIER = 'http://localhost/containers/%s' % ID_VAL -EXAMPLE = { - 'container_ref': IDENTIFIER, - 'created': '2015-03-09T12:14:57.233772', - 'name': '3', - 'secret_refs': ['4'], - 'status': '5', - 'type': '6', - 'updated': '2015-03-09T12:15:57.233772', - 'consumers': ['7'] -} - - -class TestContainer(testtools.TestCase): - - def test_basic(self): - sot = container.Container() - self.assertIsNone(sot.resource_key) - self.assertEqual('containers', sot.resources_key) - self.assertEqual('/containers', sot.base_path) - self.assertEqual('key-manager', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = container.Container(**EXAMPLE) - self.assertEqual(EXAMPLE['created'], sot.created_at) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['secret_refs'], sot.secret_refs) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['type'], sot.type) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) - self.assertEqual(EXAMPLE['container_ref'], sot.id) - self.assertEqual(EXAMPLE['container_ref'], sot.container_ref) - self.assertEqual(ID_VAL, sot.container_id) - self.assertEqual(EXAMPLE['consumers'], sot.consumers) diff --git a/openstack/tests/unit/key_manager/v1/test_order.py b/openstack/tests/unit/key_manager/v1/test_order.py deleted file mode 100644 index 73250052..00000000 --- a/openstack/tests/unit/key_manager/v1/test_order.py +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.key_manager.v1 import order - -ID_VAL = "123" -SECRET_ID = "5" -IDENTIFIER = 'http://localhost/orders/%s' % ID_VAL -EXAMPLE = { - 'created': '1', - 'creator_id': '2', - 'meta': {'key': '3'}, - 'order_ref': IDENTIFIER, - 'secret_ref': 'http://localhost/secrets/%s' % SECRET_ID, - 'status': '6', - 'sub_status': '7', - 'sub_status_message': '8', - 'type': '9', - 'updated': '10' -} - - -class TestOrder(testtools.TestCase): - - def test_basic(self): - sot = order.Order() - self.assertIsNone(sot.resource_key) - self.assertEqual('orders', sot.resources_key) - self.assertEqual('/orders', sot.base_path) - self.assertEqual('key-manager', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = order.Order(**EXAMPLE) - self.assertEqual(EXAMPLE['created'], sot.created_at) - self.assertEqual(EXAMPLE['creator_id'], sot.creator_id) - self.assertEqual(EXAMPLE['meta'], sot.meta) - self.assertEqual(EXAMPLE['order_ref'], sot.order_ref) - self.assertEqual(ID_VAL, sot.order_id) - self.assertEqual(EXAMPLE['secret_ref'], sot.secret_ref) - self.assertEqual(SECRET_ID, sot.secret_id) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['sub_status'], sot.sub_status) - self.assertEqual(EXAMPLE['sub_status_message'], sot.sub_status_message) - self.assertEqual(EXAMPLE['type'], sot.type) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) diff --git a/openstack/tests/unit/key_manager/v1/test_proxy.py b/openstack/tests/unit/key_manager/v1/test_proxy.py deleted file mode 100644 index e3652fb0..00000000 --- a/openstack/tests/unit/key_manager/v1/test_proxy.py +++ /dev/null @@ -1,89 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.key_manager.v1 import _proxy -from openstack.key_manager.v1 import container -from openstack.key_manager.v1 import order -from openstack.key_manager.v1 import secret -from openstack.tests.unit import test_proxy_base2 - - -class TestKeyManagerProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestKeyManagerProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_server_create_attrs(self): - self.verify_create(self.proxy.create_container, container.Container) - - def test_container_delete(self): - self.verify_delete(self.proxy.delete_container, - container.Container, False) - - def test_container_delete_ignore(self): - self.verify_delete(self.proxy.delete_container, - container.Container, True) - - def test_container_find(self): - self.verify_find(self.proxy.find_container, container.Container) - - def test_container_get(self): - self.verify_get(self.proxy.get_container, container.Container) - - def test_containers(self): - self.verify_list(self.proxy.containers, container.Container, - paginated=False) - - def test_container_update(self): - self.verify_update(self.proxy.update_container, container.Container) - - def test_order_create_attrs(self): - self.verify_create(self.proxy.create_order, order.Order) - - def test_order_delete(self): - self.verify_delete(self.proxy.delete_order, order.Order, False) - - def test_order_delete_ignore(self): - self.verify_delete(self.proxy.delete_order, order.Order, True) - - def test_order_find(self): - self.verify_find(self.proxy.find_order, order.Order) - - def test_order_get(self): - self.verify_get(self.proxy.get_order, order.Order) - - def test_orders(self): - self.verify_list(self.proxy.orders, order.Order, paginated=False) - - def test_order_update(self): - self.verify_update(self.proxy.update_order, order.Order) - - def test_secret_create_attrs(self): - self.verify_create(self.proxy.create_secret, secret.Secret) - - def test_secret_delete(self): - self.verify_delete(self.proxy.delete_secret, secret.Secret, False) - - def test_secret_delete_ignore(self): - self.verify_delete(self.proxy.delete_secret, secret.Secret, True) - - def test_secret_find(self): - self.verify_find(self.proxy.find_secret, secret.Secret) - - def test_secret_get(self): - self.verify_get(self.proxy.get_secret, secret.Secret) - - def test_secrets(self): - self.verify_list(self.proxy.secrets, secret.Secret, paginated=False) - - def test_secret_update(self): - self.verify_update(self.proxy.update_secret, secret.Secret) diff --git a/openstack/tests/unit/key_manager/v1/test_secret.py b/openstack/tests/unit/key_manager/v1/test_secret.py deleted file mode 100644 index 9e103ecb..00000000 --- a/openstack/tests/unit/key_manager/v1/test_secret.py +++ /dev/null @@ -1,135 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.key_manager.v1 import secret - -ID_VAL = "123" -IDENTIFIER = 'http://localhost:9311/v1/secrets/%s' % ID_VAL -EXAMPLE = { - 'algorithm': '1', - 'bit_length': '2', - 'content_types': {'default': '3'}, - 'expiration': '2017-03-09T12:14:57.233772', - 'mode': '5', - 'name': '6', - 'secret_ref': IDENTIFIER, - 'status': '8', - 'updated': '2015-03-09T12:15:57.233773', - 'created': '2015-03-09T12:15:57.233774', - 'secret_type': '9', - 'payload': '10', - 'payload_content_type': '11', - 'payload_content_encoding': '12' -} - - -class TestSecret(testtools.TestCase): - - def test_basic(self): - sot = secret.Secret() - self.assertIsNone(sot.resource_key) - self.assertEqual('secrets', sot.resources_key) - self.assertEqual('/secrets', sot.base_path) - self.assertEqual('key-manager', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - self.assertDictEqual({"name": "name", - "mode": "mode", - "bits": "bits", - "secret_type": "secret_type", - "acl_only": "acl_only", - "created": "created", - "updated": "updated", - "expiration": "expiration", - "sort": "sort", - "algorithm": "alg", - "limit": "limit", - "marker": "marker"}, - sot._query_mapping._mapping) - - def test_make_it(self): - sot = secret.Secret(**EXAMPLE) - self.assertEqual(EXAMPLE['algorithm'], sot.algorithm) - self.assertEqual(EXAMPLE['bit_length'], sot.bit_length) - self.assertEqual(EXAMPLE['content_types'], sot.content_types) - self.assertEqual(EXAMPLE['expiration'], sot.expires_at) - self.assertEqual(EXAMPLE['mode'], sot.mode) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['secret_ref'], sot.secret_ref) - self.assertEqual(EXAMPLE['secret_ref'], sot.id) - self.assertEqual(ID_VAL, sot.secret_id) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) - self.assertEqual(EXAMPLE['secret_type'], sot.secret_type) - self.assertEqual(EXAMPLE['payload'], sot.payload) - self.assertEqual(EXAMPLE['payload_content_type'], - sot.payload_content_type) - self.assertEqual(EXAMPLE['payload_content_encoding'], - sot.payload_content_encoding) - - def test_get_no_payload(self): - sot = secret.Secret(id="id") - - sess = mock.Mock() - rv = mock.Mock() - return_body = {"status": "cool"} - rv.json = mock.Mock(return_value=return_body) - sess.get = mock.Mock(return_value=rv) - - sot.get(sess) - - sess.get.assert_called_once_with("secrets/id", - endpoint_filter=sot.service) - - def _test_payload(self, sot, metadata, content_type): - content_type = "some/type" - sot = secret.Secret(id="id", payload_content_type=content_type) - - metadata_response = mock.Mock() - metadata_response.json = mock.Mock(return_value=metadata) - - payload_response = mock.Mock() - payload = "secret info" - payload_response.text = payload - - sess = mock.Mock() - sess.get = mock.Mock(side_effect=[metadata_response, payload_response]) - - rv = sot.get(sess) - - sess.get.assert_has_calls( - [mock.call("secrets/id", endpoint_filter=sot.service), - mock.call("secrets/id/payload", endpoint_filter=sot.service, - headers={"Accept": content_type})]) - - self.assertEqual(rv.payload, payload) - self.assertEqual(rv.status, metadata["status"]) - - def test_get_with_payload_from_argument(self): - metadata = {"status": "great"} - content_type = "some/type" - sot = secret.Secret(id="id", payload_content_type=content_type) - self._test_payload(sot, metadata, content_type) - - def test_get_with_payload_from_content_types(self): - content_type = "some/type" - metadata = {"status": "fine", - "content_types": {"default": content_type}} - sot = secret.Secret(id="id") - self._test_payload(sot, metadata, content_type) diff --git a/openstack/tests/unit/load_balancer/__init__.py b/openstack/tests/unit/load_balancer/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/load_balancer/test_load_balancer.py b/openstack/tests/unit/load_balancer/test_load_balancer.py deleted file mode 100644 index 0e832ab8..00000000 --- a/openstack/tests/unit/load_balancer/test_load_balancer.py +++ /dev/null @@ -1,69 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.load_balancer.v2 import load_balancer - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'admin_state_up': True, - 'created_at': '3', - 'description': 'fake_description', - 'id': IDENTIFIER, - 'listeners': [{'id', '4'}], - 'name': 'test_load_balancer', - 'operating_status': '6', - 'provisioning_status': '7', - 'project_id': '8', - 'vip_address': '9', - 'vip_subnet_id': '10', - 'vip_port_id': '11', - 'pools': [{'id', '13'}], -} - - -class TestLoadBalancer(testtools.TestCase): - - def test_basic(self): - test_load_balancer = load_balancer.LoadBalancer() - self.assertEqual('loadbalancer', test_load_balancer.resource_key) - self.assertEqual('loadbalancers', test_load_balancer.resources_key) - self.assertEqual('/loadbalancers', test_load_balancer.base_path) - self.assertEqual('load_balancer', - test_load_balancer.service.service_type) - self.assertTrue(test_load_balancer.allow_create) - self.assertTrue(test_load_balancer.allow_get) - self.assertTrue(test_load_balancer.allow_delete) - self.assertTrue(test_load_balancer.allow_list) - - def test_make_it(self): - test_load_balancer = load_balancer.LoadBalancer(**EXAMPLE) - self.assertTrue(test_load_balancer.is_admin_state_up) - self.assertEqual(EXAMPLE['created_at'], test_load_balancer.created_at), - self.assertEqual(EXAMPLE['description'], - test_load_balancer.description) - self.assertEqual(EXAMPLE['id'], test_load_balancer.id) - self.assertEqual(EXAMPLE['listeners'], test_load_balancer.listeners) - self.assertEqual(EXAMPLE['name'], test_load_balancer.name) - self.assertEqual(EXAMPLE['operating_status'], - test_load_balancer.operating_status) - self.assertEqual(EXAMPLE['provisioning_status'], - test_load_balancer.provisioning_status) - self.assertEqual(EXAMPLE['project_id'], test_load_balancer.project_id) - self.assertEqual(EXAMPLE['vip_address'], - test_load_balancer.vip_address) - self.assertEqual(EXAMPLE['vip_subnet_id'], - test_load_balancer.vip_subnet_id) - self.assertEqual(EXAMPLE['vip_port_id'], - test_load_balancer.vip_port_id) - self.assertEqual(EXAMPLE['pools'], test_load_balancer.pools) diff --git a/openstack/tests/unit/load_balancer/test_load_balancer_service.py b/openstack/tests/unit/load_balancer/test_load_balancer_service.py deleted file mode 100644 index dd11ae55..00000000 --- a/openstack/tests/unit/load_balancer/test_load_balancer_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.load_balancer import load_balancer_service as lb_service - - -class TestLoadBalancingService(testtools.TestCase): - - def test_service(self): - sot = lb_service.LoadBalancerService() - self.assertEqual('load_balancer', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v2', sot.valid_versions[0].module) - self.assertEqual('v2', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/load_balancer/test_proxy.py b/openstack/tests/unit/load_balancer/test_proxy.py deleted file mode 100644 index 97cdec13..00000000 --- a/openstack/tests/unit/load_balancer/test_proxy.py +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.load_balancer.v2 import _proxy -from openstack.load_balancer.v2 import load_balancer as lb -from openstack.tests.unit import test_proxy_base2 - - -class TestLoadBalancerProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestLoadBalancerProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_load_balancers(self): - self.verify_list(self.proxy.load_balancers, - lb.LoadBalancer, - paginated=True) - - def test_load_balancer_get(self): - self.verify_get(self.proxy.get_load_balancer, - lb.LoadBalancer) - - def test_load_balancer_create(self): - self.verify_create(self.proxy.create_load_balancer, - lb.LoadBalancer) - - def test_load_balancer_delete(self): - self.verify_delete(self.proxy.delete_load_balancer, - lb.LoadBalancer, True) - - def test_load_balancer_find(self): - self.verify_find(self.proxy.find_load_balancer, - lb.LoadBalancer) diff --git a/openstack/tests/unit/load_balancer/test_version.py b/openstack/tests/unit/load_balancer/test_version.py deleted file mode 100644 index 1b77eda2..00000000 --- a/openstack/tests/unit/load_balancer/test_version.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.load_balancer import version - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'status': '3', -} - - -class TestVersion(testtools.TestCase): - - def test_basic(self): - sot = version.Version() - self.assertEqual('version', sot.resource_key) - self.assertEqual('versions', sot.resources_key) - self.assertEqual('/', sot.base_path) - self.assertEqual('load_balancer', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = version.Version(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['status'], sot.status) diff --git a/openstack/tests/unit/message/__init__.py b/openstack/tests/unit/message/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/message/test_message_service.py b/openstack/tests/unit/message/test_message_service.py deleted file mode 100644 index 66d074fc..00000000 --- a/openstack/tests/unit/message/test_message_service.py +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.message import message_service - - -class TestMessageService(testtools.TestCase): - - def test_service(self): - sot = message_service.MessageService() - self.assertEqual('messaging', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(2, len(sot.valid_versions)) - self.assertEqual('v1', sot.valid_versions[0].module) - self.assertEqual('v1', sot.valid_versions[0].path) - self.assertEqual('v2', sot.valid_versions[1].module) - self.assertEqual('v2', sot.valid_versions[1].path) diff --git a/openstack/tests/unit/message/test_version.py b/openstack/tests/unit/message/test_version.py deleted file mode 100644 index bf9662e1..00000000 --- a/openstack/tests/unit/message/test_version.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.message import version - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'status': '3', -} - - -class TestVersion(testtools.TestCase): - - def test_basic(self): - sot = version.Version() - self.assertEqual('version', sot.resource_key) - self.assertEqual('versions', sot.resources_key) - self.assertEqual('/', sot.base_path) - self.assertEqual('messaging', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_retrieve) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = version.Version(EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['status'], sot.status) diff --git a/openstack/tests/unit/message/v1/__init__.py b/openstack/tests/unit/message/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/message/v1/test_claim.py b/openstack/tests/unit/message/v1/test_claim.py deleted file mode 100644 index cbfeb9f9..00000000 --- a/openstack/tests/unit/message/v1/test_claim.py +++ /dev/null @@ -1,97 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import json -import mock -import testtools - -from openstack import exceptions -from openstack.message.v1 import claim - -CLIENT = '3381af92-2b9e-11e3-b191-71861300734c' -QUEUE = 'test_queue' -LIMIT = 2 -FAKE = { - 'ttl': 300, - 'grace': 60 -} - - -class TestClaim(testtools.TestCase): - - def test_basic(self): - sot = claim.Claim() - self.assertEqual('claims', sot.resources_key) - self.assertEqual('/queues/%(queue_name)s/claims', sot.base_path) - self.assertEqual('messaging', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertFalse(sot.allow_retrieve) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = claim.Claim.new(client_id=CLIENT, - queue_name=QUEUE, - limit=LIMIT, - **FAKE) - self.assertEqual(CLIENT, sot.client_id) - self.assertEqual(QUEUE, sot.queue_name) - self.assertEqual(LIMIT, sot.limit) - self.assertEqual(FAKE['ttl'], sot.ttl) - self.assertEqual(FAKE['grace'], sot.grace) - - def test_create(self): - sess = mock.Mock() - obj = mock.Mock() - fake_attrs = [{'foo': 'bar'}, {'zoo': 'lah'}] - obj.json = mock.Mock(return_value=fake_attrs) - sess.post = mock.Mock(return_value=obj) - sot = claim.Claim() - - c = claim.Claim.new(client_id=CLIENT, queue_name=QUEUE, **FAKE) - list(sot.claim_messages(sess, c)) - - url = '/queues/%s/claims' % QUEUE - sess.post.assert_called_with( - url, endpoint_filter=sot.service, - headers={'Client-ID': CLIENT}, params=None, - data=json.dumps(FAKE, cls=claim.ClaimEncoder)) - - def test_claim_messages_no_invalid_response(self): - sess = mock.Mock() - resp = mock.Mock() - resp.status_code = 204 - sess.post = mock.Mock( - side_effect=exceptions.InvalidResponse(response=resp)) - sot = claim.Claim() - - messages = list(sot.claim_messages( - sess, claim.Claim.new(client_id=CLIENT, queue_name=QUEUE, **FAKE))) - - self.assertEqual(0, len(messages)) - - def test_claim_messages_invalid_response(self): - sess = mock.Mock() - resp = mock.Mock() - resp.status_code = 400 - sess.post = mock.Mock( - side_effect=exceptions.InvalidResponse(response=resp)) - sot = claim.Claim() - - try: - list(sot.claim_messages( - sess, claim.Claim.new(client_id=CLIENT, - queue_name=QUEUE, - **FAKE))) - except exceptions.InvalidResponse as e: - self.assertEqual(400, e.response.status_code) diff --git a/openstack/tests/unit/message/v1/test_message.py b/openstack/tests/unit/message/v1/test_message.py deleted file mode 100644 index 6fe5d26a..00000000 --- a/openstack/tests/unit/message/v1/test_message.py +++ /dev/null @@ -1,85 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import json - -import mock -import testtools - -from openstack.message.v1 import message - -CLIENT = '3381af92-2b9e-11e3-b191-71861300734c' -QUEUE = 'test_queue' -FAKE = { - 'ttl': 300, - 'body': {'key': 'value'} -} -FAKE_HREF = { - 'href': '/v1/queues/test_queue/messages/1234', - 'ttl': 300, - 'body': {'key': 'value'} -} - - -class TestMessage(testtools.TestCase): - - def test_basic(self): - sot = message.Message() - self.assertEqual('messages', sot.resources_key) - self.assertEqual('/queues/%(queue_name)s/messages', sot.base_path) - self.assertEqual('messaging', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertFalse(sot.allow_retrieve) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = message.Message(FAKE) - self.assertEqual(FAKE['ttl'], sot.ttl) - self.assertEqual(FAKE['body'], sot.body) - - def test_create(self): - sess = mock.Mock() - obj = mock.Mock() - obj.json = mock.Mock(return_value={'resources': {'k': 'v'}}) - sess.post = mock.Mock(return_value=obj) - sot = message.Message() - - msg = message.Message.new(client_id=CLIENT, queue_name=QUEUE, **FAKE) - sot.create_messages(sess, [msg]) - - url = '/queues/%s/messages' % QUEUE - sess.post.assert_called_with( - url, endpoint_filter=sot.service, - headers={'Client-ID': CLIENT}, - data=mock.ANY) - - args, kwargs = sess.post.call_args - self.assertIn("data", kwargs) - self.assertDictEqual(json.loads(kwargs["data"])[0], FAKE) - - def test_delete(self): - sess = mock.Mock() - sess.delete = mock.Mock() - sess.delete.return_value = mock.Mock() - sot = message.Message() - - sot.delete_by_id( - sess, message.Message.new(client_id=CLIENT, - queue_name=QUEUE, - **FAKE_HREF)) - - url = '/queues/%s/messages/1234' % QUEUE - sess.delete.assert_called_with( - url, endpoint_filter=sot.service, - headers={'Client-ID': CLIENT, 'Accept': ''}) diff --git a/openstack/tests/unit/message/v1/test_proxy.py b/openstack/tests/unit/message/v1/test_proxy.py deleted file mode 100644 index 8436f024..00000000 --- a/openstack/tests/unit/message/v1/test_proxy.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.message.v1 import _proxy -from openstack.message.v1 import claim -from openstack.message.v1 import message -from openstack.message.v1 import queue -from openstack.tests.unit import test_proxy_base - -CLIENT_ID = '3381af92-2b9e-11e3-b191-71861300734c' -QUEUE_NAME = 'test_queue' - - -class TestMessageProxy(test_proxy_base.TestProxyBase): - def setUp(self): - super(TestMessageProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_queue_create_attrs(self): - self.verify_create(self.proxy.create_queue, queue.Queue) - - def test_queue_delete(self): - self.verify_delete(self.proxy.delete_queue, queue.Queue, False) - - def test_queue_delete_ignore(self): - self.verify_delete(self.proxy.delete_queue, queue.Queue, True) - - def test_messages_create(self): - self._verify2("openstack.message.v1.message.Message.create_messages", - self.proxy.create_messages, - expected_result="result", - method_args=[[]], - expected_args=[self.session, []]) - - def test_messages_claim(self): - self._verify2("openstack.message.v1.claim.Claim.claim_messages", - self.proxy.claim_messages, - expected_result="result", - method_args=[claim.Claim], - expected_args=[self.session, claim.Claim]) - - def test_message_delete(self): - self._verify2("openstack.message.v1.message.Message.delete_by_id", - self.proxy.delete_message, - method_args=[message.Message], - expected_args=[self.session, message.Message]) diff --git a/openstack/tests/unit/message/v1/test_queue.py b/openstack/tests/unit/message/v1/test_queue.py deleted file mode 100644 index 81b07df7..00000000 --- a/openstack/tests/unit/message/v1/test_queue.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.message.v1 import queue - - -FAKE_NAME = 'test_queue' -FAKE = { - 'name': FAKE_NAME, -} - - -class TestQueue(testtools.TestCase): - - def test_basic(self): - sot = queue.Queue() - self.assertEqual('queues', sot.resources_key) - self.assertEqual('/queues', sot.base_path) - self.assertEqual('messaging', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertFalse(sot.allow_retrieve) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = queue.Queue(FAKE) - self.assertEqual(FAKE['name'], sot.name) - - def test_create(self): - sess = mock.Mock() - sess.put = mock.Mock() - sess.put.return_value = mock.Mock() - sot = queue.Queue(FAKE) - - sot.create(sess) - - url = 'queues/%s' % FAKE_NAME - headers = {'Accept': ''} - sess.put.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - self.assertEqual(FAKE_NAME, sot.id) - self.assertEqual(FAKE_NAME, sot.name) diff --git a/openstack/tests/unit/message/v2/__init__.py b/openstack/tests/unit/message/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/message/v2/test_claim.py b/openstack/tests/unit/message/v2/test_claim.py deleted file mode 100644 index 94582914..00000000 --- a/openstack/tests/unit/message/v2/test_claim.py +++ /dev/null @@ -1,244 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy -import mock -import testtools -import uuid - -from openstack.message.v2 import claim - - -FAKE1 = { - "age": 1632, - "id": "576b54963990b48c644bb7e7", - "grace": 3600, - "limit": 10, - "messages": [{"id": "1"}, {"id": "2"}], - "ttl": 3600, - "queue_name": "queue1" -} - - -FAKE2 = { - "age": 1632, - "id": "576b54963990b48c644bb7e7", - "grace": 3600, - "limit": 10, - "messages": [{"id": "1"}, {"id": "2"}], - "ttl": 3600, - "queue_name": "queue1", - "client_id": "OLD_CLIENT_ID", - "project_id": "OLD_PROJECT_ID" -} - - -class TestClaim(testtools.TestCase): - def test_basic(self): - sot = claim.Claim() - self.assertEqual("claims", sot.resources_key) - self.assertEqual("/queues/%(queue_name)s/claims", sot.base_path) - self.assertEqual("messaging", sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_update) - - def test_make_it(self): - sot = claim.Claim.new(**FAKE2) - self.assertEqual(FAKE2["age"], sot.age) - self.assertEqual(FAKE2["id"], sot.id) - self.assertEqual(FAKE2["grace"], sot.grace) - self.assertEqual(FAKE2["limit"], sot.limit) - self.assertEqual(FAKE2["messages"], sot.messages) - self.assertEqual(FAKE2["ttl"], sot.ttl) - self.assertEqual(FAKE2["queue_name"], sot.queue_name) - self.assertEqual(FAKE2["client_id"], sot.client_id) - self.assertEqual(FAKE2["project_id"], sot.project_id) - - @mock.patch.object(uuid, "uuid4") - def test_create_204_resp(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.post.return_value = resp - resp.status_code = 204 - sess.get_project_id.return_value = "NEW_PROJECT_ID" - mock_uuid.return_value = "NEW_CLIENT_ID" - FAKE = copy.deepcopy(FAKE1) - - sot = claim.Claim(**FAKE1) - res = sot.create(sess) - - url = "/queues/%(queue)s/claims" % {"queue": FAKE.pop("queue_name")} - headers = {"Client-ID": "NEW_CLIENT_ID", - "X-PROJECT-ID": "NEW_PROJECT_ID"} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - headers=headers, json=FAKE) - sess.get_project_id.assert_called_once_with() - self.assertEqual(sot, res) - - @mock.patch.object(uuid, "uuid4") - def test_create_non_204_resp(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.post.return_value = resp - resp.status_code = 200 - sess.get_project_id.return_value = "NEW_PROJECT_ID" - mock_uuid.return_value = "NEW_CLIENT_ID" - FAKE = copy.deepcopy(FAKE1) - - sot = claim.Claim(**FAKE1) - sot._translate_response = mock.Mock() - res = sot.create(sess) - - url = "/queues/%(queue)s/claims" % {"queue": FAKE.pop("queue_name")} - headers = {"Client-ID": "NEW_CLIENT_ID", - "X-PROJECT-ID": "NEW_PROJECT_ID"} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - headers=headers, json=FAKE) - sess.get_project_id.assert_called_once_with() - self.assertEqual(sot, res) - sot._translate_response.assert_called_once_with(resp) - - def test_create_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.post.return_value = resp - resp.status_code = 200 - FAKE = copy.deepcopy(FAKE2) - - sot = claim.Claim(**FAKE2) - sot._translate_response = mock.Mock() - res = sot.create(sess) - - url = "/queues/%(queue)s/claims" % {"queue": FAKE.pop("queue_name")} - headers = {"Client-ID": FAKE.pop("client_id"), - "X-PROJECT-ID": FAKE.pop("project_id")} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - headers=headers, json=FAKE) - self.assertEqual(sot, res) - - @mock.patch.object(uuid, "uuid4") - def test_get(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - sess.get_project_id.return_value = "NEW_PROJECT_ID" - mock_uuid.return_value = "NEW_CLIENT_ID" - - sot = claim.Claim(**FAKE1) - sot._translate_response = mock.Mock() - res = sot.get(sess) - - url = "queues/%(queue)s/claims/%(claim)s" % { - "queue": FAKE1["queue_name"], "claim": FAKE1["id"]} - headers = {"Client-ID": "NEW_CLIENT_ID", - "X-PROJECT-ID": "NEW_PROJECT_ID"} - sess.get.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp) - self.assertEqual(sot, res) - - def test_get_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - - sot = claim.Claim(**FAKE2) - sot._translate_response = mock.Mock() - res = sot.get(sess) - - url = "queues/%(queue)s/claims/%(claim)s" % { - "queue": FAKE2["queue_name"], "claim": FAKE2["id"]} - headers = {"Client-ID": "OLD_CLIENT_ID", - "X-PROJECT-ID": "OLD_PROJECT_ID"} - sess.get.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sot._translate_response.assert_called_once_with(resp) - self.assertEqual(sot, res) - - @mock.patch.object(uuid, "uuid4") - def test_update(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.update.return_value = resp - sess.get_project_id.return_value = "NEW_PROJECT_ID" - mock_uuid.return_value = "NEW_CLIENT_ID" - FAKE = copy.deepcopy(FAKE1) - - sot = claim.Claim(**FAKE1) - res = sot.update(sess) - - url = "queues/%(queue)s/claims/%(claim)s" % { - "queue": FAKE.pop("queue_name"), "claim": FAKE["id"]} - headers = {"Client-ID": "NEW_CLIENT_ID", - "X-PROJECT-ID": "NEW_PROJECT_ID"} - sess.patch.assert_called_with(url, endpoint_filter=sot.service, - headers=headers, json=FAKE) - sess.get_project_id.assert_called_once_with() - self.assertEqual(sot, res) - - def test_update_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - FAKE = copy.deepcopy(FAKE2) - - sot = claim.Claim(**FAKE2) - res = sot.update(sess) - - url = "queues/%(queue)s/claims/%(claim)s" % { - "queue": FAKE.pop("queue_name"), "claim": FAKE["id"]} - headers = {"Client-ID": FAKE.pop("client_id"), - "X-PROJECT-ID": FAKE.pop("project_id")} - sess.patch.assert_called_with(url, endpoint_filter=sot.service, - headers=headers, json=FAKE) - self.assertEqual(sot, res) - - @mock.patch.object(uuid, "uuid4") - def test_delete(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.delete.return_value = resp - sess.get_project_id.return_value = "NEW_PROJECT_ID" - mock_uuid.return_value = "NEW_CLIENT_ID" - - sot = claim.Claim(**FAKE1) - sot._translate_response = mock.Mock() - sot.delete(sess) - - url = "queues/%(queue)s/claims/%(claim)s" % { - "queue": FAKE1["queue_name"], "claim": FAKE1["id"]} - headers = {"Client-ID": "NEW_CLIENT_ID", - "X-PROJECT-ID": "NEW_PROJECT_ID"} - sess.delete.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp, has_body=False) - - def test_delete_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.delete.return_value = resp - - sot = claim.Claim(**FAKE2) - sot._translate_response = mock.Mock() - sot.delete(sess) - - url = "queues/%(queue)s/claims/%(claim)s" % { - "queue": FAKE2["queue_name"], "claim": FAKE2["id"]} - headers = {"Client-ID": "OLD_CLIENT_ID", - "X-PROJECT-ID": "OLD_PROJECT_ID"} - sess.delete.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sot._translate_response.assert_called_once_with(resp, has_body=False) diff --git a/openstack/tests/unit/message/v2/test_message.py b/openstack/tests/unit/message/v2/test_message.py deleted file mode 100644 index d7541f5b..00000000 --- a/openstack/tests/unit/message/v2/test_message.py +++ /dev/null @@ -1,244 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools -import uuid - -from openstack.message.v2 import message - - -FAKE1 = { - 'age': 456, - 'body': { - 'current_bytes': '0', - 'event': 'BackupProgress', - 'total_bytes': '99614720' - }, - 'id': '578ee000508f153f256f717d', - 'href': '/v2/queues/queue1/messages/578ee000508f153f256f717d', - 'ttl': 3600, - 'queue_name': 'queue1' -} - - -FAKE2 = { - 'age': 456, - 'body': { - 'current_bytes': '0', - 'event': 'BackupProgress', - 'total_bytes': '99614720' - }, - 'id': '578ee000508f153f256f717d', - 'href': '/v2/queues/queue1/messages/578ee000508f153f256f717d', - 'ttl': 3600, - 'queue_name': 'queue1', - 'client_id': 'OLD_CLIENT_ID', - 'project_id': 'OLD_PROJECT_ID' -} - - -class TestMessage(testtools.TestCase): - def test_basic(self): - sot = message.Message() - self.assertEqual('messages', sot.resources_key) - self.assertEqual('/queues/%(queue_name)s/messages', sot.base_path) - self.assertEqual('messaging', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = message.Message.new(**FAKE2) - self.assertEqual(FAKE2['age'], sot.age) - self.assertEqual(FAKE2['body'], sot.body) - self.assertEqual(FAKE2['id'], sot.id) - self.assertEqual(FAKE2['href'], sot.href) - self.assertEqual(FAKE2['ttl'], sot.ttl) - self.assertEqual(FAKE2['queue_name'], sot.queue_name) - self.assertEqual(FAKE2['client_id'], sot.client_id) - self.assertEqual(FAKE2['project_id'], sot.project_id) - - @mock.patch.object(uuid, 'uuid4') - def test_post(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.post.return_value = resp - resources = [ - '/v2/queues/queue1/messages/578ee000508f153f256f717d' - '/v2/queues/queue1/messages/579edd6c368cb61de9a7e233' - ] - resp.json.return_value = {'resources': resources} - sess.get_project_id.return_value = 'NEW_PROJECT_ID' - mock_uuid.return_value = 'NEW_CLIENT_ID' - messages = [ - { - 'body': {'key': 'value1'}, - 'ttl': 3600 - }, - { - 'body': {'key': 'value2'}, - 'ttl': 1800 - } - ] - - sot = message.Message(**FAKE1) - res = sot.post(sess, messages) - - url = '/queues/%(queue)s/messages' % {'queue': FAKE1['queue_name']} - headers = {'Client-ID': 'NEW_CLIENT_ID', - 'X-PROJECT-ID': 'NEW_PROJECT_ID'} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - headers=headers, - json={'messages': messages}) - sess.get_project_id.assert_called_once_with() - resp.json.assert_called_once_with() - self.assertEqual(resources, res) - - def test_post_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.post.return_value = resp - resources = [ - '/v2/queues/queue1/messages/578ee000508f153f256f717d' - '/v2/queues/queue1/messages/579edd6c368cb61de9a7e233' - ] - resp.json.return_value = {'resources': resources} - messages = [ - { - 'body': {'key': 'value1'}, - 'ttl': 3600 - }, - { - 'body': {'key': 'value2'}, - 'ttl': 1800 - } - ] - - sot = message.Message(**FAKE2) - res = sot.post(sess, messages) - - url = '/queues/%(queue)s/messages' % {'queue': FAKE2['queue_name']} - headers = {'Client-ID': 'OLD_CLIENT_ID', - 'X-PROJECT-ID': 'OLD_PROJECT_ID'} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - headers=headers, - json={'messages': messages}) - resp.json.assert_called_once_with() - self.assertEqual(resources, res) - - @mock.patch.object(uuid, 'uuid4') - def test_get(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - sess.get_project_id.return_value = 'NEW_PROJECT_ID' - mock_uuid.return_value = 'NEW_CLIENT_ID' - - sot = message.Message(**FAKE1) - sot._translate_response = mock.Mock() - res = sot.get(sess) - - url = 'queues/%(queue)s/messages/%(message)s' % { - 'queue': FAKE1['queue_name'], 'message': FAKE1['id']} - headers = {'Client-ID': 'NEW_CLIENT_ID', - 'X-PROJECT-ID': 'NEW_PROJECT_ID'} - sess.get.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp) - self.assertEqual(sot, res) - - def test_get_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - - sot = message.Message(**FAKE1) - sot._translate_response = mock.Mock() - res = sot.get(sess) - - url = 'queues/%(queue)s/messages/%(message)s' % { - 'queue': FAKE2['queue_name'], 'message': FAKE2['id']} - sot = message.Message(**FAKE2) - sot._translate_response = mock.Mock() - res = sot.get(sess) - headers = {'Client-ID': 'OLD_CLIENT_ID', - 'X-PROJECT-ID': 'OLD_PROJECT_ID'} - sess.get.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sot._translate_response.assert_called_once_with(resp) - self.assertEqual(sot, res) - - @mock.patch.object(uuid, 'uuid4') - def test_delete_unclaimed(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.delete.return_value = resp - sess.get_project_id.return_value = 'NEW_PROJECT_ID' - mock_uuid.return_value = 'NEW_CLIENT_ID' - - sot = message.Message(**FAKE1) - sot.claim_id = None - sot._translate_response = mock.Mock() - sot.delete(sess) - - url = 'queues/%(queue)s/messages/%(message)s' % { - 'queue': FAKE1['queue_name'], 'message': FAKE1['id']} - headers = {'Client-ID': 'NEW_CLIENT_ID', - 'X-PROJECT-ID': 'NEW_PROJECT_ID'} - sess.delete.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp, has_body=False) - - @mock.patch.object(uuid, 'uuid4') - def test_delete_claimed(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.delete.return_value = resp - sess.get_project_id.return_value = 'NEW_PROJECT_ID' - mock_uuid.return_value = 'NEW_CLIENT_ID' - - sot = message.Message(**FAKE1) - sot.claim_id = 'CLAIM_ID' - sot._translate_response = mock.Mock() - sot.delete(sess) - - url = 'queues/%(queue)s/messages/%(message)s?claim_id=%(cid)s' % { - 'queue': FAKE1['queue_name'], 'message': FAKE1['id'], - 'cid': 'CLAIM_ID'} - headers = {'Client-ID': 'NEW_CLIENT_ID', - 'X-PROJECT-ID': 'NEW_PROJECT_ID'} - sess.delete.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp, has_body=False) - - def test_delete_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.delete.return_value = resp - - sot = message.Message(**FAKE2) - sot.claim_id = None - sot._translate_response = mock.Mock() - sot.delete(sess) - - url = 'queues/%(queue)s/messages/%(message)s' % { - 'queue': FAKE2['queue_name'], 'message': FAKE2['id']} - headers = {'Client-ID': 'OLD_CLIENT_ID', - 'X-PROJECT-ID': 'OLD_PROJECT_ID'} - sess.delete.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sot._translate_response.assert_called_once_with(resp, has_body=False) diff --git a/openstack/tests/unit/message/v2/test_proxy.py b/openstack/tests/unit/message/v2/test_proxy.py deleted file mode 100644 index 75a602c5..00000000 --- a/openstack/tests/unit/message/v2/test_proxy.py +++ /dev/null @@ -1,199 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock - -from openstack.message.v2 import _proxy -from openstack.message.v2 import claim -from openstack.message.v2 import message -from openstack.message.v2 import queue -from openstack.message.v2 import subscription -from openstack import proxy2 as proxy_base -from openstack.tests.unit import test_proxy_base2 - -QUEUE_NAME = 'test_queue' - - -class TestMessageProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestMessageProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_queue_create(self): - self.verify_create(self.proxy.create_queue, queue.Queue) - - def test_queue_get(self): - self.verify_get(self.proxy.get_queue, queue.Queue) - - def test_queues(self): - self.verify_list(self.proxy.queues, queue.Queue, paginated=True) - - def test_queue_delete(self): - self.verify_delete(self.proxy.delete_queue, queue.Queue, False) - - def test_queue_delete_ignore(self): - self.verify_delete(self.proxy.delete_queue, queue.Queue, True) - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_message_post(self, mock_get_resource): - message_obj = message.Message(queue_name="test_queue") - mock_get_resource.return_value = message_obj - self._verify("openstack.message.v2.message.Message.post", - self.proxy.post_message, - method_args=["test_queue", ["msg1", "msg2"]], - expected_args=[["msg1", "msg2"]]) - mock_get_resource.assert_called_once_with(message.Message, None, - queue_name="test_queue") - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_message_get(self, mock_get_resource): - mock_get_resource.return_value = "resource_or_id" - self._verify2("openstack.proxy2.BaseProxy._get", - self.proxy.get_message, - method_args=["test_queue", "resource_or_id"], - expected_args=[message.Message, "resource_or_id"]) - mock_get_resource.assert_called_once_with(message.Message, - "resource_or_id", - queue_name="test_queue") - - def test_messages(self): - self.verify_list(self.proxy.messages, message.Message, - paginated=True, method_args=["test_queue"], - expected_kwargs={"queue_name": "test_queue"}) - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_message_delete(self, mock_get_resource): - fake_message = mock.Mock() - fake_message.id = "message_id" - mock_get_resource.return_value = fake_message - self._verify2("openstack.proxy2.BaseProxy._delete", - self.proxy.delete_message, - method_args=["test_queue", "resource_or_id", None, - False], - expected_args=[message.Message, - fake_message], - expected_kwargs={"ignore_missing": False}) - self.assertIsNone(fake_message.claim_id) - mock_get_resource.assert_called_once_with(message.Message, - "resource_or_id", - queue_name="test_queue") - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_message_delete_claimed(self, mock_get_resource): - fake_message = mock.Mock() - fake_message.id = "message_id" - mock_get_resource.return_value = fake_message - self._verify2("openstack.proxy2.BaseProxy._delete", - self.proxy.delete_message, - method_args=["test_queue", "resource_or_id", "claim_id", - False], - expected_args=[message.Message, - fake_message], - expected_kwargs={"ignore_missing": False}) - self.assertEqual("claim_id", fake_message.claim_id) - mock_get_resource.assert_called_once_with(message.Message, - "resource_or_id", - queue_name="test_queue") - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_message_delete_ignore(self, mock_get_resource): - fake_message = mock.Mock() - fake_message.id = "message_id" - mock_get_resource.return_value = fake_message - self._verify2("openstack.proxy2.BaseProxy._delete", - self.proxy.delete_message, - method_args=["test_queue", "resource_or_id", None, - True], - expected_args=[message.Message, - fake_message], - expected_kwargs={"ignore_missing": True}) - self.assertIsNone(fake_message.claim_id) - mock_get_resource.assert_called_once_with(message.Message, - "resource_or_id", - queue_name="test_queue") - - def test_subscription_create(self): - self._verify("openstack.message.v2.subscription.Subscription.create", - self.proxy.create_subscription, - method_args=["test_queue"]) - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_subscription_get(self, mock_get_resource): - mock_get_resource.return_value = "resource_or_id" - self._verify2("openstack.proxy2.BaseProxy._get", - self.proxy.get_subscription, - method_args=["test_queue", "resource_or_id"], - expected_args=[subscription.Subscription, - "resource_or_id"]) - mock_get_resource.assert_called_once_with( - subscription.Subscription, "resource_or_id", - queue_name="test_queue") - - def test_subscriptions(self): - self.verify_list(self.proxy.subscriptions, subscription.Subscription, - paginated=True, method_args=["test_queue"], - expected_kwargs={"queue_name": "test_queue"}) - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_subscription_delete(self, mock_get_resource): - mock_get_resource.return_value = "resource_or_id" - self.verify_delete(self.proxy.delete_subscription, - subscription.Subscription, False, - ["test_queue", "resource_or_id"]) - mock_get_resource.assert_called_once_with( - subscription.Subscription, "resource_or_id", - queue_name="test_queue") - - @mock.patch.object(proxy_base.BaseProxy, '_get_resource') - def test_subscription_delete_ignore(self, mock_get_resource): - mock_get_resource.return_value = "resource_or_id" - self.verify_delete(self.proxy.delete_subscription, - subscription.Subscription, True, - ["test_queue", "resource_or_id"]) - mock_get_resource.assert_called_once_with( - subscription.Subscription, "resource_or_id", - queue_name="test_queue") - - def test_claim_create(self): - self._verify("openstack.message.v2.claim.Claim.create", - self.proxy.create_claim, - method_args=["test_queue"]) - - def test_claim_get(self): - self._verify2("openstack.proxy2.BaseProxy._get", - self.proxy.get_claim, - method_args=["test_queue", "resource_or_id"], - expected_args=[claim.Claim, - "resource_or_id"], - expected_kwargs={"queue_name": "test_queue"}) - - def test_claim_update(self): - self._verify2("openstack.proxy2.BaseProxy._update", - self.proxy.update_claim, - method_args=["test_queue", "resource_or_id"], - method_kwargs={"k1": "v1"}, - expected_args=[claim.Claim, - "resource_or_id"], - expected_kwargs={"queue_name": "test_queue", - "k1": "v1"}) - - def test_claim_delete(self): - self.verify_delete(self.proxy.delete_claim, - claim.Claim, False, - ["test_queue", "resource_or_id"], - expected_kwargs={"queue_name": "test_queue"}) - - def test_claim_delete_ignore(self): - self.verify_delete(self.proxy.delete_claim, - claim.Claim, True, - ["test_queue", "resource_or_id"], - expected_kwargs={"queue_name": "test_queue"}) diff --git a/openstack/tests/unit/message/v2/test_queue.py b/openstack/tests/unit/message/v2/test_queue.py deleted file mode 100644 index 566510c6..00000000 --- a/openstack/tests/unit/message/v2/test_queue.py +++ /dev/null @@ -1,171 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools -import uuid - -from openstack.message.v2 import queue - - -FAKE1 = { - 'name': 'test_queue', - 'description': 'Queue used for test.', - '_default_message_ttl': 3600, - '_max_messages_post_size': 262144 -} - - -FAKE2 = { - 'name': 'test_queue', - 'description': 'Queue used for test.', - '_default_message_ttl': 3600, - '_max_messages_post_size': 262144, - 'client_id': 'OLD_CLIENT_ID', - 'project_id': 'OLD_PROJECT_ID' -} - - -class TestQueue(testtools.TestCase): - def test_basic(self): - sot = queue.Queue() - self.assertEqual('queues', sot.resources_key) - self.assertEqual('/queues', sot.base_path) - self.assertEqual('messaging', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = queue.Queue.new(**FAKE2) - self.assertEqual(FAKE1['description'], sot.description) - self.assertEqual(FAKE1['name'], sot.name) - self.assertEqual(FAKE1['name'], sot.id) - self.assertEqual(FAKE1['_default_message_ttl'], - sot.default_message_ttl) - self.assertEqual(FAKE1['_max_messages_post_size'], - sot.max_messages_post_size) - self.assertEqual(FAKE2['client_id'], sot.client_id) - self.assertEqual(FAKE2['project_id'], sot.project_id) - - @mock.patch.object(uuid, 'uuid4') - def test_create(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.put.return_value = resp - sess.get_project_id.return_value = 'NEW_PROJECT_ID' - mock_uuid.return_value = 'NEW_CLIENT_ID' - - sot = queue.Queue(**FAKE1) - sot._translate_response = mock.Mock() - res = sot.create(sess) - - url = 'queues/%s' % FAKE1['name'] - headers = {'Client-ID': 'NEW_CLIENT_ID', - 'X-PROJECT-ID': 'NEW_PROJECT_ID'} - sess.put.assert_called_with(url, endpoint_filter=sot.service, - headers=headers, json=FAKE1) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp, has_body=False) - self.assertEqual(sot, res) - - def test_create_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.put.return_value = resp - - sot = queue.Queue(**FAKE2) - sot._translate_response = mock.Mock() - res = sot.create(sess) - - url = 'queues/%s' % FAKE2['name'] - headers = {'Client-ID': 'OLD_CLIENT_ID', - 'X-PROJECT-ID': 'OLD_PROJECT_ID'} - sess.put.assert_called_with(url, endpoint_filter=sot.service, - headers=headers, json=FAKE1) - sot._translate_response.assert_called_once_with(resp, has_body=False) - self.assertEqual(sot, res) - - @mock.patch.object(uuid, 'uuid4') - def test_get(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - sess.get_project_id.return_value = 'NEW_PROJECT_ID' - mock_uuid.return_value = 'NEW_CLIENT_ID' - - sot = queue.Queue(**FAKE1) - sot._translate_response = mock.Mock() - res = sot.get(sess) - - url = 'queues/%s' % FAKE1['name'] - headers = {'Client-ID': 'NEW_CLIENT_ID', - 'X-PROJECT-ID': 'NEW_PROJECT_ID'} - sess.get.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp) - self.assertEqual(sot, res) - - def test_get_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - - sot = queue.Queue(**FAKE2) - sot._translate_response = mock.Mock() - res = sot.get(sess) - - url = 'queues/%s' % FAKE2['name'] - headers = {'Client-ID': 'OLD_CLIENT_ID', - 'X-PROJECT-ID': 'OLD_PROJECT_ID'} - sess.get.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sot._translate_response.assert_called_once_with(resp) - self.assertEqual(sot, res) - - @mock.patch.object(uuid, 'uuid4') - def test_delete(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.delete.return_value = resp - sess.get_project_id.return_value = 'NEW_PROJECT_ID' - mock_uuid.return_value = 'NEW_CLIENT_ID' - - sot = queue.Queue(**FAKE1) - sot._translate_response = mock.Mock() - sot.delete(sess) - - url = 'queues/%s' % FAKE1['name'] - headers = {'Client-ID': 'NEW_CLIENT_ID', - 'X-PROJECT-ID': 'NEW_PROJECT_ID'} - sess.delete.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp, has_body=False) - - def test_delete_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.delete.return_value = resp - - sot = queue.Queue(**FAKE2) - sot._translate_response = mock.Mock() - sot.delete(sess) - - url = 'queues/%s' % FAKE2['name'] - headers = {'Client-ID': 'OLD_CLIENT_ID', - 'X-PROJECT-ID': 'OLD_PROJECT_ID'} - sess.delete.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sot._translate_response.assert_called_once_with(resp, has_body=False) diff --git a/openstack/tests/unit/message/v2/test_subscription.py b/openstack/tests/unit/message/v2/test_subscription.py deleted file mode 100644 index 47c165fc..00000000 --- a/openstack/tests/unit/message/v2/test_subscription.py +++ /dev/null @@ -1,191 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy -import mock -import testtools -import uuid - -from openstack.message.v2 import subscription - - -FAKE1 = { - "age": 1632, - "id": "576b54963990b48c644bb7e7", - "subscriber": "http://10.229.49.117:5679", - "subscription_id": "576b54963990b48c644bb7e7", - "source": "test", - "ttl": 3600, - "options": { - "name": "test" - }, - "queue_name": "queue1" -} - - -FAKE2 = { - "age": 1632, - "id": "576b54963990b48c644bb7e7", - "subscriber": "http://10.229.49.117:5679", - "subscription_id": "576b54963990b48c644bb7e7", - "source": "test", - "ttl": 3600, - "options": { - "name": "test" - }, - "queue_name": "queue1", - "client_id": "OLD_CLIENT_ID", - "project_id": "OLD_PROJECT_ID" -} - - -class TestSubscription(testtools.TestCase): - def test_basic(self): - sot = subscription.Subscription() - self.assertEqual("subscriptions", sot.resources_key) - self.assertEqual("/queues/%(queue_name)s/subscriptions", sot.base_path) - self.assertEqual("messaging", sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = subscription.Subscription.new(**FAKE2) - self.assertEqual(FAKE2["age"], sot.age) - self.assertEqual(FAKE2["id"], sot.id) - self.assertEqual(FAKE2["options"], sot.options) - self.assertEqual(FAKE2["source"], sot.source) - self.assertEqual(FAKE2["subscriber"], sot.subscriber) - self.assertEqual(FAKE2["subscription_id"], sot.subscription_id) - self.assertEqual(FAKE2["ttl"], sot.ttl) - self.assertEqual(FAKE2["queue_name"], sot.queue_name) - self.assertEqual(FAKE2["client_id"], sot.client_id) - self.assertEqual(FAKE2["project_id"], sot.project_id) - - @mock.patch.object(uuid, "uuid4") - def test_create(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.post.return_value = resp - sess.get_project_id.return_value = "NEW_PROJECT_ID" - mock_uuid.return_value = "NEW_CLIENT_ID" - FAKE = copy.deepcopy(FAKE1) - - sot = subscription.Subscription(**FAKE1) - sot._translate_response = mock.Mock() - res = sot.create(sess) - - url = "/queues/%(queue)s/subscriptions" % { - "queue": FAKE.pop("queue_name")} - headers = {"Client-ID": "NEW_CLIENT_ID", - "X-PROJECT-ID": "NEW_PROJECT_ID"} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - headers=headers, json=FAKE) - sess.get_project_id.assert_called_once_with() - self.assertEqual(sot, res) - - def test_create_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.post.return_value = resp - FAKE = copy.deepcopy(FAKE2) - - sot = subscription.Subscription(**FAKE2) - sot._translate_response = mock.Mock() - res = sot.create(sess) - - url = "/queues/%(queue)s/subscriptions" % { - "queue": FAKE.pop("queue_name")} - headers = {"Client-ID": FAKE.pop("client_id"), - "X-PROJECT-ID": FAKE.pop("project_id")} - sess.post.assert_called_once_with(url, endpoint_filter=sot.service, - headers=headers, json=FAKE) - self.assertEqual(sot, res) - - @mock.patch.object(uuid, "uuid4") - def test_get(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - sess.get_project_id.return_value = "NEW_PROJECT_ID" - mock_uuid.return_value = "NEW_CLIENT_ID" - - sot = subscription.Subscription(**FAKE1) - sot._translate_response = mock.Mock() - res = sot.get(sess) - - url = "queues/%(queue)s/subscriptions/%(subscription)s" % { - "queue": FAKE1["queue_name"], "subscription": FAKE1["id"]} - headers = {"Client-ID": "NEW_CLIENT_ID", - "X-PROJECT-ID": "NEW_PROJECT_ID"} - sess.get.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp) - self.assertEqual(sot, res) - - def test_get_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.get.return_value = resp - - sot = subscription.Subscription(**FAKE2) - sot._translate_response = mock.Mock() - res = sot.get(sess) - - url = "queues/%(queue)s/subscriptions/%(subscription)s" % { - "queue": FAKE2["queue_name"], "subscription": FAKE2["id"]} - headers = {"Client-ID": "OLD_CLIENT_ID", - "X-PROJECT-ID": "OLD_PROJECT_ID"} - sess.get.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sot._translate_response.assert_called_once_with(resp) - self.assertEqual(sot, res) - - @mock.patch.object(uuid, "uuid4") - def test_delete(self, mock_uuid): - sess = mock.Mock() - resp = mock.Mock() - sess.delete.return_value = resp - sess.get_project_id.return_value = "NEW_PROJECT_ID" - mock_uuid.return_value = "NEW_CLIENT_ID" - - sot = subscription.Subscription(**FAKE1) - sot._translate_response = mock.Mock() - sot.delete(sess) - - url = "queues/%(queue)s/subscriptions/%(subscription)s" % { - "queue": FAKE1["queue_name"], "subscription": FAKE1["id"]} - headers = {"Client-ID": "NEW_CLIENT_ID", - "X-PROJECT-ID": "NEW_PROJECT_ID"} - sess.delete.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sess.get_project_id.assert_called_once_with() - sot._translate_response.assert_called_once_with(resp, has_body=False) - - def test_delete_client_id_project_id_exist(self): - sess = mock.Mock() - resp = mock.Mock() - sess.delete.return_value = resp - - sot = subscription.Subscription(**FAKE2) - sot._translate_response = mock.Mock() - sot.delete(sess) - - url = "queues/%(queue)s/subscriptions/%(subscription)s" % { - "queue": FAKE2["queue_name"], "subscription": FAKE2["id"]} - headers = {"Client-ID": "OLD_CLIENT_ID", - "X-PROJECT-ID": "OLD_PROJECT_ID"} - sess.delete.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - sot._translate_response.assert_called_once_with(resp, has_body=False) diff --git a/openstack/tests/unit/metric/__init__.py b/openstack/tests/unit/metric/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/metric/test_metric_service.py b/openstack/tests/unit/metric/test_metric_service.py deleted file mode 100644 index acb846b3..00000000 --- a/openstack/tests/unit/metric/test_metric_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.metric import metric_service - - -class TestMetricService(testtools.TestCase): - - def test_service(self): - sot = metric_service.MetricService() - self.assertEqual('metric', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v1', sot.valid_versions[0].module) - self.assertEqual('v1', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/metric/v1/__init__.py b/openstack/tests/unit/metric/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/metric/v1/test_archive_policy.py b/openstack/tests/unit/metric/v1/test_archive_policy.py deleted file mode 100644 index e8c08c96..00000000 --- a/openstack/tests/unit/metric/v1/test_archive_policy.py +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.metric.v1 import archive_policy - -EXAMPLE = { - 'definition': - [ - {u'points': 12, u'timespan': u'1:00:00', - u'granularity': u'0:05:00'}, - {u'points': 24, u'timespan': u'1 day, 0:00:00', - u'granularity': u'1:00:00'}, - {u'points': 30, u'timespan': u'30 days, 0:00:00', - u'granularity': u'1 day, 0:00:00'}, - ], - u'back_window': 0, - u'name': u'low', - u'aggregation_methods': [u'sum', u'max'] -} - - -class TestArchivePolicy(testtools.TestCase): - - def setUp(self): - super(TestArchivePolicy, self).setUp() - self.resp = mock.Mock() - self.resp.body = '' - self.sess = mock.Mock() - self.sess.put = mock.Mock(return_value=self.resp) - - def test_basic(self): - m = archive_policy.ArchivePolicy() - self.assertIsNone(m.resource_key) - self.assertIsNone(m.resources_key) - self.assertEqual('/archive_policy', m.base_path) - self.assertEqual('metric', m.service.service_type) - self.assertTrue(m.allow_create) - self.assertTrue(m.allow_get) - self.assertFalse(m.allow_update) - self.assertTrue(m.allow_delete) - self.assertTrue(m.allow_list) - - def test_make_it(self): - m = archive_policy.ArchivePolicy(**EXAMPLE) - self.assertEqual(EXAMPLE['name'], m.name) - self.assertEqual(EXAMPLE['name'], m.id) - self.assertEqual(EXAMPLE['definition'], m.definition) - self.assertEqual(EXAMPLE['back_window'], m.back_window) - self.assertEqual(EXAMPLE['aggregation_methods'], m.aggregation_methods) diff --git a/openstack/tests/unit/metric/v1/test_capabilities.py b/openstack/tests/unit/metric/v1/test_capabilities.py deleted file mode 100644 index 72ee1cbe..00000000 --- a/openstack/tests/unit/metric/v1/test_capabilities.py +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.metric.v1 import capabilities - -BODY = { - 'aggregation_methods': ['mean', 'max', 'avg'], -} - - -class TestCapabilites(testtools.TestCase): - def test_basic(self): - sot = capabilities.Capabilities() - self.assertEqual('/capabilities', sot.base_path) - self.assertEqual('metric', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = capabilities.Capabilities(**BODY) - self.assertEqual(BODY['aggregation_methods'], - sot.aggregation_methods) diff --git a/openstack/tests/unit/metric/v1/test_metric.py b/openstack/tests/unit/metric/v1/test_metric.py deleted file mode 100644 index 86512982..00000000 --- a/openstack/tests/unit/metric/v1/test_metric.py +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.metric.v1 import metric - -EXAMPLE = { - 'id': '31bbd62e-b144-11e4-983c-bf9dbe7e25e6', - 'archive_policy_name': 'low', - 'created_by_user_id': '41bbd62e-b144-11e4-983c-bf9dbe7e25e6', - 'created_by_project_id': '51bbd62e-b144-11e4-983c-bf9dbe7e25e6', - 'resource_id': None, - 'name': None, -} - -EXAMPLE_AP = { - 'id': '31bbd62e-b144-11e4-983c-bf9dbe7e25e6', - 'archive_policy': { - 'name': "foobar", - }, - 'created_by_user_id': '41bbd62e-b144-11e4-983c-bf9dbe7e25e6', - 'created_by_project_id': '51bbd62e-b144-11e4-983c-bf9dbe7e25e6', - 'resource_id': "61bbd62e-b144-11e4-983c-bf9dbe7e25e6", - 'name': "foobaz", -} - - -class TestMetric(testtools.TestCase): - - def setUp(self): - super(TestMetric, self).setUp() - self.resp = mock.Mock() - self.resp.body = '' - self.sess = mock.Mock() - self.sess.put = mock.Mock(return_value=self.resp) - - def test_basic(self): - m = metric.Metric() - self.assertIsNone(m.resource_key) - self.assertIsNone(m.resources_key) - self.assertEqual('/metric', m.base_path) - self.assertEqual('metric', m.service.service_type) - self.assertTrue(m.allow_create) - self.assertTrue(m.allow_get) - self.assertFalse(m.allow_update) - self.assertTrue(m.allow_delete) - self.assertTrue(m.allow_list) - - def test_make_it(self): - m = metric.Metric(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], m.id) - self.assertEqual(EXAMPLE['archive_policy_name'], m.archive_policy_name) - self.assertEqual(EXAMPLE['created_by_user_id'], m.created_by_user_id) - self.assertEqual(EXAMPLE['created_by_project_id'], - m.created_by_project_id) - self.assertEqual(EXAMPLE['resource_id'], m.resource_id) - self.assertEqual(EXAMPLE['name'], m.name) - - m = metric.Metric(**EXAMPLE_AP) - self.assertEqual(EXAMPLE_AP['id'], m.id) - self.assertEqual(EXAMPLE_AP['archive_policy'], m.archive_policy) - self.assertEqual(EXAMPLE_AP['created_by_user_id'], - m.created_by_user_id) - self.assertEqual(EXAMPLE_AP['created_by_project_id'], - m.created_by_project_id) - self.assertEqual(EXAMPLE_AP['resource_id'], m.resource_id) - self.assertEqual(EXAMPLE_AP['name'], m.name) diff --git a/openstack/tests/unit/metric/v1/test_proxy.py b/openstack/tests/unit/metric/v1/test_proxy.py deleted file mode 100644 index c3abc4ac..00000000 --- a/openstack/tests/unit/metric/v1/test_proxy.py +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.metric.v1 import _proxy -from openstack.metric.v1 import capabilities -from openstack.tests.unit import test_proxy_base2 as test_proxy_base - - -class TestMetricProxy(test_proxy_base.TestProxyBase): - def setUp(self): - super(TestMetricProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_capabilities(self): - self.verify_list(self.proxy.capabilities, capabilities.Capabilities, - paginated=False) diff --git a/openstack/tests/unit/metric/v1/test_resource.py b/openstack/tests/unit/metric/v1/test_resource.py deleted file mode 100644 index 80dad8c5..00000000 --- a/openstack/tests/unit/metric/v1/test_resource.py +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.metric.v1 import resource - - -EXAMPLE_GENERIC = { - "created_by_user_id": "5521eab6-a3bc-4841-b253-d62871b65e76", - "started_at": "2015-03-09T12:14:57.233772", - "user_id": None, - "created_by_project_id": "41649c3e-5f7a-41d1-81fb-2efa76c09e6c", - "metrics": {}, - "ended_at": None, - "project_id": None, - "type": "generic", - "id": "a8d5e83b-0320-45ce-8282-7c8ad8fb8bf6", -} - - -class TestResource(testtools.TestCase): - def test_generic(self): - m = resource.Generic() - self.assertIsNone(m.resource_key) - self.assertIsNone(m.resources_key) - self.assertEqual('/resource/generic', m.base_path) - self.assertEqual('metric', m.service.service_type) - self.assertTrue(m.allow_create) - self.assertTrue(m.allow_get) - self.assertTrue(m.allow_update) - self.assertTrue(m.allow_delete) - self.assertTrue(m.allow_list) - - def test_make_generic(self): - r = resource.Generic(**EXAMPLE_GENERIC) - self.assertEqual(EXAMPLE_GENERIC['created_by_user_id'], - r.created_by_user_id) - self.assertEqual(EXAMPLE_GENERIC['created_by_project_id'], - r.created_by_project_id) - self.assertEqual(EXAMPLE_GENERIC['user_id'], r.user_id) - self.assertEqual(EXAMPLE_GENERIC['project_id'], r.project_id) - self.assertEqual(EXAMPLE_GENERIC['type'], r.type) - self.assertEqual(EXAMPLE_GENERIC['id'], r.id) - self.assertEqual(EXAMPLE_GENERIC['metrics'], r.metrics) - self.assertEqual(EXAMPLE_GENERIC['started_at'], r.started_at) - self.assertEqual(EXAMPLE_GENERIC['ended_at'], r.ended_at) diff --git a/openstack/tests/unit/network/__init__.py b/openstack/tests/unit/network/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/network/test_network_service.py b/openstack/tests/unit/network/test_network_service.py deleted file mode 100644 index 22980fe3..00000000 --- a/openstack/tests/unit/network/test_network_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network import network_service - - -class TestNetworkService(testtools.TestCase): - - def test_service(self): - sot = network_service.NetworkService() - self.assertEqual('network', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v2', sot.valid_versions[0].module) - self.assertEqual('v2.0', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/network/test_version.py b/openstack/tests/unit/network/test_version.py deleted file mode 100644 index 6f3def46..00000000 --- a/openstack/tests/unit/network/test_version.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network import version - -IDENTIFIER = 'v2.0' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'status': '3', -} - - -class TestVersion(testtools.TestCase): - - def test_basic(self): - sot = version.Version() - self.assertEqual('version', sot.resource_key) - self.assertEqual('versions', sot.resources_key) - self.assertEqual('/', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = version.Version(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['status'], sot.status) diff --git a/openstack/tests/unit/network/v2/__init__.py b/openstack/tests/unit/network/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/network/v2/test_address_scope.py b/openstack/tests/unit/network/v2/test_address_scope.py deleted file mode 100644 index ae9cbe85..00000000 --- a/openstack/tests/unit/network/v2/test_address_scope.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import address_scope - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'ip_version': 4, - 'name': '1', - 'shared': True, - 'tenant_id': '2', -} - - -class TestAddressScope(testtools.TestCase): - - def test_basic(self): - sot = address_scope.AddressScope() - self.assertEqual('address_scope', sot.resource_key) - self.assertEqual('address_scopes', sot.resources_key) - self.assertEqual('/address-scopes', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = address_scope.AddressScope(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['ip_version'], sot.ip_version) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertTrue(sot.is_shared) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) diff --git a/openstack/tests/unit/network/v2/test_agent.py b/openstack/tests/unit/network/v2/test_agent.py deleted file mode 100644 index 6eddcb27..00000000 --- a/openstack/tests/unit/network/v2/test_agent.py +++ /dev/null @@ -1,152 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.network.v2 import agent - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'admin_state_up': True, - 'agent_type': 'Test Agent', - 'alive': True, - 'availability_zone': 'az1', - 'binary': 'test-binary', - 'configurations': {'attr1': 'value1', 'attr2': 'value2'}, - 'created_at': '2016-03-09T12:14:57.233772', - 'description': 'test description', - 'heartbeat_timestamp': '2016-08-09T12:14:57.233772', - 'host': 'test-host', - 'id': IDENTIFIER, - 'started_at': '2016-07-09T12:14:57.233772', - 'topic': 'test-topic', - 'ha_state': 'active' -} - - -class TestAgent(testtools.TestCase): - - def test_basic(self): - sot = agent.Agent() - self.assertEqual('agent', sot.resource_key) - self.assertEqual('agents', sot.resources_key) - self.assertEqual('/agents', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = agent.Agent(**EXAMPLE) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['agent_type'], sot.agent_type) - self.assertTrue(sot.is_alive) - self.assertEqual(EXAMPLE['availability_zone'], - sot.availability_zone) - self.assertEqual(EXAMPLE['binary'], sot.binary) - self.assertEqual(EXAMPLE['configurations'], sot.configuration) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['heartbeat_timestamp'], sot.last_heartbeat_at) - self.assertEqual(EXAMPLE['host'], sot.host) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['started_at'], sot.started_at) - self.assertEqual(EXAMPLE['topic'], sot.topic) - self.assertEqual(EXAMPLE['ha_state'], sot.ha_state) - - def test_add_agent_to_network(self): - # Add agent to network - net = agent.Agent(**EXAMPLE) - response = mock.Mock() - response.body = {'network_id': '1'} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.post = mock.Mock(return_value=response) - body = {'network_id': '1'} - self.assertEqual(response.body, net.add_agent_to_network(sess, **body)) - - url = 'agents/IDENTIFIER/dhcp-networks' - sess.post.assert_called_with(url, endpoint_filter=net.service, - json=body) - - def test_remove_agent_from_network(self): - # Remove agent from agent - net = agent.Agent(**EXAMPLE) - sess = mock.Mock() - network_id = {} - self.assertIsNone(net.remove_agent_from_network(sess, network_id)) - body = {'network_id': {}} - - sess.delete.assert_called_with('agents/IDENTIFIER/dhcp-networks/', - endpoint_filter=net.service, json=body) - - def test_add_router_to_agent(self): - # Add router to agent - sot = agent.Agent(**EXAMPLE) - response = mock.Mock() - response.body = {'router_id': '1'} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.post = mock.Mock(return_value=response) - router_id = '1' - self.assertEqual(response.body, - sot.add_router_to_agent(sess, router_id)) - body = {'router_id': router_id} - url = 'agents/IDENTIFIER/l3-routers' - sess.post.assert_called_with(url, endpoint_filter=sot.service, - json=body) - - def test_remove_router_from_agent(self): - # Remove router from agent - sot = agent.Agent(**EXAMPLE) - sess = mock.Mock() - router_id = {} - self.assertIsNone(sot.remove_router_from_agent(sess, router_id)) - body = {'router_id': {}} - - sess.delete.assert_called_with('agents/IDENTIFIER/l3-routers/', - endpoint_filter=sot.service, json=body) - - -class TestNetworkHostingDHCPAgent(testtools.TestCase): - - def test_basic(self): - net = agent.NetworkHostingDHCPAgent() - self.assertEqual('agent', net.resource_key) - self.assertEqual('agents', net.resources_key) - self.assertEqual('/networks/%(network_id)s/dhcp-agents', net.base_path) - self.assertEqual('dhcp-agent', net.resource_name) - self.assertEqual('network', net.service.service_type) - self.assertFalse(net.allow_create) - self.assertTrue(net.allow_get) - self.assertFalse(net.allow_update) - self.assertFalse(net.allow_delete) - self.assertTrue(net.allow_list) - - -class TestRouterL3Agent(testtools.TestCase): - - def test_basic(self): - sot = agent.RouterL3Agent() - self.assertEqual('agent', sot.resource_key) - self.assertEqual('agents', sot.resources_key) - self.assertEqual('/routers/%(router_id)s/l3-agents', sot.base_path) - self.assertEqual('l3-agent', sot.resource_name) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_retrieve) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) diff --git a/openstack/tests/unit/network/v2/test_auto_allocated_topology.py b/openstack/tests/unit/network/v2/test_auto_allocated_topology.py deleted file mode 100644 index 941660a1..00000000 --- a/openstack/tests/unit/network/v2/test_auto_allocated_topology.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import auto_allocated_topology - -EXAMPLE = { - 'tenant_id': '1', - 'dry_run': False, -} - - -class TestAutoAllocatedTopology(testtools.TestCase): - - def test_basic(self): - topo = auto_allocated_topology.AutoAllocatedTopology - self.assertEqual('auto_allocated_topology', topo.resource_key) - self.assertEqual('/auto-allocated-topology', topo.base_path) - self.assertFalse(topo.allow_create) - self.assertTrue(topo.allow_get) - self.assertFalse(topo.allow_update) - self.assertTrue(topo.allow_delete) - self.assertFalse(topo.allow_list) - - def test_make_it(self): - topo = auto_allocated_topology.AutoAllocatedTopology(**EXAMPLE) - self.assertEqual(EXAMPLE['tenant_id'], topo.project_id) diff --git a/openstack/tests/unit/network/v2/test_availability_zone.py b/openstack/tests/unit/network/v2/test_availability_zone.py deleted file mode 100644 index 7ab1031e..00000000 --- a/openstack/tests/unit/network/v2/test_availability_zone.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import availability_zone - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'name': '1', - 'resource': '2', - 'state': '3', -} - - -class TestAvailabilityZone(testtools.TestCase): - - def test_basic(self): - sot = availability_zone.AvailabilityZone() - self.assertEqual('availability_zone', sot.resource_key) - self.assertEqual('availability_zones', sot.resources_key) - self.assertEqual('/availability_zones', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = availability_zone.AvailabilityZone(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['resource'], sot.resource) - self.assertEqual(EXAMPLE['state'], sot.state) diff --git a/openstack/tests/unit/network/v2/test_extension.py b/openstack/tests/unit/network/v2/test_extension.py deleted file mode 100644 index fd2511b7..00000000 --- a/openstack/tests/unit/network/v2/test_extension.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import extension - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'alias': '1', - 'description': '2', - 'links': '3', - 'name': '4', - 'updated': '2016-03-09T12:14:57.233772', -} - - -class TestExtension(testtools.TestCase): - - def test_basic(self): - sot = extension.Extension() - self.assertEqual('extension', sot.resource_key) - self.assertEqual('extensions', sot.resources_key) - self.assertEqual('/extensions', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = extension.Extension(**EXAMPLE) - self.assertEqual(EXAMPLE['alias'], sot.id) - self.assertEqual(EXAMPLE['alias'], sot.alias) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) diff --git a/openstack/tests/unit/network/v2/test_flavor.py b/openstack/tests/unit/network/v2/test_flavor.py deleted file mode 100644 index 9bf70d5a..00000000 --- a/openstack/tests/unit/network/v2/test_flavor.py +++ /dev/null @@ -1,94 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.network.v2 import flavor - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE_WITH_OPTIONAL = { - 'id': IDENTIFIER, - 'name': 'test-flavor', - 'service_type': 'VPN', - 'description': 'VPN flavor', - 'enabled': True, - 'service_profiles': ['1', '2'], -} - -EXAMPLE = { - 'id': IDENTIFIER, - 'name': 'test-flavor', - 'service_type': 'VPN', -} - - -class TestFlavor(testtools.TestCase): - def test_basic(self): - flavors = flavor.Flavor() - self.assertEqual('flavor', flavors.resource_key) - self.assertEqual('flavors', flavors.resources_key) - self.assertEqual('/flavors', flavors.base_path) - self.assertEqual('network', flavors.service.service_type) - self.assertTrue(flavors.allow_create) - self.assertTrue(flavors.allow_get) - self.assertTrue(flavors.allow_update) - self.assertTrue(flavors.allow_delete) - self.assertTrue(flavors.allow_list) - - def test_make_it(self): - flavors = flavor.Flavor(**EXAMPLE) - self.assertEqual(EXAMPLE['name'], flavors.name) - self.assertEqual(EXAMPLE['service_type'], flavors.service_type) - - def test_make_it_with_optional(self): - flavors = flavor.Flavor(**EXAMPLE_WITH_OPTIONAL) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['name'], flavors.name) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['service_type'], - flavors.service_type) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['description'], - flavors.description) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['enabled'], flavors.is_enabled) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['service_profiles'], - flavors.service_profile_ids) - - def test_associate_flavor_with_service_profile(self): - flav = flavor.Flavor(EXAMPLE) - response = mock.Mock() - response.body = { - 'service_profile': {'id': '1'}, - } - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.post = mock.Mock(return_value=response) - flav.id = 'IDENTIFIER' - self.assertEqual( - response.body, flav.associate_flavor_with_service_profile( - sess, '1')) - - url = 'flavors/IDENTIFIER/service_profiles' - sess.post.assert_called_with(url, endpoint_filter=flav.service, - json=response.body) - - def test_disassociate_flavor_from_service_profile(self): - flav = flavor.Flavor(EXAMPLE) - response = mock.Mock() - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.post = mock.Mock(return_value=response) - flav.id = 'IDENTIFIER' - self.assertEqual( - None, flav.disassociate_flavor_from_service_profile( - sess, '1')) - - url = 'flavors/IDENTIFIER/service_profiles/1' - sess.delete.assert_called_with(url, endpoint_filter=flav.service) diff --git a/openstack/tests/unit/network/v2/test_floating_ip.py b/openstack/tests/unit/network/v2/test_floating_ip.py deleted file mode 100644 index 4673233a..00000000 --- a/openstack/tests/unit/network/v2/test_floating_ip.py +++ /dev/null @@ -1,91 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.network.v2 import floating_ip - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'created_at': '0', - 'fixed_ip_address': '1', - 'floating_ip_address': '127.0.0.1', - 'floating_network_id': '3', - 'id': IDENTIFIER, - 'port_id': '5', - 'tenant_id': '6', - 'router_id': '7', - 'description': '8', - 'status': 'ACTIVE', - 'revision_number': 12, - 'updated_at': '13', -} - - -class TestFloatingIP(testtools.TestCase): - - def test_basic(self): - sot = floating_ip.FloatingIP() - self.assertEqual('floatingip', sot.resource_key) - self.assertEqual('floatingips', sot.resources_key) - self.assertEqual('/floatingips', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = floating_ip.FloatingIP(**EXAMPLE) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['fixed_ip_address'], sot.fixed_ip_address) - self.assertEqual(EXAMPLE['floating_ip_address'], - sot.floating_ip_address) - self.assertEqual(EXAMPLE['floating_network_id'], - sot.floating_network_id) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['port_id'], sot.port_id) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['router_id'], sot.router_id) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['revision_number'], sot.revision_number) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) - - def test_find_available(self): - mock_session = mock.Mock() - mock_session.get_filter = mock.Mock(return_value={}) - data = {'id': 'one', 'floating_ip_address': '10.0.0.1'} - fake_response = mock.Mock() - body = {floating_ip.FloatingIP.resources_key: [data]} - fake_response.json = mock.Mock(return_value=body) - mock_session.get = mock.Mock(return_value=fake_response) - - result = floating_ip.FloatingIP.find_available(mock_session) - - self.assertEqual('one', result.id) - mock_session.get.assert_called_with( - floating_ip.FloatingIP.base_path, - endpoint_filter=floating_ip.FloatingIP.service, - headers={'Accept': 'application/json'}, - params={'port_id': ''}) - - def test_find_available_nada(self): - mock_session = mock.Mock() - fake_response = mock.Mock() - body = {floating_ip.FloatingIP.resources_key: []} - fake_response.json = mock.Mock(return_value=body) - mock_session.get = mock.Mock(return_value=fake_response) - - self.assertIsNone(floating_ip.FloatingIP.find_available(mock_session)) diff --git a/openstack/tests/unit/network/v2/test_health_monitor.py b/openstack/tests/unit/network/v2/test_health_monitor.py deleted file mode 100644 index b5d89fae..00000000 --- a/openstack/tests/unit/network/v2/test_health_monitor.py +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import health_monitor - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'admin_state_up': True, - 'delay': '2', - 'expected_codes': '3', - 'http_method': '4', - 'id': IDENTIFIER, - 'max_retries': '6', - 'pools': [{'id': '7'}], - 'tenant_id': '8', - 'timeout': '9', - 'type': '10', - 'url_path': '11', - 'name': '12', -} - - -class TestHealthMonitor(testtools.TestCase): - - def test_basic(self): - sot = health_monitor.HealthMonitor() - self.assertEqual('healthmonitor', sot.resource_key) - self.assertEqual('healthmonitors', sot.resources_key) - self.assertEqual('/lbaas/healthmonitors', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = health_monitor.HealthMonitor(**EXAMPLE) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['delay'], sot.delay) - self.assertEqual(EXAMPLE['expected_codes'], sot.expected_codes) - self.assertEqual(EXAMPLE['http_method'], sot.http_method) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['max_retries'], sot.max_retries) - self.assertEqual(EXAMPLE['pools'], sot.pool_ids) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['timeout'], sot.timeout) - self.assertEqual(EXAMPLE['type'], sot.type) - self.assertEqual(EXAMPLE['url_path'], sot.url_path) - self.assertEqual(EXAMPLE['name'], sot.name) diff --git a/openstack/tests/unit/network/v2/test_listener.py b/openstack/tests/unit/network/v2/test_listener.py deleted file mode 100644 index 34c91d82..00000000 --- a/openstack/tests/unit/network/v2/test_listener.py +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import listener - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'admin_state_up': True, - 'connection_limit': '2', - 'default_pool_id': '3', - 'description': '4', - 'id': IDENTIFIER, - 'loadbalancers': [{'id': '6'}], - 'name': '7', - 'project_id': '8', - 'protocol': '9', - 'protocol_port': '10', - 'default_tls_container_ref': '11', - 'sni_container_refs': [], -} - - -class TestListener(testtools.TestCase): - - def test_basic(self): - sot = listener.Listener() - self.assertEqual('listener', sot.resource_key) - self.assertEqual('listeners', sot.resources_key) - self.assertEqual('/lbaas/listeners', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = listener.Listener(**EXAMPLE) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['connection_limit'], sot.connection_limit) - self.assertEqual(EXAMPLE['default_pool_id'], sot.default_pool_id) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['loadbalancers'], sot.load_balancer_ids) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['protocol'], sot.protocol) - self.assertEqual(EXAMPLE['protocol_port'], sot.protocol_port) - self.assertEqual(EXAMPLE['default_tls_container_ref'], - sot.default_tls_container_ref) - self.assertEqual(EXAMPLE['sni_container_refs'], - sot.sni_container_refs) diff --git a/openstack/tests/unit/network/v2/test_load_balancer.py b/openstack/tests/unit/network/v2/test_load_balancer.py deleted file mode 100644 index 9a657c4b..00000000 --- a/openstack/tests/unit/network/v2/test_load_balancer.py +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import load_balancer - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'admin_state_up': True, - 'description': '2', - 'id': IDENTIFIER, - 'listeners': [{'id', '4'}], - 'name': '5', - 'operating_status': '6', - 'provisioning_status': '7', - 'tenant_id': '8', - 'vip_address': '9', - 'vip_subnet_id': '10', - 'vip_port_id': '11', - 'provider': '12', - 'pools': [{'id', '13'}], -} - - -class TestLoadBalancer(testtools.TestCase): - - def test_basic(self): - sot = load_balancer.LoadBalancer() - self.assertEqual('loadbalancer', sot.resource_key) - self.assertEqual('loadbalancers', sot.resources_key) - self.assertEqual('/lbaas/loadbalancers', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = load_balancer.LoadBalancer(**EXAMPLE) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['listeners'], sot.listener_ids) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['operating_status'], sot.operating_status) - self.assertEqual(EXAMPLE['provisioning_status'], - sot.provisioning_status) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['vip_address'], sot.vip_address) - self.assertEqual(EXAMPLE['vip_subnet_id'], sot.vip_subnet_id) - self.assertEqual(EXAMPLE['vip_port_id'], sot.vip_port_id) - self.assertEqual(EXAMPLE['provider'], sot.provider) - self.assertEqual(EXAMPLE['pools'], sot.pool_ids) diff --git a/openstack/tests/unit/network/v2/test_metering_label.py b/openstack/tests/unit/network/v2/test_metering_label.py deleted file mode 100644 index 4d1e57a9..00000000 --- a/openstack/tests/unit/network/v2/test_metering_label.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import metering_label - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'description': '1', - 'id': IDENTIFIER, - 'name': '3', - 'tenant_id': '4', - 'shared': False, -} - - -class TestMeteringLabel(testtools.TestCase): - - def test_basic(self): - sot = metering_label.MeteringLabel() - self.assertEqual('metering_label', sot.resource_key) - self.assertEqual('metering_labels', sot.resources_key) - self.assertEqual('/metering/metering-labels', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = metering_label.MeteringLabel(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['shared'], sot.is_shared) diff --git a/openstack/tests/unit/network/v2/test_metering_label_rule.py b/openstack/tests/unit/network/v2/test_metering_label_rule.py deleted file mode 100644 index 03c134b4..00000000 --- a/openstack/tests/unit/network/v2/test_metering_label_rule.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import metering_label_rule - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'direction': '1', - 'excluded': False, - 'id': IDENTIFIER, - 'metering_label_id': '4', - 'tenant_id': '5', - 'remote_ip_prefix': '6', -} - - -class TestMeteringLabelRule(testtools.TestCase): - - def test_basic(self): - sot = metering_label_rule.MeteringLabelRule() - self.assertEqual('metering_label_rule', sot.resource_key) - self.assertEqual('metering_label_rules', sot.resources_key) - self.assertEqual('/metering/metering-label-rules', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = metering_label_rule.MeteringLabelRule(**EXAMPLE) - self.assertEqual(EXAMPLE['direction'], sot.direction) - self.assertFalse(sot.is_excluded) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['metering_label_id'], sot.metering_label_id) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['remote_ip_prefix'], sot.remote_ip_prefix) diff --git a/openstack/tests/unit/network/v2/test_network.py b/openstack/tests/unit/network/v2/test_network.py deleted file mode 100644 index f8fc88b6..00000000 --- a/openstack/tests/unit/network/v2/test_network.py +++ /dev/null @@ -1,135 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import network - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'admin_state_up': True, - 'availability_zone_hints': ['1', '2'], - 'availability_zones': ['3'], - 'created_at': '2016-03-09T12:14:57.233772', - 'description': '4', - 'dns_domain': '5', - 'id': IDENTIFIER, - 'ipv4_address_scope': '6', - 'ipv6_address_scope': '7', - 'is_default': False, - 'mtu': 8, - 'name': '9', - 'port_security_enabled': True, - 'project_id': '10', - 'provider:network_type': '11', - 'provider:physical_network': '12', - 'provider:segmentation_id': '13', - 'qos_policy_id': '14', - 'revision_number': 15, - 'router:external': True, - 'segments': '16', - 'shared': True, - 'status': '17', - 'subnets': ['18', '19'], - 'updated_at': '2016-07-09T12:14:57.233772', - 'vlan_transparent': False, -} - - -class TestNetwork(testtools.TestCase): - - def test_basic(self): - sot = network.Network() - self.assertEqual('network', sot.resource_key) - self.assertEqual('networks', sot.resources_key) - self.assertEqual('/networks', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = network.Network(**EXAMPLE) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['availability_zone_hints'], - sot.availability_zone_hints) - self.assertEqual(EXAMPLE['availability_zones'], - sot.availability_zones) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['dns_domain'], sot.dns_domain) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['ipv4_address_scope'], - sot.ipv4_address_scope_id) - self.assertEqual(EXAMPLE['ipv6_address_scope'], - sot.ipv6_address_scope_id) - self.assertFalse(sot.is_default) - self.assertEqual(EXAMPLE['mtu'], sot.mtu) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertTrue(sot.is_port_security_enabled) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['provider:network_type'], - sot.provider_network_type) - self.assertEqual(EXAMPLE['provider:physical_network'], - sot.provider_physical_network) - self.assertEqual(EXAMPLE['provider:segmentation_id'], - sot.provider_segmentation_id) - self.assertEqual(EXAMPLE['qos_policy_id'], sot.qos_policy_id) - self.assertEqual(EXAMPLE['revision_number'], sot.revision_number) - self.assertTrue(sot.is_router_external) - self.assertEqual(EXAMPLE['segments'], sot.segments) - self.assertTrue(sot.is_shared) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['subnets'], sot.subnet_ids) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) - self.assertEqual(EXAMPLE['vlan_transparent'], sot.is_vlan_transparent) - - self.assertDictEqual( - {'limit': 'limit', - 'marker': 'marker', - 'description': 'description', - 'name': 'name', - 'project_id': 'project_id', - 'status': 'status', - 'ipv4_address_scope_id': 'ipv4_address_scope', - 'ipv6_address_scope_id': 'ipv6_address_scope', - 'is_admin_state_up': 'admin_state_up', - 'is_port_security_enabled': 'port_security_enabled', - 'is_router_external': 'router:external', - 'is_shared': 'shared', - 'provider_network_type': 'provider:network_type', - 'provider_physical_network': 'provider:physical_network', - 'provider_segmentation_id': 'provider:segmentation_id', - 'tags': 'tags', - 'any_tags': 'tags-any', - 'not_tags': 'not-tags', - 'not_any_tags': 'not-tags-any', - }, - sot._query_mapping._mapping) - - -class TestDHCPAgentHostingNetwork(testtools.TestCase): - - def test_basic(self): - net = network.DHCPAgentHostingNetwork() - self.assertEqual('network', net.resource_key) - self.assertEqual('networks', net.resources_key) - self.assertEqual('/agents/%(agent_id)s/dhcp-networks', net.base_path) - self.assertEqual('dhcp-network', net.resource_name) - self.assertEqual('network', net.service.service_type) - self.assertFalse(net.allow_create) - self.assertTrue(net.allow_get) - self.assertFalse(net.allow_update) - self.assertFalse(net.allow_delete) - self.assertTrue(net.allow_list) diff --git a/openstack/tests/unit/network/v2/test_network_ip_availability.py b/openstack/tests/unit/network/v2/test_network_ip_availability.py deleted file mode 100644 index 3d0246b1..00000000 --- a/openstack/tests/unit/network/v2/test_network_ip_availability.py +++ /dev/null @@ -1,76 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import network_ip_availability - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'network_id': IDENTIFIER, - 'network_name': 'private', - 'subnet_ip_availability': [], - 'tenant_id': '5', - 'total_ips': 6, - 'used_ips': 10, -} - -EXAMPLE_WITH_OPTIONAL = { - 'network_id': IDENTIFIER, - 'network_name': 'private', - 'subnet_ip_availability': [{"used_ips": 3, "subnet_id": - "2e4db1d6-ab2d-4bb1-93bb-a003fdbc9b39", - "subnet_name": "private-subnet", - "ip_version": 6, "cidr": "fd91:c3ba:e818::/64", - "total_ips": 18446744073709551614}], - 'tenant_id': '2', - 'total_ips': 1844, - 'used_ips': 6, -} - - -class TestNetworkIPAvailability(testtools.TestCase): - - def test_basic(self): - sot = network_ip_availability.NetworkIPAvailability() - self.assertEqual('network_ip_availability', sot.resource_key) - self.assertEqual('network_ip_availabilities', sot.resources_key) - self.assertEqual('/network-ip-availabilities', sot.base_path) - self.assertEqual('network_name', sot.name_attribute) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = network_ip_availability.NetworkIPAvailability(**EXAMPLE) - self.assertEqual(EXAMPLE['network_id'], sot.network_id) - self.assertEqual(EXAMPLE['network_name'], sot.network_name) - self.assertEqual(EXAMPLE['subnet_ip_availability'], - sot.subnet_ip_availability) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['total_ips'], sot.total_ips) - self.assertEqual(EXAMPLE['used_ips'], sot.used_ips) - - def test_make_it_with_optional(self): - sot = network_ip_availability.NetworkIPAvailability( - **EXAMPLE_WITH_OPTIONAL) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['network_id'], sot.network_id) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['network_name'], - sot.network_name) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['subnet_ip_availability'], - sot.subnet_ip_availability) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['total_ips'], sot.total_ips) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['used_ips'], sot.used_ips) diff --git a/openstack/tests/unit/network/v2/test_pool.py b/openstack/tests/unit/network/v2/test_pool.py deleted file mode 100644 index e8e3c884..00000000 --- a/openstack/tests/unit/network/v2/test_pool.py +++ /dev/null @@ -1,75 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import pool - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'admin_state_up': True, - 'description': '2', - 'health_monitors': ['3'], - 'health_monitor_status': ['4'], - 'id': IDENTIFIER, - 'lb_algorithm': '5', - 'listeners': [{'id': '6'}], - 'members': [{'id': '7'}], - 'name': '8', - 'tenant_id': '9', - 'protocol': '10', - 'provider': '11', - 'session_persistence': '12', - 'status': '13', - 'status_description': '14', - 'subnet_id': '15', - 'loadbalancers': [{'id': '16'}], - 'vip_id': '17', -} - - -class TestPool(testtools.TestCase): - - def test_basic(self): - sot = pool.Pool() - self.assertEqual('pool', sot.resource_key) - self.assertEqual('pools', sot.resources_key) - self.assertEqual('/lbaas/pools', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = pool.Pool(**EXAMPLE) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['health_monitors'], sot.health_monitor_ids) - self.assertEqual(EXAMPLE['health_monitor_status'], - sot.health_monitor_status) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['lb_algorithm'], sot.lb_algorithm) - self.assertEqual(EXAMPLE['listeners'], sot.listener_ids) - self.assertEqual(EXAMPLE['members'], sot.member_ids) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['protocol'], sot.protocol) - self.assertEqual(EXAMPLE['provider'], sot.provider) - self.assertEqual(EXAMPLE['session_persistence'], - sot.session_persistence) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['status_description'], sot.status_description) - self.assertEqual(EXAMPLE['subnet_id'], sot.subnet_id) - self.assertEqual(EXAMPLE['loadbalancers'], sot.load_balancer_ids) - self.assertEqual(EXAMPLE['vip_id'], sot.virtual_ip_id) diff --git a/openstack/tests/unit/network/v2/test_pool_member.py b/openstack/tests/unit/network/v2/test_pool_member.py deleted file mode 100644 index f175cb35..00000000 --- a/openstack/tests/unit/network/v2/test_pool_member.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import pool_member - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'address': '1', - 'admin_state_up': True, - 'id': IDENTIFIER, - 'tenant_id': '4', - 'protocol_port': 5, - 'subnet_id': '6', - 'weight': 7, - 'name': '8', - 'pool_id': 'FAKE_POOL', -} - - -class TestPoolMember(testtools.TestCase): - - def test_basic(self): - sot = pool_member.PoolMember() - self.assertEqual('member', sot.resource_key) - self.assertEqual('members', sot.resources_key) - self.assertEqual('/lbaas/pools/%(pool_id)s/members', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = pool_member.PoolMember(**EXAMPLE) - self.assertEqual(EXAMPLE['address'], sot.address) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['protocol_port'], sot.protocol_port) - self.assertEqual(EXAMPLE['subnet_id'], sot.subnet_id) - self.assertEqual(EXAMPLE['weight'], sot.weight) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['pool_id'], sot.pool_id) diff --git a/openstack/tests/unit/network/v2/test_port.py b/openstack/tests/unit/network/v2/test_port.py deleted file mode 100644 index dd931a76..00000000 --- a/openstack/tests/unit/network/v2/test_port.py +++ /dev/null @@ -1,109 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import port - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'admin_state_up': True, - 'allowed_address_pairs': [{'2': 2}], - 'binding:host_id': '3', - 'binding:profile': {'4': 4}, - 'binding:vif_details': {'5': 5}, - 'binding:vif_type': '6', - 'binding:vnic_type': '7', - 'created_at': '2016-03-09T12:14:57.233772', - 'data_plane_status': '32', - 'description': '8', - 'device_id': '9', - 'device_owner': '10', - 'dns_assignment': [{'11': 11}], - 'dns_name': '12', - 'extra_dhcp_opts': [{'13': 13}], - 'fixed_ips': [{'14': '14'}], - 'id': IDENTIFIER, - 'ip_address': '15', - 'mac_address': '16', - 'name': '17', - 'network_id': '18', - 'opt_name': '19', - 'opt_value': '20', - 'port_security_enabled': True, - 'qos_policy_id': '21', - 'revision_number': 22, - 'security_groups': ['23'], - 'subnet_id': '24', - 'status': '25', - 'tenant_id': '26', - 'trunk_details': { - 'trunk_id': '27', - 'sub_ports': [{ - 'port_id': '28', - 'segmentation_id': 29, - 'segmentation_type': '30', - 'mac_address': '31'}]}, - 'updated_at': '2016-07-09T12:14:57.233772', -} - - -class TestPort(testtools.TestCase): - - def test_basic(self): - sot = port.Port() - self.assertEqual('port', sot.resource_key) - self.assertEqual('ports', sot.resources_key) - self.assertEqual('/ports', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = port.Port(**EXAMPLE) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['allowed_address_pairs'], - sot.allowed_address_pairs) - self.assertEqual(EXAMPLE['binding:host_id'], sot.binding_host_id) - self.assertEqual(EXAMPLE['binding:profile'], sot.binding_profile) - self.assertEqual(EXAMPLE['binding:vif_details'], - sot.binding_vif_details) - self.assertEqual(EXAMPLE['binding:vif_type'], sot.binding_vif_type) - self.assertEqual(EXAMPLE['binding:vnic_type'], sot.binding_vnic_type) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['data_plane_status'], sot.data_plane_status) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['device_id'], sot.device_id) - self.assertEqual(EXAMPLE['device_owner'], sot.device_owner) - self.assertEqual(EXAMPLE['dns_assignment'], sot.dns_assignment) - self.assertEqual(EXAMPLE['dns_name'], sot.dns_name) - self.assertEqual(EXAMPLE['extra_dhcp_opts'], sot.extra_dhcp_opts) - self.assertEqual(EXAMPLE['fixed_ips'], sot.fixed_ips) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['ip_address'], sot.ip_address) - self.assertEqual(EXAMPLE['mac_address'], sot.mac_address) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['network_id'], sot.network_id) - self.assertEqual(EXAMPLE['opt_name'], sot.option_name) - self.assertEqual(EXAMPLE['opt_value'], sot.option_value) - self.assertTrue(sot.is_port_security_enabled) - self.assertEqual(EXAMPLE['qos_policy_id'], sot.qos_policy_id) - self.assertEqual(EXAMPLE['revision_number'], sot.revision_number) - self.assertEqual(EXAMPLE['security_groups'], sot.security_group_ids) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['subnet_id'], sot.subnet_id) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['trunk_details'], sot.trunk_details) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/network/v2/test_proxy.py b/openstack/tests/unit/network/v2/test_proxy.py deleted file mode 100644 index 06232cd2..00000000 --- a/openstack/tests/unit/network/v2/test_proxy.py +++ /dev/null @@ -1,1083 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import deprecation -import mock -import uuid - -from openstack import exceptions -from openstack.network.v2 import _proxy -from openstack.network.v2 import address_scope -from openstack.network.v2 import agent -from openstack.network.v2 import auto_allocated_topology -from openstack.network.v2 import availability_zone -from openstack.network.v2 import extension -from openstack.network.v2 import flavor -from openstack.network.v2 import floating_ip -from openstack.network.v2 import health_monitor -from openstack.network.v2 import listener -from openstack.network.v2 import load_balancer -from openstack.network.v2 import metering_label -from openstack.network.v2 import metering_label_rule -from openstack.network.v2 import network -from openstack.network.v2 import network_ip_availability -from openstack.network.v2 import pool -from openstack.network.v2 import pool_member -from openstack.network.v2 import port -from openstack.network.v2 import qos_bandwidth_limit_rule -from openstack.network.v2 import qos_dscp_marking_rule -from openstack.network.v2 import qos_minimum_bandwidth_rule -from openstack.network.v2 import qos_policy -from openstack.network.v2 import qos_rule_type -from openstack.network.v2 import quota -from openstack.network.v2 import rbac_policy -from openstack.network.v2 import router -from openstack.network.v2 import security_group -from openstack.network.v2 import security_group_rule -from openstack.network.v2 import segment -from openstack.network.v2 import service_profile -from openstack.network.v2 import service_provider -from openstack.network.v2 import subnet -from openstack.network.v2 import subnet_pool -from openstack.network.v2 import vpn_service -from openstack import proxy2 as proxy_base2 -from openstack.tests.unit import test_proxy_base2 - - -QOS_POLICY_ID = 'qos-policy-id-' + uuid.uuid4().hex -QOS_RULE_ID = 'qos-rule-id-' + uuid.uuid4().hex -NETWORK_ID = 'network-id-' + uuid.uuid4().hex -AGENT_ID = 'agent-id-' + uuid.uuid4().hex -ROUTER_ID = 'router-id-' + uuid.uuid4().hex - - -class TestNetworkProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestNetworkProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_address_scope_create_attrs(self): - self.verify_create(self.proxy.create_address_scope, - address_scope.AddressScope) - - def test_address_scope_delete(self): - self.verify_delete(self.proxy.delete_address_scope, - address_scope.AddressScope, - False) - - def test_address_scope_delete_ignore(self): - self.verify_delete(self.proxy.delete_address_scope, - address_scope.AddressScope, - True) - - def test_address_scope_find(self): - self.verify_find(self.proxy.find_address_scope, - address_scope.AddressScope) - - def test_address_scope_get(self): - self.verify_get(self.proxy.get_address_scope, - address_scope.AddressScope) - - def test_address_scopes(self): - self.verify_list(self.proxy.address_scopes, - address_scope.AddressScope, - paginated=False) - - def test_address_scope_update(self): - self.verify_update(self.proxy.update_address_scope, - address_scope.AddressScope) - - def test_agent_delete(self): - self.verify_delete(self.proxy.delete_agent, agent.Agent, True) - - def test_agent_get(self): - self.verify_get(self.proxy.get_agent, agent.Agent) - - def test_agents(self): - self.verify_list(self.proxy.agents, agent.Agent, - paginated=False) - - def test_agent_update(self): - self.verify_update(self.proxy.update_agent, agent.Agent) - - def test_availability_zones(self): - self.verify_list_no_kwargs(self.proxy.availability_zones, - availability_zone.AvailabilityZone, - paginated=False) - - def test_dhcp_agent_hosting_networks(self): - self.verify_list( - self.proxy.dhcp_agent_hosting_networks, - network.DHCPAgentHostingNetwork, - paginated=False, - method_kwargs={'agent': AGENT_ID}, - expected_kwargs={'agent_id': AGENT_ID} - ) - - def test_network_hosting_dhcp_agents(self): - self.verify_list( - self.proxy.network_hosting_dhcp_agents, - agent.NetworkHostingDHCPAgent, - paginated=False, - method_kwargs={'network': NETWORK_ID}, - expected_kwargs={'network_id': NETWORK_ID} - ) - - def test_extension_find(self): - self.verify_find(self.proxy.find_extension, extension.Extension) - - def test_extensions(self): - self.verify_list(self.proxy.extensions, extension.Extension, - paginated=False) - - def test_floating_ip_create_attrs(self): - self.verify_create(self.proxy.create_ip, floating_ip.FloatingIP) - - def test_floating_ip_delete(self): - self.verify_delete(self.proxy.delete_ip, floating_ip.FloatingIP, - False) - - def test_floating_ip_delete_ignore(self): - self.verify_delete(self.proxy.delete_ip, floating_ip.FloatingIP, - True) - - def test_floating_ip_find(self): - self.verify_find(self.proxy.find_ip, floating_ip.FloatingIP) - - def test_floating_ip_get(self): - self.verify_get(self.proxy.get_ip, floating_ip.FloatingIP) - - def test_ips(self): - self.verify_list(self.proxy.ips, floating_ip.FloatingIP, - paginated=False) - - def test_floating_ip_update(self): - self.verify_update(self.proxy.update_ip, floating_ip.FloatingIP) - - def test_health_monitor_create_attrs(self): - self.verify_create(self.proxy.create_health_monitor, - health_monitor.HealthMonitor) - - def test_health_monitor_delete(self): - self.verify_delete(self.proxy.delete_health_monitor, - health_monitor.HealthMonitor, False) - - def test_health_monitor_delete_ignore(self): - self.verify_delete(self.proxy.delete_health_monitor, - health_monitor.HealthMonitor, True) - - def test_health_monitor_find(self): - self.verify_find(self.proxy.find_health_monitor, - health_monitor.HealthMonitor) - - def test_health_monitor_get(self): - self.verify_get(self.proxy.get_health_monitor, - health_monitor.HealthMonitor) - - def test_health_monitors(self): - self.verify_list(self.proxy.health_monitors, - health_monitor.HealthMonitor, - paginated=False) - - def test_health_monitor_update(self): - self.verify_update(self.proxy.update_health_monitor, - health_monitor.HealthMonitor) - - def test_listener_create_attrs(self): - self.verify_create(self.proxy.create_listener, listener.Listener) - - def test_listener_delete(self): - self.verify_delete(self.proxy.delete_listener, - listener.Listener, False) - - def test_listener_delete_ignore(self): - self.verify_delete(self.proxy.delete_listener, - listener.Listener, True) - - def test_listener_find(self): - self.verify_find(self.proxy.find_listener, listener.Listener) - - def test_listener_get(self): - self.verify_get(self.proxy.get_listener, listener.Listener) - - def test_listeners(self): - self.verify_list(self.proxy.listeners, listener.Listener, - paginated=False) - - def test_listener_update(self): - self.verify_update(self.proxy.update_listener, listener.Listener) - - def test_load_balancer_create_attrs(self): - self.verify_create(self.proxy.create_load_balancer, - load_balancer.LoadBalancer) - - def test_load_balancer_delete(self): - self.verify_delete(self.proxy.delete_load_balancer, - load_balancer.LoadBalancer, False) - - def test_load_balancer_delete_ignore(self): - self.verify_delete(self.proxy.delete_load_balancer, - load_balancer.LoadBalancer, True) - - def test_load_balancer_find(self): - self.verify_find(self.proxy.find_load_balancer, - load_balancer.LoadBalancer) - - def test_load_balancer_get(self): - self.verify_get(self.proxy.get_load_balancer, - load_balancer.LoadBalancer) - - def test_load_balancers(self): - self.verify_list(self.proxy.load_balancers, - load_balancer.LoadBalancer, - paginated=False) - - def test_load_balancer_update(self): - self.verify_update(self.proxy.update_load_balancer, - load_balancer.LoadBalancer) - - def test_metering_label_create_attrs(self): - self.verify_create(self.proxy.create_metering_label, - metering_label.MeteringLabel) - - def test_metering_label_delete(self): - self.verify_delete(self.proxy.delete_metering_label, - metering_label.MeteringLabel, False) - - def test_metering_label_delete_ignore(self): - self.verify_delete(self.proxy.delete_metering_label, - metering_label.MeteringLabel, True) - - def test_metering_label_find(self): - self.verify_find(self.proxy.find_metering_label, - metering_label.MeteringLabel) - - def test_metering_label_get(self): - self.verify_get(self.proxy.get_metering_label, - metering_label.MeteringLabel) - - def test_metering_labels(self): - self.verify_list(self.proxy.metering_labels, - metering_label.MeteringLabel, - paginated=False) - - def test_metering_label_update(self): - self.verify_update(self.proxy.update_metering_label, - metering_label.MeteringLabel) - - def test_metering_label_rule_create_attrs(self): - self.verify_create(self.proxy.create_metering_label_rule, - metering_label_rule.MeteringLabelRule) - - def test_metering_label_rule_delete(self): - self.verify_delete(self.proxy.delete_metering_label_rule, - metering_label_rule.MeteringLabelRule, False) - - def test_metering_label_rule_delete_ignore(self): - self.verify_delete(self.proxy.delete_metering_label_rule, - metering_label_rule.MeteringLabelRule, True) - - def test_metering_label_rule_find(self): - self.verify_find(self.proxy.find_metering_label_rule, - metering_label_rule.MeteringLabelRule) - - def test_metering_label_rule_get(self): - self.verify_get(self.proxy.get_metering_label_rule, - metering_label_rule.MeteringLabelRule) - - def test_metering_label_rules(self): - self.verify_list(self.proxy.metering_label_rules, - metering_label_rule.MeteringLabelRule, - paginated=False) - - def test_metering_label_rule_update(self): - self.verify_update(self.proxy.update_metering_label_rule, - metering_label_rule.MeteringLabelRule) - - def test_network_create_attrs(self): - self.verify_create(self.proxy.create_network, network.Network) - - def test_network_delete(self): - self.verify_delete(self.proxy.delete_network, network.Network, False) - - def test_network_delete_ignore(self): - self.verify_delete(self.proxy.delete_network, network.Network, True) - - def test_network_find(self): - self.verify_find(self.proxy.find_network, network.Network) - - def test_network_get(self): - self.verify_get(self.proxy.get_network, network.Network) - - def test_networks(self): - self.verify_list(self.proxy.networks, network.Network, - paginated=False) - - def test_network_update(self): - self.verify_update(self.proxy.update_network, network.Network) - - def test_flavor_create_attrs(self): - self.verify_create(self.proxy.create_flavor, flavor.Flavor) - - def test_flavor_delete(self): - self.verify_delete(self.proxy.delete_flavor, flavor.Flavor, True) - - def test_flavor_find(self): - self.verify_find(self.proxy.find_flavor, flavor.Flavor) - - def test_flavor_get(self): - self.verify_get(self.proxy.get_flavor, flavor.Flavor) - - def test_flavor_update(self): - self.verify_update(self.proxy.update_flavor, flavor.Flavor) - - def test_flavors(self): - self.verify_list(self.proxy.flavors, flavor.Flavor, - paginated=True) - - def test_service_profile_create_attrs(self): - self.verify_create(self.proxy.create_service_profile, - service_profile.ServiceProfile) - - def test_service_profile_delete(self): - self.verify_delete(self.proxy.delete_service_profile, - service_profile.ServiceProfile, True) - - def test_service_profile_find(self): - self.verify_find(self.proxy.find_service_profile, - service_profile.ServiceProfile) - - def test_service_profile_get(self): - self.verify_get(self.proxy.get_service_profile, - service_profile.ServiceProfile) - - def test_service_profiles(self): - self.verify_list(self.proxy.service_profiles, - service_profile.ServiceProfile, paginated=True) - - def test_service_profile_update(self): - self.verify_update(self.proxy.update_service_profile, - service_profile.ServiceProfile) - - def test_network_ip_availability_find(self): - self.verify_find(self.proxy.find_network_ip_availability, - network_ip_availability.NetworkIPAvailability) - - def test_network_ip_availability_get(self): - self.verify_get(self.proxy.get_network_ip_availability, - network_ip_availability.NetworkIPAvailability) - - def test_network_ip_availabilities(self): - self.verify_list(self.proxy.network_ip_availabilities, - network_ip_availability.NetworkIPAvailability) - - def test_pool_member_create_attrs(self): - self.verify_create(self.proxy.create_pool_member, - pool_member.PoolMember, - method_kwargs={"pool": "test_id"}, - expected_kwargs={"pool_id": "test_id"}) - - def test_pool_member_delete(self): - self.verify_delete(self.proxy.delete_pool_member, - pool_member.PoolMember, False, - {"pool": "test_id"}, {"pool_id": "test_id"}) - - def test_pool_member_delete_ignore(self): - self.verify_delete(self.proxy.delete_pool_member, - pool_member.PoolMember, True, - {"pool": "test_id"}, {"pool_id": "test_id"}) - - def test_pool_member_find(self): - self._verify2('openstack.proxy2.BaseProxy._find', - self.proxy.find_pool_member, - method_args=["MEMBER", "POOL"], - expected_args=[pool_member.PoolMember, "MEMBER"], - expected_kwargs={"pool_id": "POOL", - "ignore_missing": True}) - - def test_pool_member_get(self): - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_pool_member, - method_args=["MEMBER", "POOL"], - expected_args=[pool_member.PoolMember, "MEMBER"], - expected_kwargs={"pool_id": "POOL"}) - - def test_pool_members(self): - self.verify_list(self.proxy.pool_members, pool_member.PoolMember, - paginated=False, method_args=["test_id"], - expected_kwargs={"pool_id": "test_id"}) - - def test_pool_member_update(self): - self._verify2("openstack.proxy2.BaseProxy._update", - self.proxy.update_pool_member, - method_args=["MEMBER", "POOL"], - expected_args=[pool_member.PoolMember, "MEMBER"], - expected_kwargs={"pool_id": "POOL"}) - - def test_pool_create_attrs(self): - self.verify_create(self.proxy.create_pool, pool.Pool) - - def test_pool_delete(self): - self.verify_delete(self.proxy.delete_pool, pool.Pool, False) - - def test_pool_delete_ignore(self): - self.verify_delete(self.proxy.delete_pool, pool.Pool, True) - - def test_pool_find(self): - self.verify_find(self.proxy.find_pool, pool.Pool) - - def test_pool_get(self): - self.verify_get(self.proxy.get_pool, pool.Pool) - - def test_pools(self): - self.verify_list(self.proxy.pools, pool.Pool, paginated=False) - - def test_pool_update(self): - self.verify_update(self.proxy.update_pool, pool.Pool) - - def test_port_create_attrs(self): - self.verify_create(self.proxy.create_port, port.Port) - - def test_port_delete(self): - self.verify_delete(self.proxy.delete_port, port.Port, False) - - def test_port_delete_ignore(self): - self.verify_delete(self.proxy.delete_port, port.Port, True) - - def test_port_find(self): - self.verify_find(self.proxy.find_port, port.Port) - - def test_port_get(self): - self.verify_get(self.proxy.get_port, port.Port) - - def test_ports(self): - self.verify_list(self.proxy.ports, port.Port, paginated=False) - - def test_port_update(self): - self.verify_update(self.proxy.update_port, port.Port) - - def test_qos_bandwidth_limit_rule_create_attrs(self): - self.verify_create( - self.proxy.create_qos_bandwidth_limit_rule, - qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - method_kwargs={'qos_policy': QOS_POLICY_ID}, - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_bandwidth_limit_rule_delete(self): - self.verify_delete( - self.proxy.delete_qos_bandwidth_limit_rule, - qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - False, input_path_args=["resource_or_id", QOS_POLICY_ID], - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_bandwidth_limit_rule_delete_ignore(self): - self.verify_delete( - self.proxy.delete_qos_bandwidth_limit_rule, - qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - True, input_path_args=["resource_or_id", QOS_POLICY_ID], - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_bandwidth_limit_rule_find(self): - policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID) - self._verify2('openstack.proxy2.BaseProxy._find', - self.proxy.find_qos_bandwidth_limit_rule, - method_args=['rule_id', policy], - expected_args=[ - qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - 'rule_id'], - expected_kwargs={'ignore_missing': True, - 'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_bandwidth_limit_rule_get(self): - self.verify_get( - self.proxy.get_qos_bandwidth_limit_rule, - qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - method_kwargs={'qos_policy': QOS_POLICY_ID}, - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_bandwidth_limit_rules(self): - self.verify_list( - self.proxy.qos_bandwidth_limit_rules, - qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - paginated=False, - method_kwargs={'qos_policy': QOS_POLICY_ID}, - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_bandwidth_limit_rule_update(self): - policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID) - self._verify2('openstack.proxy2.BaseProxy._update', - self.proxy.update_qos_bandwidth_limit_rule, - method_args=['rule_id', policy], - method_kwargs={'foo': 'bar'}, - expected_args=[ - qos_bandwidth_limit_rule.QoSBandwidthLimitRule, - 'rule_id'], - expected_kwargs={'qos_policy_id': QOS_POLICY_ID, - 'foo': 'bar'}) - - def test_qos_dscp_marking_rule_create_attrs(self): - self.verify_create( - self.proxy.create_qos_dscp_marking_rule, - qos_dscp_marking_rule.QoSDSCPMarkingRule, - method_kwargs={'qos_policy': QOS_POLICY_ID}, - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_dscp_marking_rule_delete(self): - self.verify_delete( - self.proxy.delete_qos_dscp_marking_rule, - qos_dscp_marking_rule.QoSDSCPMarkingRule, - False, input_path_args=["resource_or_id", QOS_POLICY_ID], - expected_path_args={'qos_policy_id': QOS_POLICY_ID},) - - def test_qos_dscp_marking_rule_delete_ignore(self): - self.verify_delete( - self.proxy.delete_qos_dscp_marking_rule, - qos_dscp_marking_rule.QoSDSCPMarkingRule, - True, input_path_args=["resource_or_id", QOS_POLICY_ID], - expected_path_args={'qos_policy_id': QOS_POLICY_ID}, ) - - def test_qos_dscp_marking_rule_find(self): - policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID) - self._verify2('openstack.proxy2.BaseProxy._find', - self.proxy.find_qos_dscp_marking_rule, - method_args=['rule_id', policy], - expected_args=[qos_dscp_marking_rule.QoSDSCPMarkingRule, - 'rule_id'], - expected_kwargs={'ignore_missing': True, - 'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_dscp_marking_rule_get(self): - self.verify_get( - self.proxy.get_qos_dscp_marking_rule, - qos_dscp_marking_rule.QoSDSCPMarkingRule, - method_kwargs={'qos_policy': QOS_POLICY_ID}, - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_dscp_marking_rules(self): - self.verify_list( - self.proxy.qos_dscp_marking_rules, - qos_dscp_marking_rule.QoSDSCPMarkingRule, - paginated=False, - method_kwargs={'qos_policy': QOS_POLICY_ID}, - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_dscp_marking_rule_update(self): - policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID) - self._verify2('openstack.proxy2.BaseProxy._update', - self.proxy.update_qos_dscp_marking_rule, - method_args=['rule_id', policy], - method_kwargs={'foo': 'bar'}, - expected_args=[ - qos_dscp_marking_rule.QoSDSCPMarkingRule, - 'rule_id'], - expected_kwargs={'qos_policy_id': QOS_POLICY_ID, - 'foo': 'bar'}) - - def test_qos_minimum_bandwidth_rule_create_attrs(self): - self.verify_create( - self.proxy.create_qos_minimum_bandwidth_rule, - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - method_kwargs={'qos_policy': QOS_POLICY_ID}, - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_minimum_bandwidth_rule_delete(self): - self.verify_delete( - self.proxy.delete_qos_minimum_bandwidth_rule, - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - False, input_path_args=["resource_or_id", QOS_POLICY_ID], - expected_path_args={'qos_policy_id': QOS_POLICY_ID},) - - def test_qos_minimum_bandwidth_rule_delete_ignore(self): - self.verify_delete( - self.proxy.delete_qos_minimum_bandwidth_rule, - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - True, input_path_args=["resource_or_id", QOS_POLICY_ID], - expected_path_args={'qos_policy_id': QOS_POLICY_ID}, ) - - def test_qos_minimum_bandwidth_rule_find(self): - policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID) - self._verify2('openstack.proxy2.BaseProxy._find', - self.proxy.find_qos_minimum_bandwidth_rule, - method_args=['rule_id', policy], - expected_args=[ - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - 'rule_id'], - expected_kwargs={'ignore_missing': True, - 'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_minimum_bandwidth_rule_get(self): - self.verify_get( - self.proxy.get_qos_minimum_bandwidth_rule, - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - method_kwargs={'qos_policy': QOS_POLICY_ID}, - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_minimum_bandwidth_rules(self): - self.verify_list( - self.proxy.qos_minimum_bandwidth_rules, - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - paginated=False, - method_kwargs={'qos_policy': QOS_POLICY_ID}, - expected_kwargs={'qos_policy_id': QOS_POLICY_ID}) - - def test_qos_minimum_bandwidth_rule_update(self): - policy = qos_policy.QoSPolicy.new(id=QOS_POLICY_ID) - self._verify2('openstack.proxy2.BaseProxy._update', - self.proxy.update_qos_minimum_bandwidth_rule, - method_args=['rule_id', policy], - method_kwargs={'foo': 'bar'}, - expected_args=[ - qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, - 'rule_id'], - expected_kwargs={'qos_policy_id': QOS_POLICY_ID, - 'foo': 'bar'}) - - def test_qos_policy_create_attrs(self): - self.verify_create(self.proxy.create_qos_policy, qos_policy.QoSPolicy) - - def test_qos_policy_delete(self): - self.verify_delete(self.proxy.delete_qos_policy, qos_policy.QoSPolicy, - False) - - def test_qos_policy_delete_ignore(self): - self.verify_delete(self.proxy.delete_qos_policy, qos_policy.QoSPolicy, - True) - - def test_qos_policy_find(self): - self.verify_find(self.proxy.find_qos_policy, qos_policy.QoSPolicy) - - def test_qos_policy_get(self): - self.verify_get(self.proxy.get_qos_policy, qos_policy.QoSPolicy) - - def test_qos_policies(self): - self.verify_list(self.proxy.qos_policies, qos_policy.QoSPolicy, - paginated=False) - - def test_qos_policy_update(self): - self.verify_update(self.proxy.update_qos_policy, qos_policy.QoSPolicy) - - def test_qos_rule_types(self): - self.verify_list(self.proxy.qos_rule_types, qos_rule_type.QoSRuleType, - paginated=False) - - def test_quota_delete(self): - self.verify_delete(self.proxy.delete_quota, quota.Quota, False) - - def test_quota_delete_ignore(self): - self.verify_delete(self.proxy.delete_quota, quota.Quota, True) - - def test_quota_get(self): - self.verify_get(self.proxy.get_quota, quota.Quota) - - @mock.patch.object(proxy_base2.BaseProxy, "_get_resource") - def test_quota_default_get(self, mock_get): - fake_quota = mock.Mock(project_id='PROJECT') - mock_get.return_value = fake_quota - self._verify2("openstack.proxy2.BaseProxy._get", - self.proxy.get_quota_default, - method_args=['QUOTA_ID'], - expected_args=[quota.QuotaDefault], - expected_kwargs={'project': fake_quota.id, - 'requires_id': False}) - mock_get.assert_called_once_with(quota.Quota, 'QUOTA_ID') - - def test_quotas(self): - self.verify_list(self.proxy.quotas, quota.Quota, paginated=False) - - def test_quota_update(self): - self.verify_update(self.proxy.update_quota, quota.Quota) - - def test_rbac_policy_create_attrs(self): - self.verify_create(self.proxy.create_rbac_policy, - rbac_policy.RBACPolicy) - - def test_rbac_policy_delete(self): - self.verify_delete(self.proxy.delete_rbac_policy, - rbac_policy.RBACPolicy, False) - - def test_rbac_policy_delete_ignore(self): - self.verify_delete(self.proxy.delete_rbac_policy, - rbac_policy.RBACPolicy, True) - - def test_rbac_policy_find(self): - self.verify_find(self.proxy.find_rbac_policy, rbac_policy.RBACPolicy) - - def test_rbac_policy_get(self): - self.verify_get(self.proxy.get_rbac_policy, rbac_policy.RBACPolicy) - - def test_rbac_policies(self): - self.verify_list(self.proxy.rbac_policies, - rbac_policy.RBACPolicy, paginated=False) - - def test_rbac_policy_update(self): - self.verify_update(self.proxy.update_rbac_policy, - rbac_policy.RBACPolicy) - - def test_router_create_attrs(self): - self.verify_create(self.proxy.create_router, router.Router) - - def test_router_delete(self): - self.verify_delete(self.proxy.delete_router, router.Router, False) - - def test_router_delete_ignore(self): - self.verify_delete(self.proxy.delete_router, router.Router, True) - - def test_router_find(self): - self.verify_find(self.proxy.find_router, router.Router) - - def test_router_get(self): - self.verify_get(self.proxy.get_router, router.Router) - - def test_routers(self): - self.verify_list(self.proxy.routers, router.Router, paginated=False) - - def test_router_update(self): - self.verify_update(self.proxy.update_router, router.Router) - - @mock.patch.object(proxy_base2.BaseProxy, '_get_resource') - @mock.patch.object(router.Router, 'add_interface') - def test_add_interface_to_router_with_port(self, mock_add_interface, - mock_get): - x_router = router.Router.new(id="ROUTER_ID") - mock_get.return_value = x_router - - self._verify("openstack.network.v2.router.Router.add_interface", - self.proxy.add_interface_to_router, - method_args=["FAKE_ROUTER"], - method_kwargs={"port_id": "PORT"}, - expected_kwargs={"port_id": "PORT"}) - mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER") - - @mock.patch.object(proxy_base2.BaseProxy, '_get_resource') - @mock.patch.object(router.Router, 'add_interface') - def test_add_interface_to_router_with_subnet(self, mock_add_interface, - mock_get): - x_router = router.Router.new(id="ROUTER_ID") - mock_get.return_value = x_router - - self._verify("openstack.network.v2.router.Router.add_interface", - self.proxy.add_interface_to_router, - method_args=["FAKE_ROUTER"], - method_kwargs={"subnet_id": "SUBNET"}, - expected_kwargs={"subnet_id": "SUBNET"}) - mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER") - - @mock.patch.object(proxy_base2.BaseProxy, '_get_resource') - @mock.patch.object(router.Router, 'remove_interface') - def test_remove_interface_from_router_with_port(self, mock_remove, - mock_get): - x_router = router.Router.new(id="ROUTER_ID") - mock_get.return_value = x_router - - self._verify("openstack.network.v2.router.Router.remove_interface", - self.proxy.remove_interface_from_router, - method_args=["FAKE_ROUTER"], - method_kwargs={"port_id": "PORT"}, - expected_kwargs={"port_id": "PORT"}) - mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER") - - @mock.patch.object(proxy_base2.BaseProxy, '_get_resource') - @mock.patch.object(router.Router, 'remove_interface') - def test_remove_interface_from_router_with_subnet(self, mock_remove, - mock_get): - x_router = router.Router.new(id="ROUTER_ID") - mock_get.return_value = x_router - - self._verify("openstack.network.v2.router.Router.remove_interface", - self.proxy.remove_interface_from_router, - method_args=["FAKE_ROUTER"], - method_kwargs={"subnet_id": "SUBNET"}, - expected_kwargs={"subnet_id": "SUBNET"}) - mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER") - - @mock.patch.object(proxy_base2.BaseProxy, '_get_resource') - @mock.patch.object(router.Router, 'add_gateway') - def test_add_gateway_to_router(self, mock_add, mock_get): - x_router = router.Router.new(id="ROUTER_ID") - mock_get.return_value = x_router - - self._verify("openstack.network.v2.router.Router.add_gateway", - self.proxy.add_gateway_to_router, - method_args=["FAKE_ROUTER"], - method_kwargs={"foo": "bar"}, - expected_kwargs={"foo": "bar"}) - mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER") - - @mock.patch.object(proxy_base2.BaseProxy, '_get_resource') - @mock.patch.object(router.Router, 'remove_gateway') - def test_remove_gateway_from_router(self, mock_remove, mock_get): - x_router = router.Router.new(id="ROUTER_ID") - mock_get.return_value = x_router - - self._verify("openstack.network.v2.router.Router.remove_gateway", - self.proxy.remove_gateway_from_router, - method_args=["FAKE_ROUTER"], - method_kwargs={"foo": "bar"}, - expected_kwargs={"foo": "bar"}) - mock_get.assert_called_once_with(router.Router, "FAKE_ROUTER") - - def test_router_hosting_l3_agents_list(self): - self.verify_list( - self.proxy.routers_hosting_l3_agents, - agent.RouterL3Agent, - paginated=False, - method_kwargs={'router': ROUTER_ID}, - expected_kwargs={'router_id': ROUTER_ID}, - ) - - def test_agent_hosted_routers_list(self): - self.verify_list( - self.proxy.agent_hosted_routers, - router.L3AgentRouter, - paginated=False, - method_kwargs={'agent': AGENT_ID}, - expected_kwargs={'agent_id': AGENT_ID}, - ) - - def test_security_group_create_attrs(self): - self.verify_create(self.proxy.create_security_group, - security_group.SecurityGroup) - - def test_security_group_delete(self): - self.verify_delete(self.proxy.delete_security_group, - security_group.SecurityGroup, False) - - def test_security_group_delete_ignore(self): - self.verify_delete(self.proxy.delete_security_group, - security_group.SecurityGroup, True) - - def test_security_group_find(self): - self.verify_find(self.proxy.find_security_group, - security_group.SecurityGroup) - - def test_security_group_get(self): - self.verify_get(self.proxy.get_security_group, - security_group.SecurityGroup) - - def test_security_groups(self): - self.verify_list(self.proxy.security_groups, - security_group.SecurityGroup, - paginated=False) - - def test_security_group_update(self): - self.verify_update(self.proxy.update_security_group, - security_group.SecurityGroup) - - @deprecation.fail_if_not_removed - def test_security_group_open_port(self): - mock_class = 'openstack.network.v2._proxy.Proxy' - mock_method = mock_class + '.create_security_group_rule' - expected_result = 'result' - sgid = 1 - port = 2 - with mock.patch(mock_method) as mocked: - mocked.return_value = expected_result - actual = self.proxy.security_group_open_port(sgid, port) - self.assertEqual(expected_result, actual) - expected_args = { - 'direction': 'ingress', - 'protocol': 'tcp', - 'remote_ip_prefix': '0.0.0.0/0', - 'port_range_max': port, - 'security_group_id': sgid, - 'port_range_min': port, - 'ethertype': 'IPv4', - } - mocked.assert_called_with(**expected_args) - - @deprecation.fail_if_not_removed - def test_security_group_allow_ping(self): - mock_class = 'openstack.network.v2._proxy.Proxy' - mock_method = mock_class + '.create_security_group_rule' - expected_result = 'result' - sgid = 1 - with mock.patch(mock_method) as mocked: - mocked.return_value = expected_result - actual = self.proxy.security_group_allow_ping(sgid) - self.assertEqual(expected_result, actual) - expected_args = { - 'direction': 'ingress', - 'protocol': 'icmp', - 'remote_ip_prefix': '0.0.0.0/0', - 'port_range_max': None, - 'security_group_id': sgid, - 'port_range_min': None, - 'ethertype': 'IPv4', - } - mocked.assert_called_with(**expected_args) - - def test_security_group_rule_create_attrs(self): - self.verify_create(self.proxy.create_security_group_rule, - security_group_rule.SecurityGroupRule) - - def test_security_group_rule_delete(self): - self.verify_delete(self.proxy.delete_security_group_rule, - security_group_rule.SecurityGroupRule, False) - - def test_security_group_rule_delete_ignore(self): - self.verify_delete(self.proxy.delete_security_group_rule, - security_group_rule.SecurityGroupRule, True) - - def test_security_group_rule_find(self): - self.verify_find(self.proxy.find_security_group_rule, - security_group_rule.SecurityGroupRule) - - def test_security_group_rule_get(self): - self.verify_get(self.proxy.get_security_group_rule, - security_group_rule.SecurityGroupRule) - - def test_security_group_rules(self): - self.verify_list(self.proxy.security_group_rules, - security_group_rule.SecurityGroupRule, - paginated=False) - - def test_segment_create_attrs(self): - self.verify_create(self.proxy.create_segment, segment.Segment) - - def test_segment_delete(self): - self.verify_delete(self.proxy.delete_segment, segment.Segment, False) - - def test_segment_delete_ignore(self): - self.verify_delete(self.proxy.delete_segment, segment.Segment, True) - - def test_segment_find(self): - self.verify_find(self.proxy.find_segment, segment.Segment) - - def test_segment_get(self): - self.verify_get(self.proxy.get_segment, segment.Segment) - - def test_segments(self): - self.verify_list(self.proxy.segments, segment.Segment, paginated=False) - - def test_segment_update(self): - self.verify_update(self.proxy.update_segment, segment.Segment) - - def test_subnet_create_attrs(self): - self.verify_create(self.proxy.create_subnet, subnet.Subnet) - - def test_subnet_delete(self): - self.verify_delete(self.proxy.delete_subnet, subnet.Subnet, False) - - def test_subnet_delete_ignore(self): - self.verify_delete(self.proxy.delete_subnet, subnet.Subnet, True) - - def test_subnet_find(self): - self.verify_find(self.proxy.find_subnet, subnet.Subnet) - - def test_subnet_get(self): - self.verify_get(self.proxy.get_subnet, subnet.Subnet) - - def test_subnets(self): - self.verify_list(self.proxy.subnets, subnet.Subnet, paginated=False) - - def test_subnet_update(self): - self.verify_update(self.proxy.update_subnet, subnet.Subnet) - - def test_subnet_pool_create_attrs(self): - self.verify_create(self.proxy.create_subnet_pool, - subnet_pool.SubnetPool) - - def test_subnet_pool_delete(self): - self.verify_delete(self.proxy.delete_subnet_pool, - subnet_pool.SubnetPool, False) - - def test_subnet_pool_delete_ignore(self): - self.verify_delete(self.proxy.delete_subnet_pool, - subnet_pool.SubnetPool, True) - - def test_subnet_pool_find(self): - self.verify_find(self.proxy.find_subnet_pool, - subnet_pool.SubnetPool) - - def test_subnet_pool_get(self): - self.verify_get(self.proxy.get_subnet_pool, - subnet_pool.SubnetPool) - - def test_subnet_pools(self): - self.verify_list(self.proxy.subnet_pools, - subnet_pool.SubnetPool, - paginated=False) - - def test_subnet_pool_update(self): - self.verify_update(self.proxy.update_subnet_pool, - subnet_pool.SubnetPool) - - def test_vpn_service_create_attrs(self): - self.verify_create(self.proxy.create_vpn_service, - vpn_service.VPNService) - - def test_vpn_service_delete(self): - self.verify_delete(self.proxy.delete_vpn_service, - vpn_service.VPNService, False) - - def test_vpn_service_delete_ignore(self): - self.verify_delete(self.proxy.delete_vpn_service, - vpn_service.VPNService, True) - - def test_vpn_service_find(self): - self.verify_find(self.proxy.find_vpn_service, - vpn_service.VPNService) - - def test_vpn_service_get(self): - self.verify_get(self.proxy.get_vpn_service, vpn_service.VPNService) - - def test_vpn_services(self): - self.verify_list(self.proxy.vpn_services, vpn_service.VPNService, - paginated=False) - - def test_vpn_service_update(self): - self.verify_update(self.proxy.update_vpn_service, - vpn_service.VPNService) - - def test_service_provider(self): - self.verify_list(self.proxy.service_providers, - service_provider.ServiceProvider, - paginated=False) - - def test_auto_allocated_topology_get(self): - self.verify_get(self.proxy.get_auto_allocated_topology, - auto_allocated_topology.AutoAllocatedTopology) - - def test_auto_allocated_topology_delete(self): - self.verify_delete(self.proxy.delete_auto_allocated_topology, - auto_allocated_topology.AutoAllocatedTopology, - False) - - def test_auto_allocated_topology_delete_ignore(self): - self.verify_delete(self.proxy.delete_auto_allocated_topology, - auto_allocated_topology.AutoAllocatedTopology, - True) - - def test_validate_topology(self): - self.verify_get(self.proxy.validate_auto_allocated_topology, - auto_allocated_topology.ValidateTopology, - value=[mock.sentinel.project_id], - expected_args=[ - auto_allocated_topology.ValidateTopology], - expected_kwargs={"project": mock.sentinel.project_id, - "requires_id": False}) - - def test_set_tags(self): - x_network = network.Network.new(id='NETWORK_ID') - self._verify('openstack.network.v2.network.Network.set_tags', - self.proxy.set_tags, - method_args=[x_network, ['TAG1', 'TAG2']], - expected_args=[['TAG1', 'TAG2']], - expected_result=mock.sentinel.result_set_tags) - - @mock.patch('openstack.network.v2.network.Network.set_tags') - def test_set_tags_resource_without_tag_suport(self, mock_set_tags): - no_tag_resource = object() - self.assertRaises(exceptions.InvalidRequest, - self.proxy.set_tags, - no_tag_resource, ['TAG1', 'TAG2']) - self.assertEqual(0, mock_set_tags.call_count) diff --git a/openstack/tests/unit/network/v2/test_qos_bandwidth_limit_rule.py b/openstack/tests/unit/network/v2/test_qos_bandwidth_limit_rule.py deleted file mode 100644 index f6fc9fd3..00000000 --- a/openstack/tests/unit/network/v2/test_qos_bandwidth_limit_rule.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools -import uuid - -from openstack.network.v2 import qos_bandwidth_limit_rule - -EXAMPLE = { - 'id': 'IDENTIFIER', - 'qos_policy_id': 'qos-policy-' + uuid.uuid4().hex, - 'max_kbps': 1500, - 'max_burst_kbps': 1200, - 'direction': 'egress', -} - - -class TestQoSBandwidthLimitRule(testtools.TestCase): - - def test_basic(self): - sot = qos_bandwidth_limit_rule.QoSBandwidthLimitRule() - self.assertEqual('bandwidth_limit_rule', sot.resource_key) - self.assertEqual('bandwidth_limit_rules', sot.resources_key) - self.assertEqual( - '/qos/policies/%(qos_policy_id)s/bandwidth_limit_rules', - sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = qos_bandwidth_limit_rule.QoSBandwidthLimitRule(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['qos_policy_id'], sot.qos_policy_id) - self.assertEqual(EXAMPLE['max_kbps'], sot.max_kbps) - self.assertEqual(EXAMPLE['max_burst_kbps'], sot.max_burst_kbps) - self.assertEqual(EXAMPLE['direction'], sot.direction) diff --git a/openstack/tests/unit/network/v2/test_qos_dscp_marking_rule.py b/openstack/tests/unit/network/v2/test_qos_dscp_marking_rule.py deleted file mode 100644 index 46bffd1c..00000000 --- a/openstack/tests/unit/network/v2/test_qos_dscp_marking_rule.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools -import uuid - -from openstack.network.v2 import qos_dscp_marking_rule - -EXAMPLE = { - 'id': 'IDENTIFIER', - 'qos_policy_id': 'qos-policy-' + uuid.uuid4().hex, - 'dscp_mark': 40, -} - - -class TestQoSDSCPMarkingRule(testtools.TestCase): - - def test_basic(self): - sot = qos_dscp_marking_rule.QoSDSCPMarkingRule() - self.assertEqual('dscp_marking_rule', sot.resource_key) - self.assertEqual('dscp_marking_rules', sot.resources_key) - self.assertEqual('/qos/policies/%(qos_policy_id)s/dscp_marking_rules', - sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = qos_dscp_marking_rule.QoSDSCPMarkingRule(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['qos_policy_id'], sot.qos_policy_id) - self.assertEqual(EXAMPLE['dscp_mark'], sot.dscp_mark) diff --git a/openstack/tests/unit/network/v2/test_qos_minimum_bandwidth_rule.py b/openstack/tests/unit/network/v2/test_qos_minimum_bandwidth_rule.py deleted file mode 100644 index f6b2f442..00000000 --- a/openstack/tests/unit/network/v2/test_qos_minimum_bandwidth_rule.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools -import uuid - -from openstack.network.v2 import qos_minimum_bandwidth_rule - -EXAMPLE = { - 'id': 'IDENTIFIER', - 'qos_policy_id': 'qos-policy-' + uuid.uuid4().hex, - 'min_kbps': 1500, - 'direction': 'egress', -} - - -class TestQoSMinimumBandwidthRule(testtools.TestCase): - - def test_basic(self): - sot = qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule() - self.assertEqual('minimum_bandwidth_rule', sot.resource_key) - self.assertEqual('minimum_bandwidth_rules', sot.resources_key) - self.assertEqual( - '/qos/policies/%(qos_policy_id)s/minimum_bandwidth_rules', - sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['qos_policy_id'], sot.qos_policy_id) - self.assertEqual(EXAMPLE['min_kbps'], sot.min_kbps) - self.assertEqual(EXAMPLE['direction'], sot.direction) diff --git a/openstack/tests/unit/network/v2/test_qos_policy.py b/openstack/tests/unit/network/v2/test_qos_policy.py deleted file mode 100644 index 7c5e6c4d..00000000 --- a/openstack/tests/unit/network/v2/test_qos_policy.py +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools -import uuid - -from openstack.network.v2 import qos_policy - -EXAMPLE = { - 'id': 'IDENTIFIER', - 'description': 'QoS policy description', - 'name': 'qos-policy-name', - 'shared': True, - 'tenant_id': '2', - 'rules': [uuid.uuid4().hex], - 'is_default': False -} - - -class TestQoSPolicy(testtools.TestCase): - - def test_basic(self): - sot = qos_policy.QoSPolicy() - self.assertEqual('policy', sot.resource_key) - self.assertEqual('policies', sot.resources_key) - self.assertEqual('/qos/policies', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = qos_policy.QoSPolicy(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertTrue(sot.is_shared) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['rules'], sot.rules) - self.assertEqual(EXAMPLE['is_default'], sot.is_default) diff --git a/openstack/tests/unit/network/v2/test_qos_rule_type.py b/openstack/tests/unit/network/v2/test_qos_rule_type.py deleted file mode 100644 index 59b2f6bf..00000000 --- a/openstack/tests/unit/network/v2/test_qos_rule_type.py +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import qos_rule_type - -EXAMPLE = { - 'type': 'bandwidth_limit', -} - - -class TestQoSRuleType(testtools.TestCase): - - def test_basic(self): - sot = qos_rule_type.QoSRuleType() - self.assertEqual('rule_type', sot.resource_key) - self.assertEqual('rule_types', sot.resources_key) - self.assertEqual('/qos/rule-types', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = qos_rule_type.QoSRuleType(**EXAMPLE) - self.assertEqual(EXAMPLE['type'], sot.type) diff --git a/openstack/tests/unit/network/v2/test_quota.py b/openstack/tests/unit/network/v2/test_quota.py deleted file mode 100644 index 20f55eff..00000000 --- a/openstack/tests/unit/network/v2/test_quota.py +++ /dev/null @@ -1,117 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import quota -from openstack import resource2 as resource - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'floatingip': 1, - 'network': 2, - 'port': 3, - 'tenant_id': '4', - 'router': 5, - 'subnet': 6, - 'subnetpool': 7, - 'security_group_rule': 8, - 'security_group': 9, - 'rbac_policy': -1, - 'healthmonitor': 11, - 'listener': 12, - 'loadbalancer': 13, - 'l7policy': 14, - 'pool': 15, -} - - -class TestQuota(testtools.TestCase): - - def test_basic(self): - sot = quota.Quota() - self.assertEqual('quota', sot.resource_key) - self.assertEqual('quotas', sot.resources_key) - self.assertEqual('/quotas', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = quota.Quota(**EXAMPLE) - self.assertEqual(EXAMPLE['floatingip'], sot.floating_ips) - self.assertEqual(EXAMPLE['network'], sot.networks) - self.assertEqual(EXAMPLE['port'], sot.ports) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['router'], sot.routers) - self.assertEqual(EXAMPLE['subnet'], sot.subnets) - self.assertEqual(EXAMPLE['subnetpool'], sot.subnet_pools) - self.assertEqual(EXAMPLE['security_group_rule'], - sot.security_group_rules) - self.assertEqual(EXAMPLE['security_group'], sot.security_groups) - self.assertEqual(EXAMPLE['rbac_policy'], sot.rbac_policies) - self.assertEqual(EXAMPLE['healthmonitor'], sot.health_monitors) - self.assertEqual(EXAMPLE['listener'], sot.listeners) - self.assertEqual(EXAMPLE['loadbalancer'], sot.load_balancers) - self.assertEqual(EXAMPLE['l7policy'], sot.l7_policies) - self.assertEqual(EXAMPLE['pool'], sot.pools) - - def test_prepare_request(self): - body = {'id': 'ABCDEFGH', 'network': '12345'} - quota_obj = quota.Quota(**body) - response = quota_obj._prepare_request() - self.assertNotIn('id', response) - - def test_alternate_id(self): - my_tenant_id = 'my-tenant-id' - body = {'tenant_id': my_tenant_id, 'network': 12345} - quota_obj = quota.Quota(**body) - self.assertEqual(my_tenant_id, - resource.Resource._get_id(quota_obj)) - - -class TestQuotaDefault(testtools.TestCase): - - def test_basic(self): - sot = quota.QuotaDefault() - self.assertEqual('quota', sot.resource_key) - self.assertEqual('quotas', sot.resources_key) - self.assertEqual('/quotas/%(project)s/default', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = quota.QuotaDefault(project='FAKE_PROJECT', **EXAMPLE) - self.assertEqual(EXAMPLE['floatingip'], sot.floating_ips) - self.assertEqual(EXAMPLE['network'], sot.networks) - self.assertEqual(EXAMPLE['port'], sot.ports) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['router'], sot.routers) - self.assertEqual(EXAMPLE['subnet'], sot.subnets) - self.assertEqual(EXAMPLE['subnetpool'], sot.subnet_pools) - self.assertEqual(EXAMPLE['security_group_rule'], - sot.security_group_rules) - self.assertEqual(EXAMPLE['security_group'], sot.security_groups) - self.assertEqual(EXAMPLE['rbac_policy'], sot.rbac_policies) - self.assertEqual(EXAMPLE['healthmonitor'], sot.health_monitors) - self.assertEqual(EXAMPLE['listener'], sot.listeners) - self.assertEqual(EXAMPLE['loadbalancer'], sot.load_balancers) - self.assertEqual(EXAMPLE['l7policy'], sot.l7_policies) - self.assertEqual(EXAMPLE['pool'], sot.pools) - self.assertEqual('FAKE_PROJECT', sot.project) diff --git a/openstack/tests/unit/network/v2/test_rbac_policy.py b/openstack/tests/unit/network/v2/test_rbac_policy.py deleted file mode 100644 index c8189c9c..00000000 --- a/openstack/tests/unit/network/v2/test_rbac_policy.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import rbac_policy - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'action': 'access_as_shared', - 'object_id': IDENTIFIER, - 'object_type': 'network', - 'target_tenant': '10', - 'tenant_id': '5', -} - - -class TestRBACPolicy(testtools.TestCase): - - def test_basic(self): - sot = rbac_policy.RBACPolicy() - self.assertEqual('rbac_policy', sot.resource_key) - self.assertEqual('rbac_policies', sot.resources_key) - self.assertEqual('/rbac-policies', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = rbac_policy.RBACPolicy(**EXAMPLE) - self.assertEqual(EXAMPLE['action'], sot.action) - self.assertEqual(EXAMPLE['object_id'], sot.object_id) - self.assertEqual(EXAMPLE['object_type'], sot.object_type) - self.assertEqual(EXAMPLE['target_tenant'], sot.target_project_id) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) diff --git a/openstack/tests/unit/network/v2/test_router.py b/openstack/tests/unit/network/v2/test_router.py deleted file mode 100644 index 5fb87f16..00000000 --- a/openstack/tests/unit/network/v2/test_router.py +++ /dev/null @@ -1,221 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.network.v2 import router - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'admin_state_up': True, - 'availability_zone_hints': ['1'], - 'availability_zones': ['2'], - 'created_at': 'timestamp1', - 'description': '3', - 'distributed': False, - 'external_gateway_info': {'4': 4}, - 'flavor_id': '5', - 'ha': False, - 'id': IDENTIFIER, - 'name': '6', - 'revision': 7, - 'routes': ['8'], - 'status': '9', - 'tenant_id': '10', - 'updated_at': 'timestamp2', -} - -EXAMPLE_WITH_OPTIONAL = { - 'admin_state_up': False, - 'availability_zone_hints': ['zone-1', 'zone-2'], - 'availability_zones': ['zone-2'], - 'description': 'description', - 'distributed': True, - 'external_gateway_info': { - 'network_id': '1', - 'enable_snat': True, - 'external_fixed_ips': [] - }, - 'ha': True, - 'id': IDENTIFIER, - 'name': 'router1', - 'routes': [{ - 'nexthop': '172.24.4.20', - 'destination': '10.0.3.1/24' - }], - 'status': 'ACTIVE', - 'tenant_id': '2', -} - - -class TestRouter(testtools.TestCase): - - def test_basic(self): - sot = router.Router() - self.assertEqual('router', sot.resource_key) - self.assertEqual('routers', sot.resources_key) - self.assertEqual('/routers', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = router.Router(**EXAMPLE) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['availability_zone_hints'], - sot.availability_zone_hints) - self.assertEqual(EXAMPLE['availability_zones'], - sot.availability_zones) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertFalse(sot.is_distributed) - self.assertEqual(EXAMPLE['external_gateway_info'], - sot.external_gateway_info) - self.assertEqual(EXAMPLE['flavor_id'], sot.flavor_id) - self.assertFalse(sot.is_ha) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['revision'], sot.revision_number) - self.assertEqual(EXAMPLE['routes'], sot.routes) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) - - def test_make_it_with_optional(self): - sot = router.Router(**EXAMPLE_WITH_OPTIONAL) - self.assertFalse(sot.is_admin_state_up) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['availability_zone_hints'], - sot.availability_zone_hints) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['availability_zones'], - sot.availability_zones) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['description'], - sot.description) - self.assertTrue(sot.is_distributed) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['external_gateway_info'], - sot.external_gateway_info) - self.assertTrue(sot.is_ha) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['id'], sot.id) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['name'], sot.name) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['routes'], sot.routes) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['status'], sot.status) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['tenant_id'], sot.project_id) - - def test_add_interface_subnet(self): - # Add subnet to a router - sot = router.Router(**EXAMPLE) - response = mock.Mock() - response.body = {"subnet_id": "3", "port_id": "2"} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.put = mock.Mock(return_value=response) - body = {"subnet_id": "3"} - self.assertEqual(response.body, sot.add_interface(sess, **body)) - - url = 'routers/IDENTIFIER/add_router_interface' - sess.put.assert_called_with(url, endpoint_filter=sot.service, - json=body) - - def test_add_interface_port(self): - # Add port to a router - sot = router.Router(**EXAMPLE) - response = mock.Mock() - response.body = {"subnet_id": "3", "port_id": "3"} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.put = mock.Mock(return_value=response) - - body = {"port_id": "3"} - self.assertEqual(response.body, sot.add_interface(sess, **body)) - - url = 'routers/IDENTIFIER/add_router_interface' - sess.put.assert_called_with(url, endpoint_filter=sot.service, - json=body) - - def test_remove_interface_subnet(self): - # Remove subnet from a router - sot = router.Router(**EXAMPLE) - response = mock.Mock() - response.body = {"subnet_id": "3", "port_id": "2"} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.put = mock.Mock(return_value=response) - body = {"subnet_id": "3"} - self.assertEqual(response.body, sot.remove_interface(sess, **body)) - - url = 'routers/IDENTIFIER/remove_router_interface' - sess.put.assert_called_with(url, endpoint_filter=sot.service, - json=body) - - def test_remove_interface_port(self): - # Remove port from a router - sot = router.Router(**EXAMPLE) - response = mock.Mock() - response.body = {"subnet_id": "3", "port_id": "3"} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.put = mock.Mock(return_value=response) - body = {"network_id": 3, "enable_snat": True} - self.assertEqual(response.body, sot.remove_interface(sess, **body)) - - url = 'routers/IDENTIFIER/remove_router_interface' - sess.put.assert_called_with(url, endpoint_filter=sot.service, - json=body) - - def test_add_router_gateway(self): - # Add gateway to a router - sot = router.Router(**EXAMPLE_WITH_OPTIONAL) - response = mock.Mock() - response.body = {"network_id": "3", "enable_snat": True} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.put = mock.Mock(return_value=response) - body = {"network_id": 3, "enable_snat": True} - self.assertEqual(response.body, sot.add_gateway(sess, **body)) - - url = 'routers/IDENTIFIER/add_gateway_router' - sess.put.assert_called_with(url, endpoint_filter=sot.service, - json=body) - - def test_remove_router_gateway(self): - # Remove gateway to a router - sot = router.Router(**EXAMPLE_WITH_OPTIONAL) - response = mock.Mock() - response.body = {"network_id": "3", "enable_snat": True} - response.json = mock.Mock(return_value=response.body) - sess = mock.Mock() - sess.put = mock.Mock(return_value=response) - body = {"network_id": 3, "enable_snat": True} - self.assertEqual(response.body, sot.remove_gateway(sess, **body)) - - url = 'routers/IDENTIFIER/remove_gateway_router' - sess.put.assert_called_with(url, endpoint_filter=sot.service, - json=body) - - -class TestL3AgentRouters(testtools.TestCase): - - def test_basic(self): - sot = router.L3AgentRouter() - self.assertEqual('router', sot.resource_key) - self.assertEqual('routers', sot.resources_key) - self.assertEqual('/agents/%(agent_id)s/l3-routers', sot.base_path) - self.assertEqual('l3-router', sot.resource_name) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_retrieve) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) diff --git a/openstack/tests/unit/network/v2/test_security_group.py b/openstack/tests/unit/network/v2/test_security_group.py deleted file mode 100644 index 2d18edb0..00000000 --- a/openstack/tests/unit/network/v2/test_security_group.py +++ /dev/null @@ -1,89 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import security_group - -IDENTIFIER = 'IDENTIFIER' -RULES = [ - { - "remote_group_id": None, - "direction": "egress", - "remote_ip_prefix": None, - "protocol": None, - "ethertype": - "IPv6", - "tenant_id": "4", - "port_range_max": None, - "port_range_min": None, - "id": "5", - "security_group_id": IDENTIFIER, - "created_at": "2016-10-04T12:14:57.233772", - "updated_at": "2016-10-12T12:15:34.233222", - "revision_number": 6, - }, - { - "remote_group_id": "9", - "direction": "ingress", - "remote_ip_prefix": None, - "protocol": None, - "ethertype": "IPv6", - "tenant_id": "4", - "port_range_max": None, - "port_range_min": None, - "id": "6", - "security_group_id": IDENTIFIER, - "created_at": "2016-10-04T12:14:57.233772", - "updated_at": "2016-10-12T12:15:34.233222", - "revision_number": 7, - }, -] - -EXAMPLE = { - 'created_at': '2016-10-04T12:14:57.233772', - 'description': '1', - 'id': IDENTIFIER, - 'name': '2', - 'revision_number': 3, - 'security_group_rules': RULES, - 'tenant_id': '4', - 'updated_at': '2016-10-14T12:16:57.233772', -} - - -class TestSecurityGroup(testtools.TestCase): - - def test_basic(self): - sot = security_group.SecurityGroup() - self.assertEqual('security_group', sot.resource_key) - self.assertEqual('security_groups', sot.resources_key) - self.assertEqual('/security-groups', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = security_group.SecurityGroup(**EXAMPLE) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['revision_number'], sot.revision_number) - self.assertEqual(EXAMPLE['security_group_rules'], - sot.security_group_rules) - self.assertEqual(dict, type(sot.security_group_rules[0])) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/network/v2/test_security_group_rule.py b/openstack/tests/unit/network/v2/test_security_group_rule.py deleted file mode 100644 index 5ad00d91..00000000 --- a/openstack/tests/unit/network/v2/test_security_group_rule.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import security_group_rule - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'created_at': '0', - 'description': '1', - 'direction': '2', - 'ethertype': '3', - 'id': IDENTIFIER, - 'port_range_max': 4, - 'port_range_min': 5, - 'protocol': '6', - 'remote_group_id': '7', - 'remote_ip_prefix': '8', - 'revision_number': 9, - 'security_group_id': '10', - 'tenant_id': '11', - 'updated_at': '12' -} - - -class TestSecurityGroupRule(testtools.TestCase): - - def test_basic(self): - sot = security_group_rule.SecurityGroupRule() - self.assertEqual('security_group_rule', sot.resource_key) - self.assertEqual('security_group_rules', sot.resources_key) - self.assertEqual('/security-group-rules', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = security_group_rule.SecurityGroupRule(**EXAMPLE) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['direction'], sot.direction) - self.assertEqual(EXAMPLE['ethertype'], sot.ether_type) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['port_range_max'], sot.port_range_max) - self.assertEqual(EXAMPLE['port_range_min'], sot.port_range_min) - self.assertEqual(EXAMPLE['protocol'], sot.protocol) - self.assertEqual(EXAMPLE['remote_group_id'], sot.remote_group_id) - self.assertEqual(EXAMPLE['remote_ip_prefix'], sot.remote_ip_prefix) - self.assertEqual(EXAMPLE['revision_number'], sot.revision_number) - self.assertEqual(EXAMPLE['security_group_id'], sot.security_group_id) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/network/v2/test_segment.py b/openstack/tests/unit/network/v2/test_segment.py deleted file mode 100644 index 307f7568..00000000 --- a/openstack/tests/unit/network/v2/test_segment.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import segment - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'description': '1', - 'id': IDENTIFIER, - 'name': '2', - 'network_id': '3', - 'network_type': '4', - 'physical_network': '5', - 'segmentation_id': 6, -} - - -class TestSegment(testtools.TestCase): - - def test_basic(self): - sot = segment.Segment() - self.assertEqual('segment', sot.resource_key) - self.assertEqual('segments', sot.resources_key) - self.assertEqual('/segments', sot.base_path) - self.assertEqual('network', sot.service.service_type) - - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = segment.Segment(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['network_id'], sot.network_id) - self.assertEqual(EXAMPLE['network_type'], sot.network_type) - self.assertEqual(EXAMPLE['physical_network'], sot.physical_network) - self.assertEqual(EXAMPLE['segmentation_id'], sot.segmentation_id) diff --git a/openstack/tests/unit/network/v2/test_service_profile.py b/openstack/tests/unit/network/v2/test_service_profile.py deleted file mode 100644 index 232cab5d..00000000 --- a/openstack/tests/unit/network/v2/test_service_profile.py +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import service_profile - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE_WITH_OPTIONAL = { - 'description': 'test flavor profile', - 'driver': 'neutron_lbaas.drivers.octavia.driver.OctaviaDriver', - 'enabled': True, - 'metainfo': {'foo': 'bar'}, - 'tenant_id': '5', -} - -EXAMPLE = { - 'driver': 'neutron_lbaas.drivers.octavia.driver.OctaviaDriver', -} - - -class TestServiceProfile(testtools.TestCase): - def test_basic(self): - service_profiles = service_profile.ServiceProfile() - self.assertEqual('service_profile', service_profiles.resource_key) - self.assertEqual('service_profiles', service_profiles.resources_key) - self.assertEqual('/service_profiles', service_profiles.base_path) - self.assertTrue(service_profiles.allow_create) - self.assertTrue(service_profiles.allow_get) - self.assertTrue(service_profiles.allow_update) - self.assertTrue(service_profiles.allow_delete) - self.assertTrue(service_profiles.allow_list) - - def test_make_it(self): - service_profiles = service_profile.ServiceProfile(**EXAMPLE) - self.assertEqual(EXAMPLE['driver'], service_profiles.driver) - - def test_make_it_with_optional(self): - service_profiles = service_profile.ServiceProfile( - **EXAMPLE_WITH_OPTIONAL) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['description'], - service_profiles.description) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['driver'], - service_profiles.driver) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['enabled'], - service_profiles.is_enabled) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['metainfo'], - service_profiles.meta_info) - self.assertEqual(EXAMPLE_WITH_OPTIONAL['tenant_id'], - service_profiles.project_id) diff --git a/openstack/tests/unit/network/v2/test_service_provider.py b/openstack/tests/unit/network/v2/test_service_provider.py deleted file mode 100644 index bc946a03..00000000 --- a/openstack/tests/unit/network/v2/test_service_provider.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import service_provider - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'service_type': 'L3_ROUTER_NAT', - 'name': '4', - 'default': False, -} - - -class TestServiceProvider(testtools.TestCase): - - def test_basic(self): - sot = service_provider.ServiceProvider() - - self.assertEqual('service_providers', sot.resources_key) - self.assertEqual('/service-providers', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = service_provider.ServiceProvider(**EXAMPLE) - self.assertEqual(EXAMPLE['service_type'], sot.service_type) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['default'], sot.is_default) diff --git a/openstack/tests/unit/network/v2/test_subnet.py b/openstack/tests/unit/network/v2/test_subnet.py deleted file mode 100644 index 2e344a9a..00000000 --- a/openstack/tests/unit/network/v2/test_subnet.py +++ /dev/null @@ -1,79 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import subnet - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'allocation_pools': [{'1': 1}], - 'cidr': '2', - 'created_at': '3', - 'description': '4', - 'dns_nameservers': ['5'], - 'enable_dhcp': True, - 'gateway_ip': '6', - 'host_routes': ['7'], - 'id': IDENTIFIER, - 'ip_version': 8, - 'ipv6_address_mode': '9', - 'ipv6_ra_mode': '10', - 'name': '11', - 'network_id': '12', - 'revision_number': 13, - 'segment_id': '14', - 'service_types': ['15'], - 'subnetpool_id': '16', - 'tenant_id': '17', - 'updated_at': '18', - 'use_default_subnetpool': True, -} - - -class TestSubnet(testtools.TestCase): - - def test_basic(self): - sot = subnet.Subnet() - self.assertEqual('subnet', sot.resource_key) - self.assertEqual('subnets', sot.resources_key) - self.assertEqual('/subnets', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = subnet.Subnet(**EXAMPLE) - self.assertEqual(EXAMPLE['allocation_pools'], sot.allocation_pools) - self.assertEqual(EXAMPLE['cidr'], sot.cidr) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['dns_nameservers'], sot.dns_nameservers) - self.assertTrue(sot.is_dhcp_enabled) - self.assertEqual(EXAMPLE['gateway_ip'], sot.gateway_ip) - self.assertEqual(EXAMPLE['host_routes'], sot.host_routes) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['ip_version'], sot.ip_version) - self.assertEqual(EXAMPLE['ipv6_address_mode'], sot.ipv6_address_mode) - self.assertEqual(EXAMPLE['ipv6_ra_mode'], sot.ipv6_ra_mode) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['network_id'], sot.network_id) - self.assertEqual(EXAMPLE['revision_number'], sot.revision_number) - self.assertEqual(EXAMPLE['segment_id'], sot.segment_id) - self.assertEqual(EXAMPLE['service_types'], sot.service_types) - self.assertEqual(EXAMPLE['subnetpool_id'], sot.subnet_pool_id) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) - self.assertTrue(sot.use_default_subnet_pool) diff --git a/openstack/tests/unit/network/v2/test_subnet_pool.py b/openstack/tests/unit/network/v2/test_subnet_pool.py deleted file mode 100644 index 908a0378..00000000 --- a/openstack/tests/unit/network/v2/test_subnet_pool.py +++ /dev/null @@ -1,70 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import subnet_pool - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'address_scope_id': '1', - 'created_at': '2', - 'default_prefixlen': 3, - 'default_quota': 4, - 'description': '5', - 'id': IDENTIFIER, - 'ip_version': 6, - 'is_default': True, - 'max_prefixlen': 7, - 'min_prefixlen': 8, - 'name': '9', - 'prefixes': ['10', '11'], - 'revision_number': 12, - 'shared': True, - 'tenant_id': '13', - 'updated_at': '14', -} - - -class TestSubnetpool(testtools.TestCase): - - def test_basic(self): - sot = subnet_pool.SubnetPool() - self.assertEqual('subnetpool', sot.resource_key) - self.assertEqual('subnetpools', sot.resources_key) - self.assertEqual('/subnetpools', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = subnet_pool.SubnetPool(**EXAMPLE) - self.assertEqual(EXAMPLE['address_scope_id'], sot.address_scope_id) - self.assertEqual(EXAMPLE['created_at'], sot.created_at) - self.assertEqual(EXAMPLE['default_prefixlen'], - sot.default_prefix_length) - self.assertEqual(EXAMPLE['default_quota'], sot.default_quota) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['ip_version'], sot.ip_version) - self.assertTrue(sot.is_default) - self.assertEqual(EXAMPLE['max_prefixlen'], sot.maximum_prefix_length) - self.assertEqual(EXAMPLE['min_prefixlen'], sot.minimum_prefix_length) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['prefixes'], sot.prefixes) - self.assertEqual(EXAMPLE['revision_number'], sot.revision_number) - self.assertTrue(sot.is_shared) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) - self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/network/v2/test_tag.py b/openstack/tests/unit/network/v2/test_tag.py deleted file mode 100644 index b22ae87d..00000000 --- a/openstack/tests/unit/network/v2/test_tag.py +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.network.v2 import network - - -ID = 'IDENTIFIER' - - -class TestTag(testtools.TestCase): - - @staticmethod - def _create_resource(tags=None): - tags = tags or [] - return network.Network(id=ID, name='test-net', tags=tags) - - def test_tags_attribute(self): - net = self._create_resource() - self.assertTrue(hasattr(net, 'tags')) - self.assertIsInstance(net.tags, list) - - def test_set_tags(self): - net = self._create_resource() - sess = mock.Mock() - result = net.set_tags(sess, ['blue', 'green']) - # Check tags attribute is updated - self.assertEqual(['blue', 'green'], net.tags) - # Check the passed resource is returned - self.assertEqual(net, result) - url = 'networks/' + ID + '/tags' - sess.put.assert_called_once_with(url, endpoint_filter=net.service, - json={'tags': ['blue', 'green']}) diff --git a/openstack/tests/unit/network/v2/test_vpn_service.py b/openstack/tests/unit/network/v2/test_vpn_service.py deleted file mode 100644 index a5b54590..00000000 --- a/openstack/tests/unit/network/v2/test_vpn_service.py +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.network.v2 import vpn_service - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - "admin_state_up": True, - "description": "1", - "external_v4_ip": "2", - "external_v6_ip": "3", - "id": IDENTIFIER, - "name": "4", - "router_id": "5", - "status": "6", - "subnet_id": "7", - "tenant_id": "8", -} - - -class TestVPNService(testtools.TestCase): - - def test_basic(self): - sot = vpn_service.VPNService() - self.assertEqual('vpnservice', sot.resource_key) - self.assertEqual('vpnservices', sot.resources_key) - self.assertEqual('/vpn/vpnservices', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = vpn_service.VPNService(**EXAMPLE) - self.assertTrue(sot.is_admin_state_up) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['external_v4_ip'], sot.external_v4_ip) - self.assertEqual(EXAMPLE['external_v6_ip'], sot.external_v6_ip) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['router_id'], sot.router_id) - self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['subnet_id'], sot.subnet_id) - self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) diff --git a/openstack/tests/unit/object_store/__init__.py b/openstack/tests/unit/object_store/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/object_store/test_object_store_service.py b/openstack/tests/unit/object_store/test_object_store_service.py deleted file mode 100644 index a2707a13..00000000 --- a/openstack/tests/unit/object_store/test_object_store_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.object_store import object_store_service - - -class TestObjectStoreService(testtools.TestCase): - - def test_service(self): - sot = object_store_service.ObjectStoreService() - self.assertEqual('object-store', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v1', sot.valid_versions[0].module) - self.assertEqual('v1', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/object_store/v1/__init__.py b/openstack/tests/unit/object_store/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/object_store/v1/test_account.py b/openstack/tests/unit/object_store/v1/test_account.py deleted file mode 100644 index e0df5390..00000000 --- a/openstack/tests/unit/object_store/v1/test_account.py +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.object_store.v1 import account - - -CONTAINER_NAME = "mycontainer" - -ACCOUNT_EXAMPLE = { - 'content-length': '0', - 'accept-ranges': 'bytes', - 'date': 'Sat, 05 Jul 2014 19:17:40 GMT', - 'x-account-bytes-used': '12345', - 'x-account-container-count': '678', - 'content-type': 'text/plain; charset=utf-8', - 'x-account-object-count': '98765', - 'x-timestamp': '1453413555.88937' -} - - -class TestAccount(testtools.TestCase): - - def test_basic(self): - sot = account.Account.new(**ACCOUNT_EXAMPLE) - self.assertIsNone(sot.resources_key) - self.assertIsNone(sot.id) - self.assertEqual('/', sot.base_path) - self.assertEqual('object-store', sot.service.service_type) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_head) - self.assertTrue(sot.allow_retrieve) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - self.assertFalse(sot.allow_create) - - def test_make_it(self): - sot = account.Account.new(**{'headers': ACCOUNT_EXAMPLE}) - self.assertIsNone(sot.id) - self.assertEqual(int(ACCOUNT_EXAMPLE['x-account-bytes-used']), - sot.account_bytes_used) - self.assertEqual(int(ACCOUNT_EXAMPLE['x-account-container-count']), - sot.account_container_count) - self.assertEqual(int(ACCOUNT_EXAMPLE['x-account-object-count']), - sot.account_object_count) - self.assertEqual(ACCOUNT_EXAMPLE['x-timestamp'], sot.timestamp) diff --git a/openstack/tests/unit/object_store/v1/test_container.py b/openstack/tests/unit/object_store/v1/test_container.py deleted file mode 100644 index 587c7e47..00000000 --- a/openstack/tests/unit/object_store/v1/test_container.py +++ /dev/null @@ -1,171 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.object_store.v1 import container - - -CONTAINER_NAME = "mycontainer" - -CONT_EXAMPLE = { - "count": 999, - "bytes": 12345, - "name": CONTAINER_NAME -} - -HEAD_EXAMPLE = { - 'content-length': '346', - 'x-container-object-count': '2', - 'accept-ranges': 'bytes', - 'id': 'tx1878fdc50f9b4978a3fdc-0053c31462', - 'date': 'Sun, 13 Jul 2014 23:21:06 GMT', - 'x-container-read': 'read-settings', - 'x-container-write': 'write-settings', - 'x-container-sync-to': 'sync-to', - 'x-container-sync-key': 'sync-key', - 'x-container-bytes-used': '630666', - 'x-versions-location': 'versions-location', - 'content-type': 'application/json; charset=utf-8', - 'x-timestamp': '1453414055.48672' -} - -LIST_EXAMPLE = [ - { - "count": 999, - "bytes": 12345, - "name": "container1" - }, - { - "count": 888, - "bytes": 54321, - "name": "container2" - } -] - - -class TestContainer(testtools.TestCase): - - def setUp(self): - super(TestContainer, self).setUp() - self.resp = mock.Mock() - self.resp.body = {} - self.resp.json = mock.Mock(return_value=self.resp.body) - self.resp.headers = {"X-Trans-Id": "abcdef"} - self.sess = mock.Mock() - self.sess.put = mock.Mock(return_value=self.resp) - self.sess.post = mock.Mock(return_value=self.resp) - - def test_basic(self): - sot = container.Container.new(**CONT_EXAMPLE) - self.assertIsNone(sot.resources_key) - self.assertEqual('name', sot.id_attribute) - self.assertEqual('/', sot.base_path) - self.assertEqual('object-store', sot.service.service_type) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_retrieve) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.allow_head) - - def test_make_it(self): - sot = container.Container.new(**CONT_EXAMPLE) - self.assertEqual(CONT_EXAMPLE['name'], sot.id) - self.assertEqual(CONT_EXAMPLE['name'], sot.name) - self.assertEqual(CONT_EXAMPLE['count'], sot.count) - self.assertEqual(CONT_EXAMPLE['bytes'], sot.bytes) - - def test_create_and_head(self): - sot = container.Container(CONT_EXAMPLE) - - # Update container with HEAD data - sot._attrs.update({'headers': HEAD_EXAMPLE}) - - # Attributes from create - self.assertEqual(CONT_EXAMPLE['name'], sot.id) - self.assertEqual(CONT_EXAMPLE['name'], sot.name) - self.assertEqual(CONT_EXAMPLE['count'], sot.count) - self.assertEqual(CONT_EXAMPLE['bytes'], sot.bytes) - - # Attributes from header - self.assertEqual(int(HEAD_EXAMPLE['x-container-object-count']), - sot.object_count) - self.assertEqual(int(HEAD_EXAMPLE['x-container-bytes-used']), - sot.bytes_used) - self.assertEqual(HEAD_EXAMPLE['x-container-read'], - sot.read_ACL) - self.assertEqual(HEAD_EXAMPLE['x-container-write'], - sot.write_ACL) - self.assertEqual(HEAD_EXAMPLE['x-container-sync-to'], - sot.sync_to) - self.assertEqual(HEAD_EXAMPLE['x-container-sync-key'], - sot.sync_key) - self.assertEqual(HEAD_EXAMPLE['x-versions-location'], - sot.versions_location) - self.assertEqual(HEAD_EXAMPLE['x-timestamp'], sot.timestamp) - - @mock.patch("openstack.resource.Resource.list") - def test_list(self, fake_list): - fake_val = [container.Container.existing(**ex) for ex in LIST_EXAMPLE] - fake_list.return_value = fake_val - - # Since the list method is mocked out, just pass None for the session. - response = container.Container.list(None) - - self.assertEqual(len(LIST_EXAMPLE), len(response)) - for item in range(len(response)): - self.assertEqual(container.Container, type(response[item])) - self.assertEqual(LIST_EXAMPLE[item]["name"], response[item].name) - self.assertEqual(LIST_EXAMPLE[item]["count"], response[item].count) - self.assertEqual(LIST_EXAMPLE[item]["bytes"], response[item].bytes) - - def _test_create_update(self, sot, sot_call, sess_method): - sot.read_ACL = "some ACL" - sot.write_ACL = "another ACL" - sot.is_content_type_detected = True - headers = { - "x-container-read": "some ACL", - "x-container-write": "another ACL", - "x-detect-content-type": True, - "Accept": "", - } - sot_call(self.sess) - - url = "/%s" % CONTAINER_NAME - sess_method.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - - def test_create(self): - sot = container.Container.new(name=CONTAINER_NAME) - self._test_create_update(sot, sot.create, self.sess.put) - - def test_update(self): - sot = container.Container.new(name=CONTAINER_NAME) - self._test_create_update(sot, sot.update, self.sess.post) - - def _test_no_headers(self, sot, sot_call, sess_method): - sot = container.Container.new(name=CONTAINER_NAME) - sot.create(self.sess) - url = "/%s" % CONTAINER_NAME - headers = {'Accept': ''} - self.sess.put.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - - def test_create_no_headers(self): - sot = container.Container.new(name=CONTAINER_NAME) - self._test_no_headers(sot, sot.create, self.sess.put) - - def test_update_no_headers(self): - sot = container.Container.new(name=CONTAINER_NAME) - self._test_no_headers(sot, sot.update, self.sess.post) diff --git a/openstack/tests/unit/object_store/v1/test_obj.py b/openstack/tests/unit/object_store/v1/test_obj.py deleted file mode 100644 index 47a3b95a..00000000 --- a/openstack/tests/unit/object_store/v1/test_obj.py +++ /dev/null @@ -1,137 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.object_store.v1 import obj - - -CONTAINER_NAME = "mycontainer" -OBJECT_NAME = "myobject" - -# Object can receive both last-modified in headers and last_modified in -# the body. However, originally, only last-modified was handled as an -# expected prop but it was named last_modified. Under Python 3, creating -# an Object with the body value last_modified causes the _attrs dictionary -# size to change while iterating over its values as we have an attribute -# called `last_modified` and we attempt to grow an additional attribute -# called `last-modified`, which is the "name" of `last_modified`. -# The same is true of content_type and content-type, or any prop -# attribute which would follow the same pattern. -# This example should represent the body values returned by a GET, so the keys -# must be underscores. -OBJ_EXAMPLE = { - "hash": "243f87b91224d85722564a80fd3cb1f1", - "last_modified": "2014-07-13T18:41:03.319240", - "bytes": 252466, - "name": OBJECT_NAME, - "content_type": "application/octet-stream" -} - -DICT_EXAMPLE = { - 'container': CONTAINER_NAME, - 'name': OBJECT_NAME, - 'content_type': 'application/octet-stream', - 'headers': { - 'content-length': '252466', - 'accept-ranges': 'bytes', - 'last-modified': 'Sun, 13 Jul 2014 18:41:04 GMT', - 'etag': '243f87b91224d85722564a80fd3cb1f1', - 'x-timestamp': '1453414256.28112', - 'date': 'Thu, 28 Aug 2014 14:41:59 GMT', - 'id': 'tx5fb5ad4f4d0846c6b2bc7-0053ff3fb7', - 'x-delete-at': '1453416226.16744' - } -} - - -class TestObject(testtools.TestCase): - - def setUp(self): - super(TestObject, self).setUp() - self.resp = mock.Mock() - self.resp.content = "lol here's some content" - self.resp.headers = {"X-Trans-Id": "abcdef"} - self.sess = mock.Mock() - self.sess.get = mock.Mock(return_value=self.resp) - self.sess.put = mock.Mock(return_value=self.resp) - self.sess.post = mock.Mock(return_value=self.resp) - - def test_basic(self): - sot = obj.Object.new(**OBJ_EXAMPLE) - self.assertIsNone(sot.resources_key) - self.assertEqual("name", sot.id_attribute) - self.assertEqual('/%(container)s', sot.base_path) - self.assertEqual('object-store', sot.service.service_type) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_retrieve) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.allow_head) - - def test_new(self): - sot = obj.Object.new(container=CONTAINER_NAME, name=OBJECT_NAME) - self.assertEqual(OBJECT_NAME, sot.name) - self.assertEqual(CONTAINER_NAME, sot.container) - - def test_head(self): - sot = obj.Object.existing(**DICT_EXAMPLE) - - # Attributes from header - self.assertEqual(DICT_EXAMPLE['container'], sot.container) - headers = DICT_EXAMPLE['headers'] - self.assertEqual(headers['content-length'], sot.content_length) - self.assertEqual(headers['accept-ranges'], sot.accept_ranges) - self.assertEqual(headers['last-modified'], sot.last_modified_at) - self.assertEqual(headers['etag'], sot.etag) - self.assertEqual(headers['x-timestamp'], sot.timestamp) - self.assertEqual(headers['content-type'], sot.content_type) - self.assertEqual(headers['x-delete-at'], sot.delete_at) - - def test_get(self): - sot = obj.Object.new(container=CONTAINER_NAME, name=OBJECT_NAME) - sot.is_newest = True - sot.if_match = {"who": "what"} - - rv = sot.get(self.sess) - - url = "%s/%s" % (CONTAINER_NAME, OBJECT_NAME) - # TODO(thowe): Should allow filtering bug #1488269 - # headers = { - # "x-newest": True, - # "if-match": {"who": "what"} - # } - headers = {'Accept': 'bytes'} - self.sess.get.assert_called_with(url, endpoint_filter=sot.service, - headers=headers) - self.assertEqual(self.resp.content, rv) - - def _test_create(self, method, data, accept): - sot = obj.Object.new(container=CONTAINER_NAME, name=OBJECT_NAME, - data=data) - sot.is_newest = True - headers = {"x-newest": True, "Accept": ""} - - rv = sot.create(self.sess) - - url = "%s/%s" % (CONTAINER_NAME, OBJECT_NAME) - method.assert_called_with(url, endpoint_filter=sot.service, data=data, - headers=headers) - self.assertEqual(self.resp.headers, rv.get_headers()) - - def test_create_data(self): - self._test_create(self.sess.put, "data", "bytes") - - def test_create_no_data(self): - self._test_create(self.sess.post, None, None) diff --git a/openstack/tests/unit/object_store/v1/test_proxy.py b/openstack/tests/unit/object_store/v1/test_proxy.py deleted file mode 100644 index 5fa85c76..00000000 --- a/openstack/tests/unit/object_store/v1/test_proxy.py +++ /dev/null @@ -1,277 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import six - -from openstack.object_store.v1 import _proxy -from openstack.object_store.v1 import account -from openstack.object_store.v1 import container -from openstack.object_store.v1 import obj -from openstack.tests.unit import test_proxy_base - - -class TestObjectStoreProxy(test_proxy_base.TestProxyBase): - - def setUp(self): - super(TestObjectStoreProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_account_metadata_get(self): - self.verify_head(self.proxy.get_account_metadata, account.Account) - - def test_container_metadata_get(self): - self.verify_head(self.proxy.get_container_metadata, - container.Container, value="container") - - def test_container_delete(self): - self.verify_delete(self.proxy.delete_container, - container.Container, False) - - def test_container_delete_ignore(self): - self.verify_delete(self.proxy.delete_container, - container.Container, True) - - def test_container_create_attrs(self): - self.verify_create(self.proxy.create_container, container.Container) - - def test_object_metadata_get(self): - self.verify_head(self.proxy.get_object_metadata, obj.Object, - value="object", container="container") - - def _test_object_delete(self, ignore): - expected_kwargs = {"path_args": {"container": "name"}} - expected_kwargs["ignore_missing"] = ignore - - self._verify2("openstack.proxy.BaseProxy._delete", - self.proxy.delete_object, - method_args=["resource"], - method_kwargs={"container": "name", - "ignore_missing": ignore}, - expected_args=[obj.Object, "resource"], - expected_kwargs=expected_kwargs) - - def test_object_delete(self): - self._test_object_delete(False) - - def test_object_delete_ignore(self): - self._test_object_delete(True) - - def test_object_create_attrs(self): - path_args = {"path_args": {"container": "name"}} - method_kwargs = {"name": "test", "data": "data", "container": "name"} - - expected_kwargs = path_args.copy() - expected_kwargs.update(method_kwargs) - expected_kwargs.pop("container") - - self._verify2("openstack.proxy.BaseProxy._create", - self.proxy.upload_object, - method_kwargs=method_kwargs, - expected_args=[obj.Object], - expected_kwargs=expected_kwargs) - - def test_object_create_no_container(self): - self.assertRaises(ValueError, self.proxy.upload_object) - - def test_object_get(self): - self.verify_get(self.proxy.get_object, obj.Object, - value=["object"], container="container") - - -class Test_containers(TestObjectStoreProxy): - - def setUp(self): - super(Test_containers, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - self.containers_body = [] - for i in range(3): - self.containers_body.append({six.text_type("name"): - six.text_type("container%d" % i)}) - -# @httpretty.activate -# def test_all_containers(self): -# self.stub_url(httpretty.GET, -# path=[container.Container.base_path], -# responses=[httpretty.Response( -# body=json.dumps(self.containers_body), -# status=200, content_type="application/json"), -# httpretty.Response(body=json.dumps([]), -# status=200, content_type="application/json")]) -# -# count = 0 -# for actual, expected in zip(self.proxy.containers(), -# self.containers_body): -# self.assertEqual(expected, actual) -# count += 1 -# self.assertEqual(len(self.containers_body), count) - -# @httpretty.activate -# def test_containers_limited(self): -# limit = len(self.containers_body) + 1 -# limit_param = "?limit=%d" % limit -# -# self.stub_url(httpretty.GET, -# path=[container.Container.base_path + limit_param], -# json=self.containers_body) -# -# count = 0 -# for actual, expected in zip(self.proxy.containers(limit=limit), -# self.containers_body): -# self.assertEqual(actual, expected) -# count += 1 -# -# self.assertEqual(len(self.containers_body), count) -# # Since we've chosen a limit larger than the body, only one request -# # should be made, so it should be the last one. -# self.assertIn(limit_param, httpretty.last_request().path) - -# @httpretty.activate -# def test_containers_with_marker(self): -# marker = six.text_type("container2") -# marker_param = "marker=%s" % marker -# -# self.stub_url(httpretty.GET, -# path=[container.Container.base_path + "?" + -# marker_param], -# json=self.containers_body) -# -# count = 0 -# for actual, expected in zip(self.proxy.containers(marker=marker), -# self.containers_body): -# # Make sure the marker made it into the actual request. -# self.assertIn(marker_param, httpretty.last_request().path) -# self.assertEqual(expected, actual) -# count += 1 -# -# self.assertEqual(len(self.containers_body), count) -# -# # Since we have to make one request beyond the end, because no -# # limit was provided, make sure the last container appears as -# # the marker in this last request. -# self.assertIn(self.containers_body[-1]["name"], -# httpretty.last_request().path) - - -class Test_objects(TestObjectStoreProxy): - - def setUp(self): - super(Test_objects, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - self.container_name = six.text_type("my_container") - - self.objects_body = [] - for i in range(3): - self.objects_body.append({six.text_type("name"): - six.text_type("object%d" % i)}) - - # Returned object bodies have their container inserted. - self.returned_objects = [] - for ob in self.objects_body: - ob[six.text_type("container")] = self.container_name - self.returned_objects.append(ob) - self.assertEqual(len(self.objects_body), len(self.returned_objects)) - -# @httpretty.activate -# def test_all_objects(self): -# self.stub_url(httpretty.GET, -# path=[obj.Object.base_path % -# {"container": self.container_name}], -# responses=[httpretty.Response( -# body=json.dumps(self.objects_body), -# status=200, content_type="application/json"), -# httpretty.Response(body=json.dumps([]), -# status=200, content_type="application/json")]) -# -# count = 0 -# for actual, expected in zip(self.proxy.objects(self.container_name), -# self.returned_objects): -# self.assertEqual(expected, actual) -# count += 1 -# self.assertEqual(len(self.returned_objects), count) - -# @httpretty.activate -# def test_objects_limited(self): -# limit = len(self.objects_body) + 1 -# limit_param = "?limit=%d" % limit -# -# self.stub_url(httpretty.GET, -# path=[obj.Object.base_path % -# {"container": self.container_name} + limit_param], -# json=self.objects_body) -# -# count = 0 -# for actual, expected in zip(self.proxy.objects(self.container_name, -# limit=limit), -# self.returned_objects): -# self.assertEqual(expected, actual) -# count += 1 -# -# self.assertEqual(len(self.returned_objects), count) -# # Since we've chosen a limit larger than the body, only one request -# # should be made, so it should be the last one. -# self.assertIn(limit_param, httpretty.last_request().path) - -# @httpretty.activate -# def test_objects_with_marker(self): -# marker = six.text_type("object2") -# # marker_param = "marker=%s" % marker -# -# self.stub_url(httpretty.GET, -# path=[obj.Object.base_path % -# {"container": self.container_name} + "?" + -# marker_param], -# json=self.objects_body) -# -# count = 0 -# for actual, expected in zip(self.proxy.objects(self.container_name, -# marker=marker), -# self.returned_objects): -# # Make sure the marker made it into the actual request. -# self.assertIn(marker_param, httpretty.last_request().path) -# self.assertEqual(expected, actual) -# count += 1 -# -# self.assertEqual(len(self.returned_objects), count) -# -# # Since we have to make one request beyond the end, because no -# # limit was provided, make sure the last container appears as -# # the marker in this last request. -# self.assertIn(self.returned_objects[-1]["name"], -# httpretty.last_request().path) - - -class Test_download_object(TestObjectStoreProxy): - - @mock.patch("openstack.object_store.v1._proxy.Proxy.get_object") - def test_download(self, mock_get): - the_data = "here's some data" - mock_get.return_value = the_data - ob = mock.Mock() - - fake_open = mock.mock_open() - file_path = "blarga/somefile" - with mock.patch("openstack.object_store.v1._proxy.open", - fake_open, create=True): - self.proxy.download_object(ob, container="tainer", path=file_path) - - fake_open.assert_called_once_with(file_path, "w") - fake_handle = fake_open() - fake_handle.write.assert_called_once_with(the_data) - - -class Test_copy_object(TestObjectStoreProxy): - - def test_copy_object(self): - self.assertRaises(NotImplementedError, self.proxy.copy_object) diff --git a/openstack/tests/unit/orchestration/__init__.py b/openstack/tests/unit/orchestration/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/orchestration/test_orchestration_service.py b/openstack/tests/unit/orchestration/test_orchestration_service.py deleted file mode 100644 index 9d0840ad..00000000 --- a/openstack/tests/unit/orchestration/test_orchestration_service.py +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.orchestration import orchestration_service - - -class TestOrchestrationService(testtools.TestCase): - - def test_service(self): - sot = orchestration_service.OrchestrationService() - self.assertEqual('orchestration', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v1', sot.valid_versions[0].module) - self.assertEqual('v1', sot.valid_versions[0].path) - self.assertTrue(sot.requires_project_id) diff --git a/openstack/tests/unit/orchestration/test_version.py b/openstack/tests/unit/orchestration/test_version.py deleted file mode 100644 index 5da8a37c..00000000 --- a/openstack/tests/unit/orchestration/test_version.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.orchestration import version - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'status': '3', -} - - -class TestVersion(testtools.TestCase): - - def test_basic(self): - sot = version.Version() - self.assertEqual('version', sot.resource_key) - self.assertEqual('versions', sot.resources_key) - self.assertEqual('/', sot.base_path) - self.assertEqual('orchestration', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = version.Version(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['status'], sot.status) diff --git a/openstack/tests/unit/orchestration/v1/__init__.py b/openstack/tests/unit/orchestration/v1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/orchestration/v1/test_proxy.py b/openstack/tests/unit/orchestration/v1/test_proxy.py deleted file mode 100644 index 9628198a..00000000 --- a/openstack/tests/unit/orchestration/v1/test_proxy.py +++ /dev/null @@ -1,266 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import six - -from openstack import exceptions -from openstack.orchestration.v1 import _proxy -from openstack.orchestration.v1 import resource -from openstack.orchestration.v1 import software_config as sc -from openstack.orchestration.v1 import software_deployment as sd -from openstack.orchestration.v1 import stack -from openstack.orchestration.v1 import stack_environment -from openstack.orchestration.v1 import stack_files -from openstack.orchestration.v1 import stack_template -from openstack.orchestration.v1 import template -from openstack.tests.unit import test_proxy_base2 - - -class TestOrchestrationProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestOrchestrationProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_create_stack(self): - self.verify_create(self.proxy.create_stack, stack.Stack) - - def test_create_stack_preview(self): - method_kwargs = {"preview": True, "x": 1, "y": 2, "z": 3} - self.verify_create(self.proxy.create_stack, stack.StackPreview, - method_kwargs=method_kwargs) - - def test_find_stack(self): - self.verify_find(self.proxy.find_stack, stack.Stack) - - def test_stacks(self): - self.verify_list(self.proxy.stacks, stack.Stack, paginated=False) - - def test_get_stack(self): - self.verify_get(self.proxy.get_stack, stack.Stack) - - def test_update_stack(self): - self.verify_update(self.proxy.update_stack, stack.Stack) - - def test_delete_stack(self): - self.verify_delete(self.proxy.delete_stack, stack.Stack, False) - - def test_delete_stack_ignore(self): - self.verify_delete(self.proxy.delete_stack, stack.Stack, True) - - @mock.patch.object(stack.Stack, 'check') - def test_check_stack_with_stack_object(self, mock_check): - stk = stack.Stack(id='FAKE_ID') - - res = self.proxy.check_stack(stk) - - self.assertIsNone(res) - mock_check.assert_called_once_with(self.proxy._session) - - @mock.patch.object(stack.Stack, 'existing') - def test_check_stack_with_stack_ID(self, mock_stack): - stk = mock.Mock() - mock_stack.return_value = stk - - res = self.proxy.check_stack('FAKE_ID') - - self.assertIsNone(res) - mock_stack.assert_called_once_with(id='FAKE_ID') - stk.check.assert_called_once_with(self.proxy._session) - - @mock.patch.object(stack.Stack, 'find') - def test_get_stack_environment_with_stack_identity(self, mock_find): - stack_id = '1234' - stack_name = 'test_stack' - stk = stack.Stack(id=stack_id, name=stack_name) - mock_find.return_value = stk - - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_stack_environment, - method_args=['IDENTITY'], - expected_args=[stack_environment.StackEnvironment], - expected_kwargs={'requires_id': False, - 'stack_name': stack_name, - 'stack_id': stack_id}) - mock_find.assert_called_once_with(mock.ANY, 'IDENTITY', - ignore_missing=False) - - def test_get_stack_environment_with_stack_object(self): - stack_id = '1234' - stack_name = 'test_stack' - stk = stack.Stack(id=stack_id, name=stack_name) - - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_stack_environment, - method_args=[stk], - expected_args=[stack_environment.StackEnvironment], - expected_kwargs={'requires_id': False, - 'stack_name': stack_name, - 'stack_id': stack_id}) - - @mock.patch.object(stack_files.StackFiles, 'get') - @mock.patch.object(stack.Stack, 'find') - def test_get_stack_files_with_stack_identity(self, mock_find, mock_get): - stack_id = '1234' - stack_name = 'test_stack' - stk = stack.Stack(id=stack_id, name=stack_name) - mock_find.return_value = stk - mock_get.return_value = {'file': 'content'} - - res = self.proxy.get_stack_files('IDENTITY') - - self.assertEqual({'file': 'content'}, res) - mock_find.assert_called_once_with(mock.ANY, 'IDENTITY', - ignore_missing=False) - mock_get.assert_called_once_with(self.proxy._session) - - @mock.patch.object(stack_files.StackFiles, 'get') - def test_get_stack_files_with_stack_object(self, mock_get): - stack_id = '1234' - stack_name = 'test_stack' - stk = stack.Stack(id=stack_id, name=stack_name) - mock_get.return_value = {'file': 'content'} - - res = self.proxy.get_stack_files(stk) - - self.assertEqual({'file': 'content'}, res) - mock_get.assert_called_once_with(self.proxy._session) - - @mock.patch.object(stack.Stack, 'find') - def test_get_stack_template_with_stack_identity(self, mock_find): - stack_id = '1234' - stack_name = 'test_stack' - stk = stack.Stack(id=stack_id, name=stack_name) - mock_find.return_value = stk - - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_stack_template, - method_args=['IDENTITY'], - expected_args=[stack_template.StackTemplate], - expected_kwargs={'requires_id': False, - 'stack_name': stack_name, - 'stack_id': stack_id}) - mock_find.assert_called_once_with(mock.ANY, 'IDENTITY', - ignore_missing=False) - - def test_get_stack_template_with_stack_object(self): - stack_id = '1234' - stack_name = 'test_stack' - stk = stack.Stack(id=stack_id, name=stack_name) - - self._verify2('openstack.proxy2.BaseProxy._get', - self.proxy.get_stack_template, - method_args=[stk], - expected_args=[stack_template.StackTemplate], - expected_kwargs={'requires_id': False, - 'stack_name': stack_name, - 'stack_id': stack_id}) - - @mock.patch.object(stack.Stack, 'find') - def test_resources_with_stack_object(self, mock_find): - stack_id = '1234' - stack_name = 'test_stack' - stk = stack.Stack(id=stack_id, name=stack_name) - - self.verify_list(self.proxy.resources, resource.Resource, - paginated=False, method_args=[stk], - expected_kwargs={'stack_name': stack_name, - 'stack_id': stack_id}) - - self.assertEqual(0, mock_find.call_count) - - @mock.patch.object(stack.Stack, 'find') - def test_resources_with_stack_name(self, mock_find): - stack_id = '1234' - stack_name = 'test_stack' - stk = stack.Stack(id=stack_id, name=stack_name) - mock_find.return_value = stk - - self.verify_list(self.proxy.resources, resource.Resource, - paginated=False, method_args=[stack_id], - expected_kwargs={'stack_name': stack_name, - 'stack_id': stack_id}) - - mock_find.assert_called_once_with(mock.ANY, stack_id, - ignore_missing=False) - - @mock.patch.object(stack.Stack, 'find') - @mock.patch.object(resource.Resource, 'list') - def test_resources_stack_not_found(self, mock_list, mock_find): - stack_name = 'test_stack' - mock_find.side_effect = exceptions.ResourceNotFound( - 'No stack found for test_stack') - - ex = self.assertRaises(exceptions.ResourceNotFound, - self.proxy.resources, stack_name) - self.assertEqual('ResourceNotFound: No stack found for test_stack', - six.text_type(ex)) - - def test_create_software_config(self): - self.verify_create(self.proxy.create_software_config, - sc.SoftwareConfig) - - def test_software_configs(self): - self.verify_list(self.proxy.software_configs, sc.SoftwareConfig, - paginated=True) - - def test_get_software_config(self): - self.verify_get(self.proxy.get_software_config, sc.SoftwareConfig) - - def test_delete_software_config(self): - self.verify_delete(self.proxy.delete_software_config, - sc.SoftwareConfig, True) - self.verify_delete(self.proxy.delete_software_config, - sc.SoftwareConfig, False) - - def test_create_software_deployment(self): - self.verify_create(self.proxy.create_software_deployment, - sd.SoftwareDeployment) - - def test_software_deployments(self): - self.verify_list(self.proxy.software_deployments, - sd.SoftwareDeployment, paginated=False) - - def test_get_software_deployment(self): - self.verify_get(self.proxy.get_software_deployment, - sd.SoftwareDeployment) - - def test_update_software_deployment(self): - self.verify_update(self.proxy.update_software_deployment, - sd.SoftwareDeployment) - - def test_delete_software_deployment(self): - self.verify_delete(self.proxy.delete_software_deployment, - sd.SoftwareDeployment, True) - self.verify_delete(self.proxy.delete_software_deployment, - sd.SoftwareDeployment, False) - - @mock.patch.object(template.Template, 'validate') - def test_validate_template(self, mock_validate): - tmpl = mock.Mock() - env = mock.Mock() - tmpl_url = 'A_URI' - ignore_errors = 'a_string' - - res = self.proxy.validate_template(tmpl, env, tmpl_url, ignore_errors) - - mock_validate.assert_called_once_with( - self.proxy._session, tmpl, environment=env, template_url=tmpl_url, - ignore_errors=ignore_errors) - self.assertEqual(mock_validate.return_value, res) - - def test_validate_template_invalid_request(self): - err = self.assertRaises(exceptions.InvalidRequest, - self.proxy.validate_template, - None, template_url=None) - self.assertEqual("'template_url' must be specified when template is " - "None", six.text_type(err)) diff --git a/openstack/tests/unit/orchestration/v1/test_resource.py b/openstack/tests/unit/orchestration/v1/test_resource.py deleted file mode 100644 index b4080ac3..00000000 --- a/openstack/tests/unit/orchestration/v1/test_resource.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.orchestration.v1 import resource - - -FAKE_ID = '32e39358-2422-4ad0-a1b5-dd60696bf564' -FAKE_NAME = 'test_stack' -FAKE = { - 'links': [{ - 'href': 'http://res_link', - 'rel': 'self' - }, { - 'href': 'http://stack_link', - 'rel': 'stack' - }], - 'logical_resource_id': 'the_resource', - 'name': 'the_resource', - 'physical_resource_id': '9f38ab5a-37c8-4e40-9702-ce27fc5f6954', - 'required_by': [], - 'resource_type': 'OS::Heat::FakeResource', - 'status': 'CREATE_COMPLETE', - 'status_reason': 'state changed', - 'updated_time': '2015-03-09T12:15:57.233772', -} - - -class TestResource(testtools.TestCase): - - def test_basic(self): - sot = resource.Resource() - self.assertEqual('resource', sot.resource_key) - self.assertEqual('resources', sot.resources_key) - self.assertEqual('/stacks/%(stack_name)s/%(stack_id)s/resources', - sot.base_path) - self.assertEqual('orchestration', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_retrieve) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = resource.Resource(**FAKE) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['logical_resource_id'], sot.logical_resource_id) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['physical_resource_id'], - sot.physical_resource_id) - self.assertEqual(FAKE['required_by'], sot.required_by) - self.assertEqual(FAKE['resource_type'], sot.resource_type) - self.assertEqual(FAKE['status'], sot.status) - self.assertEqual(FAKE['status_reason'], sot.status_reason) - self.assertEqual(FAKE['updated_time'], sot.updated_at) diff --git a/openstack/tests/unit/orchestration/v1/test_software_config.py b/openstack/tests/unit/orchestration/v1/test_software_config.py deleted file mode 100644 index aa752a7b..00000000 --- a/openstack/tests/unit/orchestration/v1/test_software_config.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.orchestration.v1 import software_config - - -FAKE_ID = 'ce8ae86c-9810-4cb1-8888-7fb53bc523bf' -FAKE_NAME = 'test_software_config' -FAKE = { - 'id': FAKE_ID, - 'name': FAKE_NAME, - 'config': 'fake config', - 'creation_time': '2015-03-09T12:15:57', - 'group': 'fake group', - 'inputs': [{'foo': 'bar'}], - 'outputs': [{'baz': 'zoo'}], - 'options': {'key': 'value'}, -} - - -class TestSoftwareConfig(testtools.TestCase): - - def test_basic(self): - sot = software_config.SoftwareConfig() - self.assertEqual('software_config', sot.resource_key) - self.assertEqual('software_configs', sot.resources_key) - self.assertEqual('/software_configs', sot.base_path) - self.assertEqual('orchestration', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = software_config.SoftwareConfig(**FAKE) - self.assertEqual(FAKE_ID, sot.id) - self.assertEqual(FAKE_NAME, sot.name) - self.assertEqual(FAKE['config'], sot.config) - self.assertEqual(FAKE['creation_time'], sot.created_at) - self.assertEqual(FAKE['group'], sot.group) - self.assertEqual(FAKE['inputs'], sot.inputs) - self.assertEqual(FAKE['outputs'], sot.outputs) - self.assertEqual(FAKE['options'], sot.options) diff --git a/openstack/tests/unit/orchestration/v1/test_software_deployment.py b/openstack/tests/unit/orchestration/v1/test_software_deployment.py deleted file mode 100644 index cb03ac0f..00000000 --- a/openstack/tests/unit/orchestration/v1/test_software_deployment.py +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.orchestration.v1 import software_deployment - -FAKE = { - 'id': 'ce8ae86c-9810-4cb1-8888-7fb53bc523bf', - 'action': 'CREATE', - 'config_id': 'CONFIG ID', - 'creation_time': '2015-03-09T12:15:57', - 'server_id': 'FAKE_SERVER', - 'stack_user_project_id': 'ANOTHER PROJECT', - 'status': 'IN_PROGRESS', - 'status_reason': 'Why are we here?', - 'input_values': {'foo': 'bar'}, - 'output_values': {'baz': 'zoo'}, - 'updated_time': '2015-03-09T12:15:57', -} - - -class TestSoftwareDeployment(testtools.TestCase): - - def test_basic(self): - sot = software_deployment.SoftwareDeployment() - self.assertEqual('software_deployment', sot.resource_key) - self.assertEqual('software_deployments', sot.resources_key) - self.assertEqual('/software_deployments', sot.base_path) - self.assertEqual('orchestration', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = software_deployment.SoftwareDeployment(**FAKE) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['action'], sot.action) - self.assertEqual(FAKE['config_id'], sot.config_id) - self.assertEqual(FAKE['creation_time'], sot.created_at) - self.assertEqual(FAKE['server_id'], sot.server_id) - self.assertEqual(FAKE['stack_user_project_id'], - sot.stack_user_project_id) - self.assertEqual(FAKE['input_values'], sot.input_values) - self.assertEqual(FAKE['output_values'], sot.output_values) - self.assertEqual(FAKE['status'], sot.status) - self.assertEqual(FAKE['status_reason'], sot.status_reason) - self.assertEqual(FAKE['updated_time'], sot.updated_at) diff --git a/openstack/tests/unit/orchestration/v1/test_stack.py b/openstack/tests/unit/orchestration/v1/test_stack.py deleted file mode 100644 index 4ca0d2ba..00000000 --- a/openstack/tests/unit/orchestration/v1/test_stack.py +++ /dev/null @@ -1,151 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import six -import testtools - -from openstack import exceptions -from openstack.orchestration.v1 import stack -from openstack import resource2 as resource - - -FAKE_ID = 'ce8ae86c-9810-4cb1-8888-7fb53bc523bf' -FAKE_NAME = 'test_stack' -FAKE = { - 'capabilities': '1', - 'creation_time': '2015-03-09T12:15:57.233772', - 'description': '3', - 'disable_rollback': True, - 'id': FAKE_ID, - 'links': [{ - 'href': 'stacks/%s/%s' % (FAKE_NAME, FAKE_ID), - 'rel': 'self'}], - 'notification_topics': '7', - 'outputs': '8', - 'parameters': {'OS::stack_id': '9'}, - 'name': FAKE_NAME, - 'status': '11', - 'status_reason': '12', - 'tags': ['FOO', 'bar:1'], - 'template_description': '13', - 'template_url': 'http://www.example.com/wordpress.yaml', - 'timeout_mins': '14', - 'updated_time': '2015-03-09T12:30:00.000000', -} -FAKE_CREATE_RESPONSE = { - 'stack': { - 'id': FAKE_ID, - 'links': [{ - 'href': 'stacks/%s/%s' % (FAKE_NAME, FAKE_ID), - 'rel': 'self'}]} -} - - -class TestStack(testtools.TestCase): - - def test_basic(self): - sot = stack.Stack() - self.assertEqual('stack', sot.resource_key) - self.assertEqual('stacks', sot.resources_key) - self.assertEqual('/stacks', sot.base_path) - self.assertEqual('orchestration', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = stack.Stack(**FAKE) - self.assertEqual(FAKE['capabilities'], sot.capabilities) - self.assertEqual(FAKE['creation_time'], sot.created_at) - self.assertEqual(FAKE['description'], sot.description) - self.assertTrue(sot.is_rollback_disabled) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['links'], sot.links) - self.assertEqual(FAKE['notification_topics'], - sot.notification_topics) - self.assertEqual(FAKE['outputs'], sot.outputs) - self.assertEqual(FAKE['parameters'], sot.parameters) - self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['status'], sot.status) - self.assertEqual(FAKE['status_reason'], sot.status_reason) - self.assertEqual(FAKE['tags'], sot.tags) - self.assertEqual(FAKE['template_description'], - sot.template_description) - self.assertEqual(FAKE['template_url'], sot.template_url) - self.assertEqual(FAKE['timeout_mins'], sot.timeout_mins) - self.assertEqual(FAKE['updated_time'], sot.updated_at) - - @mock.patch.object(resource.Resource, 'create') - def test_create(self, mock_create): - sess = mock.Mock() - sot = stack.Stack(FAKE) - - res = sot.create(sess) - - mock_create.assert_called_once_with(sess, prepend_key=False) - self.assertEqual(mock_create.return_value, res) - - @mock.patch.object(resource.Resource, 'update') - def test_update(self, mock_update): - sess = mock.Mock() - sot = stack.Stack(FAKE) - - res = sot.update(sess) - - mock_update.assert_called_once_with(sess, prepend_key=False, - has_body=False) - self.assertEqual(mock_update.return_value, res) - - def test_check(self): - sess = mock.Mock() - sot = stack.Stack(**FAKE) - sot._action = mock.Mock() - body = {'check': ''} - - sot.check(sess) - - sot._action.assert_called_with(sess, body) - - @mock.patch.object(resource.Resource, 'get') - def test_get(self, mock_get): - sess = mock.Mock() - sot = stack.Stack(**FAKE) - deleted_stack = mock.Mock(id=FAKE_ID, status='DELETE_COMPLETE') - normal_stack = mock.Mock(status='CREATE_COMPLETE') - mock_get.side_effect = [ - normal_stack, - exceptions.NotFoundException(message='oops'), - deleted_stack, - ] - - self.assertEqual(normal_stack, sot.get(sess)) - ex = self.assertRaises(exceptions.NotFoundException, sot.get, sess) - self.assertEqual('NotFoundException: oops', six.text_type(ex)) - ex = self.assertRaises(exceptions.NotFoundException, sot.get, sess) - self.assertEqual('NotFoundException: No stack found for %s' % FAKE_ID, - six.text_type(ex)) - - -class TestStackPreview(testtools.TestCase): - - def test_basic(self): - sot = stack.StackPreview() - - self.assertEqual('/stacks/preview', sot.base_path) - self.assertTrue(sot.allow_create) - self.assertFalse(sot.allow_list) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) diff --git a/openstack/tests/unit/orchestration/v1/test_stack_environment.py b/openstack/tests/unit/orchestration/v1/test_stack_environment.py deleted file mode 100644 index 93b7286e..00000000 --- a/openstack/tests/unit/orchestration/v1/test_stack_environment.py +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.orchestration.v1 import stack_environment as se - - -FAKE = { - 'encrypted_param_names': ['n1', 'n2'], - 'event_sinks': { - 's1': 'v1' - }, - 'parameters': { - 'key_name': { - 'type': 'string' - } - }, - 'parameter_defaults': { - 'p1': 'def1' - }, - 'resource_registry': { - 'resources': { - 'type1': 'type2' - } - }, -} - - -class TestStackTemplate(testtools.TestCase): - - def test_basic(self): - sot = se.StackEnvironment() - self.assertEqual('orchestration', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = se.StackEnvironment(**FAKE) - self.assertEqual(FAKE['encrypted_param_names'], - sot.encrypted_param_names) - self.assertEqual(FAKE['event_sinks'], sot.event_sinks) - self.assertEqual(FAKE['parameters'], sot.parameters) - self.assertEqual(FAKE['parameter_defaults'], sot.parameter_defaults) - self.assertEqual(FAKE['resource_registry'], sot.resource_registry) diff --git a/openstack/tests/unit/orchestration/v1/test_stack_files.py b/openstack/tests/unit/orchestration/v1/test_stack_files.py deleted file mode 100644 index 58d8def5..00000000 --- a/openstack/tests/unit/orchestration/v1/test_stack_files.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.orchestration.v1 import stack_files as sf - -FAKE = { - 'stack_id': 'ID', - 'stack_name': 'NAME' -} - - -class TestStackFiles(testtools.TestCase): - - def test_basic(self): - sot = sf.StackFiles() - self.assertEqual('orchestration', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = sf.StackFiles(**FAKE) - self.assertEqual(FAKE['stack_id'], sot.stack_id) - self.assertEqual(FAKE['stack_name'], sot.stack_name) diff --git a/openstack/tests/unit/orchestration/v1/test_stack_template.py b/openstack/tests/unit/orchestration/v1/test_stack_template.py deleted file mode 100644 index 592d644e..00000000 --- a/openstack/tests/unit/orchestration/v1/test_stack_template.py +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.orchestration.v1 import stack_template - - -FAKE = { - 'description': 'template description', - 'heat_template_version': '2014-10-16', - 'parameters': { - 'key_name': { - 'type': 'string' - } - }, - 'resources': { - 'resource1': { - 'type': 'ResourceType' - } - }, - 'outputs': { - 'key1': 'value1' - } -} - - -class TestStackTemplate(testtools.TestCase): - - def test_basic(self): - sot = stack_template.StackTemplate() - self.assertEqual('orchestration', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = stack_template.StackTemplate(**FAKE) - self.assertEqual(FAKE['description'], sot.description) - self.assertEqual(FAKE['heat_template_version'], - sot.heat_template_version) - self.assertEqual(FAKE['outputs'], sot.outputs) - self.assertEqual(FAKE['parameters'], sot.parameters) - self.assertEqual(FAKE['resources'], sot.resources) diff --git a/openstack/tests/unit/orchestration/v1/test_template.py b/openstack/tests/unit/orchestration/v1/test_template.py deleted file mode 100644 index c92b0ae7..00000000 --- a/openstack/tests/unit/orchestration/v1/test_template.py +++ /dev/null @@ -1,103 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.orchestration.v1 import template -from openstack import resource2 as resource - - -FAKE = { - 'Description': 'Blah blah', - 'Parameters': { - 'key_name': { - 'type': 'string' - } - }, - 'ParameterGroups': [{ - 'label': 'Group 1', - 'parameters': ['key_name'] - }] -} - - -class TestTemplate(testtools.TestCase): - - def test_basic(self): - sot = template.Template() - self.assertEqual('orchestration', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - - def test_make_it(self): - sot = template.Template(**FAKE) - self.assertEqual(FAKE['Description'], sot.description) - self.assertEqual(FAKE['Parameters'], sot.parameters) - self.assertEqual(FAKE['ParameterGroups'], sot.parameter_groups) - - @mock.patch.object(resource.Resource, '_translate_response') - def test_validate(self, mock_translate): - sess = mock.Mock() - sot = template.Template() - tmpl = mock.Mock() - body = {'template': tmpl} - - sot.validate(sess, tmpl) - - sess.post.assert_called_once_with( - '/validate', endpoint_filter=sot.service, json=body) - mock_translate.assert_called_once_with(sess.post.return_value) - - @mock.patch.object(resource.Resource, '_translate_response') - def test_validate_with_env(self, mock_translate): - sess = mock.Mock() - sot = template.Template() - tmpl = mock.Mock() - env = mock.Mock() - body = {'template': tmpl, 'environment': env} - - sot.validate(sess, tmpl, environment=env) - - sess.post.assert_called_once_with( - '/validate', endpoint_filter=sot.service, json=body) - mock_translate.assert_called_once_with(sess.post.return_value) - - @mock.patch.object(resource.Resource, '_translate_response') - def test_validate_with_template_url(self, mock_translate): - sess = mock.Mock() - sot = template.Template() - template_url = 'http://host1' - body = {'template': None, 'template_url': template_url} - - sot.validate(sess, None, template_url=template_url) - - sess.post.assert_called_once_with( - '/validate', endpoint_filter=sot.service, json=body) - mock_translate.assert_called_once_with(sess.post.return_value) - - @mock.patch.object(resource.Resource, '_translate_response') - def test_validate_with_ignore_errors(self, mock_translate): - sess = mock.Mock() - sot = template.Template() - tmpl = mock.Mock() - body = {'template': tmpl} - - sot.validate(sess, tmpl, ignore_errors='123,456') - - sess.post.assert_called_once_with( - '/validate?ignore_errors=123%2C456', - endpoint_filter=sot.service, json=body) - mock_translate.assert_called_once_with(sess.post.return_value) diff --git a/openstack/tests/unit/telemetry/__init__.py b/openstack/tests/unit/telemetry/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/telemetry/alarm/__init__.py b/openstack/tests/unit/telemetry/alarm/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/telemetry/alarm/test_alarm_service.py b/openstack/tests/unit/telemetry/alarm/test_alarm_service.py deleted file mode 100644 index 8106e961..00000000 --- a/openstack/tests/unit/telemetry/alarm/test_alarm_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.telemetry.alarm import alarm_service - - -class TestAlarmService(testtools.TestCase): - - def test_service(self): - sot = alarm_service.AlarmService() - self.assertEqual('alarming', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v2', sot.valid_versions[0].module) - self.assertEqual('v2', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/telemetry/alarm/v2/__init__.py b/openstack/tests/unit/telemetry/alarm/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/telemetry/alarm/v2/test_alarm.py b/openstack/tests/unit/telemetry/alarm/v2/test_alarm.py deleted file mode 100644 index cd0cb1af..00000000 --- a/openstack/tests/unit/telemetry/alarm/v2/test_alarm.py +++ /dev/null @@ -1,107 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.telemetry.alarm.v2 import alarm - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'alarm_actions': ['1'], - 'alarm_id': IDENTIFIER, - 'combination_rule': {'alarm_ids': ['2', 'b'], 'operator': 'or', }, - 'description': '3', - 'enabled': True, - 'insufficient_data_actions': ['4'], - 'name': '5', - 'ok_actions': ['6'], - 'project_id': '7', - 'repeat_actions': False, - 'severity': 'low', - 'state': 'insufficient data', - 'state_timestamp': '2015-03-09T12:15:57.233772', - 'timestamp': '2015-03-09T12:15:57.233772', - 'threshold_rule': { - 'meter_name': 'a', - 'evaluation_periods:': '1', - 'period': '60', - 'statistic': 'avg', - 'threshold': '92.6', - 'comparison_operator': 'gt', - 'exclude_outliers': True, - }, - 'time_constraints': [{'name': 'a', 'duration': 'b', 'start': 'c', }], - 'type': '10', - 'user_id': '11', -} - - -class TestAlarm(testtools.TestCase): - - def setUp(self): - super(TestAlarm, self).setUp() - self.resp = mock.Mock() - self.resp.body = '' - self.resp.json = mock.Mock(return_value=self.resp.body) - self.sess = mock.Mock() - self.sess.put = mock.Mock(return_value=self.resp) - - def test_basic(self): - sot = alarm.Alarm() - self.assertIsNone(sot.resource_key) - self.assertIsNone(sot.resources_key) - self.assertEqual('/alarms', sot.base_path) - self.assertEqual('alarming', sot.service.service_type) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_retrieve) - self.assertTrue(sot.allow_update) - self.assertTrue(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = alarm.Alarm(EXAMPLE) - self.assertEqual(IDENTIFIER, sot.id) - self.assertEqual(EXAMPLE['alarm_actions'], sot.alarm_actions) - self.assertEqual(IDENTIFIER, sot.alarm_id) - self.assertEqual(EXAMPLE['combination_rule'], sot.combination_rule) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertTrue(sot.is_enabled) - self.assertEqual(EXAMPLE['insufficient_data_actions'], - sot.insufficient_data_actions) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['ok_actions'], sot.ok_actions) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertFalse(sot.is_repeat_actions) - self.assertEqual(EXAMPLE['severity'], sot.severity) - self.assertEqual(EXAMPLE['state'], sot.state) - self.assertEqual(EXAMPLE['state_timestamp'], sot.state_changed_at) - self.assertEqual(EXAMPLE['timestamp'], sot.updated_at) - self.assertEqual(EXAMPLE['threshold_rule'], sot.threshold_rule) - self.assertEqual(EXAMPLE['time_constraints'], sot.time_constraints) - self.assertEqual(EXAMPLE['type'], sot.type) - self.assertEqual(EXAMPLE['user_id'], sot.user_id) - - def test_check_status(self): - sot = alarm.Alarm(EXAMPLE) - sot.check_state(self.sess) - - url = 'alarms/IDENTIFIER/state' - self.sess.get.assert_called_with(url, endpoint_filter=sot.service) - - def test_change_status(self): - sot = alarm.Alarm(EXAMPLE) - self.assertEqual(self.resp.body, sot.change_state(self.sess, 'alarm')) - - url = 'alarms/IDENTIFIER/state' - self.sess.put.assert_called_with(url, endpoint_filter=sot.service, - json='alarm') diff --git a/openstack/tests/unit/telemetry/alarm/v2/test_alarm_change.py b/openstack/tests/unit/telemetry/alarm/v2/test_alarm_change.py deleted file mode 100644 index bd272440..00000000 --- a/openstack/tests/unit/telemetry/alarm/v2/test_alarm_change.py +++ /dev/null @@ -1,74 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.telemetry.alarm.v2 import alarm_change - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'alarm_id': 0, - 'detail': '1', - 'event_id': IDENTIFIER, - 'on_behalf_of': '3', - 'project_id': '4', - 'timestamp': '2015-03-09T12:15:57.233772', - 'type': '6', - 'user_id': '7', -} - - -class TestAlarmChange(testtools.TestCase): - - def test_basic(self): - sot = alarm_change.AlarmChange() - self.assertEqual('alarm_change', sot.resource_key) - self.assertIsNone(sot.resources_key) - self.assertEqual('/alarms/%(alarm_id)s/history', sot.base_path) - self.assertEqual('alarming', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_retrieve) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = alarm_change.AlarmChange(EXAMPLE) - self.assertEqual(IDENTIFIER, sot.id) - self.assertEqual(EXAMPLE['alarm_id'], sot.alarm_id) - self.assertEqual(EXAMPLE['detail'], sot.detail) - self.assertEqual(IDENTIFIER, sot.event_id) - self.assertEqual(EXAMPLE['on_behalf_of'], sot.on_behalf_of_id) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['timestamp'], sot.triggered_at) - self.assertEqual(EXAMPLE['type'], sot.type) - self.assertEqual(EXAMPLE['user_id'], sot.user_id) - - def test_list(self): - sess = mock.Mock() - resp = mock.Mock() - resp.json = mock.Mock(return_value=[EXAMPLE, EXAMPLE]) - sess.get = mock.Mock(return_value=resp) - path_args = {'alarm_id': IDENTIFIER} - - found = alarm_change.AlarmChange.list(sess, path_args=path_args) - first = next(found) - self.assertEqual(IDENTIFIER, first.id) - self.assertEqual(EXAMPLE['alarm_id'], first.alarm_id) - self.assertEqual(EXAMPLE['detail'], first.detail) - self.assertEqual(IDENTIFIER, first.event_id) - self.assertEqual(EXAMPLE['on_behalf_of'], first.on_behalf_of_id) - self.assertEqual(EXAMPLE['project_id'], first.project_id) - self.assertEqual(EXAMPLE['timestamp'], first.triggered_at) - self.assertEqual(EXAMPLE['type'], first.type) - self.assertEqual(EXAMPLE['user_id'], first.user_id) diff --git a/openstack/tests/unit/telemetry/alarm/v2/test_proxy.py b/openstack/tests/unit/telemetry/alarm/v2/test_proxy.py deleted file mode 100644 index 343db891..00000000 --- a/openstack/tests/unit/telemetry/alarm/v2/test_proxy.py +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.telemetry.alarm.v2 import _proxy -from openstack.telemetry.alarm.v2 import alarm -from openstack.telemetry.alarm.v2 import alarm_change -from openstack.tests.unit import test_proxy_base - - -class TestAlarmProxy(test_proxy_base.TestProxyBase): - def setUp(self): - super(TestAlarmProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_alarm_change_find(self): - self.verify_find(self.proxy.find_alarm_change, - alarm_change.AlarmChange) - - def test_alarm_changes(self): - larm = alarm.Alarm.existing(alarm_id='larm') - expected_kwargs = {'path_args': {'alarm_id': 'larm'}} - self.verify_list(self.proxy.alarm_changes, alarm_change.AlarmChange, - method_args=[larm], paginated=False, - expected_kwargs=expected_kwargs) - - def test_alarm_create_attrs(self): - self.verify_create(self.proxy.create_alarm, alarm.Alarm) - - def test_alarm_delete(self): - self.verify_delete(self.proxy.delete_alarm, alarm.Alarm, False) - - def test_alarm_delete_ignore(self): - self.verify_delete(self.proxy.delete_alarm, alarm.Alarm, True) - - def test_alarm_find(self): - self.verify_find(self.proxy.find_alarm, alarm.Alarm) - - def test_alarm_get(self): - self.verify_get(self.proxy.get_alarm, alarm.Alarm) - - def test_alarms(self): - self.verify_list(self.proxy.alarms, alarm.Alarm, paginated=False) - - def test_alarm_update(self): - self.verify_update(self.proxy.update_alarm, alarm.Alarm) diff --git a/openstack/tests/unit/telemetry/test_telemetry_service.py b/openstack/tests/unit/telemetry/test_telemetry_service.py deleted file mode 100644 index acc7da94..00000000 --- a/openstack/tests/unit/telemetry/test_telemetry_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.telemetry import telemetry_service - - -class TestTelemetryService(testtools.TestCase): - - def test_service(self): - sot = telemetry_service.TelemetryService() - self.assertEqual('metering', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v2', sot.valid_versions[0].module) - self.assertEqual('v2', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/telemetry/v2/__init__.py b/openstack/tests/unit/telemetry/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/telemetry/v2/test_capability.py b/openstack/tests/unit/telemetry/v2/test_capability.py deleted file mode 100644 index 8d37c8ae..00000000 --- a/openstack/tests/unit/telemetry/v2/test_capability.py +++ /dev/null @@ -1,70 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.telemetry.v2 import capability - -EXAMPLE = { - "id": "123", - "enabled": False, -} -BODY = { - "api": { - "statistics:query:complex": False, - "alarms:history:query:simple": True, - "events:query:simple": True, - "alarms:query:simple": True, - "resources:query:simple": True, - } -} - - -class TestCapability(testtools.TestCase): - def test_basic(self): - sot = capability.Capability() - self.assertEqual('capability', sot.resource_key) - self.assertEqual('capabilities', sot.resources_key) - self.assertEqual('/capabilities', sot.base_path) - self.assertEqual('metering', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = capability.Capability(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['enabled'], sot.is_enabled) - - def test_list(self): - sess = mock.Mock() - resp = mock.Mock() - resp.json = mock.Mock(return_value=BODY) - sess.get = mock.Mock(return_value=resp) - - caps = capability.Capability.list(sess) - - caps = sorted(caps, key=lambda cap: cap.id) - self.assertEqual(5, len(caps)) - self.assertEqual('alarms:history:query:simple', caps[0].id) - self.assertTrue(caps[0].is_enabled) - self.assertEqual('alarms:query:simple', caps[1].id) - self.assertTrue(caps[1].is_enabled) - self.assertEqual('events:query:simple', caps[2].id) - self.assertTrue(caps[2].is_enabled) - self.assertEqual('resources:query:simple', caps[3].id) - self.assertTrue(caps[3].is_enabled) - self.assertEqual('statistics:query:complex', caps[4].id) - self.assertFalse(caps[4].is_enabled) diff --git a/openstack/tests/unit/telemetry/v2/test_meter.py b/openstack/tests/unit/telemetry/v2/test_meter.py deleted file mode 100644 index 83cdb894..00000000 --- a/openstack/tests/unit/telemetry/v2/test_meter.py +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.telemetry.v2 import meter - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'meter_id': IDENTIFIER, - 'name': 'instance', - 'project_id': '123', - 'resource_id': '456', - 'source': 'abc', - 'type': 'def', - 'unit': 'ghi', - 'user_id': '789' -} - - -class TestMeter(testtools.TestCase): - - def test_basic(self): - sot = meter.Meter() - self.assertEqual('meter', sot.resource_key) - self.assertIsNone(sot.resources_key) - self.assertEqual('/meters', sot.base_path) - self.assertEqual('metering', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = meter.Meter(**EXAMPLE) - self.assertEqual(EXAMPLE['meter_id'], sot.id) - self.assertEqual(EXAMPLE['meter_id'], sot.meter_id) - self.assertEqual(EXAMPLE['name'], sot.name) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['resource_id'], sot.resource_id) - self.assertEqual(EXAMPLE['source'], sot.source) - self.assertEqual(EXAMPLE['type'], sot.type) - self.assertEqual(EXAMPLE['unit'], sot.unit) - self.assertEqual(EXAMPLE['user_id'], sot.user_id) diff --git a/openstack/tests/unit/telemetry/v2/test_proxy.py b/openstack/tests/unit/telemetry/v2/test_proxy.py deleted file mode 100644 index 974dd8f0..00000000 --- a/openstack/tests/unit/telemetry/v2/test_proxy.py +++ /dev/null @@ -1,66 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.telemetry.v2 import _proxy -from openstack.telemetry.v2 import capability -from openstack.telemetry.v2 import meter -from openstack.telemetry.v2 import resource -from openstack.telemetry.v2 import sample -from openstack.telemetry.v2 import statistics -from openstack.tests.unit import test_proxy_base2 - - -class TestTelemetryProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestTelemetryProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_capability_find(self): - self.verify_find(self.proxy.find_capability, capability.Capability) - - def test_capabilities(self): - self.verify_list(self.proxy.capabilities, capability.Capability, - paginated=False) - - def test_meter_find(self): - self.verify_find(self.proxy.find_meter, meter.Meter) - - def test_meters(self): - self.verify_list(self.proxy.meters, meter.Meter, paginated=False) - - def test_resource_find(self): - self.verify_find(self.proxy.find_resource, resource.Resource) - - def test_resource_get(self): - self.verify_get(self.proxy.get_resource, resource.Resource) - - def test_resources(self): - self.verify_list(self.proxy.resources, resource.Resource, - paginated=False) - - def test_sample_find(self): - self.verify_find(self.proxy.find_sample, sample.Sample) - - def test_samples(self): - expected_kwargs = {'counter_name': 'meterone'} - self.verify_list(self.proxy.samples, sample.Sample, - method_args=['meterone'], - paginated=False, expected_kwargs=expected_kwargs) - - def test_statistics_find(self): - self.verify_find(self.proxy.find_statistics, statistics.Statistics) - - def test_statistics(self): - expected_kwargs = {'meter_name': 'meterone'} - self.verify_list(self.proxy.statistics, statistics.Statistics, - method_args=['meterone'], - paginated=False, expected_kwargs=expected_kwargs) diff --git a/openstack/tests/unit/telemetry/v2/test_resource.py b/openstack/tests/unit/telemetry/v2/test_resource.py deleted file mode 100644 index 62051830..00000000 --- a/openstack/tests/unit/telemetry/v2/test_resource.py +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.telemetry.v2 import resource - -IDENTIFIER = 'IDENTIFIER' -LINKS = [{'href': 'first_uri', 'rel': 'label 1', }, - {'href': 'other_uri', 'rel': 'label', }, ] -EXAMPLE = { - 'resource_id': IDENTIFIER, - 'first_sample_timestamp': '2015-03-09T12:15:57.233772', - 'last_sample_timestamp': '2015-03-09T12:15:57.233772', - 'links': LINKS, - 'metadata': {'name_one': '1', 'name_two': '2', }, - 'project_id': '123', - 'source': 'abc', - 'user_id': '789' -} - - -class TestResource(testtools.TestCase): - - def test_basic(self): - sot = resource.Resource() - self.assertIsNone(sot.resource_key) - self.assertIsNone(sot.resources_key) - self.assertEqual('/resources', sot.base_path) - self.assertEqual('metering', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = resource.Resource(**EXAMPLE) - self.assertEqual(EXAMPLE['resource_id'], sot.id) - self.assertEqual(EXAMPLE['resource_id'], sot.resource_id) - self.assertEqual(EXAMPLE['first_sample_timestamp'], - sot.first_sample_at) - self.assertEqual(EXAMPLE['last_sample_timestamp'], - sot.last_sample_at) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['metadata'], sot.metadata) - self.assertEqual(EXAMPLE['project_id'], sot.project_id) - self.assertEqual(EXAMPLE['resource_id'], sot.resource_id) - self.assertEqual(EXAMPLE['source'], sot.source) - self.assertEqual(EXAMPLE['user_id'], sot.user_id) diff --git a/openstack/tests/unit/telemetry/v2/test_sample.py b/openstack/tests/unit/telemetry/v2/test_sample.py deleted file mode 100644 index 9c31427d..00000000 --- a/openstack/tests/unit/telemetry/v2/test_sample.py +++ /dev/null @@ -1,83 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.telemetry.v2 import sample - -SAMPLE = { - 'sample_id': '0', - 'metadata': {'1': 'one'}, - 'counter_name': '2', - 'message_id': '4', - 'project_id': '3', - 'recorded_at': '2015-03-09T12:15:57.233772', - 'resource_id': '5', - 'source': '6', - 'timestamp': '2015-03-09T12:15:57.233772', - 'type': '8', - 'unit': '9', - 'user_id': '10', - 'volume': '11.1', -} - - -class TestSample(testtools.TestCase): - - def test_basic(self): - sot = sample.Sample() - self.assertIsNone(sot.resource_key) - self.assertIsNone(sot.resources_key) - self.assertEqual('/meters/%(counter_name)s', sot.base_path) - self.assertEqual('metering', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_new(self): - sot = sample.Sample(**SAMPLE) - self.assertEqual(SAMPLE['message_id'], sot.id) - self.assertEqual(SAMPLE['metadata'], sot.metadata) - self.assertEqual(SAMPLE['counter_name'], sot.counter_name) - self.assertEqual(SAMPLE['project_id'], sot.project_id) - self.assertEqual(SAMPLE['recorded_at'], sot.recorded_at) - self.assertEqual(SAMPLE['resource_id'], sot.resource_id) - self.assertEqual(SAMPLE['source'], sot.source) - self.assertEqual(SAMPLE['timestamp'], sot.generated_at) - self.assertEqual(SAMPLE['type'], sot.type) - self.assertEqual(SAMPLE['unit'], sot.unit) - self.assertEqual(SAMPLE['user_id'], sot.user_id) - self.assertEqual(SAMPLE['volume'], sot.volume) - - def test_list(self): - sess = mock.Mock() - resp = mock.Mock() - resp.json = mock.Mock(return_value=[SAMPLE]) - sess.get = mock.Mock(return_value=resp) - - found = sample.Sample.list(sess, counter_name='name_of_meter') - first = next(found) - self.assertEqual(SAMPLE['message_id'], first.id) - self.assertEqual(SAMPLE['metadata'], first.metadata) - self.assertEqual(SAMPLE['counter_name'], first.counter_name) - self.assertEqual(SAMPLE['project_id'], first.project_id) - self.assertEqual(SAMPLE['recorded_at'], first.recorded_at) - self.assertEqual(SAMPLE['resource_id'], first.resource_id) - self.assertEqual(SAMPLE['source'], first.source) - self.assertEqual(SAMPLE['timestamp'], first.generated_at) - self.assertEqual(SAMPLE['type'], first.type) - self.assertEqual(SAMPLE['unit'], first.unit) - self.assertEqual(SAMPLE['user_id'], first.user_id) - self.assertEqual(SAMPLE['volume'], first.volume) diff --git a/openstack/tests/unit/telemetry/v2/test_statistics.py b/openstack/tests/unit/telemetry/v2/test_statistics.py deleted file mode 100644 index 71ea61b3..00000000 --- a/openstack/tests/unit/telemetry/v2/test_statistics.py +++ /dev/null @@ -1,93 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack.telemetry.v2 import statistics - -EXAMPLE = { - 'aggregate': '1', - 'avg': '2', - 'count': '3', - 'duration': '4', - 'duration_end': '2015-03-09T12:45:00.000000', - 'duration_start': '2015-03-09T12:15:00.000000', - 'groupby': '7', - 'max': '8', - 'min': '9', - 'period': '10', - 'period_end': '2015-03-09T12:45:00.000000', - 'period_start': '2015-03-09T12:15:00.000000', - 'sum': '13', - 'unit': '14', -} - - -class TestStatistics(testtools.TestCase): - - def test_basic(self): - sot = statistics.Statistics() - self.assertEqual('statistics', sot.resource_key) - self.assertIsNone(sot.resources_key) - self.assertEqual('/meters/%(meter_name)s/statistics', sot.base_path) - self.assertEqual('metering', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = statistics.Statistics(**EXAMPLE) - self.assertEqual(EXAMPLE['unit'], sot.id) - self.assertEqual(EXAMPLE['aggregate'], sot.aggregate) - self.assertEqual(EXAMPLE['avg'], sot.avg) - self.assertEqual(EXAMPLE['count'], sot.count) - self.assertEqual(EXAMPLE['duration'], sot.duration) - self.assertEqual(EXAMPLE['duration_end'], sot.duration_end_at) - self.assertEqual(EXAMPLE['duration_start'], sot.duration_start_at) - self.assertEqual(EXAMPLE['groupby'], sot.group_by) - self.assertEqual(EXAMPLE['max'], sot.max) - self.assertEqual(EXAMPLE['min'], sot.min) - self.assertEqual(EXAMPLE['period'], sot.period) - self.assertEqual(EXAMPLE['period_end'], sot.period_end_at) - self.assertEqual(EXAMPLE['period_start'], sot.period_start_at) - self.assertEqual(EXAMPLE['sum'], sot.sum) - self.assertEqual(EXAMPLE['unit'], sot.unit) - - def test_list(self): - sess = mock.Mock() - resp = mock.Mock() - resp.json = mock.Mock(return_value=[EXAMPLE]) - sess.get = mock.Mock(return_value=resp) - reply = statistics.Statistics.list(sess, meter_name='example') - - url = '/meters/example/statistics' - stat = next(reply) - sess.get.assert_called_with(url, endpoint_filter=stat.service, - params={}) - self.assertEqual(EXAMPLE['aggregate'], stat.aggregate) - self.assertEqual(EXAMPLE['avg'], stat.avg) - self.assertEqual(EXAMPLE['count'], stat.count) - self.assertEqual(EXAMPLE['duration'], stat.duration) - self.assertEqual(EXAMPLE['duration_end'], stat.duration_end_at) - self.assertEqual(EXAMPLE['duration_start'], stat.duration_start_at) - self.assertEqual(EXAMPLE['groupby'], stat.group_by) - self.assertEqual(EXAMPLE['max'], stat.max) - self.assertEqual(EXAMPLE['min'], stat.min) - self.assertEqual(EXAMPLE['period'], stat.period) - self.assertEqual(EXAMPLE['period_end'], stat.period_end_at) - self.assertEqual(EXAMPLE['period_start'], stat.period_start_at) - self.assertEqual(EXAMPLE['sum'], stat.sum) - self.assertEqual(EXAMPLE['unit'], stat.unit) - self.assertRaises(StopIteration, next, reply) diff --git a/openstack/tests/unit/test_connection.py b/openstack/tests/unit/test_connection.py deleted file mode 100644 index 229dbb72..00000000 --- a/openstack/tests/unit/test_connection.py +++ /dev/null @@ -1,244 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import os - -import fixtures -from keystoneauth1 import session as ksa_session -import mock -import os_client_config - -from openstack import connection -from openstack import exceptions -from openstack import profile -from openstack import session -from openstack.tests.unit import base - - -CONFIG_AUTH_URL = "http://127.0.0.1:5000/v2.0" -CONFIG_USERNAME = "BozoTheClown" -CONFIG_PASSWORD = "TopSecret" -CONFIG_PROJECT = "TheGrandPrizeGame" -CONFIG_CACERT = "TrustMe" - -CLOUD_CONFIG = """ -clouds: - sample: - region_name: RegionOne - auth: - auth_url: {auth_url} - username: {username} - password: {password} - project_name: {project} - insecure: - auth: - auth_url: {auth_url} - username: {username} - password: {password} - project_name: {project} - cacert: {cacert} - insecure: True - cacert: - auth: - auth_url: {auth_url} - username: {username} - password: {password} - project_name: {project} - cacert: {cacert} - insecure: False -""".format(auth_url=CONFIG_AUTH_URL, username=CONFIG_USERNAME, - password=CONFIG_PASSWORD, project=CONFIG_PROJECT, - cacert=CONFIG_CACERT) - - -class TestConnection(base.TestCase): - @mock.patch("openstack.session.Session") - def test_other_parameters(self, mock_session_init): - mock_session_init.return_value = mock_session_init - mock_profile = mock.Mock() - mock_profile.get_services = mock.Mock(return_value=[]) - conn = connection.Connection(profile=mock_profile, authenticator='2', - verify=True, cert='cert', user_agent='1') - args = {'auth': '2', 'user_agent': '1', 'verify': True, 'cert': 'cert'} - mock_session_init.assert_called_with(mock_profile, **args) - self.assertEqual(mock_session_init, conn.session) - - def test_session_provided(self): - mock_session = mock.Mock(spec=session.Session) - mock_profile = mock.Mock() - mock_profile.get_services = mock.Mock(return_value=[]) - conn = connection.Connection(session=mock_session, - profile=mock_profile, - user_agent='1') - self.assertEqual(mock_session, conn.session) - - def test_ksa_session_provided(self): - mock_session = mock.Mock(spec=ksa_session.Session) - mock_profile = mock.Mock() - mock_profile.get_services = mock.Mock(return_value=[]) - self.assertRaises(exceptions.SDKException, connection.Connection, - session=mock_session, profile=mock_profile, - user_agent='1') - - @mock.patch("keystoneauth1.loading.base.get_plugin_loader") - def test_create_authenticator(self, mock_get_plugin): - mock_plugin = mock.Mock() - mock_loader = mock.Mock() - mock_options = [ - mock.Mock(dest="auth_url"), - mock.Mock(dest="password"), - mock.Mock(dest="username"), - ] - mock_loader.get_options = mock.Mock(return_value=mock_options) - mock_loader.load_from_options = mock.Mock(return_value=mock_plugin) - mock_get_plugin.return_value = mock_loader - auth_args = { - 'auth_url': '0', - 'username': '1', - 'password': '2', - } - conn = connection.Connection(auth_plugin='v2password', **auth_args) - mock_get_plugin.assert_called_with('v2password') - mock_loader.load_from_options.assert_called_with(**auth_args) - self.assertEqual(mock_plugin, conn.authenticator) - - @mock.patch("keystoneauth1.loading.base.get_plugin_loader") - def test_default_plugin(self, mock_get_plugin): - connection.Connection() - self.assertTrue(mock_get_plugin.called) - self.assertEqual(mock_get_plugin.call_args, mock.call("password")) - - @mock.patch("keystoneauth1.loading.base.get_plugin_loader") - def test_pass_authenticator(self, mock_get_plugin): - mock_plugin = mock.Mock() - mock_get_plugin.return_value = None - conn = connection.Connection(authenticator=mock_plugin) - self.assertFalse(mock_get_plugin.called) - self.assertEqual(mock_plugin, conn.authenticator) - - def test_create_session(self): - auth = mock.Mock() - prof = profile.Profile() - conn = connection.Connection(authenticator=auth, profile=prof) - self.assertEqual(auth, conn.authenticator) - self.assertEqual(prof, conn.profile) - self.assertEqual('openstack.telemetry.alarm.v2._proxy', - conn.alarm.__class__.__module__) - self.assertEqual('openstack.cluster.v1._proxy', - conn.cluster.__class__.__module__) - self.assertEqual('openstack.compute.v2._proxy', - conn.compute.__class__.__module__) - self.assertEqual('openstack.database.v1._proxy', - conn.database.__class__.__module__) - self.assertEqual('openstack.identity.v3._proxy', - conn.identity.__class__.__module__) - self.assertEqual('openstack.image.v2._proxy', - conn.image.__class__.__module__) - self.assertEqual('openstack.network.v2._proxy', - conn.network.__class__.__module__) - self.assertEqual('openstack.object_store.v1._proxy', - conn.object_store.__class__.__module__) - self.assertEqual('openstack.load_balancer.v2._proxy', - conn.load_balancer.__class__.__module__) - self.assertEqual('openstack.orchestration.v1._proxy', - conn.orchestration.__class__.__module__) - self.assertEqual('openstack.telemetry.v2._proxy', - conn.telemetry.__class__.__module__) - self.assertEqual('openstack.workflow.v2._proxy', - conn.workflow.__class__.__module__) - - def _prepare_test_config(self): - # Create a temporary directory where our test config will live - # and insert it into the search path via OS_CLIENT_CONFIG_FILE. - config_dir = self.useFixture(fixtures.TempDir()).path - config_path = os.path.join(config_dir, "clouds.yaml") - - with open(config_path, "w") as conf: - conf.write(CLOUD_CONFIG) - - self.useFixture(fixtures.EnvironmentVariable( - "OS_CLIENT_CONFIG_FILE", config_path)) - - def test_from_config_given_data(self): - self._prepare_test_config() - - data = os_client_config.OpenStackConfig().get_one_cloud("sample") - - sot = connection.from_config(cloud_config=data) - - self.assertEqual(CONFIG_USERNAME, - sot.authenticator._username) - self.assertEqual(CONFIG_PASSWORD, - sot.authenticator._password) - self.assertEqual(CONFIG_AUTH_URL, - sot.authenticator.auth_url) - self.assertEqual(CONFIG_PROJECT, - sot.authenticator._project_name) - - def test_from_config_given_name(self): - self._prepare_test_config() - - sot = connection.from_config(cloud_name="sample") - - self.assertEqual(CONFIG_USERNAME, - sot.authenticator._username) - self.assertEqual(CONFIG_PASSWORD, - sot.authenticator._password) - self.assertEqual(CONFIG_AUTH_URL, - sot.authenticator.auth_url) - self.assertEqual(CONFIG_PROJECT, - sot.authenticator._project_name) - - def test_from_config_given_options(self): - self._prepare_test_config() - - version = "100" - - class Opts(object): - compute_api_version = version - - sot = connection.from_config(cloud_name="sample", options=Opts) - - pref = sot.session.profile.get_filter("compute") - - # NOTE: Along the way, the `v` prefix gets added so we can build - # up URLs with it. - self.assertEqual("v" + version, pref.version) - - def test_from_config_verify(self): - self._prepare_test_config() - - sot = connection.from_config(cloud_name="insecure") - self.assertFalse(sot.session.verify) - - sot = connection.from_config(cloud_name="cacert") - self.assertEqual(CONFIG_CACERT, sot.session.verify) - - def test_authorize_works(self): - fake_session = mock.Mock(spec=session.Session) - fake_headers = {'X-Auth-Token': 'FAKE_TOKEN'} - fake_session.get_auth_headers.return_value = fake_headers - - sot = connection.Connection(session=fake_session, - authenticator=mock.Mock()) - res = sot.authorize() - self.assertEqual('FAKE_TOKEN', res) - - def test_authorize_silent_failure(self): - fake_session = mock.Mock(spec=session.Session) - fake_session.get_auth_headers.return_value = None - fake_session.__module__ = 'openstack.session' - - sot = connection.Connection(session=fake_session, - authenticator=mock.Mock()) - res = sot.authorize() - self.assertIsNone(res) diff --git a/openstack/tests/unit/test_exceptions.py b/openstack/tests/unit/test_exceptions.py deleted file mode 100644 index 54a95b1f..00000000 --- a/openstack/tests/unit/test_exceptions.py +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack import exceptions - - -class Test_Exception(testtools.TestCase): - def test_method_not_supported(self): - exc = exceptions.MethodNotSupported(self.__class__, 'list') - expected = ('The list method is not supported for ' + - 'openstack.tests.unit.test_exceptions.Test_Exception') - self.assertEqual(expected, str(exc)) - - -class Test_HttpException(testtools.TestCase): - - def setUp(self): - super(Test_HttpException, self).setUp() - self.message = "mayday" - - def _do_raise(self, *args, **kwargs): - raise exceptions.HttpException(*args, **kwargs) - - def test_message(self): - exc = self.assertRaises(exceptions.HttpException, - self._do_raise, self.message) - - self.assertEqual(self.message, exc.message) - - def test_details(self): - details = "some details" - exc = self.assertRaises(exceptions.HttpException, - self._do_raise, self.message, - details=details) - - self.assertEqual(self.message, exc.message) - self.assertEqual(details, exc.details) - - def test_http_status(self): - http_status = 123 - exc = self.assertRaises(exceptions.HttpException, - self._do_raise, self.message, - http_status=http_status) - - self.assertEqual(self.message, exc.message) - self.assertEqual(http_status, exc.http_status) diff --git a/openstack/tests/unit/test_format.py b/openstack/tests/unit/test_format.py deleted file mode 100644 index f78454dd..00000000 --- a/openstack/tests/unit/test_format.py +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack import format - - -class TestBoolStrFormatter(testtools.TestCase): - - def test_deserialize(self): - self.assertTrue(format.BoolStr.deserialize(True)) - self.assertTrue(format.BoolStr.deserialize('True')) - self.assertTrue(format.BoolStr.deserialize('TRUE')) - self.assertTrue(format.BoolStr.deserialize('true')) - self.assertFalse(format.BoolStr.deserialize(False)) - self.assertFalse(format.BoolStr.deserialize('False')) - self.assertFalse(format.BoolStr.deserialize('FALSE')) - self.assertFalse(format.BoolStr.deserialize('false')) - self.assertRaises(ValueError, format.BoolStr.deserialize, None) - self.assertRaises(ValueError, format.BoolStr.deserialize, '') - self.assertRaises(ValueError, format.BoolStr.deserialize, 'INVALID') - - def test_serialize(self): - self.assertEqual('true', format.BoolStr.serialize(True)) - self.assertEqual('false', format.BoolStr.serialize(False)) - self.assertRaises(ValueError, format.BoolStr.serialize, None) - self.assertRaises(ValueError, format.BoolStr.serialize, '') - self.assertRaises(ValueError, format.BoolStr.serialize, 'True') diff --git a/openstack/tests/unit/test_profile.py b/openstack/tests/unit/test_profile.py deleted file mode 100644 index 27291817..00000000 --- a/openstack/tests/unit/test_profile.py +++ /dev/null @@ -1,106 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import exceptions -from openstack import profile -from openstack.tests.unit import base - - -class TestProfile(base.TestCase): - def test_init(self): - prof = profile.Profile() - expected = [ - 'alarming', - 'baremetal', - 'clustering', - 'compute', - 'database', - 'identity', - 'image', - 'key-manager', - 'load_balancer', - 'messaging', - 'metering', - 'network', - 'object-store', - 'orchestration', - 'volume', - 'workflowv2', - ] - self.assertEqual(expected, prof.service_keys) - - def test_default_versions(self): - prof = profile.Profile() - self.assertEqual('v1', prof.get_filter('baremetal').version) - self.assertEqual('v1', prof.get_filter('clustering').version) - self.assertEqual('v2', prof.get_filter('compute').version) - self.assertEqual('v1', prof.get_filter('database').version) - self.assertEqual('v3', prof.get_filter('identity').version) - self.assertEqual('v2', prof.get_filter('image').version) - self.assertEqual('v2', prof.get_filter('load_balancer').version) - self.assertEqual('v2', prof.get_filter('network').version) - self.assertEqual('v1', prof.get_filter('object-store').version) - self.assertEqual('v1', prof.get_filter('orchestration').version) - self.assertEqual('v1', prof.get_filter('key-manager').version) - self.assertEqual('v2', prof.get_filter('metering').version) - self.assertEqual('v2', prof.get_filter('volume').version) - self.assertEqual('v1', prof.get_filter('messaging').version) - - def test_set(self): - prof = profile.Profile() - prof.set_version('alarming', 'v2') - self.assertEqual('v2', prof.get_filter('alarming').version) - prof.set_version('baremetal', 'v1') - self.assertEqual('v1', prof.get_filter('baremetal').version) - prof.set_version('clustering', 'v1') - self.assertEqual('v1', prof.get_filter('clustering').version) - prof.set_version('compute', 'v2') - self.assertEqual('v2', prof.get_filter('compute').version) - prof.set_version('database', 'v3') - self.assertEqual('v3', prof.get_filter('database').version) - prof.set_version('identity', 'v4') - self.assertEqual('v4', prof.get_filter('identity').version) - prof.set_version('image', 'v5') - self.assertEqual('v5', prof.get_filter('image').version) - prof.set_version('metering', 'v6') - self.assertEqual('v6', prof.get_filter('metering').version) - prof.set_version('network', 'v7') - self.assertEqual('v7', prof.get_filter('network').version) - prof.set_version('object-store', 'v8') - self.assertEqual('v8', prof.get_filter('object-store').version) - prof.set_version('orchestration', 'v9') - self.assertEqual('v9', prof.get_filter('orchestration').version) - - def test_set_version_bad_service(self): - prof = profile.Profile() - self.assertRaises(exceptions.SDKException, prof.set_version, 'bogus', - 'v2') - - def test_set_api_version(self): - # This tests that api_version is effective after explicit setting, or - # else it defaults to None. - prof = profile.Profile() - prof.set_api_version('clustering', '1.2') - svc = prof.get_filter('clustering') - self.assertEqual('1.2', svc.api_version) - svc = prof.get_filter('compute') - self.assertIsNone(svc.api_version) - - def test_set_all(self): - prof = profile.Profile() - prof.set_name(prof.ALL, 'fee') - prof.set_region(prof.ALL, 'fie') - prof.set_interface(prof.ALL, 'public') - for service in prof.service_keys: - self.assertEqual('fee', prof.get_filter(service).service_name) - self.assertEqual('fie', prof.get_filter(service).region) - self.assertEqual('public', prof.get_filter(service).interface) diff --git a/openstack/tests/unit/test_proxy.py b/openstack/tests/unit/test_proxy.py deleted file mode 100644 index ec4f6807..00000000 --- a/openstack/tests/unit/test_proxy.py +++ /dev/null @@ -1,353 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack import exceptions -from openstack import proxy -from openstack import resource - - -class DeleteableResource(resource.Resource): - allow_delete = True - - -class UpdateableResource(resource.Resource): - allow_update = True - - -class CreateableResource(resource.Resource): - allow_create = True - - -class RetrieveableResource(resource.Resource): - allow_retrieve = True - - -class ListableResource(resource.Resource): - allow_list = True - - -class HeadableResource(resource.Resource): - allow_head = True - - -class Test_check_resource(testtools.TestCase): - - def setUp(self): - super(Test_check_resource, self).setUp() - - def method(self, expected_type, value): - return value - - self.sot = mock.Mock() - self.sot.method = method - - def _test_correct(self, value): - decorated = proxy._check_resource(strict=False)(self.sot.method) - rv = decorated(self.sot, resource.Resource, value) - - self.assertEqual(value, rv) - - def test_correct_resource(self): - res = resource.Resource() - self._test_correct(res) - - def test_notstrict_id(self): - self._test_correct("abc123-id") - - def test_strict_id(self): - decorated = proxy._check_resource(strict=True)(self.sot.method) - self.assertRaisesRegex(ValueError, "A Resource must be passed", - decorated, self.sot, resource.Resource, - "this-is-not-a-resource") - - def test_incorrect_resource(self): - class OneType(resource.Resource): - pass - - class AnotherType(resource.Resource): - pass - - value = AnotherType() - decorated = proxy._check_resource(strict=False)(self.sot.method) - self.assertRaisesRegex(ValueError, - "Expected OneType but received AnotherType", - decorated, self.sot, OneType, value) - - -class TestProxyDelete(testtools.TestCase): - - def setUp(self): - super(TestProxyDelete, self).setUp() - - self.session = mock.Mock() - - self.fake_id = 1 - self.res = mock.Mock(spec=DeleteableResource) - self.res.id = self.fake_id - self.res.delete = mock.Mock() - - self.sot = proxy.BaseProxy(self.session) - DeleteableResource.existing = mock.Mock(return_value=self.res) - - def test_delete(self): - self.sot._delete(DeleteableResource, self.res) - self.res.delete.assert_called_with(self.session) - - self.sot._delete(DeleteableResource, self.fake_id) - DeleteableResource.existing.assert_called_with(id=self.fake_id) - self.res.delete.assert_called_with(self.session) - - # Delete generally doesn't return anything, so we will normally - # swallow any return from within a service's proxy, but make sure - # we can still return for any cases where values are returned. - self.res.delete.return_value = self.fake_id - rv = self.sot._delete(DeleteableResource, self.fake_id) - self.assertEqual(rv, self.fake_id) - - def test_delete_ignore_missing(self): - self.res.delete.side_effect = exceptions.NotFoundException( - message="test", http_status=404) - - rv = self.sot._delete(DeleteableResource, self.fake_id) - self.assertIsNone(rv) - - def test_delete_ResourceNotFound(self): - self.res.delete.side_effect = exceptions.NotFoundException( - message="test", http_status=404) - - self.assertRaisesRegex( - exceptions.ResourceNotFound, - "No %s found for %s" % (DeleteableResource.__name__, self.res), - self.sot._delete, DeleteableResource, self.res, - ignore_missing=False) - - def test_delete_HttpException(self): - self.res.delete.side_effect = exceptions.HttpException( - message="test", http_status=500) - - self.assertRaises(exceptions.HttpException, self.sot._delete, - DeleteableResource, self.res, ignore_missing=False) - - -class TestProxyUpdate(testtools.TestCase): - - def setUp(self): - super(TestProxyUpdate, self).setUp() - - self.session = mock.Mock() - - self.fake_id = 1 - self.fake_result = "fake_result" - - self.res = mock.Mock(spec=UpdateableResource) - self.res.update = mock.Mock(return_value=self.fake_result) - self.res.update_attrs = mock.Mock() - - self.sot = proxy.BaseProxy(self.session) - - self.attrs = {"x": 1, "y": 2, "z": 3} - - UpdateableResource.existing = mock.Mock(return_value=self.res) - - def _test_update(self, value): - rv = self.sot._update(UpdateableResource, value, **self.attrs) - - self.assertEqual(rv, self.fake_result) - self.res.update_attrs.assert_called_once_with(self.attrs) - self.res.update.assert_called_once_with(self.session) - - def test_update_resource(self): - self._test_update(self.res) - - def test_update_id(self): - self._test_update(self.fake_id) - - -class TestProxyCreate(testtools.TestCase): - - def setUp(self): - super(TestProxyCreate, self).setUp() - - self.session = mock.Mock() - - self.fake_result = "fake_result" - self.res = mock.Mock(spec=CreateableResource) - self.res.create = mock.Mock(return_value=self.fake_result) - - self.sot = proxy.BaseProxy(self.session) - - def test_create_attributes(self): - CreateableResource.new = mock.Mock(return_value=self.res) - - attrs = {"x": 1, "y": 2, "z": 3} - rv = self.sot._create(CreateableResource, **attrs) - - self.assertEqual(rv, self.fake_result) - CreateableResource.new.assert_called_once_with(**attrs) - self.res.create.assert_called_once_with(self.session) - - -class TestProxyGet(testtools.TestCase): - - def setUp(self): - super(TestProxyGet, self).setUp() - - self.session = mock.Mock() - - self.fake_id = 1 - self.fake_name = "fake_name" - self.fake_result = "fake_result" - self.res = mock.Mock(spec=RetrieveableResource) - self.res.id = self.fake_id - self.res.get = mock.Mock(return_value=self.fake_result) - - self.sot = proxy.BaseProxy(self.session) - RetrieveableResource.existing = mock.Mock(return_value=self.res) - - def test_get_resource(self): - rv = self.sot._get(RetrieveableResource, self.res) - - self.res.get.assert_called_with(self.session, args=None) - self.assertEqual(rv, self.fake_result) - - def test_get_resource_with_args(self): - rv = self.sot._get(RetrieveableResource, self.res, args={'K': 'V'}) - - self.res.get.assert_called_with(self.session, args={'K': 'V'}) - self.assertEqual(rv, self.fake_result) - - def test_get_id(self): - rv = self.sot._get(RetrieveableResource, self.fake_id) - - RetrieveableResource.existing.assert_called_with(id=self.fake_id) - self.res.get.assert_called_with(self.session, args=None) - self.assertEqual(rv, self.fake_result) - - def test_get_not_found(self): - self.res.get.side_effect = exceptions.NotFoundException( - message="test", http_status=404) - - self.assertRaisesRegex( - exceptions.ResourceNotFound, - "No %s found for %s" % (RetrieveableResource.__name__, self.res), - self.sot._get, RetrieveableResource, self.res) - - -class TestProxyList(testtools.TestCase): - - def setUp(self): - super(TestProxyList, self).setUp() - - self.session = mock.Mock() - - self.fake_a = 1 - self.fake_b = 2 - self.fake_c = 3 - self.fake_resource = resource.Resource.new(id=self.fake_a) - self.fake_response = [resource.Resource()] - self.fake_query = {"a": self.fake_resource, "b": self.fake_b} - self.fake_path_args = {"c": self.fake_c} - - self.sot = proxy.BaseProxy(self.session) - ListableResource.list = mock.Mock() - ListableResource.list.return_value = self.fake_response - - def _test_list(self, path_args, paginated, **query): - rv = self.sot._list(ListableResource, path_args=path_args, - paginated=paginated, **query) - - self.assertEqual(self.fake_response, rv) - ListableResource.list.assert_called_once_with( - self.session, path_args=path_args, paginated=paginated, - params={'a': self.fake_a, 'b': self.fake_b}) - - def test_list_paginated(self): - self._test_list(self.fake_path_args, True, **self.fake_query) - - def test_list_non_paginated(self): - self._test_list(self.fake_path_args, False, **self.fake_query) - - -class TestProxyHead(testtools.TestCase): - - def setUp(self): - super(TestProxyHead, self).setUp() - - self.session = mock.Mock() - - self.fake_id = 1 - self.fake_name = "fake_name" - self.fake_result = "fake_result" - self.res = mock.Mock(spec=HeadableResource) - self.res.id = self.fake_id - self.res.head = mock.Mock(return_value=self.fake_result) - - self.sot = proxy.BaseProxy(self.session) - HeadableResource.existing = mock.Mock(return_value=self.res) - - def test_head_resource(self): - rv = self.sot._head(HeadableResource, self.res) - - self.res.head.assert_called_with(self.session) - self.assertEqual(rv, self.fake_result) - - def test_head_id(self): - rv = self.sot._head(HeadableResource, self.fake_id) - - HeadableResource.existing.assert_called_with(id=self.fake_id) - self.res.head.assert_called_with(self.session) - self.assertEqual(rv, self.fake_result) - - def test_head_no_value(self): - MockHeadResource = mock.Mock(spec=HeadableResource) - instance = mock.Mock() - MockHeadResource.return_value = instance - - self.sot._head(MockHeadResource) - - MockHeadResource.assert_called_with() - instance.head.assert_called_with(self.session) - - @mock.patch("openstack.resource.wait_for_status") - def test_wait_for(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - self.sot.wait_for_status(mock_resource, 'ACTIVE') - mock_wait.assert_called_once_with( - self.session, mock_resource, 'ACTIVE', [], 2, 120) - - @mock.patch("openstack.resource.wait_for_status") - def test_wait_for_params(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - self.sot.wait_for_status(mock_resource, 'ACTIVE', ['ERROR'], 1, 2) - mock_wait.assert_called_once_with( - self.session, mock_resource, 'ACTIVE', ['ERROR'], 1, 2) - - @mock.patch("openstack.resource.wait_for_delete") - def test_wait_for_delete(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - self.sot.wait_for_delete(mock_resource) - mock_wait.assert_called_once_with( - self.session, mock_resource, 2, 120) - - @mock.patch("openstack.resource.wait_for_delete") - def test_wait_for_delete_params(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - self.sot.wait_for_delete(mock_resource, 1, 2) - mock_wait.assert_called_once_with( - self.session, mock_resource, 1, 2) diff --git a/openstack/tests/unit/test_proxy2.py b/openstack/tests/unit/test_proxy2.py deleted file mode 100644 index 33201281..00000000 --- a/openstack/tests/unit/test_proxy2.py +++ /dev/null @@ -1,418 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from openstack import exceptions -from openstack import proxy2 -from openstack import resource2 - - -class DeleteableResource(resource2.Resource): - allow_delete = True - - -class UpdateableResource(resource2.Resource): - allow_update = True - - -class CreateableResource(resource2.Resource): - allow_create = True - - -class RetrieveableResource(resource2.Resource): - allow_retrieve = True - - -class ListableResource(resource2.Resource): - allow_list = True - - -class HeadableResource(resource2.Resource): - allow_head = True - - -class TestProxyPrivate(testtools.TestCase): - - def setUp(self): - super(TestProxyPrivate, self).setUp() - - def method(self, expected_type, value): - return value - - self.sot = mock.Mock() - self.sot.method = method - - self.fake_proxy = proxy2.BaseProxy("session") - - def _test_correct(self, value): - decorated = proxy2._check_resource(strict=False)(self.sot.method) - rv = decorated(self.sot, resource2.Resource, value) - - self.assertEqual(value, rv) - - def test__check_resource_correct_resource(self): - res = resource2.Resource() - self._test_correct(res) - - def test__check_resource_notstrict_id(self): - self._test_correct("abc123-id") - - def test__check_resource_strict_id(self): - decorated = proxy2._check_resource(strict=True)(self.sot.method) - self.assertRaisesRegex(ValueError, "A Resource must be passed", - decorated, self.sot, resource2.Resource, - "this-is-not-a-resource") - - def test__check_resource_incorrect_resource(self): - class OneType(resource2.Resource): - pass - - class AnotherType(resource2.Resource): - pass - - value = AnotherType() - decorated = proxy2._check_resource(strict=False)(self.sot.method) - self.assertRaisesRegex(ValueError, - "Expected OneType but received AnotherType", - decorated, self.sot, OneType, value) - - def test__get_uri_attribute_no_parent(self): - class Child(resource2.Resource): - something = resource2.Body("something") - - attr = "something" - value = "nothing" - child = Child(something=value) - - result = self.fake_proxy._get_uri_attribute(child, None, attr) - - self.assertEqual(value, result) - - def test__get_uri_attribute_with_parent(self): - class Parent(resource2.Resource): - pass - - value = "nothing" - parent = Parent(id=value) - - result = self.fake_proxy._get_uri_attribute("child", parent, "attr") - - self.assertEqual(value, result) - - def test__get_resource_new(self): - value = "hello" - fake_type = mock.Mock(spec=resource2.Resource) - fake_type.new = mock.Mock(return_value=value) - attrs = {"first": "Brian", "last": "Curtin"} - - result = self.fake_proxy._get_resource(fake_type, None, **attrs) - - fake_type.new.assert_called_with(**attrs) - self.assertEqual(value, result) - - def test__get_resource_from_id(self): - id = "eye dee" - value = "hello" - attrs = {"first": "Brian", "last": "Curtin"} - - # The isinstance check needs to take a type, not an instance, - # so the mock.assert_called_with method isn't helpful here since - # we can't pass in a mocked object. This class is a crude version - # of that same behavior to let us check that `new` gets - # called with the expected arguments. - - class Fake(object): - call = {} - - @classmethod - def new(cls, **kwargs): - cls.call = kwargs - return value - - result = self.fake_proxy._get_resource(Fake, id, **attrs) - - self.assertDictEqual(dict(id=id, **attrs), Fake.call) - self.assertEqual(value, result) - - def test__get_resource_from_resource(self): - res = mock.Mock(spec=resource2.Resource) - res._update = mock.Mock() - - attrs = {"first": "Brian", "last": "Curtin"} - - result = self.fake_proxy._get_resource(resource2.Resource, - res, **attrs) - - res._update.assert_called_once_with(**attrs) - self.assertEqual(result, res) - - -class TestProxyDelete(testtools.TestCase): - - def setUp(self): - super(TestProxyDelete, self).setUp() - - self.session = mock.Mock() - - self.fake_id = 1 - self.res = mock.Mock(spec=DeleteableResource) - self.res.id = self.fake_id - self.res.delete = mock.Mock() - - self.sot = proxy2.BaseProxy(self.session) - DeleteableResource.new = mock.Mock(return_value=self.res) - - def test_delete(self): - self.sot._delete(DeleteableResource, self.res) - self.res.delete.assert_called_with(self.session) - - self.sot._delete(DeleteableResource, self.fake_id) - DeleteableResource.new.assert_called_with(id=self.fake_id) - self.res.delete.assert_called_with(self.session) - - # Delete generally doesn't return anything, so we will normally - # swallow any return from within a service's proxy, but make sure - # we can still return for any cases where values are returned. - self.res.delete.return_value = self.fake_id - rv = self.sot._delete(DeleteableResource, self.fake_id) - self.assertEqual(rv, self.fake_id) - - def test_delete_ignore_missing(self): - self.res.delete.side_effect = exceptions.NotFoundException( - message="test", http_status=404) - - rv = self.sot._delete(DeleteableResource, self.fake_id) - self.assertIsNone(rv) - - def test_delete_ResourceNotFound(self): - self.res.delete.side_effect = exceptions.NotFoundException( - message="test", http_status=404) - - self.assertRaisesRegex( - exceptions.ResourceNotFound, - "No %s found for %s" % (DeleteableResource.__name__, self.res), - self.sot._delete, DeleteableResource, self.res, - ignore_missing=False) - - def test_delete_HttpException(self): - self.res.delete.side_effect = exceptions.HttpException( - message="test", http_status=500) - - self.assertRaises(exceptions.HttpException, self.sot._delete, - DeleteableResource, self.res, ignore_missing=False) - - -class TestProxyUpdate(testtools.TestCase): - - def setUp(self): - super(TestProxyUpdate, self).setUp() - - self.session = mock.Mock() - - self.fake_id = 1 - self.fake_result = "fake_result" - - self.res = mock.Mock(spec=UpdateableResource) - self.res.update = mock.Mock(return_value=self.fake_result) - - self.sot = proxy2.BaseProxy(self.session) - - self.attrs = {"x": 1, "y": 2, "z": 3} - - UpdateableResource.new = mock.Mock(return_value=self.res) - - def test_update_resource(self): - rv = self.sot._update(UpdateableResource, self.res, **self.attrs) - - self.assertEqual(rv, self.fake_result) - self.res._update.assert_called_once_with(**self.attrs) - self.res.update.assert_called_once_with(self.session) - - def test_update_id(self): - rv = self.sot._update(UpdateableResource, self.fake_id, **self.attrs) - - self.assertEqual(rv, self.fake_result) - self.res.update.assert_called_once_with(self.session) - - -class TestProxyCreate(testtools.TestCase): - - def setUp(self): - super(TestProxyCreate, self).setUp() - - self.session = mock.Mock() - - self.fake_result = "fake_result" - self.res = mock.Mock(spec=CreateableResource) - self.res.create = mock.Mock(return_value=self.fake_result) - - self.sot = proxy2.BaseProxy(self.session) - - def test_create_attributes(self): - CreateableResource.new = mock.Mock(return_value=self.res) - - attrs = {"x": 1, "y": 2, "z": 3} - rv = self.sot._create(CreateableResource, **attrs) - - self.assertEqual(rv, self.fake_result) - CreateableResource.new.assert_called_once_with(**attrs) - self.res.create.assert_called_once_with(self.session) - - -class TestProxyGet(testtools.TestCase): - - def setUp(self): - super(TestProxyGet, self).setUp() - - self.session = mock.Mock() - - self.fake_id = 1 - self.fake_name = "fake_name" - self.fake_result = "fake_result" - self.res = mock.Mock(spec=RetrieveableResource) - self.res.id = self.fake_id - self.res.get = mock.Mock(return_value=self.fake_result) - - self.sot = proxy2.BaseProxy(self.session) - RetrieveableResource.new = mock.Mock(return_value=self.res) - - def test_get_resource(self): - rv = self.sot._get(RetrieveableResource, self.res) - - self.res.get.assert_called_with(self.session, requires_id=True) - self.assertEqual(rv, self.fake_result) - - def test_get_resource_with_args(self): - args = {"key": "value"} - rv = self.sot._get(RetrieveableResource, self.res, **args) - - self.res._update.assert_called_once_with(**args) - self.res.get.assert_called_with(self.session, requires_id=True) - self.assertEqual(rv, self.fake_result) - - def test_get_id(self): - rv = self.sot._get(RetrieveableResource, self.fake_id) - - RetrieveableResource.new.assert_called_with(id=self.fake_id) - self.res.get.assert_called_with(self.session, requires_id=True) - self.assertEqual(rv, self.fake_result) - - def test_get_not_found(self): - self.res.get.side_effect = exceptions.NotFoundException( - message="test", http_status=404) - - self.assertRaisesRegex( - exceptions.ResourceNotFound, - "No %s found for %s" % (RetrieveableResource.__name__, self.res), - self.sot._get, RetrieveableResource, self.res) - - -class TestProxyList(testtools.TestCase): - - def setUp(self): - super(TestProxyList, self).setUp() - - self.session = mock.Mock() - - self.args = {"a": "A", "b": "B", "c": "C"} - self.fake_response = [resource2.Resource()] - - self.sot = proxy2.BaseProxy(self.session) - ListableResource.list = mock.Mock() - ListableResource.list.return_value = self.fake_response - - def _test_list(self, paginated): - rv = self.sot._list(ListableResource, paginated=paginated, **self.args) - - self.assertEqual(self.fake_response, rv) - ListableResource.list.assert_called_once_with( - self.session, paginated=paginated, **self.args) - - def test_list_paginated(self): - self._test_list(True) - - def test_list_non_paginated(self): - self._test_list(False) - - -class TestProxyHead(testtools.TestCase): - - def setUp(self): - super(TestProxyHead, self).setUp() - - self.session = mock.Mock() - - self.fake_id = 1 - self.fake_name = "fake_name" - self.fake_result = "fake_result" - self.res = mock.Mock(spec=HeadableResource) - self.res.id = self.fake_id - self.res.head = mock.Mock(return_value=self.fake_result) - - self.sot = proxy2.BaseProxy(self.session) - HeadableResource.new = mock.Mock(return_value=self.res) - - def test_head_resource(self): - rv = self.sot._head(HeadableResource, self.res) - - self.res.head.assert_called_with(self.session) - self.assertEqual(rv, self.fake_result) - - def test_head_id(self): - rv = self.sot._head(HeadableResource, self.fake_id) - - HeadableResource.new.assert_called_with(id=self.fake_id) - self.res.head.assert_called_with(self.session) - self.assertEqual(rv, self.fake_result) - - -class TestProxyWaits(testtools.TestCase): - - def setUp(self): - super(TestProxyWaits, self).setUp() - - self.session = mock.Mock() - self.sot = proxy2.BaseProxy(self.session) - - @mock.patch("openstack.resource2.wait_for_status") - def test_wait_for(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - self.sot.wait_for_status(mock_resource, 'ACTIVE') - mock_wait.assert_called_once_with( - self.session, mock_resource, 'ACTIVE', [], 2, 120) - - @mock.patch("openstack.resource2.wait_for_status") - def test_wait_for_params(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - self.sot.wait_for_status(mock_resource, 'ACTIVE', ['ERROR'], 1, 2) - mock_wait.assert_called_once_with( - self.session, mock_resource, 'ACTIVE', ['ERROR'], 1, 2) - - @mock.patch("openstack.resource2.wait_for_delete") - def test_wait_for_delete(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - self.sot.wait_for_delete(mock_resource) - mock_wait.assert_called_once_with( - self.session, mock_resource, 2, 120) - - @mock.patch("openstack.resource2.wait_for_delete") - def test_wait_for_delete_params(self, mock_wait): - mock_resource = mock.Mock() - mock_wait.return_value = mock_resource - self.sot.wait_for_delete(mock_resource, 1, 2) - mock_wait.assert_called_once_with( - self.session, mock_resource, 1, 2) diff --git a/openstack/tests/unit/test_proxy_base.py b/openstack/tests/unit/test_proxy_base.py deleted file mode 100644 index 348422d8..00000000 --- a/openstack/tests/unit/test_proxy_base.py +++ /dev/null @@ -1,223 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock - -from openstack.tests.unit import base - - -class TestProxyBase(base.TestCase): - def setUp(self): - super(TestProxyBase, self).setUp() - self.session = mock.Mock() - - def _add_path_args_for_verify(self, path_args, method_args, - expected_kwargs, value=None): - if path_args is not None: - if value is None: - for key in path_args: - method_args.append(path_args[key]) - expected_kwargs['path_args'] = path_args - - def _verify(self, mock_method, test_method, - method_args=None, method_kwargs=None, - expected_args=None, expected_kwargs=None, - expected_result=None): - with mock.patch(mock_method) as mocked: - mocked.return_value = expected_result - if any([method_args, method_kwargs, - expected_args, expected_kwargs]): - method_args = method_args or () - method_kwargs = method_kwargs or {} - expected_args = expected_args or () - expected_kwargs = expected_kwargs or {} - - self.assertEqual(expected_result, test_method(*method_args, - **method_kwargs)) - mocked.assert_called_with(self.session, - *expected_args, **expected_kwargs) - else: - self.assertEqual(expected_result, test_method()) - mocked.assert_called_with(self.session) - - # NOTE(briancurtin): This is a duplicate version of _verify that is - # temporarily here while we shift APIs. The difference is that - # calls from the Proxy classes aren't going to be going directly into - # the Resource layer anymore, so they don't pass in the session which - # was tested in assert_called_with. - # This is being done in lieu of adding logic and complicating - # the _verify method. It will be removed once there is one API to - # be verifying. - def _verify2(self, mock_method, test_method, - method_args=None, method_kwargs=None, method_result=None, - expected_args=None, expected_kwargs=None, - expected_result=None): - with mock.patch(mock_method) as mocked: - mocked.return_value = expected_result - if any([method_args, method_kwargs, - expected_args, expected_kwargs]): - method_args = method_args or () - method_kwargs = method_kwargs or {} - expected_args = expected_args or () - expected_kwargs = expected_kwargs or {} - - if method_result: - self.assertEqual(method_result, test_method(*method_args, - **method_kwargs)) - else: - self.assertEqual(expected_result, test_method(*method_args, - **method_kwargs)) - mocked.assert_called_with(*expected_args, **expected_kwargs) - else: - self.assertEqual(expected_result, test_method()) - mocked.assert_called_with(self.session) - - def verify_create(self, test_method, resource_type, - mock_method="openstack.proxy.BaseProxy._create", - expected_result="result", **kwargs): - the_kwargs = {"x": 1, "y": 2, "z": 3} - method_kwargs = kwargs.pop("method_kwargs", the_kwargs) - expected_args = [resource_type] - expected_kwargs = kwargs.pop("expected_kwargs", the_kwargs) - - self._verify2(mock_method, test_method, - expected_result=expected_result, - method_kwargs=method_kwargs, - expected_args=expected_args, - expected_kwargs=expected_kwargs, - **kwargs) - - def verify_delete(self, test_method, resource_type, ignore, - input_path_args=None, expected_path_args=None, - mock_method="openstack.proxy.BaseProxy._delete"): - method_args = ["resource_or_id"] - method_kwargs = {"ignore_missing": ignore} - if isinstance(input_path_args, dict): - for key in input_path_args: - method_kwargs[key] = input_path_args[key] - elif isinstance(input_path_args, list): - method_args = input_path_args - expected_kwargs = {"ignore_missing": ignore} - if expected_path_args: - expected_kwargs["path_args"] = expected_path_args - self._verify2(mock_method, test_method, - method_args=method_args, - method_kwargs=method_kwargs, - expected_args=[resource_type, "resource_or_id"], - expected_kwargs=expected_kwargs) - - def verify_get(self, test_method, resource_type, value=None, args=None, - mock_method="openstack.proxy.BaseProxy._get", - ignore_value=False, **kwargs): - the_value = value - if value is None: - the_value = [] if ignore_value else ["value"] - expected_args = kwargs.pop("expected_args", []) - expected_kwargs = kwargs.pop("expected_kwargs", {}) - method_kwargs = kwargs.pop("method_kwargs", kwargs) - if args: - expected_kwargs["args"] = args - if kwargs: - expected_kwargs["path_args"] = kwargs - if not expected_args: - expected_args = [resource_type] + the_value - self._verify2(mock_method, test_method, - method_args=the_value, - method_kwargs=method_kwargs or {}, - expected_args=expected_args, - expected_kwargs=expected_kwargs) - - def verify_head(self, test_method, resource_type, - mock_method="openstack.proxy.BaseProxy._head", - value=None, **kwargs): - the_value = [value] if value is not None else [] - expected_kwargs = {"path_args": kwargs} if kwargs else {} - self._verify2(mock_method, test_method, - method_args=the_value, - method_kwargs=kwargs, - expected_args=[resource_type] + the_value, - expected_kwargs=expected_kwargs) - - def verify_find(self, test_method, resource_type, value=None, - mock_method="openstack.proxy.BaseProxy._find", - path_args=None, **kwargs): - method_args = value or ["name_or_id"] - expected_kwargs = {} - - self._add_path_args_for_verify(path_args, method_args, expected_kwargs, - value=value) - - # TODO(briancurtin): if sub-tests worked in this mess of - # test dependencies, the following would be a lot easier to work with. - expected_kwargs["ignore_missing"] = False - self._verify2(mock_method, test_method, - method_args=method_args + [False], - expected_args=[resource_type, "name_or_id"], - expected_kwargs=expected_kwargs, - expected_result="result", - **kwargs) - - expected_kwargs["ignore_missing"] = True - self._verify2(mock_method, test_method, - method_args=method_args + [True], - expected_args=[resource_type, "name_or_id"], - expected_kwargs=expected_kwargs, - expected_result="result", - **kwargs) - - def verify_list(self, test_method, resource_type, paginated=False, - mock_method="openstack.proxy.BaseProxy._list", - **kwargs): - expected_kwargs = kwargs.pop("expected_kwargs", {}) - expected_kwargs.update({"paginated": paginated}) - expected_kwargs['limit'] = 2 - method_kwargs = kwargs.pop("method_kwargs", {}) - method_kwargs['limit'] = 2 - self._verify2(mock_method, test_method, - method_kwargs=method_kwargs, - expected_args=[resource_type], - expected_kwargs=expected_kwargs, - expected_result=["result"], - **kwargs) - - def verify_list_no_kwargs(self, test_method, resource_type, - paginated=False, - mock_method="openstack.proxy.BaseProxy._list"): - self._verify2(mock_method, test_method, - method_kwargs={}, - expected_args=[resource_type], - expected_kwargs={"paginated": paginated}, - expected_result=["result"]) - - def verify_update(self, test_method, resource_type, value=None, - mock_method="openstack.proxy.BaseProxy._update", - expected_result="result", path_args=None, **kwargs): - method_args = value or ["resource_or_id"] - method_kwargs = {"x": 1, "y": 2, "z": 3} - expected_args = kwargs.pop("expected_args", ["resource_or_id"]) - expected_kwargs = method_kwargs.copy() - - self._add_path_args_for_verify(path_args, method_args, expected_kwargs, - value=value) - - self._verify2(mock_method, test_method, - expected_result=expected_result, - method_args=method_args, - method_kwargs=method_kwargs, - expected_args=[resource_type] + expected_args, - expected_kwargs=expected_kwargs, - **kwargs) - - def verify_wait_for_status( - self, test_method, - mock_method="openstack.resource.wait_for_status", **kwargs): - self._verify(mock_method, test_method, **kwargs) diff --git a/openstack/tests/unit/test_proxy_base2.py b/openstack/tests/unit/test_proxy_base2.py deleted file mode 100644 index f984de65..00000000 --- a/openstack/tests/unit/test_proxy_base2.py +++ /dev/null @@ -1,226 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock - -from openstack.tests.unit import base - - -class TestProxyBase(base.TestCase): - def setUp(self): - super(TestProxyBase, self).setUp() - self.session = mock.Mock() - - def _add_path_args_for_verify(self, path_args, method_args, - expected_kwargs, value=None): - if path_args is not None: - if value is None: - for key in path_args: - method_args.append(path_args[key]) - expected_kwargs['path_args'] = path_args - - def _verify(self, mock_method, test_method, - method_args=None, method_kwargs=None, - expected_args=None, expected_kwargs=None, - expected_result=None): - with mock.patch(mock_method) as mocked: - mocked.return_value = expected_result - if any([method_args, method_kwargs, - expected_args, expected_kwargs]): - method_args = method_args or () - method_kwargs = method_kwargs or {} - expected_args = expected_args or () - expected_kwargs = expected_kwargs or {} - - self.assertEqual(expected_result, test_method(*method_args, - **method_kwargs)) - mocked.assert_called_with(self.session, - *expected_args, **expected_kwargs) - else: - self.assertEqual(expected_result, test_method()) - mocked.assert_called_with(self.session) - - # NOTE(briancurtin): This is a duplicate version of _verify that is - # temporarily here while we shift APIs. The difference is that - # calls from the Proxy classes aren't going to be going directly into - # the Resource layer anymore, so they don't pass in the session which - # was tested in assert_called_with. - # This is being done in lieu of adding logic and complicating - # the _verify method. It will be removed once there is one API to - # be verifying. - def _verify2(self, mock_method, test_method, - method_args=None, method_kwargs=None, method_result=None, - expected_args=None, expected_kwargs=None, - expected_result=None): - with mock.patch(mock_method) as mocked: - mocked.return_value = expected_result - if any([method_args, method_kwargs, - expected_args, expected_kwargs]): - method_args = method_args or () - method_kwargs = method_kwargs or {} - expected_args = expected_args or () - expected_kwargs = expected_kwargs or {} - - if method_result: - self.assertEqual(method_result, test_method(*method_args, - **method_kwargs)) - else: - self.assertEqual(expected_result, test_method(*method_args, - **method_kwargs)) - mocked.assert_called_with(*expected_args, **expected_kwargs) - else: - self.assertEqual(expected_result, test_method()) - mocked.assert_called_with(self.session) - - def verify_create(self, test_method, resource_type, - mock_method="openstack.proxy2.BaseProxy._create", - expected_result="result", **kwargs): - the_kwargs = {"x": 1, "y": 2, "z": 3} - method_kwargs = kwargs.pop("method_kwargs", the_kwargs) - expected_args = [resource_type] - expected_kwargs = kwargs.pop("expected_kwargs", the_kwargs) - - self._verify2(mock_method, test_method, - expected_result=expected_result, - method_kwargs=method_kwargs, - expected_args=expected_args, - expected_kwargs=expected_kwargs, - **kwargs) - - def verify_delete(self, test_method, resource_type, ignore, - input_path_args=None, expected_path_args=None, - method_kwargs=None, expected_args=None, - expected_kwargs=None, - mock_method="openstack.proxy2.BaseProxy._delete"): - method_args = ["resource_or_id"] - method_kwargs = method_kwargs or {} - method_kwargs["ignore_missing"] = ignore - if isinstance(input_path_args, dict): - for key in input_path_args: - method_kwargs[key] = input_path_args[key] - elif isinstance(input_path_args, list): - method_args = input_path_args - expected_kwargs = expected_kwargs or {} - expected_kwargs["ignore_missing"] = ignore - if expected_path_args: - expected_kwargs.update(expected_path_args) - expected_args = expected_args or [resource_type, "resource_or_id"] - self._verify2(mock_method, test_method, - method_args=method_args, - method_kwargs=method_kwargs, - expected_args=expected_args, - expected_kwargs=expected_kwargs) - - def verify_get(self, test_method, resource_type, value=None, args=None, - mock_method="openstack.proxy2.BaseProxy._get", - ignore_value=False, **kwargs): - the_value = value - if value is None: - the_value = [] if ignore_value else ["value"] - expected_args = kwargs.pop("expected_args", []) - expected_kwargs = kwargs.pop("expected_kwargs", {}) - method_kwargs = kwargs.pop("method_kwargs", kwargs) - if args: - expected_kwargs["args"] = args - if kwargs: - expected_kwargs["path_args"] = kwargs - if not expected_args: - expected_args = [resource_type] + the_value - self._verify2(mock_method, test_method, - method_args=the_value, - method_kwargs=method_kwargs or {}, - expected_args=expected_args, - expected_kwargs=expected_kwargs) - - def verify_head(self, test_method, resource_type, - mock_method="openstack.proxy2.BaseProxy._head", - value=None, **kwargs): - the_value = [value] if value is not None else [] - expected_kwargs = {"path_args": kwargs} if kwargs else {} - self._verify2(mock_method, test_method, - method_args=the_value, - method_kwargs=kwargs, - expected_args=[resource_type] + the_value, - expected_kwargs=expected_kwargs) - - def verify_find(self, test_method, resource_type, value=None, - mock_method="openstack.proxy2.BaseProxy._find", - path_args=None, **kwargs): - method_args = value or ["name_or_id"] - expected_kwargs = {} - - self._add_path_args_for_verify(path_args, method_args, expected_kwargs, - value=value) - - # TODO(briancurtin): if sub-tests worked in this mess of - # test dependencies, the following would be a lot easier to work with. - expected_kwargs["ignore_missing"] = False - self._verify2(mock_method, test_method, - method_args=method_args + [False], - expected_args=[resource_type, "name_or_id"], - expected_kwargs=expected_kwargs, - expected_result="result", - **kwargs) - - expected_kwargs["ignore_missing"] = True - self._verify2(mock_method, test_method, - method_args=method_args + [True], - expected_args=[resource_type, "name_or_id"], - expected_kwargs=expected_kwargs, - expected_result="result", - **kwargs) - - def verify_list(self, test_method, resource_type, paginated=False, - mock_method="openstack.proxy2.BaseProxy._list", - **kwargs): - expected_kwargs = kwargs.pop("expected_kwargs", {}) - expected_kwargs.update({"paginated": paginated}) - method_kwargs = kwargs.pop("method_kwargs", {}) - self._verify2(mock_method, test_method, - method_kwargs=method_kwargs, - expected_args=[resource_type], - expected_kwargs=expected_kwargs, - expected_result=["result"], - **kwargs) - - def verify_list_no_kwargs(self, test_method, resource_type, - paginated=False, - mock_method="openstack.proxy2.BaseProxy._list"): - self._verify2(mock_method, test_method, - method_kwargs={}, - expected_args=[resource_type], - expected_kwargs={"paginated": paginated}, - expected_result=["result"]) - - def verify_update(self, test_method, resource_type, value=None, - mock_method="openstack.proxy2.BaseProxy._update", - expected_result="result", path_args=None, **kwargs): - method_args = value or ["resource_or_id"] - method_kwargs = {"x": 1, "y": 2, "z": 3} - expected_args = kwargs.pop("expected_args", ["resource_or_id"]) - expected_kwargs = method_kwargs.copy() - - self._add_path_args_for_verify(path_args, method_args, expected_kwargs, - value=value) - - self._verify2(mock_method, test_method, - expected_result=expected_result, - method_args=method_args, - method_kwargs=method_kwargs, - expected_args=[resource_type] + expected_args, - expected_kwargs=expected_kwargs, - **kwargs) - - def verify_wait_for_status( - self, test_method, - mock_method="openstack.resource2.wait_for_status", **kwargs): - self._verify(mock_method, test_method, **kwargs) diff --git a/openstack/tests/unit/test_resource.py b/openstack/tests/unit/test_resource.py deleted file mode 100644 index 87f40092..00000000 --- a/openstack/tests/unit/test_resource.py +++ /dev/null @@ -1,1533 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy -import json -import os - -from keystoneauth1 import session -import mock -import requests -from testtools import matchers - -from openstack import exceptions -from openstack import format -from openstack import resource -from openstack.tests.unit import base -from openstack import utils - - -fake_parent = 'robert' -fake_name = 'rey' -fake_id = 99 -fake_attr1 = 'lana' -fake_attr2 = 'del' - -fake_resource = 'fake' -fake_resources = 'fakes' -fake_arguments = {'parent_name': fake_parent} -fake_base_path = '/fakes/%(parent_name)s/data' -fake_path = '/fakes/rey/data' - -fake_data = {'id': fake_id, - 'enabled': True, - 'name': fake_name, - 'parent': fake_parent, - 'attr1': fake_attr1, - 'attr2': fake_attr2, - 'status': None} -fake_body = {fake_resource: fake_data} - - -class FakeParent(resource.Resource): - id_attribute = "name" - name = resource.prop('name') - - -class FakeResource(resource.Resource): - - resource_key = fake_resource - resources_key = fake_resources - base_path = fake_base_path - - allow_create = allow_retrieve = allow_update = True - allow_delete = allow_list = allow_head = True - - enabled = resource.prop('enabled', type=format.BoolStr) - name = resource.prop('name') - parent = resource.prop('parent_name') - first = resource.prop('attr1') - second = resource.prop('attr2') - third = resource.prop('attr3', alias='attr_three') - status = resource.prop('status') - - -class FakeResourceNoKeys(FakeResource): - - resource_key = None - resources_key = None - - -class PropTests(base.TestCase): - - def test_with_alias_and_type(self): - class Test(resource.Resource): - attr = resource.prop("attr1", alias="attr2", type=bool) - - t = Test(attrs={"attr2": 500}) - - # Don't test with assertTrue because 500 evaluates to True. - # Need to test that bool(500) happened and attr2 *is* True. - self.assertIs(t.attr, True) - - def test_defaults(self): - new_default = "new_default" - - class Test(resource.Resource): - attr1 = resource.prop("attr1") - attr2 = resource.prop("attr2", default=new_default) - - t = Test() - - self.assertIsNone(t.attr1) - self.assertEqual(new_default, t.attr2) - - # When the default value is passed in, it is left untouched. - # Check that attr2 is literally the same object we set as default. - t.attr2 = new_default - self.assertIs(new_default, t.attr2) - - not_default = 'not default' - t2 = Test({'attr2': not_default}) - self.assertEqual(not_default, t2.attr2) - - # Assert that if the default is passed in, it overrides the previously - # set value (bug #1425996) - t2.attr2 = new_default - self.assertEqual(new_default, t2.attr2) - - def test_get_without_instance(self): - self.assertIsNone(FakeResource.name) - - def test_set_ValueError(self): - class Test(resource.Resource): - attr = resource.prop("attr", type=int) - - t = Test() - - def should_raise(): - t.attr = "this is not an int" - - self.assertThat(should_raise, matchers.raises(ValueError)) - - def test_set_TypeError(self): - class Type(object): - def __init__(self): - pass - - class Test(resource.Resource): - attr = resource.prop("attr", type=Type) - - t = Test() - - def should_raise(): - t.attr = "this type takes no args" - - self.assertThat(should_raise, matchers.raises(TypeError)) - - def test_resource_type(self): - class FakestResource(resource.Resource): - shortstop = resource.prop("shortstop", type=FakeResource) - third_base = resource.prop("third_base", type=FakeResource) - - sot = FakestResource() - id1 = "Ernie Banks" - id2 = "Ron Santo" - sot.shortstop = id1 - sot.third_base = id2 - - resource1 = FakeResource.new(id=id1) - self.assertEqual(resource1, sot.shortstop) - self.assertEqual(id1, sot.shortstop.id) - self.assertEqual(FakeResource, type(sot.shortstop)) - - resource2 = FakeResource.new(id=id2) - self.assertEqual(resource2, sot.third_base) - self.assertEqual(id2, sot.third_base.id) - self.assertEqual(FakeResource, type(sot.third_base)) - - sot2 = FakestResource() - sot2.shortstop = resource1 - sot2.third_base = resource2 - self.assertEqual(resource1, sot2.shortstop) - self.assertEqual(id1, sot2.shortstop.id) - self.assertEqual(FakeResource, type(sot2.shortstop)) - self.assertEqual(resource2, sot2.third_base) - self.assertEqual(id2, sot2.third_base.id) - self.assertEqual(FakeResource, type(sot2.third_base)) - - body = { - "shortstop": id1, - "third_base": id2 - } - sot3 = FakestResource(body) - self.assertEqual(FakeResource({"id": id1}), sot3.shortstop) - self.assertEqual(FakeResource({"id": id2}), sot3.third_base) - - def test_set_alias_same_name(self): - class Test(resource.Resource): - attr = resource.prop("something", alias="attr") - - val = "hey" - args = {"something": val} - sot = Test(args) - - self.assertEqual(val, sot._attrs["something"]) - self.assertEqual(val, sot.attr) - - def test_property_is_none(self): - class Test(resource.Resource): - attr = resource.prop("something", type=dict) - - args = {"something": None} - sot = Test(args) - - self.assertIsNone(sot._attrs["something"]) - self.assertIsNone(sot.attr) - - -class HeaderTests(base.TestCase): - class Test(resource.Resource): - base_path = "/ramones" - service = "punk" - allow_create = True - allow_update = True - hey = resource.header("vocals") - ho = resource.header("guitar") - letsgo = resource.header("bass") - - def test_get(self): - val = "joey" - args = {"vocals": val} - sot = HeaderTests.Test({'headers': args}) - self.assertEqual(val, sot.hey) - self.assertIsNone(sot.ho) - self.assertIsNone(sot.letsgo) - - def test_set_new(self): - args = {"vocals": "joey", "bass": "deedee"} - sot = HeaderTests.Test({'headers': args}) - sot._reset_dirty() - sot.ho = "johnny" - self.assertEqual("johnny", sot.ho) - self.assertTrue(sot.is_dirty) - - def test_set_old(self): - args = {"vocals": "joey", "bass": "deedee"} - sot = HeaderTests.Test({'headers': args}) - sot._reset_dirty() - sot.letsgo = "cj" - self.assertEqual("cj", sot.letsgo) - self.assertTrue(sot.is_dirty) - - def test_set_brand_new(self): - sot = HeaderTests.Test({'headers': {}}) - sot._reset_dirty() - sot.ho = "johnny" - self.assertEqual("johnny", sot.ho) - self.assertTrue(sot.is_dirty) - self.assertEqual({'headers': {"guitar": "johnny"}}, sot) - - def test_1428342(self): - sot = HeaderTests.Test({'headers': - requests.structures.CaseInsensitiveDict()}) - - self.assertIsNone(sot.hey) - - def test_create_update_headers(self): - sot = HeaderTests.Test() - sot._reset_dirty() - sot.ho = "johnny" - sot.letsgo = "deedee" - response = mock.Mock() - response_body = {'id': 1} - response.json = mock.Mock(return_value=response_body) - response.headers = None - sess = mock.Mock() - sess.post = mock.Mock(return_value=response) - sess.put = mock.Mock(return_value=response) - - sot.create(sess) - headers = {'guitar': 'johnny', 'bass': 'deedee'} - sess.post.assert_called_with(HeaderTests.Test.base_path, - endpoint_filter=HeaderTests.Test.service, - headers=headers, - json={}) - - sot['id'] = 1 - sot.letsgo = "cj" - headers = {'guitar': 'johnny', 'bass': 'cj'} - sot.update(sess) - sess.put.assert_called_with('ramones/1', - endpoint_filter=HeaderTests.Test.service, - headers=headers, - json={}) - - -class ResourceTests(base.TestCase): - - def setUp(self): - super(ResourceTests, self).setUp() - self.session = mock.Mock(spec=session.Session) - self.session.get_filter = mock.Mock(return_value={}) - - def assertCalledURL(self, method, url): - # call_args gives a tuple of *args and tuple of **kwargs. - # Check that the first arg in *args (the URL) has our url. - self.assertEqual(method.call_args[0][0], url) - - def test_empty_id(self): - resp = mock.Mock() - resp.json = mock.Mock(return_value=fake_body) - self.session.get.return_value = resp - - obj = FakeResource.new(**fake_arguments) - self.assertEqual(obj, obj.get(self.session)) - - self.assertEqual(fake_id, obj.id) - self.assertEqual(fake_name, obj['name']) - self.assertEqual(fake_attr1, obj['attr1']) - self.assertEqual(fake_attr2, obj['attr2']) - - self.assertEqual(fake_name, obj.name) - self.assertEqual(fake_attr1, obj.first) - self.assertEqual(fake_attr2, obj.second) - - def test_not_allowed(self): - class Nope(resource.Resource): - allow_create = allow_retrieve = allow_update = False - allow_delete = allow_list = allow_head = False - - nope = Nope() - - def cant_create(): - nope.create_by_id(1, 2) - - def cant_retrieve(): - nope.get_data_by_id(1, 2) - - def cant_update(): - nope.update_by_id(1, 2, 3) - - def cant_delete(): - nope.delete_by_id(1, 2) - - def cant_list(): - for i in nope.list(1): - pass - - def cant_head(): - nope.head_data_by_id(1, 2) - - self.assertThat(cant_create, - matchers.raises(exceptions.MethodNotSupported)) - self.assertThat(cant_retrieve, - matchers.raises(exceptions.MethodNotSupported)) - self.assertThat(cant_update, - matchers.raises(exceptions.MethodNotSupported)) - self.assertThat(cant_delete, - matchers.raises(exceptions.MethodNotSupported)) - self.assertThat(cant_list, - matchers.raises(exceptions.MethodNotSupported)) - self.assertThat(cant_head, - matchers.raises(exceptions.MethodNotSupported)) - - def _test_create_by_id(self, key, response_value, response_body, - attrs, json_body, response_headers=None): - - class FakeResource2(FakeResource): - resource_key = key - service = "my_service" - - response = mock.Mock() - response.json = mock.Mock(return_value=response_body) - response.headers = response_headers - expected_resp = response_value.copy() - if response_headers: - expected_resp.update({'headers': response_headers}) - - sess = mock.Mock() - sess.put = mock.Mock(return_value=response) - sess.post = mock.Mock(return_value=response) - - resp = FakeResource2.create_by_id(sess, attrs) - self.assertEqual(expected_resp, resp) - sess.post.assert_called_with(FakeResource2.base_path, - endpoint_filter=FakeResource2.service, - json=json_body) - - r_id = "my_id" - resp = FakeResource2.create_by_id(sess, attrs, resource_id=r_id) - self.assertEqual(response_value, resp) - sess.put.assert_called_with( - utils.urljoin(FakeResource2.base_path, r_id), - endpoint_filter=FakeResource2.service, - json=json_body) - - path_args = {"parent_name": "my_name"} - resp = FakeResource2.create_by_id(sess, attrs, path_args=path_args) - self.assertEqual(response_value, resp) - sess.post.assert_called_with(FakeResource2.base_path % path_args, - endpoint_filter=FakeResource2.service, - json=json_body) - - resp = FakeResource2.create_by_id(sess, attrs, resource_id=r_id, - path_args=path_args) - self.assertEqual(response_value, resp) - sess.put.assert_called_with( - utils.urljoin(FakeResource2.base_path % path_args, r_id), - endpoint_filter=FakeResource2.service, - json=json_body) - - def test_create_without_resource_key(self): - key = None - response_value = {"a": 1, "b": 2, "c": 3} - response_body = response_value - attrs = response_value - json_body = attrs - self._test_create_by_id(key, response_value, response_body, - attrs, json_body) - - def test_create_with_response_headers(self): - key = None - response_value = {"a": 1, "b": 2, "c": 3} - response_body = response_value - response_headers = {'location': 'foo'} - attrs = response_value.copy() - json_body = attrs - self._test_create_by_id(key, response_value, response_body, - attrs, json_body, - response_headers=response_headers) - - def test_create_with_resource_key(self): - key = "my_key" - response_value = {"a": 1, "b": 2, "c": 3} - response_body = {key: response_value} - attrs = response_body - json_body = {key: attrs} - self._test_create_by_id(key, response_value, response_body, - attrs, json_body) - - def _test_get_data_by_id(self, key, response_value, response_body): - class FakeResource2(FakeResource): - resource_key = key - service = "my_service" - - response = mock.Mock() - response.json = mock.Mock(return_value=response_body) - - sess = mock.Mock() - sess.get = mock.Mock(return_value=response) - - r_id = "my_id" - resp = FakeResource2.get_data_by_id(sess, resource_id=r_id) - self.assertEqual(response_value, resp) - sess.get.assert_called_with( - utils.urljoin(FakeResource2.base_path, r_id), - endpoint_filter=FakeResource2.service) - - path_args = {"parent_name": "my_name"} - resp = FakeResource2.get_data_by_id(sess, resource_id=r_id, - path_args=path_args) - self.assertEqual(response_value, resp) - sess.get.assert_called_with( - utils.urljoin(FakeResource2.base_path % path_args, r_id), - endpoint_filter=FakeResource2.service) - - def test_get_data_without_resource_key(self): - key = None - response_value = {"a": 1, "b": 2, "c": 3} - response_body = response_value - self._test_get_data_by_id(key, response_value, response_body) - - def test_get_data_with_resource_key(self): - key = "my_key" - response_value = {"a": 1, "b": 2, "c": 3} - response_body = {key: response_value} - self._test_get_data_by_id(key, response_value, response_body) - - def _test_head_data_by_id(self, key, response_value): - class FakeResource2(FakeResource): - resource_key = key - service = "my_service" - - response = mock.Mock() - response.headers = response_value - - sess = mock.Mock() - sess.head = mock.Mock(return_value=response) - - r_id = "my_id" - resp = FakeResource2.head_data_by_id(sess, resource_id=r_id) - self.assertEqual({'headers': response_value}, resp) - headers = {'Accept': ''} - sess.head.assert_called_with( - utils.urljoin(FakeResource2.base_path, r_id), - endpoint_filter=FakeResource2.service, - headers=headers) - - path_args = {"parent_name": "my_name"} - resp = FakeResource2.head_data_by_id(sess, resource_id=r_id, - path_args=path_args) - self.assertEqual({'headers': response_value}, resp) - headers = {'Accept': ''} - sess.head.assert_called_with( - utils.urljoin(FakeResource2.base_path % path_args, r_id), - endpoint_filter=FakeResource2.service, - headers=headers) - - def test_head_data_without_resource_key(self): - key = None - response_value = {"key1": "value1", "key2": "value2"} - self._test_head_data_by_id(key, response_value) - - def test_head_data_with_resource_key(self): - key = "my_key" - response_value = {"key1": "value1", "key2": "value2"} - self._test_head_data_by_id(key, response_value) - - def _test_update_by_id(self, key, response_value, response_body, - attrs, json_body, response_headers=None): - - class FakeResource2(FakeResource): - patch_update = True - resource_key = key - service = "my_service" - - response = mock.Mock() - response.json = mock.Mock(return_value=response_body) - response.headers = response_headers - expected_resp = response_value.copy() - if response_headers: - expected_resp.update({'headers': response_headers}) - - sess = mock.Mock() - sess.patch = mock.Mock(return_value=response) - - r_id = "my_id" - resp = FakeResource2.update_by_id(sess, r_id, attrs) - self.assertEqual(expected_resp, resp) - sess.patch.assert_called_with( - utils.urljoin(FakeResource2.base_path, r_id), - endpoint_filter=FakeResource2.service, - json=json_body) - - path_args = {"parent_name": "my_name"} - resp = FakeResource2.update_by_id(sess, r_id, attrs, - path_args=path_args) - self.assertEqual(expected_resp, resp) - sess.patch.assert_called_with( - utils.urljoin(FakeResource2.base_path % path_args, r_id), - endpoint_filter=FakeResource2.service, - json=json_body) - - def test_update_without_resource_key(self): - key = None - response_value = {"a": 1, "b": 2, "c": 3} - response_body = response_value - attrs = response_value - json_body = attrs - self._test_update_by_id(key, response_value, response_body, - attrs, json_body) - - def test_update_with_resource_key(self): - key = "my_key" - response_value = {"a": 1, "b": 2, "c": 3} - response_body = {key: response_value} - attrs = response_value - json_body = {key: attrs} - self._test_update_by_id(key, response_value, response_body, - attrs, json_body) - - def test_update_with_response_headers(self): - key = "my_key" - response_value = {"a": 1, "b": 2, "c": 3} - response_body = {key: response_value} - response_headers = {'location': 'foo'} - attrs = response_value.copy() - json_body = {key: attrs} - self._test_update_by_id(key, response_value, response_body, - attrs, json_body, - response_headers=response_headers) - - def test_delete_by_id(self): - class FakeResource2(FakeResource): - service = "my_service" - - sess = mock.Mock() - sess.delete = mock.Mock(return_value=None) - - r_id = "my_id" - resp = FakeResource2.delete_by_id(sess, r_id) - self.assertIsNone(resp) - headers = {'Accept': ''} - sess.delete.assert_called_with( - utils.urljoin(FakeResource2.base_path, r_id), - endpoint_filter=FakeResource2.service, - headers=headers) - - path_args = {"parent_name": "my_name"} - resp = FakeResource2.delete_by_id(sess, r_id, path_args=path_args) - self.assertIsNone(resp) - headers = {'Accept': ''} - sess.delete.assert_called_with( - utils.urljoin(FakeResource2.base_path % path_args, r_id), - endpoint_filter=FakeResource2.service, - headers=headers) - - def test_create(self): - resp = mock.Mock() - resp.json = mock.Mock(return_value=fake_body) - resp.headers = {'location': 'foo'} - self.session.post = mock.Mock(return_value=resp) - - # Create resource with subset of attributes in order to - # verify create refreshes all attributes from response. - obj = FakeResource.new(parent_name=fake_parent, - name=fake_name, - enabled=True, - attr1=fake_attr1) - - self.assertEqual(obj, obj.create(self.session)) - self.assertFalse(obj.is_dirty) - - last_req = self.session.post.call_args[1]["json"][ - FakeResource.resource_key] - - self.assertEqual(4, len(last_req)) - self.assertTrue(last_req['enabled']) - self.assertEqual(fake_parent, last_req['parent_name']) - self.assertEqual(fake_name, last_req['name']) - self.assertEqual(fake_attr1, last_req['attr1']) - - self.assertTrue(obj['enabled']) - self.assertEqual(fake_name, obj['name']) - self.assertEqual(fake_parent, obj['parent_name']) - self.assertEqual(fake_attr1, obj['attr1']) - self.assertEqual(fake_attr2, obj['attr2']) - self.assertIsNone(obj['status']) - - self.assertTrue(obj.enabled) - self.assertEqual(fake_id, obj.id) - self.assertEqual(fake_name, obj.name) - self.assertEqual(fake_parent, obj.parent_name) - self.assertEqual(fake_parent, obj.parent) - self.assertEqual(fake_attr1, obj.first) - self.assertEqual(fake_attr1, obj.attr1) - self.assertEqual(fake_attr2, obj.second) - self.assertEqual(fake_attr2, obj.attr2) - self.assertIsNone(obj.status) - self.assertEqual('foo', obj.location) - - def test_get(self): - resp = mock.Mock() - resp.json = mock.Mock(return_value=fake_body) - resp.headers = {'location': 'foo'} - self.session.get = mock.Mock(return_value=resp) - - # Create resource with subset of attributes in order to - # verify get refreshes all attributes from response. - obj = FakeResource.from_id(str(fake_id)) - obj['parent_name'] = fake_parent - - self.assertEqual(obj, obj.get(self.session)) - - # Check that the proper URL is being built. - self.assertCalledURL(self.session.get, - os.path.join(fake_base_path % fake_arguments, - str(fake_id))[1:]) - - self.assertTrue(obj['enabled']) - self.assertEqual(fake_name, obj['name']) - self.assertEqual(fake_parent, obj['parent_name']) - self.assertEqual(fake_attr1, obj['attr1']) - self.assertEqual(fake_attr2, obj['attr2']) - self.assertIsNone(obj['status']) - - self.assertTrue(obj.enabled) - self.assertEqual(fake_id, obj.id) - self.assertEqual(fake_name, obj.name) - self.assertEqual(fake_parent, obj.parent_name) - self.assertEqual(fake_parent, obj.parent) - self.assertEqual(fake_attr1, obj.first) - self.assertEqual(fake_attr1, obj.attr1) - self.assertEqual(fake_attr2, obj.second) - self.assertEqual(fake_attr2, obj.attr2) - self.assertIsNone(obj.status) - self.assertIsNone(obj.location) - - def test_get_by_id(self): - resp = mock.Mock() - resp.json = mock.Mock(return_value=fake_body) - self.session.get = mock.Mock(return_value=resp) - - obj = FakeResource.get_by_id(self.session, fake_id, - path_args=fake_arguments) - - # Check that the proper URL is being built. - self.assertCalledURL(self.session.get, - os.path.join(fake_base_path % fake_arguments, - str(fake_id))[1:]) - - self.assertEqual(fake_id, obj.id) - self.assertEqual(fake_name, obj['name']) - self.assertEqual(fake_attr1, obj['attr1']) - self.assertEqual(fake_attr2, obj['attr2']) - - self.assertEqual(fake_name, obj.name) - self.assertEqual(fake_attr1, obj.first) - self.assertEqual(fake_attr2, obj.second) - - def test_get_by_id_with_headers(self): - header1 = "fake-value1" - header2 = "fake-value2" - headers = {"header1": header1, - "header2": header2} - - resp = mock.Mock(headers=headers) - resp.json = mock.Mock(return_value=fake_body) - self.session.get = mock.Mock(return_value=resp) - - class FakeResource2(FakeResource): - header1 = resource.header("header1") - header2 = resource.header("header2") - - obj = FakeResource2.get_by_id(self.session, fake_id, - path_args=fake_arguments, - include_headers=True) - - self.assertCalledURL(self.session.get, - os.path.join(fake_base_path % fake_arguments, - str(fake_id))[1:]) - - self.assertEqual(fake_id, obj.id) - self.assertEqual(fake_name, obj['name']) - self.assertEqual(fake_attr1, obj['attr1']) - self.assertEqual(fake_attr2, obj['attr2']) - self.assertEqual(header1, obj['headers']['header1']) - self.assertEqual(header2, obj['headers']['header2']) - - self.assertEqual(fake_name, obj.name) - self.assertEqual(fake_attr1, obj.first) - self.assertEqual(fake_attr2, obj.second) - self.assertEqual(header1, obj.header1) - self.assertEqual(header2, obj.header2) - - def test_head_by_id(self): - class FakeResource2(FakeResource): - header1 = resource.header("header1") - header2 = resource.header("header2") - - resp = mock.Mock(headers={"header1": "one", "header2": "two"}) - self.session.head = mock.Mock(return_value=resp) - - obj = FakeResource2.head_by_id(self.session, fake_id, - path_args=fake_arguments) - - self.assertCalledURL(self.session.head, - os.path.join(fake_base_path % fake_arguments, - str(fake_id))[1:]) - - self.assertEqual('one', obj['headers']['header1']) - self.assertEqual('two', obj['headers']['header2']) - - self.assertEqual('one', obj.header1) - self.assertEqual('two', obj.header2) - - def test_patch_update(self): - class FakeResourcePatch(FakeResource): - patch_update = True - - resp = mock.Mock() - resp.json = mock.Mock(return_value=fake_body) - resp.headers = {'location': 'foo'} - self.session.patch = mock.Mock(return_value=resp) - - # Create resource with subset of attributes in order to - # verify update refreshes all attributes from response. - obj = FakeResourcePatch.new(id=fake_id, parent_name=fake_parent, - name=fake_name, attr1=fake_attr1) - self.assertTrue(obj.is_dirty) - - self.assertEqual(obj, obj.update(self.session)) - self.assertFalse(obj.is_dirty) - - self.assertCalledURL(self.session.patch, - os.path.join(fake_base_path % fake_arguments, - str(fake_id))[1:]) - - last_req = self.session.patch.call_args[1]["json"][ - FakeResource.resource_key] - - self.assertEqual(3, len(last_req)) - self.assertEqual(fake_parent, last_req['parent_name']) - self.assertEqual(fake_name, last_req['name']) - self.assertEqual(fake_attr1, last_req['attr1']) - - self.assertTrue(obj['enabled']) - self.assertEqual(fake_name, obj['name']) - self.assertEqual(fake_parent, obj['parent_name']) - self.assertEqual(fake_attr1, obj['attr1']) - self.assertEqual(fake_attr2, obj['attr2']) - self.assertIsNone(obj['status']) - - self.assertTrue(obj.enabled) - self.assertEqual(fake_id, obj.id) - self.assertEqual(fake_name, obj.name) - self.assertEqual(fake_parent, obj.parent_name) - self.assertEqual(fake_parent, obj.parent) - self.assertEqual(fake_attr1, obj.first) - self.assertEqual(fake_attr1, obj.attr1) - self.assertEqual(fake_attr2, obj.second) - self.assertEqual(fake_attr2, obj.attr2) - self.assertIsNone(obj.status) - self.assertEqual('foo', obj.location) - - def test_put_update(self): - class FakeResourcePut(FakeResource): - # This is False by default, but explicit for this test. - patch_update = False - - resp = mock.Mock() - resp.json = mock.Mock(return_value=fake_body) - resp.headers = {'location': 'foo'} - self.session.put = mock.Mock(return_value=resp) - - # Create resource with subset of attributes in order to - # verify update refreshes all attributes from response. - obj = FakeResourcePut.new(id=fake_id, parent_name=fake_parent, - name=fake_name, attr1=fake_attr1) - self.assertTrue(obj.is_dirty) - - self.assertEqual(obj, obj.update(self.session)) - self.assertFalse(obj.is_dirty) - - self.assertCalledURL(self.session.put, - os.path.join(fake_base_path % fake_arguments, - str(fake_id))[1:]) - - last_req = self.session.put.call_args[1]["json"][ - FakeResource.resource_key] - - self.assertEqual(3, len(last_req)) - self.assertEqual(fake_parent, last_req['parent_name']) - self.assertEqual(fake_name, last_req['name']) - self.assertEqual(fake_attr1, last_req['attr1']) - - self.assertTrue(obj['enabled']) - self.assertEqual(fake_name, obj['name']) - self.assertEqual(fake_parent, obj['parent_name']) - self.assertEqual(fake_attr1, obj['attr1']) - self.assertEqual(fake_attr2, obj['attr2']) - self.assertIsNone(obj['status']) - - self.assertTrue(obj.enabled) - self.assertEqual(fake_id, obj.id) - self.assertEqual(fake_name, obj.name) - self.assertEqual(fake_parent, obj.parent_name) - self.assertEqual(fake_parent, obj.parent) - self.assertEqual(fake_attr1, obj.first) - self.assertEqual(fake_attr1, obj.attr1) - self.assertEqual(fake_attr2, obj.second) - self.assertEqual(fake_attr2, obj.attr2) - self.assertIsNone(obj.status) - self.assertEqual('foo', obj.location) - - def test_update_early_exit(self): - obj = FakeResource() - obj._dirty = [] # Bail out early if there's nothing to update. - - self.assertIsNone(obj.update("session")) - - def test_update_no_id_attribute(self): - obj = FakeResource.existing(id=1, attr="value1", - parent_name=fake_parent) - obj.first = "value2" # Make it dirty - obj.update_by_id = mock.Mock(return_value=dict()) - # If no id_attribute is returned in the update response, make sure - # we handle the resulting KeyError. - self.assertEqual(obj, obj.update("session")) - - def test_delete(self): - obj = FakeResource({"id": fake_id, "parent_name": fake_parent}) - obj.delete(self.session) - - self.assertCalledURL(self.session.delete, - os.path.join(fake_base_path % fake_arguments, - str(fake_id))[1:]) - - def _test_list(self, resource_class): - results = [fake_data.copy(), fake_data.copy(), fake_data.copy()] - for i in range(len(results)): - results[i]['id'] = fake_id + i - if resource_class.resources_key is not None: - body = {resource_class.resources_key: - self._get_expected_results()} - sentinel = {resource_class.resources_key: []} - else: - body = self._get_expected_results() - sentinel = [] - resp1 = mock.Mock() - resp1.json = mock.Mock(return_value=body) - resp2 = mock.Mock() - resp2.json = mock.Mock(return_value=sentinel) - self.session.get.side_effect = [resp1, resp2] - - objs = list(resource_class.list(self.session, path_args=fake_arguments, - paginated=True)) - - params = {'limit': 3, 'marker': results[-1]['id']} - self.assertEqual(params, self.session.get.call_args[1]['params']) - self.assertEqual(3, len(objs)) - for obj in objs: - self.assertIn(obj.id, range(fake_id, fake_id + 3)) - self.assertEqual(fake_name, obj['name']) - self.assertEqual(fake_name, obj.name) - self.assertIsInstance(obj, FakeResource) - - def _get_expected_results(self): - results = [fake_data.copy(), fake_data.copy(), fake_data.copy()] - for i in range(len(results)): - results[i]['id'] = fake_id + i - return results - - def test_list_keyed_resource(self): - self._test_list(FakeResource) - - def test_list_non_keyed_resource(self): - self._test_list(FakeResourceNoKeys) - - def _test_list_call_count(self, paginated): - # Test that we've only made one call to receive all data - results = [fake_data.copy(), fake_data.copy(), fake_data.copy()] - resp = mock.Mock() - resp.json = mock.Mock(return_value={fake_resources: results}) - attrs = {"get.return_value": resp} - session = mock.Mock(**attrs) - - list(FakeResource.list(session, params={'limit': len(results) + 1}, - path_args=fake_arguments, - paginated=paginated)) - - # Ensure we only made one call to complete this. - self.assertEqual(1, session.get.call_count) - - def test_list_bail_out(self): - # When we get less data than limit, make sure we made one call - self._test_list_call_count(True) - - def test_list_nonpaginated(self): - # When we call with paginated=False, make sure we made one call - self._test_list_call_count(False) - - def test_determine_limit(self): - full_page = [fake_data.copy(), fake_data.copy(), fake_data.copy()] - last_page = [fake_data.copy()] - - session = mock.Mock() - session.get = mock.Mock() - full_response = mock.Mock() - response_body = {FakeResource.resources_key: full_page} - full_response.json = mock.Mock(return_value=response_body) - last_response = mock.Mock() - response_body = {FakeResource.resources_key: last_page} - last_response.json = mock.Mock(return_value=response_body) - pages = [full_response, full_response, last_response] - session.get.side_effect = pages - - # Don't specify a limit. Resource.list will determine the limit - # is 3 based on the first `full_page`. - results = list(FakeResource.list(session, path_args=fake_arguments, - paginated=True)) - - self.assertEqual(session.get.call_count, len(pages)) - self.assertEqual(len(full_page + full_page + last_page), len(results)) - - def test_empty_list(self): - page = [] - - session = mock.Mock() - session.get = mock.Mock() - full_response = mock.Mock() - response_body = {FakeResource.resources_key: page} - full_response.json = mock.Mock(return_value=response_body) - pages = [full_response] - session.get.side_effect = pages - - results = list(FakeResource.list(session, path_args=fake_arguments, - paginated=True)) - - self.assertEqual(session.get.call_count, len(pages)) - self.assertEqual(len(page), len(results)) - - def test_attrs_name(self): - obj = FakeResource() - - self.assertIsNone(obj.name) - del obj.name - - def test_to_dict(self): - kwargs = { - 'enabled': True, - 'name': 'FOO', - 'parent': 'dad', - 'attr1': 'BAR', - 'attr2': ['ZOO', 'BAZ'], - 'status': 'Active', - 'headers': { - 'key': 'value' - } - } - obj = FakeResource(kwargs) - res = obj.to_dict() - self.assertIsInstance(res, dict) - self.assertTrue(res['enabled']) - self.assertEqual('FOO', res['name']) - self.assertEqual('dad', res['parent']) - self.assertEqual('BAR', res['attr1']) - self.assertEqual(['ZOO', 'BAZ'], res['attr2']) - self.assertEqual('Active', res['status']) - self.assertNotIn('headers', res) - - def test_composite_attr_happy(self): - obj = FakeResource.existing(**{'attr3': '3'}) - - try: - self.assertEqual('3', obj.third) - except AttributeError: - self.fail("third was not found as expected") - - def test_composite_attr_fallback(self): - obj = FakeResource.existing(**{'attr_three': '3'}) - - try: - self.assertEqual('3', obj.third) - except AttributeError: - self.fail("third was not found in fallback as expected") - - def test_id_del(self): - - class Test(resource.Resource): - id_attribute = "my_id" - - attrs = {"my_id": 100} - t = Test(attrs=attrs) - - self.assertEqual(attrs["my_id"], t.id) - del t.id - self.assertTrue(Test.id_attribute not in t._attrs) - - def test_from_name_with_name(self): - name = "Ernie Banks" - - obj = FakeResource.from_name(name) - self.assertEqual(name, obj.name) - - def test_from_id_with_name(self): - name = "Sandy Koufax" - - obj = FakeResource.from_id(name) - self.assertEqual(name, obj.id) - - def test_from_id_with_object(self): - name = "Mickey Mantle" - obj = FakeResource.new(name=name) - - new_obj = FakeResource.from_id(obj) - self.assertIs(new_obj, obj) - self.assertEqual(obj.name, new_obj.name) - - def test_from_id_with_bad_value(self): - def should_raise(): - FakeResource.from_id(3.14) - - self.assertThat(should_raise, matchers.raises(ValueError)) - - def test_dirty_list(self): - class Test(resource.Resource): - attr = resource.prop("attr") - - # Check if dirty after setting by prop - sot1 = Test() - self.assertFalse(sot1.is_dirty) - sot1.attr = 1 - self.assertTrue(sot1.is_dirty) - - # Check if dirty after setting by mapping - sot2 = Test() - sot2["attr"] = 1 - self.assertTrue(sot1.is_dirty) - - # Check if dirty after creation - sot3 = Test({"attr": 1}) - self.assertTrue(sot3.is_dirty) - - def test_update_attrs(self): - class Test(resource.Resource): - moe = resource.prop("the-attr") - larry = resource.prop("the-attr2") - curly = resource.prop("the-attr3", type=int) - shemp = resource.prop("the-attr4") - - value1 = "one" - value2 = "two" - value3 = "3" - value4 = "fore" - value5 = "fiver" - - sot = Test({"the-attr": value1}) - - sot.update_attrs({"the-attr2": value2, "notprop": value4}) - self.assertTrue(sot.is_dirty) - self.assertEqual(value1, sot.moe) - self.assertEqual(value1, sot["the-attr"]) - self.assertEqual(value2, sot.larry) - self.assertEqual(value4, sot.notprop) - - sot._reset_dirty() - - sot.update_attrs(curly=value3) - self.assertTrue(sot.is_dirty) - self.assertEqual(int, type(sot.curly)) - self.assertEqual(int(value3), sot.curly) - - sot._reset_dirty() - - sot.update_attrs(**{"the-attr4": value5}) - self.assertTrue(sot.is_dirty) - self.assertEqual(value5, sot.shemp) - - def test_get_id(self): - class Test(resource.Resource): - pass - - ID = "an id" - res = Test({"id": ID}) - - self.assertEqual(ID, resource.Resource.get_id(ID)) - self.assertEqual(ID, resource.Resource.get_id(res)) - - def test_convert_ids(self): - class TestResourceFoo(resource.Resource): - pass - - class TestResourceBar(resource.Resource): - pass - - resfoo = TestResourceFoo({'id': 'FAKEFOO'}) - resbar = TestResourceBar({'id': 'FAKEBAR'}) - - self.assertIsNone(resource.Resource.convert_ids(None)) - attrs = { - 'key1': 'value1' - } - self.assertEqual(attrs, resource.Resource.convert_ids(attrs)) - - attrs = { - 'foo': resfoo, - 'bar': resbar, - 'other': 'whatever', - } - res = resource.Resource.convert_ids(attrs) - self.assertEqual('FAKEFOO', res['foo']) - self.assertEqual('FAKEBAR', res['bar']) - self.assertEqual('whatever', res['other']) - - def test_repr(self): - fr = FakeResource() - fr._loaded = False - fr.first = "hey" - fr.second = "hi" - fr.third = "nah" - the_repr = repr(fr) - the_repr = the_repr.replace('openstack.tests.unit.test_resource.', '') - result = eval(the_repr) - self.assertEqual(fr._loaded, result._loaded) - self.assertEqual(fr.first, result.first) - self.assertEqual(fr.second, result.second) - self.assertEqual(fr.third, result.third) - - def test_id_attribute(self): - faker = FakeResource(fake_data) - self.assertEqual(fake_id, faker.id) - faker.id_attribute = 'name' - self.assertEqual(fake_name, faker.id) - faker.id_attribute = 'attr1' - self.assertEqual(fake_attr1, faker.id) - faker.id_attribute = 'attr2' - self.assertEqual(fake_attr2, faker.id) - faker.id_attribute = 'id' - self.assertEqual(fake_id, faker.id) - - def test_name_attribute(self): - class Person_ES(resource.Resource): - name_attribute = "nombre" - nombre = resource.prop('nombre') - - name = "Brian" - args = {'nombre': name} - - person = Person_ES(args) - self.assertEqual(name, person.nombre) - self.assertEqual(name, person.name) - - new_name = "Julien" - person.name = new_name - self.assertEqual(new_name, person.nombre) - self.assertEqual(new_name, person.name) - - def test_boolstr_prop(self): - faker = FakeResource(fake_data) - self.assertTrue(faker.enabled) - self.assertTrue(faker['enabled']) - - faker._attrs['enabled'] = False - self.assertFalse(faker.enabled) - self.assertFalse(faker['enabled']) - - # should fail fast - def set_invalid(): - faker.enabled = 'INVALID' - self.assertRaises(ValueError, set_invalid) - - -class ResourceMapping(base.TestCase): - - def test__getitem(self): - value = 10 - - class Test(resource.Resource): - attr = resource.prop("attr") - - t = Test(attrs={"attr": value}) - - self.assertEqual(value, t["attr"]) - - def test__setitem__existing_item_changed(self): - - class Test(resource.Resource): - pass - - t = Test() - key = "attr" - value = 1 - t[key] = value - - self.assertEqual(value, t._attrs[key]) - self.assertTrue(key in t._dirty) - - def test__setitem__existing_item_unchanged(self): - - class Test(resource.Resource): - pass - - key = "attr" - value = 1 - t = Test(attrs={key: value}) - t._reset_dirty() # Clear dirty list so this checks as unchanged. - t[key] = value - - self.assertEqual(value, t._attrs[key]) - self.assertTrue(key not in t._dirty) - - def test__setitem__new_item(self): - - class Test(resource.Resource): - pass - - t = Test() - key = "attr" - value = 1 - t[key] = value - - self.assertEqual(value, t._attrs[key]) - self.assertTrue(key in t._dirty) - - def test__delitem__(self): - - class Test(resource.Resource): - pass - - key = "attr" - value = 1 - t = Test(attrs={key: value}) - - del t[key] - - self.assertTrue(key not in t._attrs) - self.assertTrue(key in t._dirty) - - def test__len__(self): - - class Test(resource.Resource): - pass - - attrs = {"a": 1, "b": 2, "c": 3} - t = Test(attrs=attrs) - - self.assertEqual(len(attrs.keys()), len(t)) - - def test__iter__(self): - - class Test(resource.Resource): - pass - - attrs = {"a": 1, "b": 2, "c": 3} - t = Test(attrs=attrs) - - for attr in t: - self.assertEqual(attrs[attr], t[attr]) - - def _test_resource_serialization(self, session_method, resource_method): - attr_type = resource.Resource - - class Test(resource.Resource): - allow_create = True - attr = resource.prop("attr", type=attr_type) - - the_id = 123 - sot = Test() - sot.attr = resource.Resource({"id": the_id}) - self.assertEqual(attr_type, type(sot.attr)) - - def fake_call(*args, **kwargs): - attrs = kwargs["json"] - try: - json.dumps(attrs) - except TypeError as e: - self.fail("Unable to serialize _attrs: %s" % e) - resp = mock.Mock() - resp.json = mock.Mock(return_value=attrs) - return resp - - session = mock.Mock() - setattr(session, session_method, mock.Mock(side_effect=fake_call)) - - if resource_method == "create_by_id": - session.create_by_id(session, sot._attrs) - elif resource_method == "update_by_id": - session.update_by_id(session, None, sot._attrs) - - def test_create_serializes_resource_types(self): - self._test_resource_serialization("post", "create_by_id") - - def test_update_serializes_resource_types(self): - self._test_resource_serialization("patch", "update_by_id") - - -class FakeResponse(object): - def __init__(self, response): - self.body = response - - def json(self): - return self.body - - -class TestFind(base.TestCase): - NAME = 'matrix' - ID = 'Fishburne' - PROP = 'attribute2' - - def setUp(self): - super(TestFind, self).setUp() - self.mock_session = mock.Mock() - self.mock_get = mock.Mock() - self.mock_session.get = self.mock_get - self.matrix = {'id': self.ID, 'name': self.NAME, 'prop': self.PROP} - - def test_name(self): - self.mock_get.side_effect = [ - exceptions.NotFoundException(), - FakeResponse({FakeResource.resources_key: [self.matrix]}) - ] - - result = FakeResource.find(self.mock_session, self.NAME, - path_args=fake_arguments) - - self.assertEqual(self.NAME, result.name) - self.assertEqual(self.PROP, result.prop) - - def test_id(self): - self.mock_get.side_effect = [ - FakeResponse({FakeResource.resource_key: self.matrix}) - ] - - result = FakeResource.find(self.mock_session, self.ID, - path_args=fake_arguments) - - self.assertEqual(self.ID, result.id) - self.assertEqual(self.PROP, result.prop) - - path = "fakes/" + fake_parent + "/data/" + self.ID - self.mock_get.assert_any_call(path, endpoint_filter=None) - - def test_id_no_retrieve(self): - self.mock_get.side_effect = [ - FakeResponse({FakeResource.resources_key: [self.matrix]}) - ] - - class NoRetrieveResource(FakeResource): - allow_retrieve = False - - result = NoRetrieveResource.find(self.mock_session, self.ID, - path_args=fake_arguments) - - self.assertEqual(self.ID, result.id) - self.assertEqual(self.PROP, result.prop) - - def test_dups(self): - dupe = self.matrix.copy() - dupe['id'] = 'different' - self.mock_get.side_effect = [ - # Raise a 404 first so we get out of the ID search and into name. - exceptions.NotFoundException(), - FakeResponse({FakeResource.resources_key: [self.matrix, dupe]}) - ] - - self.assertRaises(exceptions.DuplicateResource, FakeResource.find, - self.mock_session, self.NAME) - - def test_id_attribute_find(self): - floater = {'ip_address': "127.0.0.1", 'prop': self.PROP} - self.mock_get.side_effect = [ - FakeResponse({FakeResource.resource_key: floater}) - ] - - FakeResource.id_attribute = 'ip_address' - FakeResource.id_attribute = 'ip_address' - result = FakeResource.find(self.mock_session, "127.0.0.1", - path_args=fake_arguments) - self.assertEqual("127.0.0.1", result.id) - self.assertEqual(self.PROP, result.prop) - - FakeResource.id_attribute = 'id' - - p = {'ip_address': "127.0.0.1"} - path = fake_path + "?limit=2" - self.mock_get.called_once_with(path, params=p, endpoint_filter=None) - - def test_nada(self): - self.mock_get.side_effect = [ - exceptions.NotFoundException(), - FakeResponse({FakeResource.resources_key: []}) - ] - - self.assertIsNone(FakeResource.find(self.mock_session, self.NAME)) - - def test_no_name(self): - self.mock_get.side_effect = [ - exceptions.NotFoundException(), - FakeResponse({FakeResource.resources_key: [self.matrix]}) - ] - FakeResource.name_attribute = None - - self.assertIsNone(FakeResource.find(self.mock_session, self.NAME)) - - def test_nada_not_ignored(self): - self.mock_get.side_effect = [ - exceptions.NotFoundException(), - FakeResponse({FakeResource.resources_key: []}) - ] - - self.assertRaises(exceptions.ResourceNotFound, FakeResource.find, - self.mock_session, self.NAME, ignore_missing=False) - - -class TestWaitForStatus(base.TestCase): - - def __init__(self, *args, **kwargs): - super(TestWaitForStatus, self).__init__(*args, **kwargs) - self.build = FakeResponse(self.body_with_status(fake_body, 'BUILD')) - self.active = FakeResponse(self.body_with_status(fake_body, 'ACTIVE')) - self.error = FakeResponse(self.body_with_status(fake_body, 'ERROR')) - - def setUp(self): - super(TestWaitForStatus, self).setUp() - self.sess = mock.Mock() - - def body_with_status(self, body, status): - body_copy = copy.deepcopy(body) - body_copy[fake_resource]['status'] = status - return body_copy - - def test_wait_for_status_nothing(self): - self.sess.get = mock.Mock() - sot = FakeResource.new(**fake_data) - sot.status = 'ACTIVE' - - self.assertEqual(sot, resource.wait_for_status( - self.sess, sot, 'ACTIVE', [], 1, 2)) - self.assertEqual([], self.sess.get.call_args_list) - - def test_wait_for_status(self): - self.sess.get = mock.Mock() - self.sess.get.side_effect = [self.build, self.active] - sot = FakeResource.new(**fake_data) - - self.assertEqual(sot, resource.wait_for_status( - self.sess, sot, 'ACTIVE', [], 1, 2)) - - def test_wait_for_status_timeout(self): - self.sess.get = mock.Mock() - self.sess.get.side_effect = [self.build, self.build] - sot = FakeResource.new(**fake_data) - - self.assertRaises(exceptions.ResourceTimeout, resource.wait_for_status, - self.sess, sot, 'ACTIVE', ['ERROR'], 1, 2) - - def test_wait_for_status_failures(self): - self.sess.get = mock.Mock() - self.sess.get.side_effect = [self.build, self.error] - sot = FakeResource.new(**fake_data) - - self.assertRaises(exceptions.ResourceFailure, resource.wait_for_status, - self.sess, sot, 'ACTIVE', ['ERROR'], 1, 2) - - def test_wait_for_status_no_status(self): - class FakeResourceNoStatus(resource.Resource): - allow_retrieve = True - - sot = FakeResourceNoStatus.new(id=123) - - self.assertRaises(AttributeError, resource.wait_for_status, - self.sess, sot, 'ACTIVE', ['ERROR'], 1, 2) - - -class TestWaitForDelete(base.TestCase): - - def test_wait_for_delete(self): - sess = mock.Mock() - sot = FakeResource.new(**fake_data) - sot.get = mock.Mock() - sot.get.side_effect = [ - sot, - exceptions.NotFoundException()] - - self.assertEqual(sot, resource.wait_for_delete(sess, sot, 1, 2)) - - def test_wait_for_delete_fail(self): - sess = mock.Mock() - sot = FakeResource.new(**fake_data) - sot.get = mock.Mock(return_value=sot) - - self.assertRaises(exceptions.ResourceTimeout, resource.wait_for_delete, - sess, sot, 1, 2) diff --git a/openstack/tests/unit/test_resource2.py b/openstack/tests/unit/test_resource2.py deleted file mode 100644 index c4055f53..00000000 --- a/openstack/tests/unit/test_resource2.py +++ /dev/null @@ -1,1507 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import itertools - -import mock -import six - -from openstack import exceptions -from openstack import format -from openstack import resource2 -from openstack import session -from openstack.tests.unit import base - - -class TestComponent(base.TestCase): - - class ExampleComponent(resource2._BaseComponent): - key = "_example" - - # Since we're testing ExampleComponent, which is as isolated as we - # can test _BaseComponent due to it's needing to be a data member - # of a class that has an attribute on the parent class named `key`, - # each test has to implement a class with a name that is the same - # as ExampleComponent.key, which should be a dict containing the - # keys and values to test against. - - def test_implementations(self): - self.assertEqual("_body", resource2.Body.key) - self.assertEqual("_header", resource2.Header.key) - self.assertEqual("_uri", resource2.URI.key) - - def test_creation(self): - sot = resource2._BaseComponent("name", type=int, default=1, - alternate_id=True) - - self.assertEqual("name", sot.name) - self.assertEqual(int, sot.type) - self.assertEqual(1, sot.default) - self.assertTrue(sot.alternate_id) - - def test_get_no_instance(self): - sot = resource2._BaseComponent("test") - - # Test that we short-circuit everything when given no instance. - result = sot.__get__(None, None) - self.assertIsNone(result) - - # NOTE: Some tests will use a default=1 setting when testing result - # values that should be None because the default-for-default is also None. - def test_get_name_None(self): - name = "name" - - class Parent(object): - _example = {name: None} - - instance = Parent() - sot = TestComponent.ExampleComponent(name, default=1) - - # Test that we short-circuit any typing of a None value. - result = sot.__get__(instance, None) - self.assertIsNone(result) - - def test_get_default(self): - expected_result = 123 - - class Parent(object): - _example = {} - - instance = Parent() - # NOTE: type=dict but the default value is an int. If we didn't - # short-circuit the typing part of __get__ it would fail. - sot = TestComponent.ExampleComponent("name", type=dict, - default=expected_result) - - # Test that we directly return any default value. - result = sot.__get__(instance, None) - self.assertEqual(expected_result, result) - - def test_get_name_untyped(self): - name = "name" - expected_result = 123 - - class Parent(object): - _example = {name: expected_result} - - instance = Parent() - sot = TestComponent.ExampleComponent("name") - - # Test that we return any the value as it is set. - result = sot.__get__(instance, None) - self.assertEqual(expected_result, result) - - # The code path for typing after a raw value has been found is the same. - def test_get_name_typed(self): - name = "name" - value = "123" - - class Parent(object): - _example = {name: value} - - instance = Parent() - sot = TestComponent.ExampleComponent("name", type=int) - - # Test that we run the underlying value through type conversion. - result = sot.__get__(instance, None) - self.assertEqual(int(value), result) - - def test_get_name_formatter(self): - name = "name" - value = "123" - expected_result = "one hundred twenty three" - - class Parent(object): - _example = {name: value} - - class FakeFormatter(object): - @classmethod - def deserialize(cls, value): - return expected_result - - instance = Parent() - sot = TestComponent.ExampleComponent("name", type=FakeFormatter) - - # Mock out issubclass rather than having an actual format.Formatter - # This can't be mocked via decorator, isolate it to wrapping the call. - mock_issubclass = mock.Mock(return_value=True) - module = six.moves.builtins.__name__ - with mock.patch("%s.issubclass" % module, mock_issubclass): - result = sot.__get__(instance, None) - self.assertEqual(expected_result, result) - - def test_set_name_untyped(self): - name = "name" - expected_value = "123" - - class Parent(object): - _example = {} - - instance = Parent() - sot = TestComponent.ExampleComponent("name") - - # Test that we don't run the value through type conversion. - sot.__set__(instance, expected_value) - self.assertEqual(expected_value, instance._example[name]) - - def test_set_name_typed(self): - expected_value = "123" - - class Parent(object): - _example = {} - - instance = Parent() - - # The type we give to ExampleComponent has to be an actual type, - # not an instance, so we can't get the niceties of a mock.Mock - # instance that would allow us to call `assert_called_once_with` to - # ensure that we're sending the value through the type. - # Instead, we use this tiny version of a similar thing. - class FakeType(object): - calls = [] - - def __init__(self, arg): - FakeType.calls.append(arg) - - sot = TestComponent.ExampleComponent("name", type=FakeType) - - # Test that we run the value through type conversion. - sot.__set__(instance, expected_value) - self.assertEqual([expected_value], FakeType.calls) - - def test_set_name_formatter(self): - expected_value = "123" - - class Parent(object): - _example = {} - - instance = Parent() - - # As with test_set_name_typed, create a pseudo-Mock to track what - # gets called on the type. - class FakeFormatter(format.Formatter): - calls = [] - - @classmethod - def serialize(cls, arg): - FakeFormatter.calls.append(arg) - - sot = TestComponent.ExampleComponent("name", type=FakeFormatter) - - # Test that we run the value through type conversion. - sot.__set__(instance, expected_value) - self.assertEqual([expected_value], FakeFormatter.calls) - - def test_delete_name(self): - name = "name" - expected_value = "123" - - class Parent(object): - _example = {name: expected_value} - - instance = Parent() - - sot = TestComponent.ExampleComponent("name") - - sot.__delete__(instance) - - self.assertNotIn(name, instance._example) - - def test_delete_name_doesnt_exist(self): - name = "name" - expected_value = "123" - - class Parent(object): - _example = {"what": expected_value} - - instance = Parent() - - sot = TestComponent.ExampleComponent(name) - - sot.__delete__(instance) - - self.assertNotIn(name, instance._example) - - -class TestComponentManager(base.TestCase): - - def test_create_basic(self): - sot = resource2._ComponentManager() - self.assertEqual(dict(), sot.attributes) - self.assertEqual(set(), sot._dirty) - - def test_create_unsynced(self): - attrs = {"hey": 1, "hi": 2, "hello": 3} - sync = False - - sot = resource2._ComponentManager(attributes=attrs, synchronized=sync) - self.assertEqual(attrs, sot.attributes) - self.assertEqual(set(attrs.keys()), sot._dirty) - - def test_create_synced(self): - attrs = {"hey": 1, "hi": 2, "hello": 3} - sync = True - - sot = resource2._ComponentManager(attributes=attrs, synchronized=sync) - self.assertEqual(attrs, sot.attributes) - self.assertEqual(set(), sot._dirty) - - def test_getitem(self): - key = "key" - value = "value" - attrs = {key: value} - - sot = resource2._ComponentManager(attributes=attrs) - self.assertEqual(value, sot.__getitem__(key)) - - def test_setitem_new(self): - key = "key" - value = "value" - - sot = resource2._ComponentManager() - sot.__setitem__(key, value) - - self.assertIn(key, sot.attributes) - self.assertIn(key, sot.dirty) - - def test_setitem_unchanged(self): - key = "key" - value = "value" - attrs = {key: value} - - sot = resource2._ComponentManager(attributes=attrs, synchronized=True) - # This shouldn't end up in the dirty list since we're just re-setting. - sot.__setitem__(key, value) - - self.assertEqual(value, sot.attributes[key]) - self.assertNotIn(key, sot.dirty) - - def test_delitem(self): - key = "key" - value = "value" - attrs = {key: value} - - sot = resource2._ComponentManager(attributes=attrs, synchronized=True) - sot.__delitem__(key) - - self.assertIsNone(sot.dirty[key]) - - def test_iter(self): - attrs = {"key": "value"} - sot = resource2._ComponentManager(attributes=attrs) - self.assertItemsEqual(iter(attrs), sot.__iter__()) - - def test_len(self): - attrs = {"key": "value"} - sot = resource2._ComponentManager(attributes=attrs) - self.assertEqual(len(attrs), sot.__len__()) - - def test_dirty(self): - key = "key" - key2 = "key2" - value = "value" - attrs = {key: value} - sot = resource2._ComponentManager(attributes=attrs, synchronized=False) - self.assertEqual({key: value}, sot.dirty) - - sot.__setitem__(key2, value) - self.assertEqual({key: value, key2: value}, sot.dirty) - - def test_clean(self): - key = "key" - value = "value" - attrs = {key: value} - sot = resource2._ComponentManager(attributes=attrs, synchronized=False) - self.assertEqual(attrs, sot.dirty) - - sot.clean() - - self.assertEqual(dict(), sot.dirty) - - -class Test_Request(base.TestCase): - - def test_create(self): - uri = 1 - body = 2 - headers = 3 - - sot = resource2._Request(uri, body, headers) - - self.assertEqual(uri, sot.uri) - self.assertEqual(body, sot.body) - self.assertEqual(headers, sot.headers) - - -class TestQueryParameters(base.TestCase): - - def test_create(self): - location = "location" - mapping = {"first_name": "first-name"} - - sot = resource2.QueryParameters(location, **mapping) - - self.assertEqual({"location": "location", - "first_name": "first-name", - "limit": "limit", - "marker": "marker"}, - sot._mapping) - - def test_transpose_unmapped(self): - location = "location" - mapping = {"first_name": "first-name"} - - sot = resource2.QueryParameters(location, **mapping) - result = sot._transpose({"location": "Brooklyn", - "first_name": "Brian", - "last_name": "Curtin"}) - - # last_name isn't mapped and shouldn't be included - self.assertEqual({"location": "Brooklyn", "first-name": "Brian"}, - result) - - def test_transpose_not_in_query(self): - location = "location" - mapping = {"first_name": "first-name"} - - sot = resource2.QueryParameters(location, **mapping) - result = sot._transpose({"location": "Brooklyn"}) - - # first_name not being in the query shouldn't affect results - self.assertEqual({"location": "Brooklyn"}, - result) - - -class TestResource(base.TestCase): - - def test_initialize_basic(self): - body = {"body": 1} - header = {"header": 2, "Location": "somewhere"} - uri = {"uri": 3} - everything = dict(itertools.chain(body.items(), header.items(), - uri.items())) - - mock_collect = mock.Mock() - mock_collect.return_value = body, header, uri - - with mock.patch.object(resource2.Resource, - "_collect_attrs", mock_collect): - sot = resource2.Resource(_synchronized=False, **everything) - mock_collect.assert_called_once_with(everything) - self.assertEqual("somewhere", sot.location) - - self.assertIsInstance(sot._body, resource2._ComponentManager) - self.assertEqual(body, sot._body.dirty) - self.assertIsInstance(sot._header, resource2._ComponentManager) - self.assertEqual(header, sot._header.dirty) - self.assertIsInstance(sot._uri, resource2._ComponentManager) - self.assertEqual(uri, sot._uri.dirty) - - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertFalse(sot.allow_list) - self.assertFalse(sot.allow_head) - self.assertFalse(sot.patch_update) - self.assertFalse(sot.put_create) - - def test_repr(self): - a = {"a": 1} - b = {"b": 2} - c = {"c": 3} - - class Test(resource2.Resource): - def __init__(self): - self._body = mock.Mock() - self._body.attributes.items = mock.Mock( - return_value=a.items()) - - self._header = mock.Mock() - self._header.attributes.items = mock.Mock( - return_value=b.items()) - - self._uri = mock.Mock() - self._uri.attributes.items = mock.Mock( - return_value=c.items()) - - the_repr = repr(Test()) - - # Don't test the arguments all together since the dictionary order - # they're rendered in can't be depended on, nor does it matter. - self.assertIn("openstack.tests.unit.test_resource2.Test", the_repr) - self.assertIn("a=1", the_repr) - self.assertIn("b=2", the_repr) - self.assertIn("c=3", the_repr) - - def test_equality(self): - class Example(resource2.Resource): - x = resource2.Body("x") - y = resource2.Header("y") - z = resource2.URI("z") - - e1 = Example(x=1, y=2, z=3) - e2 = Example(x=1, y=2, z=3) - e3 = Example(x=0, y=0, z=0) - - self.assertEqual(e1, e2) - self.assertNotEqual(e1, e3) - - def test__update(self): - sot = resource2.Resource() - - body = "body" - header = "header" - uri = "uri" - - sot._collect_attrs = mock.Mock(return_value=(body, header, uri)) - sot._body.update = mock.Mock() - sot._header.update = mock.Mock() - sot._uri.update = mock.Mock() - - args = {"arg": 1} - sot._update(**args) - - sot._collect_attrs.assert_called_once_with(args) - sot._body.update.assert_called_once_with(body) - sot._header.update.assert_called_once_with(header) - sot._uri.update.assert_called_once_with(uri) - - def test__collect_attrs(self): - sot = resource2.Resource() - - expected_attrs = ["body", "header", "uri"] - - sot._consume_attrs = mock.Mock() - sot._consume_attrs.side_effect = expected_attrs - - # It'll get passed an empty dict at the least. - actual_attrs = sot._collect_attrs(dict()) - - self.assertItemsEqual(expected_attrs, actual_attrs) - - def test__consume_attrs(self): - serverside_key1 = "someKey1" - clientside_key1 = "some_key1" - serverside_key2 = "someKey2" - clientside_key2 = "some_key2" - value1 = "value1" - value2 = "value2" - mapping = {clientside_key1: serverside_key1, - clientside_key2: serverside_key2} - - other_key = "otherKey" - other_value = "other" - attrs = {clientside_key1: value1, - serverside_key2: value2, - other_key: other_value} - - sot = resource2.Resource() - - result = sot._consume_attrs(mapping, attrs) - - # Make sure that the expected key was consumed and we're only - # left with the other stuff. - self.assertDictEqual({other_key: other_value}, attrs) - - # Make sure that after we've popped our relevant client-side - # key off that we are returning it keyed off of its server-side - # name. - self.assertDictEqual({serverside_key1: value1, - serverside_key2: value2}, result) - - def test__mapping_defaults(self): - # Check that even on an empty class, we get the expected - # built-in attributes. - - self.assertIn("location", resource2.Resource._header_mapping()) - self.assertIn("name", resource2.Resource._body_mapping()) - self.assertIn("id", resource2.Resource._body_mapping()) - - def test__mapping_overrides(self): - # Iterating through the MRO used to wipe out overrides of mappings - # found in base classes. - new_name = "MyName" - new_id = "MyID" - - class Test(resource2.Resource): - name = resource2.Body(new_name) - id = resource2.Body(new_id) - - mapping = Test._body_mapping() - - self.assertEqual(new_name, mapping["name"]) - self.assertEqual(new_id, mapping["id"]) - - def test__body_mapping(self): - class Test(resource2.Resource): - x = resource2.Body("x") - y = resource2.Body("y") - z = resource2.Body("z") - - self.assertIn("x", Test._body_mapping()) - self.assertIn("y", Test._body_mapping()) - self.assertIn("z", Test._body_mapping()) - - def test__header_mapping(self): - class Test(resource2.Resource): - x = resource2.Header("x") - y = resource2.Header("y") - z = resource2.Header("z") - - self.assertIn("x", Test._header_mapping()) - self.assertIn("y", Test._header_mapping()) - self.assertIn("z", Test._header_mapping()) - - def test__uri_mapping(self): - class Test(resource2.Resource): - x = resource2.URI("x") - y = resource2.URI("y") - z = resource2.URI("z") - - self.assertIn("x", Test._uri_mapping()) - self.assertIn("y", Test._uri_mapping()) - self.assertIn("z", Test._uri_mapping()) - - def test__getattribute__id_in_body(self): - id = "lol" - sot = resource2.Resource(id=id) - - result = getattr(sot, "id") - self.assertEqual(result, id) - - def test__getattribute__id_with_alternate(self): - id = "lol" - - class Test(resource2.Resource): - blah = resource2.Body("blah", alternate_id=True) - - sot = Test(blah=id) - - result = getattr(sot, "id") - self.assertEqual(result, id) - - def test__getattribute__id_without_alternate(self): - class Test(resource2.Resource): - id = None - - sot = Test() - self.assertIsNone(sot.id) - - def test__alternate_id_None(self): - self.assertEqual("", resource2.Resource._alternate_id()) - - def test__alternate_id(self): - class Test(resource2.Resource): - alt = resource2.Body("the_alt", alternate_id=True) - - self.assertTrue("the_alt", Test._alternate_id()) - - value1 = "lol" - sot = Test(alt=value1) - self.assertEqual(sot.alt, value1) - self.assertEqual(sot.id, value1) - - value2 = "rofl" - sot = Test(the_alt=value2) - self.assertEqual(sot.alt, value2) - self.assertEqual(sot.id, value2) - - def test__get_id_instance(self): - class Test(resource2.Resource): - id = resource2.Body("id") - - value = "id" - sot = Test(id=value) - - self.assertEqual(value, sot._get_id(sot)) - - def test__get_id_instance_alternate(self): - class Test(resource2.Resource): - attr = resource2.Body("attr", alternate_id=True) - - value = "id" - sot = Test(attr=value) - - self.assertEqual(value, sot._get_id(sot)) - - def test__get_id_value(self): - value = "id" - self.assertEqual(value, resource2.Resource._get_id(value)) - - def test_to_dict(self): - - class Test(resource2.Resource): - foo = resource2.Header('foo') - bar = resource2.Body('bar') - - res = Test(id='FAKE_ID') - - expected = { - 'id': 'FAKE_ID', - 'name': None, - 'location': None, - 'foo': None, - 'bar': None - } - self.assertEqual(expected, res.to_dict()) - - def test_to_dict_no_body(self): - - class Test(resource2.Resource): - foo = resource2.Header('foo') - bar = resource2.Body('bar') - - res = Test(id='FAKE_ID') - - expected = { - 'location': None, - 'foo': None, - } - self.assertEqual(expected, res.to_dict(body=False)) - - def test_to_dict_no_header(self): - - class Test(resource2.Resource): - foo = resource2.Header('foo') - bar = resource2.Body('bar') - - res = Test(id='FAKE_ID') - - expected = { - 'id': 'FAKE_ID', - 'name': None, - 'bar': None - } - self.assertEqual(expected, res.to_dict(headers=False)) - - def test_to_dict_ignore_none(self): - - class Test(resource2.Resource): - foo = resource2.Header('foo') - bar = resource2.Body('bar') - - res = Test(id='FAKE_ID', bar='BAR') - - expected = { - 'id': 'FAKE_ID', - 'bar': 'BAR', - } - self.assertEqual(expected, res.to_dict(ignore_none=True)) - - def test_to_dict_with_mro(self): - - class Parent(resource2.Resource): - foo = resource2.Header('foo') - bar = resource2.Body('bar') - - class Child(Parent): - foo_new = resource2.Header('foo_baz_server') - bar_new = resource2.Body('bar_baz_server') - - res = Child(id='FAKE_ID') - - expected = { - 'foo': None, - 'bar': None, - 'foo_new': None, - 'bar_new': None, - 'id': 'FAKE_ID', - 'location': None, - 'name': None - } - self.assertEqual(expected, res.to_dict()) - - def test_to_dict_value_error(self): - - class Test(resource2.Resource): - foo = resource2.Header('foo') - bar = resource2.Body('bar') - - res = Test(id='FAKE_ID') - - err = self.assertRaises(ValueError, - res.to_dict, body=False, headers=False) - self.assertEqual('At least one of `body` or `headers` must be True', - six.text_type(err)) - - def test_to_dict_with_mro_no_override(self): - - class Parent(resource2.Resource): - header = resource2.Header('HEADER') - body = resource2.Body('BODY') - - class Child(Parent): - # The following two properties are not supposed to be overridden - # by the parent class property values. - header = resource2.Header('ANOTHER_HEADER') - body = resource2.Body('ANOTHER_BODY') - - res = Child(id='FAKE_ID', body='BODY_VALUE', header='HEADER_VALUE') - - expected = { - 'body': 'BODY_VALUE', - 'header': 'HEADER_VALUE', - 'id': 'FAKE_ID', - 'location': None, - 'name': None - } - self.assertEqual(expected, res.to_dict()) - - def test_new(self): - class Test(resource2.Resource): - attr = resource2.Body("attr") - - value = "value" - sot = Test.new(attr=value) - - self.assertIn("attr", sot._body.dirty) - self.assertEqual(value, sot.attr) - - def test_existing(self): - class Test(resource2.Resource): - attr = resource2.Body("attr") - - value = "value" - sot = Test.existing(attr=value) - - self.assertNotIn("attr", sot._body.dirty) - self.assertEqual(value, sot.attr) - - def test__prepare_request_with_id(self): - class Test(resource2.Resource): - base_path = "/something" - body_attr = resource2.Body("x") - header_attr = resource2.Header("y") - - the_id = "id" - body_value = "body" - header_value = "header" - sot = Test(id=the_id, body_attr=body_value, header_attr=header_value, - _synchronized=False) - - result = sot._prepare_request(requires_id=True) - - self.assertEqual("something/id", result.uri) - self.assertEqual({"x": body_value, "id": the_id}, result.body) - self.assertEqual({"y": header_value}, result.headers) - - def test__prepare_request_missing_id(self): - sot = resource2.Resource(id=None) - - self.assertRaises(exceptions.InvalidRequest, - sot._prepare_request, requires_id=True) - - def test__prepare_request_with_key(self): - key = "key" - - class Test(resource2.Resource): - base_path = "/something" - resource_key = key - body_attr = resource2.Body("x") - header_attr = resource2.Header("y") - - body_value = "body" - header_value = "header" - sot = Test(body_attr=body_value, header_attr=header_value, - _synchronized=False) - - result = sot._prepare_request(requires_id=False, prepend_key=True) - - self.assertEqual("/something", result.uri) - self.assertEqual({key: {"x": body_value}}, result.body) - self.assertEqual({"y": header_value}, result.headers) - - def test__filter_component(self): - client_name = "client_name" - server_name = "serverName" - value = "value" - # Include something in the mapping that we don't receive - # so the branch that looks at existence in the compoment is checked. - mapping = {client_name: server_name, "other": "blah"} - component = {server_name: value, "something": "else"} - - sot = resource2.Resource() - result = sot._filter_component(component, mapping) - - # The something:else mapping should not make it into here. - self.assertEqual({server_name: value}, result) - - def test__translate_response_no_body(self): - class Test(resource2.Resource): - attr = resource2.Header("attr") - - response = mock.Mock() - response.headers = dict() - - sot = Test() - sot._filter_component = mock.Mock(return_value={"attr": "value"}) - - sot._translate_response(response, has_body=False) - - self.assertEqual(dict(), sot._header.dirty) - self.assertEqual("value", sot.attr) - - def test__translate_response_with_body_no_resource_key(self): - class Test(resource2.Resource): - attr = resource2.Body("attr") - - body = {"attr": "value"} - response = mock.Mock() - response.headers = dict() - response.json.return_value = body - - sot = Test() - sot._filter_component = mock.Mock(side_effect=[body, dict()]) - - sot._translate_response(response, has_body=True) - - self.assertEqual("value", sot.attr) - self.assertEqual(dict(), sot._body.dirty) - self.assertEqual(dict(), sot._header.dirty) - - def test__translate_response_with_body_with_resource_key(self): - key = "key" - - class Test(resource2.Resource): - resource_key = key - attr = resource2.Body("attr") - - body = {"attr": "value"} - response = mock.Mock() - response.headers = dict() - response.json.return_value = {key: body} - - sot = Test() - sot._filter_component = mock.Mock(side_effect=[body, dict()]) - - sot._translate_response(response, has_body=True) - - self.assertEqual("value", sot.attr) - self.assertEqual(dict(), sot._body.dirty) - self.assertEqual(dict(), sot._header.dirty) - - def test_cant_do_anything(self): - class Test(resource2.Resource): - allow_create = False - allow_get = False - allow_update = False - allow_delete = False - allow_head = False - allow_list = False - - sot = Test() - - # The first argument to all of these operations is the session, - # but we raise before we get to it so just pass anything in. - self.assertRaises(exceptions.MethodNotSupported, sot.create, "") - self.assertRaises(exceptions.MethodNotSupported, sot.get, "") - self.assertRaises(exceptions.MethodNotSupported, sot.delete, "") - self.assertRaises(exceptions.MethodNotSupported, sot.head, "") - - # list is a generator so you need to begin consuming - # it in order to exercise the failure. - the_list = sot.list("") - self.assertRaises(exceptions.MethodNotSupported, next, the_list) - - # Update checks the dirty list first before even trying to see - # if the call can be made, so fake a dirty list. - sot._body = mock.Mock() - sot._body.dirty = mock.Mock(return_value={"x": "y"}) - self.assertRaises(exceptions.MethodNotSupported, sot.update, "") - - -class TestResourceActions(base.TestCase): - - def setUp(self): - super(TestResourceActions, self).setUp() - - self.service_name = "service" - self.base_path = "base_path" - - class Test(resource2.Resource): - service = self.service_name - base_path = self.base_path - allow_create = True - allow_get = True - allow_head = True - allow_update = True - allow_delete = True - allow_list = True - - self.test_class = Test - - self.request = mock.Mock(spec=resource2._Request) - self.request.uri = "uri" - self.request.body = "body" - self.request.headers = "headers" - - self.response = mock.Mock() - - self.sot = Test(id="id") - self.sot._prepare_request = mock.Mock(return_value=self.request) - self.sot._translate_response = mock.Mock() - - self.session = mock.Mock(spec=session.Session) - self.session.create = mock.Mock(return_value=self.response) - self.session.get = mock.Mock(return_value=self.response) - self.session.put = mock.Mock(return_value=self.response) - self.session.patch = mock.Mock(return_value=self.response) - self.session.post = mock.Mock(return_value=self.response) - self.session.delete = mock.Mock(return_value=self.response) - self.session.head = mock.Mock(return_value=self.response) - - def _test_create(self, cls, requires_id=False, prepend_key=False): - id = "id" if requires_id else None - sot = cls(id=id) - sot._prepare_request = mock.Mock(return_value=self.request) - sot._translate_response = mock.Mock() - - result = sot.create(self.session, prepend_key=prepend_key) - - sot._prepare_request.assert_called_once_with( - requires_id=requires_id, prepend_key=prepend_key) - if requires_id: - self.session.put.assert_called_once_with( - self.request.uri, - endpoint_filter=self.service_name, - json=self.request.body, headers=self.request.headers) - else: - self.session.post.assert_called_once_with( - self.request.uri, - endpoint_filter=self.service_name, - json=self.request.body, headers=self.request.headers) - - sot._translate_response.assert_called_once_with(self.response) - self.assertEqual(result, sot) - - def test_put_create(self): - class Test(resource2.Resource): - service = self.service_name - base_path = self.base_path - allow_create = True - put_create = True - - self._test_create(Test, requires_id=True, prepend_key=True) - - def test_post_create(self): - class Test(resource2.Resource): - service = self.service_name - base_path = self.base_path - allow_create = True - put_create = False - - self._test_create(Test, requires_id=False, prepend_key=True) - - def test_get(self): - result = self.sot.get(self.session) - - self.sot._prepare_request.assert_called_once_with(requires_id=True) - self.session.get.assert_called_once_with( - self.request.uri, endpoint_filter=self.service_name) - - self.sot._translate_response.assert_called_once_with(self.response) - self.assertEqual(result, self.sot) - - def test_get_not_requires_id(self): - result = self.sot.get(self.session, False) - - self.sot._prepare_request.assert_called_once_with(requires_id=False) - self.session.get.assert_called_once_with( - self.request.uri, endpoint_filter=self.service_name) - - self.sot._translate_response.assert_called_once_with(self.response) - self.assertEqual(result, self.sot) - - def test_head(self): - result = self.sot.head(self.session) - - self.sot._prepare_request.assert_called_once_with() - self.session.head.assert_called_once_with( - self.request.uri, - endpoint_filter=self.service_name, - headers={"Accept": ""}) - - self.sot._translate_response.assert_called_once_with(self.response) - self.assertEqual(result, self.sot) - - def _test_update(self, patch_update=False, prepend_key=True, - has_body=True): - self.sot.patch_update = patch_update - - # Need to make sot look dirty so we can attempt an update - self.sot._body = mock.Mock() - self.sot._body.dirty = mock.Mock(return_value={"x": "y"}) - - self.sot.update(self.session, prepend_key=prepend_key, - has_body=has_body) - - self.sot._prepare_request.assert_called_once_with( - prepend_key=prepend_key) - - if patch_update: - self.session.patch.assert_called_once_with( - self.request.uri, - endpoint_filter=self.service_name, - json=self.request.body, headers=self.request.headers) - else: - self.session.put.assert_called_once_with( - self.request.uri, - endpoint_filter=self.service_name, - json=self.request.body, headers=self.request.headers) - - self.sot._translate_response.assert_called_once_with( - self.response, has_body=has_body) - - def test_update_put(self): - self._test_update(patch_update=False, prepend_key=True, has_body=True) - - def test_update_patch(self): - self._test_update(patch_update=True, prepend_key=False, has_body=False) - - def test_update_not_dirty(self): - self.sot._body = mock.Mock() - self.sot._body.dirty = dict() - self.sot._header = mock.Mock() - self.sot._header.dirty = dict() - - self.sot.update(self.session) - - self.session.put.assert_not_called() - - def test_delete(self): - result = self.sot.delete(self.session) - - self.sot._prepare_request.assert_called_once_with() - self.session.delete.assert_called_once_with( - self.request.uri, - endpoint_filter=self.service_name, - headers={"Accept": ""}) - - self.sot._translate_response.assert_called_once_with( - self.response, has_body=False) - self.assertEqual(result, self.sot) - - # NOTE: As list returns a generator, testing it requires consuming - # the generator. Wrap calls to self.sot.list in a `list` - # and then test the results as a list of responses. - def test_list_empty_response(self): - mock_response = mock.Mock() - mock_response.json.return_value = [] - - self.session.get.return_value = mock_response - - result = list(self.sot.list(self.session)) - - self.session.get.assert_called_once_with( - self.base_path, - endpoint_filter=self.service_name, - headers={"Accept": "application/json"}, - params={}) - - self.assertEqual([], result) - - def test_list_one_page_response_paginated(self): - id_value = 1 - mock_response = mock.Mock() - mock_response.json.side_effect = [[{"id": id_value}], - []] - - self.session.get.return_value = mock_response - - # Ensure that we break out of the loop on a paginated call - # that still only results in one page of data. - results = list(self.sot.list(self.session, paginated=True)) - - self.assertEqual(1, len(results)) - - # Look at the `params` argument to each of the get calls that - # were made. - self.session.get.call_args_list[0][1]["params"] = {} - self.session.get.call_args_list[1][1]["params"] = {"marker": id_value} - self.assertEqual(id_value, results[0].id) - self.assertIsInstance(results[0], self.test_class) - - def test_list_one_page_response_not_paginated(self): - id_value = 1 - mock_response = mock.Mock() - mock_response.json.return_value = [{"id": id_value}] - - self.session.get.return_value = mock_response - - results = list(self.sot.list(self.session, paginated=False)) - - self.session.get.assert_called_once_with( - self.base_path, - endpoint_filter=self.service_name, - headers={"Accept": "application/json"}, - params={}) - - self.assertEqual(1, len(results)) - self.assertEqual(id_value, results[0].id) - self.assertIsInstance(results[0], self.test_class) - - def test_list_one_page_response_resources_key(self): - key = "resources" - - class Test(self.test_class): - resources_key = key - - id_value = 1 - mock_response = mock.Mock() - mock_response.json.return_value = {key: [{"id": id_value}]} - - self.session.get.return_value = mock_response - - sot = Test() - - results = list(sot.list(self.session)) - - self.session.get.assert_called_once_with( - self.base_path, - endpoint_filter=self.service_name, - headers={"Accept": "application/json"}, - params={}) - - self.assertEqual(1, len(results)) - self.assertEqual(id_value, results[0].id) - self.assertIsInstance(results[0], self.test_class) - - def test_list_multi_page_response_not_paginated(self): - ids = [1, 2] - mock_response = mock.Mock() - mock_response.json.side_effect = [[{"id": ids[0]}], - [{"id": ids[1]}]] - - self.session.get.return_value = mock_response - - results = list(self.sot.list(self.session, paginated=False)) - - self.assertEqual(1, len(results)) - self.assertEqual(ids[0], results[0].id) - self.assertIsInstance(results[0], self.test_class) - - def test_list_query_params(self): - id = 1 - qp = "query param!" - qp_name = "query-param" - uri_param = "uri param!" - - mock_response = mock.Mock() - mock_response.json.side_effect = [[{"id": id}], - []] - - self.session.get.return_value = mock_response - - class Test(self.test_class): - _query_mapping = resource2.QueryParameters(query_param=qp_name) - base_path = "/%(something)s/blah" - something = resource2.URI("something") - - results = list(Test.list(self.session, paginated=True, - query_param=qp, something=uri_param)) - - self.assertEqual(1, len(results)) - - # Look at the `params` argument to each of the get calls that - # were made. - self.session.get.call_args_list[0][1]["params"] = {qp_name: qp} - - self.assertEqual(self.session.get.call_args_list[0][0][0], - Test.base_path % {"something": uri_param}) - - def test_list_multi_page_response_paginated(self): - # This tests our ability to stop making calls once - # we've received all of the data. However, this tests - # the case that we always receive full pages of data - # and then the signal that there is no more data - an empty list. - # In this case, we need to make one extra request beyond - # the end of data to ensure we've received it all. - ids = [1, 2] - resp1 = mock.Mock() - resp1.json.return_value = [{"id": ids[0]}] - resp2 = mock.Mock() - resp2.json.return_value = [{"id": ids[1]}] - resp3 = mock.Mock() - resp3.json.return_value = [] - - self.session.get.side_effect = [resp1, resp2, resp3] - - results = self.sot.list(self.session, paginated=True) - - result0 = next(results) - self.assertEqual(result0.id, ids[0]) - self.session.get.assert_called_with( - self.base_path, - endpoint_filter=self.service_name, - headers={"Accept": "application/json"}, - params={}) - - result1 = next(results) - self.assertEqual(result1.id, ids[1]) - self.session.get.assert_called_with( - self.base_path, - endpoint_filter=self.service_name, - headers={"Accept": "application/json"}, - params={"limit": 1, "marker": 1}) - - self.assertRaises(StopIteration, next, results) - self.session.get.assert_called_with( - self.base_path, - endpoint_filter=self.service_name, - headers={"Accept": "application/json"}, - params={"limit": 1, "marker": 2}) - - def test_list_multi_page_early_termination(self): - # This tests our ability to be somewhat smart when evaluating - # the contents of the responses. When we receive a full page - # of data, we can be smart about terminating our responses - # once we see that we've received a page with less data than - # expected, saving one request. - ids = [1, 2, 3] - resp1 = mock.Mock() - resp1.json.return_value = [{"id": ids[0]}, {"id": ids[1]}] - resp2 = mock.Mock() - resp2.json.return_value = [{"id": ids[2]}] - - self.session.get.side_effect = [resp1, resp2] - - results = self.sot.list(self.session, paginated=True) - - # Get the first page's two items - result0 = next(results) - self.assertEqual(result0.id, ids[0]) - result1 = next(results) - self.assertEqual(result1.id, ids[1]) - self.session.get.assert_called_with( - self.base_path, - endpoint_filter=self.service_name, - headers={"Accept": "application/json"}, - params={}) - - # Second page only has one item - result2 = next(results) - self.assertEqual(result2.id, ids[2]) - self.session.get.assert_called_with( - self.base_path, - endpoint_filter=self.service_name, - headers={"Accept": "application/json"}, - params={"limit": 2, "marker": 2}) - - # Ensure we're done after those three items - self.assertRaises(StopIteration, next, results) - - # Ensure we only made two calls to get this done - self.assertEqual(2, len(self.session.get.call_args_list)) - - -class TestResourceFind(base.TestCase): - - def setUp(self): - super(TestResourceFind, self).setUp() - - self.result = 1 - - class Base(resource2.Resource): - - @classmethod - def existing(cls, **kwargs): - raise exceptions.NotFoundException - - @classmethod - def list(cls, session): - return None - - class OneResult(Base): - - @classmethod - def _get_one_match(cls, *args): - return self.result - - class NoResults(Base): - - @classmethod - def _get_one_match(cls, *args): - return None - - self.no_results = NoResults - self.one_result = OneResult - - def test_find_short_circuit(self): - value = 1 - - class Test(resource2.Resource): - - @classmethod - def existing(cls, **kwargs): - mock_match = mock.Mock() - mock_match.get.return_value = value - return mock_match - - result = Test.find("session", "name") - - self.assertEqual(result, value) - - def test_no_match_raise(self): - self.assertRaises(exceptions.ResourceNotFound, self.no_results.find, - "session", "name", ignore_missing=False) - - def test_no_match_return(self): - self.assertIsNone( - self.no_results.find("session", "name", ignore_missing=True)) - - def test_find_result(self): - self.assertEqual(self.result, self.one_result.find("session", "name")) - - def test_match_empty_results(self): - self.assertIsNone(resource2.Resource._get_one_match("name", [])) - - def test_no_match_by_name(self): - the_name = "Brian" - - match = mock.Mock(spec=resource2.Resource) - match.name = the_name - - result = resource2.Resource._get_one_match("Richard", [match]) - - self.assertIsNone(result, match) - - def test_single_match_by_name(self): - the_name = "Brian" - - match = mock.Mock(spec=resource2.Resource) - match.name = the_name - - result = resource2.Resource._get_one_match(the_name, [match]) - - self.assertIs(result, match) - - def test_single_match_by_id(self): - the_id = "Brian" - - match = mock.Mock(spec=resource2.Resource) - match.id = the_id - - result = resource2.Resource._get_one_match(the_id, [match]) - - self.assertIs(result, match) - - def test_single_match_by_alternate_id(self): - the_id = "Richard" - - class Test(resource2.Resource): - other_id = resource2.Body("other_id", alternate_id=True) - - match = Test(other_id=the_id) - result = Test._get_one_match(the_id, [match]) - - self.assertIs(result, match) - - def test_multiple_matches(self): - the_id = "Brian" - - match = mock.Mock(spec=resource2.Resource) - match.id = the_id - - self.assertRaises( - exceptions.DuplicateResource, - resource2.Resource._get_one_match, the_id, [match, match]) - - -class TestWaitForStatus(base.TestCase): - - def test_immediate_status(self): - status = "loling" - resource = mock.Mock() - resource.status = status - - result = resource2.wait_for_status("session", resource, status, - "failures", "interval", "wait") - - self.assertEqual(result, resource) - - @mock.patch("time.sleep", return_value=None) - def test_status_match(self, mock_sleep): - status = "loling" - resource = mock.Mock() - - # other gets past the first check, two anothers gets through - # the sleep loop, and the third matches - statuses = ["other", "another", "another", status] - type(resource).status = mock.PropertyMock(side_effect=statuses) - - result = resource2.wait_for_status("session", resource, status, - None, 1, 5) - - self.assertEqual(result, resource) - - @mock.patch("time.sleep", return_value=None) - def test_status_fails(self, mock_sleep): - status = "loling" - failure = "crying" - resource = mock.Mock() - - # other gets past the first check, the first failure doesn't - # match the expected, the third matches the failure, - # the fourth is used in creating the exception message - statuses = ["other", failure, failure, failure] - type(resource).status = mock.PropertyMock(side_effect=statuses) - - self.assertRaises(exceptions.ResourceFailure, - resource2.wait_for_status, - "session", resource, status, [failure], 1, 5) - - @mock.patch("time.sleep", return_value=None) - def test_timeout(self, mock_sleep): - status = "loling" - resource = mock.Mock() - - # The first "other" gets past the first check, and then three - # pairs of "other" statuses run through the sleep counter loop, - # after which time should be up. This is because we have a - # one second interval and three second waiting period. - statuses = ["other"] * 7 - type(resource).status = mock.PropertyMock(side_effect=statuses) - - self.assertRaises(exceptions.ResourceTimeout, - resource2.wait_for_status, - "session", resource, status, None, 1, 3) - - def test_no_sleep(self): - resource = mock.Mock() - statuses = ["other"] - type(resource).status = mock.PropertyMock(side_effect=statuses) - - self.assertRaises(exceptions.ResourceTimeout, - resource2.wait_for_status, - "session", resource, "status", None, 0, -1) - - -class TestWaitForDelete(base.TestCase): - - @mock.patch("time.sleep", return_value=None) - def test_success(self, mock_sleep): - resource = mock.Mock() - resource.get.side_effect = [None, None, exceptions.NotFoundException] - - result = resource2.wait_for_delete("session", resource, 1, 3) - - self.assertEqual(result, resource) - - @mock.patch("time.sleep", return_value=None) - def test_timeout(self, mock_sleep): - resource = mock.Mock() - resource.get.side_effect = [None, None, None] - - self.assertRaises(exceptions.ResourceTimeout, - resource2.wait_for_delete, - "session", resource, 1, 3) diff --git a/openstack/tests/unit/test_service_filter.py b/openstack/tests/unit/test_service_filter.py deleted file mode 100644 index 7d012991..00000000 --- a/openstack/tests/unit/test_service_filter.py +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.identity import identity_service -from openstack import service_filter - - -class TestValidVersion(testtools.TestCase): - def test_constructor(self): - sot = service_filter.ValidVersion('v1.0', 'v1') - self.assertEqual('v1.0', sot.module) - self.assertEqual('v1', sot.path) - - -class TestServiceFilter(testtools.TestCase): - def test_init(self): - sot = service_filter.ServiceFilter( - 'ServiceType', region='REGION1', service_name='ServiceName', - version='1', api_version='1.23', requires_project_id=True) - self.assertEqual('servicetype', sot.service_type) - self.assertEqual('REGION1', sot.region) - self.assertEqual('ServiceName', sot.service_name) - self.assertEqual('1', sot.version) - self.assertEqual('1.23', sot.api_version) - self.assertTrue(sot.requires_project_id) - - def test_get_module(self): - sot = identity_service.IdentityService() - self.assertEqual('openstack.identity.v3', sot.get_module()) - self.assertEqual('identity', sot.get_service_module()) diff --git a/openstack/tests/unit/test_session.py b/openstack/tests/unit/test_session.py deleted file mode 100644 index 82cdeeca..00000000 --- a/openstack/tests/unit/test_session.py +++ /dev/null @@ -1,437 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import testtools - -from keystoneauth1 import exceptions as _exceptions - -from openstack import exceptions -from openstack import profile -from openstack import session -from openstack import utils - -HTML_MSG = """ - - 404 Entity Not Found - - -

404 Entity Not Found

- Entity could not be found -

- -""" - - -class TestSession(testtools.TestCase): - - def test_init_user_agent_none(self): - sot = session.Session(None) - self.assertTrue(sot.user_agent.startswith("openstacksdk")) - - def test_init_user_agent_set(self): - sot = session.Session(None, user_agent="testing/123") - self.assertTrue(sot.user_agent.startswith("testing/123 openstacksdk")) - - def test_init_with_single_api_request(self): - prof = profile.Profile() - prof.set_api_version('clustering', '1.2') - - sot = session.Session(prof) - - # The assertion acutally tests the property assigned in parent class - self.assertEqual({'openstack-api-version': 'clustering 1.2'}, - sot.additional_headers) - - def test_init_with_multi_api_requests(self): - prof = profile.Profile() - prof.set_api_version('clustering', '1.2') - prof.set_api_version('compute', '2.15') - - sot = session.Session(prof) - - versions = sot.additional_headers['openstack-api-version'] - requests = [req.strip() for req in versions.split(',')] - self.assertIn('clustering 1.2', requests) - self.assertIn('compute 2.15', requests) - - def test_init_with_no_api_requests(self): - prof = profile.Profile() - - sot = session.Session(prof) - - self.assertEqual({}, sot.additional_headers) - - def _assert_map_exceptions(self, expected_exc, ksa_exc, func): - os_exc = self.assertRaises( - expected_exc, session.map_exceptions(func)) - self.assertIsInstance(os_exc, expected_exc) - self.assertEqual(ksa_exc.message, os_exc.message) - self.assertEqual(ksa_exc.http_status, os_exc.http_status) - self.assertEqual(ksa_exc, os_exc.cause) - return os_exc - - def test_map_exceptions_not_found_exception(self): - response = mock.Mock() - response_body = {'NotFoundException': { - 'message': 'Resource not found'}} - response.json = mock.Mock(return_value=response_body) - response.headers = {"content-type": "application/json"} - response.status_code = 404 - ksa_exc = _exceptions.HttpError( - message="test", http_status=404, response=response) - func = mock.Mock(side_effect=ksa_exc) - os_exc = self._assert_map_exceptions( - exceptions.NotFoundException, ksa_exc, func) - self.assertEqual('Resource not found', os_exc.details) - - def test_map_exceptions_http_exception(self): - response = mock.Mock() - response_body = {'HTTPBadRequest': { - 'message': 'request is invalid'}} - response.json = mock.Mock(return_value=response_body) - response.headers = {"content-type": "application/json"} - response.status_code = 400 - ksa_exc = _exceptions.HttpError( - message="test", http_status=400, response=response) - func = mock.Mock(side_effect=ksa_exc) - - os_exc = self._assert_map_exceptions( - exceptions.HttpException, ksa_exc, func) - self.assertEqual('request is invalid', os_exc.details) - - def test_map_exceptions_http_exception_handle_json(self): - mock_resp = mock.Mock() - mock_resp.status_code = 413 - mock_resp.json.return_value = { - "overLimit": { - "message": "OverLimit413...", - "retryAt": "2017-01-03T13:33:06Z" - }, - "overLimitRetry": { - "message": "OverLimit Retry...", - "retryAt": "2017-01-03T13:33:06Z" - } - } - mock_resp.headers = { - "content-type": "application/json" - } - ksa_exc = _exceptions.HttpError( - message="test", http_status=413, response=mock_resp) - func = mock.Mock(side_effect=ksa_exc) - - os_exc = self._assert_map_exceptions( - exceptions.HttpException, ksa_exc, func) - # It's not sure that which 'message' will be first so exact checking is - # difficult here. It can be 'OverLimit413...\nOverLimit Retry...' or - # it can be 'OverLimit Retry...\nOverLimit413...'. - self.assertIn('OverLimit413...', os_exc.details) - self.assertIn('OverLimit Retry...', os_exc.details) - - def test_map_exceptions_http_exception_handle_json_1(self): - # A test for json containing non-dict values - mock_resp = mock.Mock() - mock_resp.status_code = 404 - mock_resp.json.return_value = { - "code": 404, - "error": { - "message": "resource not found", - }, - } - mock_resp.headers = { - "content-type": "application/json" - } - ksa_exc = _exceptions.HttpError(message="test", http_status=404, - response=mock_resp) - func = mock.Mock(side_effect=ksa_exc) - - os_exc = self._assert_map_exceptions( - exceptions.HttpException, ksa_exc, func) - self.assertIn('not found', os_exc.details) - - def test_map_exceptions_notfound_exception_handle_html(self): - mock_resp = mock.Mock() - mock_resp.status_code = 404 - mock_resp.text = HTML_MSG - mock_resp.headers = { - "content-type": "text/html" - } - ksa_exc = _exceptions.HttpError( - message="test", http_status=404, response=mock_resp) - func = mock.Mock(side_effect=ksa_exc) - - os_exc = self._assert_map_exceptions( - exceptions.NotFoundException, ksa_exc, func) - self.assertEqual('404 Entity Not Found: Entity could not be found', - os_exc.details) - - def test_map_exceptions_notfound_exception_handle_other_content_type(self): - mock_resp = mock.Mock() - mock_resp.status_code = 404 - fake_text = ("{'UnknownException': {'message': " - "'UnknownException occurred...'}}") - mock_resp.text = fake_text - mock_resp.headers = { - "content-type": 'application/octet-stream' - } - ksa_exc = _exceptions.HttpError( - message="test", http_status=404, response=mock_resp) - func = mock.Mock(side_effect=ksa_exc) - - os_exc = self._assert_map_exceptions( - exceptions.NotFoundException, ksa_exc, func) - self.assertEqual(fake_text, os_exc.details) - - def test_map_exceptions_sdk_exception_1(self): - ksa_exc = _exceptions.ClientException() - func = mock.Mock(side_effect=ksa_exc) - - os_exc = self.assertRaises( - exceptions.SDKException, session.map_exceptions(func)) - self.assertIsInstance(os_exc, exceptions.SDKException) - self.assertEqual(ksa_exc, os_exc.cause) - - def test_map_exceptions_sdk_exception_2(self): - ksa_exc = _exceptions.VersionNotAvailable() - func = mock.Mock(side_effect=ksa_exc) - - os_exc = self.assertRaises( - exceptions.SDKException, session.map_exceptions(func)) - self.assertIsInstance(os_exc, exceptions.SDKException) - self.assertEqual(ksa_exc, os_exc.cause) - - def test__parse_versions_response_exception(self): - uri = "http://www.openstack.org" - level = "DEBUG" - sot = session.Session(None) - sot.get = mock.Mock(side_effect=exceptions.NotFoundException) - - with self.assertLogs(logger=session.__name__, level=level) as log: - self.assertIsNone(sot._parse_versions_response(uri)) - - self.assertEqual(len(log.output), 1, - "Too many warnings were logged") - self.assertEqual( - log.output[0], - "%s:%s:Looking for versions at %s" % (level, session.__name__, - uri)) - - def test__parse_versions_response_no_json(self): - sot = session.Session(None) - retval = mock.Mock() - retval.json = mock.Mock(side_effect=ValueError) - sot.get = mock.Mock(return_value=retval) - - self.assertIsNone(sot._parse_versions_response("test")) - - def test__parse_versions_response_no_versions(self): - sot = session.Session(None) - retval = mock.Mock() - retval.json = mock.Mock(return_value={"no_versions_here": "blarga"}) - sot.get = mock.Mock(return_value=retval) - - self.assertIsNone(sot._parse_versions_response("test")) - - def test__parse_versions_response_with_versions(self): - uri = "http://openstack.org" - versions = [1, 2, 3] - - sot = session.Session(None) - retval = mock.Mock() - retval.json = mock.Mock(return_value={"versions": versions}) - sot.get = mock.Mock(return_value=retval) - - expected = session.Session._Endpoint(uri, versions) - self.assertEqual(expected, sot._parse_versions_response(uri)) - - def test__parse_versions_response_with_nested_versions(self): - uri = "http://openstack.org" - versions = [1, 2, 3] - - sot = session.Session(None) - retval = mock.Mock() - retval.json = mock.Mock(return_value={"versions": - {"values": versions}}) - sot.get = mock.Mock(return_value=retval) - - expected = session.Session._Endpoint(uri, versions) - self.assertEqual(expected, sot._parse_versions_response(uri)) - - def test__get_endpoint_versions_at_subdomain(self): - # This test covers a common case of services deployed under - # subdomains. Additionally, it covers the case of a service - # deployed at the root, which will be the first request made - # for versions. - sc_uri = "https://service.cloud.com/v1/" - versions_uri = "https://service.cloud.com" - - sot = session.Session(None) - sot.get_project_id = mock.Mock(return_value="project_id") - - responses = [session.Session._Endpoint(versions_uri, "versions")] - sot._parse_versions_response = mock.Mock(side_effect=responses) - - result = sot._get_endpoint_versions("type", sc_uri) - - sot._parse_versions_response.assert_called_once_with(versions_uri) - self.assertEqual(result, responses[0]) - self.assertFalse(result.needs_project_id) - - def test__get_endpoint_versions_at_path(self): - # This test covers a common case of services deployed under - # a path. Additionally, it covers the case of a service - # deployed at a path deeper than the root, which will mean - # more than one request will need to be made. - sc_uri = "https://cloud.com/api/service/v2/project_id" - versions_uri = "https://cloud.com/api/service" - - sot = session.Session(None) - sot.get_project_id = mock.Mock(return_value="project_id") - - responses = [None, None, - session.Session._Endpoint(versions_uri, "versions")] - sot._parse_versions_response = mock.Mock(side_effect=responses) - - result = sot._get_endpoint_versions("type", sc_uri) - - sot._parse_versions_response.assert_has_calls( - [mock.call("https://cloud.com"), - mock.call("https://cloud.com/api"), - mock.call(versions_uri)]) - self.assertEqual(result, responses[2]) - self.assertTrue(result.needs_project_id) - - def test__get_endpoint_versions_at_port(self): - # This test covers a common case of services deployed under - # a port. - sc_uri = "https://cloud.com:1234/v3" - versions_uri = "https://cloud.com:1234" - - sot = session.Session(None) - sot.get_project_id = mock.Mock(return_value="project_id") - - responses = [session.Session._Endpoint(versions_uri, "versions")] - sot._parse_versions_response = mock.Mock(side_effect=responses) - - result = sot._get_endpoint_versions("type", sc_uri) - - sot._parse_versions_response.assert_called_once_with(versions_uri) - self.assertEqual(result, responses[0]) - self.assertFalse(result.needs_project_id) - - def test__get_endpoint_versions_with_domain_scope(self): - # This test covers a common case of services deployed under - # subdomains. Additionally, it covers the case of getting endpoint - # versions with domain scope token - sc_uri = "https://service.cloud.com/identity" - versions_uri = "https://service.cloud.com" - - sot = session.Session(None) - # Project id is None when domain scope session present - sot.get_project_id = mock.Mock(return_value=None) - - responses = [session.Session._Endpoint(versions_uri, "versions")] - sot._parse_versions_response = mock.Mock(side_effect=responses) - - result = sot._get_endpoint_versions("type", sc_uri) - - sot._parse_versions_response.assert_called_once_with(versions_uri) - self.assertEqual(result, responses[0]) - self.assertFalse(result.needs_project_id) - self.assertIsNone(result.project_id) - - def test__parse_version(self): - sot = session.Session(None) - - self.assertEqual(sot._parse_version("2"), (2, -1)) - self.assertEqual(sot._parse_version("v2"), (2, -1)) - self.assertEqual(sot._parse_version("v2.1"), (2, 1)) - self.assertRaises(ValueError, sot._parse_version, "lol") - - def test__get_version_match_none(self): - sot = session.Session(None) - - endpoint = session.Session._Endpoint("root", []) - self.assertRaises( - exceptions.EndpointNotFound, - sot._get_version_match, endpoint, None, "service") - - def test__get_version_match_fuzzy(self): - match = "http://devstack/v2.1" - root_endpoint = "http://devstack" - versions = [{"id": "v2.0", - "links": [{"href": "http://devstack/v2/", - "rel": "self"}]}, - {"id": "v2.1", - "links": [{"href": match, - "rel": "self"}]}] - - sot = session.Session(None) - - endpoint = session.Session._Endpoint(root_endpoint, versions) - # Look for a v2 match, which we internally denote as a minor - # version of -1 so we can find the highest matching minor. - rv = sot._get_version_match(endpoint, session.Version(2, -1), - "service") - self.assertEqual(rv, match) - - def test__get_version_match_exact(self): - match = "http://devstack/v2" - root_endpoint = "http://devstack" - versions = [{"id": "v2.0", - "links": [{"href": match, - "rel": "self"}]}, - {"id": "v2.1", - "links": [{"href": "http://devstack/v2.1/", - "rel": "self"}]}] - - sot = session.Session(None) - endpoint = session.Session._Endpoint(root_endpoint, versions) - rv = sot._get_version_match(endpoint, session.Version(2, 0), - "service") - self.assertEqual(rv, match) - - def test__get_version_match_fragment(self): - root = "http://cloud.net" - match = "/v2" - versions = [{"id": "v2.0", "links": [{"href": match, "rel": "self"}]}] - - sot = session.Session(None) - endpoint = session.Session._Endpoint(root, versions) - rv = sot._get_version_match(endpoint, session.Version(2, 0), "service") - self.assertEqual(rv, root + match) - - def test__get_version_match_project_id(self): - match = "http://devstack/v2" - root_endpoint = "http://devstack" - project_id = "asdf123" - versions = [{"id": "v2.0", "links": [{"href": match, "rel": "self"}]}] - - sot = session.Session(None) - sot.get_project_id = mock.Mock(return_value=project_id) - endpoint = session.Session._Endpoint(root_endpoint, versions, - project_id=project_id, - needs_project_id=True) - rv = sot._get_version_match(endpoint, session.Version(2, 0), - "service") - match_endpoint = utils.urljoin(match, project_id) - self.assertEqual(rv, match_endpoint) - - def test_get_endpoint_cached(self): - sot = session.Session(None) - service_type = "compute" - interface = "public" - endpoint = "the world wide web" - - sot.endpoint_cache[(service_type, interface)] = endpoint - rv = sot.get_endpoint(service_type=service_type, interface=interface) - self.assertEqual(rv, endpoint) diff --git a/openstack/tests/unit/test_utils.py b/openstack/tests/unit/test_utils.py deleted file mode 100644 index f0ea12d6..00000000 --- a/openstack/tests/unit/test_utils.py +++ /dev/null @@ -1,90 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import sys -import testtools - -from openstack import utils - - -class Test_enable_logging(testtools.TestCase): - - def _console_tests(self, fake_logging, level, debug, stream): - the_logger = mock.Mock() - fake_logging.getLogger.return_value = the_logger - - utils.enable_logging(debug=debug, stream=stream) - - self.assertEqual(the_logger.addHandler.call_count, 2) - the_logger.setLevel.assert_called_with(level) - - def _file_tests(self, fake_logging, level, debug): - the_logger = mock.Mock() - fake_logging.getLogger.return_value = the_logger - fake_path = "fake/path.log" - - utils.enable_logging(debug=debug, path=fake_path) - - fake_logging.FileHandler.assert_called_with(fake_path) - self.assertEqual(the_logger.addHandler.call_count, 2) - the_logger.setLevel.assert_called_with(level) - - def test_none(self): - self.assertRaises( - ValueError, utils.enable_logging, - debug=True, path=None, stream=None) - - @mock.patch("openstack.utils.logging") - def test_debug_console_stderr(self, fake_logging): - self._console_tests(fake_logging, - fake_logging.DEBUG, True, sys.stderr) - - @mock.patch("openstack.utils.logging") - def test_warning_console_stderr(self, fake_logging): - self._console_tests(fake_logging, - fake_logging.WARNING, False, sys.stderr) - - @mock.patch("openstack.utils.logging") - def test_debug_console_stdout(self, fake_logging): - self._console_tests(fake_logging, - fake_logging.DEBUG, True, sys.stdout) - - @mock.patch("openstack.utils.logging") - def test_warning_console_stdout(self, fake_logging): - self._console_tests(fake_logging, - fake_logging.WARNING, False, sys.stdout) - - @mock.patch("openstack.utils.logging") - def test_debug_file(self, fake_logging): - self._file_tests(fake_logging, fake_logging.DEBUG, True) - - @mock.patch("openstack.utils.logging") - def test_warning_file(self, fake_logging): - self._file_tests(fake_logging, fake_logging.WARNING, False) - - -class Test_urljoin(testtools.TestCase): - - def test_strings(self): - root = "http://www.example.com" - leaves = "foo", "bar" - - result = utils.urljoin(root, *leaves) - self.assertEqual(result, "http://www.example.com/foo/bar") - - def test_with_none(self): - root = "http://www.example.com" - leaves = "foo", None - - result = utils.urljoin(root, *leaves) - self.assertEqual(result, "http://www.example.com/foo/") diff --git a/openstack/tests/unit/workflow/__init__.py b/openstack/tests/unit/workflow/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/tests/unit/workflow/test_execution.py b/openstack/tests/unit/workflow/test_execution.py deleted file mode 100644 index bb8a4c00..00000000 --- a/openstack/tests/unit/workflow/test_execution.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.workflow.v2 import execution - -FAKE_INPUT = { - 'cluster_id': '8c74607c-5a74-4490-9414-a3475b1926c2', - 'node_id': 'fba2cc5d-706f-4631-9577-3956048d13a2', - 'flavor_id': '1' -} - -FAKE = { - 'id': 'ffaed25e-46f5-4089-8e20-b3b4722fd597', - 'workflow_name': 'cluster-coldmigration', - 'input': FAKE_INPUT, -} - - -class TestExecution(testtools.TestCase): - - def setUp(self): - super(TestExecution, self).setUp() - - def test_basic(self): - sot = execution.Execution() - self.assertEqual('execution', sot.resource_key) - self.assertEqual('executions', sot.resources_key) - self.assertEqual('/executions', sot.base_path) - self.assertEqual('workflowv2', sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_delete) - - def test_instantiate(self): - sot = execution.Execution(**FAKE) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['workflow_name'], sot.workflow_name) - self.assertEqual(FAKE['input'], sot.input) diff --git a/openstack/tests/unit/workflow/test_proxy.py b/openstack/tests/unit/workflow/test_proxy.py deleted file mode 100644 index 3f01420c..00000000 --- a/openstack/tests/unit/workflow/test_proxy.py +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack.tests.unit import test_proxy_base2 -from openstack.workflow.v2 import _proxy -from openstack.workflow.v2 import execution -from openstack.workflow.v2 import workflow - - -class TestWorkflowProxy(test_proxy_base2.TestProxyBase): - def setUp(self): - super(TestWorkflowProxy, self).setUp() - self.proxy = _proxy.Proxy(self.session) - - def test_workflows(self): - self.verify_list(self.proxy.workflows, - workflow.Workflow, - paginated=True) - - def test_executions(self): - self.verify_list(self.proxy.executions, - execution.Execution, - paginated=True) - - def test_workflow_get(self): - self.verify_get(self.proxy.get_workflow, - workflow.Workflow) - - def test_execution_get(self): - self.verify_get(self.proxy.get_execution, - execution.Execution) - - def test_workflow_create(self): - self.verify_create(self.proxy.create_workflow, - workflow.Workflow) - - def test_execution_create(self): - self.verify_create(self.proxy.create_execution, - execution.Execution) - - def test_workflow_delete(self): - self.verify_delete(self.proxy.delete_workflow, - workflow.Workflow, True) - - def test_execution_delete(self): - self.verify_delete(self.proxy.delete_execution, - execution.Execution, True) - - def test_workflow_find(self): - self.verify_find(self.proxy.find_workflow, - workflow.Workflow) - - def test_execution_find(self): - self.verify_find(self.proxy.find_execution, - execution.Execution) diff --git a/openstack/tests/unit/workflow/test_version.py b/openstack/tests/unit/workflow/test_version.py deleted file mode 100644 index 1aca9a8f..00000000 --- a/openstack/tests/unit/workflow/test_version.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.workflow import version - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'id': IDENTIFIER, - 'links': '2', - 'status': '3', -} - - -class TestVersion(testtools.TestCase): - - def test_basic(self): - sot = version.Version() - self.assertEqual('version', sot.resource_key) - self.assertEqual('versions', sot.resources_key) - self.assertEqual('/', sot.base_path) - self.assertEqual('workflowv2', sot.service.service_type) - self.assertFalse(sot.allow_create) - self.assertFalse(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertFalse(sot.allow_delete) - self.assertTrue(sot.allow_list) - - def test_make_it(self): - sot = version.Version(**EXAMPLE) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['links'], sot.links) - self.assertEqual(EXAMPLE['status'], sot.status) diff --git a/openstack/tests/unit/workflow/test_workflow.py b/openstack/tests/unit/workflow/test_workflow.py deleted file mode 100644 index c5b2e22a..00000000 --- a/openstack/tests/unit/workflow/test_workflow.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.workflow.v2 import workflow - - -FAKE = { - 'scope': 'private', - 'id': 'ffaed25e-46f5-4089-8e20-b3b4722fd597', - 'definition': 'workflow_def', -} - - -class TestWorkflow(testtools.TestCase): - - def setUp(self): - super(TestWorkflow, self).setUp() - - def test_basic(self): - sot = workflow.Workflow() - self.assertEqual('workflow', sot.resource_key) - self.assertEqual('workflows', sot.resources_key) - self.assertEqual('/workflows', sot.base_path) - self.assertEqual('workflowv2', sot.service.service_type) - self.assertTrue(sot.allow_get) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_delete) - - def test_instantiate(self): - sot = workflow.Workflow(**FAKE) - self.assertEqual(FAKE['id'], sot.id) - self.assertEqual(FAKE['scope'], sot.scope) - self.assertEqual(FAKE['definition'], sot.definition) diff --git a/openstack/tests/unit/workflow/test_workflow_service.py b/openstack/tests/unit/workflow/test_workflow_service.py deleted file mode 100644 index cc5dd9b0..00000000 --- a/openstack/tests/unit/workflow/test_workflow_service.py +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from openstack.workflow import workflow_service - - -class TestWorkflowService(testtools.TestCase): - - def test_service(self): - sot = workflow_service.WorkflowService() - self.assertEqual('workflowv2', sot.service_type) - self.assertEqual('public', sot.interface) - self.assertIsNone(sot.region) - self.assertIsNone(sot.service_name) - self.assertEqual(1, len(sot.valid_versions)) - self.assertEqual('v2', sot.valid_versions[0].module) - self.assertEqual('v2', sot.valid_versions[0].path) diff --git a/openstack/utils.py b/openstack/utils.py deleted file mode 100644 index 1864ecc5..00000000 --- a/openstack/utils.py +++ /dev/null @@ -1,98 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import functools -import logging - -import deprecation - -from openstack import version - - -def deprecated(deprecated_in=None, removed_in=None, - details=""): - """Mark a method as deprecated - - :param deprecated_in: The version string where this method is deprecated. - Generally this is the next version to be released. - :param removed_in: The version where this method will be removed - from the code base. Generally this is the next - major version. This argument is helpful for the - tests when using ``deprecation.fail_if_not_removed``. - :param str details: Helpful details to callers and the documentation. - This will usually be a recommendation for alternate - code to use. - """ - # As all deprecations within this library have the same current_version, - # return a partial function with the library version always set. - partial = functools.partial(deprecation.deprecated, - current_version=version.__version__) - - return partial(deprecated_in=deprecated_in, removed_in=removed_in, - details=details) - - -def enable_logging(debug=False, path=None, stream=None): - """Enable logging to a file at path and/or a console stream. - - This function is available for debugging purposes. If you wish to - log this package's message in your application, the standard library - ``logging`` package will receive these messages in any handlers you - create. - - :param bool debug: Set this to ``True`` to receive debug messages, - which includes HTTP requests and responses, - or ``False`` for warning messages. - :param str path: If a *path* is specified, logging output will - written to that file in addition to sys.stderr. - The path is passed to logging.FileHandler, - which will append messages the file (and create - it if needed). - :param stream: One of ``None `` or ``sys.stdout`` or ``sys.stderr``. - If it is ``None``, nothing is logged to a stream. - If it isn't ``None``, console output is logged - to this stream. - - :rtype: None - """ - if path is None and stream is None: - raise ValueError("path and/or stream must be set") - - logger = logging.getLogger('openstack') - ksalog = logging.getLogger('keystoneauth') - formatter = logging.Formatter( - '%(asctime)s %(levelname)s: %(name)s %(message)s') - - if stream is not None: - console = logging.StreamHandler(stream) - console.setFormatter(formatter) - logger.addHandler(console) - ksalog.addHandler(console) - - if path is not None: - file_handler = logging.FileHandler(path) - file_handler.setFormatter(formatter) - logger.addHandler(file_handler) - ksalog.addHandler(file_handler) - - logger.setLevel(logging.DEBUG if debug else logging.WARNING) - ksalog.setLevel(logging.DEBUG if debug else logging.WARNING) - - -def urljoin(*args): - """A custom version of urljoin that simply joins strings into a path. - - The real urljoin takes into account web semantics like when joining a url - like /path this should be joined to http://host/path as it is an anchored - link. We generally won't care about that in client. - """ - return '/'.join(str(a or '').strip('/') for a in args) diff --git a/openstack/version.py b/openstack/version.py deleted file mode 100644 index 7b1c884a..00000000 --- a/openstack/version.py +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -import pbr.version - -__version__ = pbr.version.VersionInfo('openstacksdk').version_string() diff --git a/openstack/workflow/__init__.py b/openstack/workflow/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/workflow/v2/__init__.py b/openstack/workflow/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openstack/workflow/v2/_proxy.py b/openstack/workflow/v2/_proxy.py deleted file mode 100644 index 8a99531e..00000000 --- a/openstack/workflow/v2/_proxy.py +++ /dev/null @@ -1,168 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import proxy2 -from openstack.workflow.v2 import execution as _execution -from openstack.workflow.v2 import workflow as _workflow - - -class Proxy(proxy2.BaseProxy): - - def create_workflow(self, **attrs): - """Create a new workflow from attributes - - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.workflow.v2.workflow.Workflow`, - comprised of the properties on the Workflow class. - - :returns: The results of workflow creation - :rtype: :class:`~openstack.workflow.v2.workflow.Workflow` - """ - return self._create(_workflow.Workflow, **attrs) - - def get_workflow(self, *attrs): - """Get a workflow - - :param workflow: The value can be the name of a workflow or - :class:`~openstack.workflow.v2.workflow.Workflow` instance. - - :returns: One :class:`~openstack.workflow.v2.workflow.Workflow` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - workflow matching the name could be found. - """ - return self._get(_workflow.Workflow, *attrs) - - def workflows(self, **query): - """Retrieve a generator of workflows - - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the workflows to be returned. Available parameters - include: - - * limit: Requests at most the specified number of items be - returned from the query. - * marker: Specifies the ID of the last-seen workflow. Use the - limit parameter to make an initial limited request and use - the ID of the last-seen workflow from the response as the - marker parameter value in a subsequent limited request. - - :returns: A generator of workflow instances. - """ - return self._list(_workflow.Workflow, paginated=True, **query) - - def delete_workflow(self, value, ignore_missing=True): - """Delete a workflow - - :param value: The value can be either the name of a workflow or a - :class:`~openstack.workflow.v2.workflow.Workflow` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will - be raised when the workflow does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent workflow. - - :returns: ``None`` - """ - return self._delete(_workflow.Workflow, value, - ignore_missing=ignore_missing) - - def find_workflow(self, name_or_id, ignore_missing=True): - """Find a single workflow - - :param name_or_id: The name or ID of an workflow. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.compute.v2.workflow.Extension` or - None - """ - return self._find(_workflow.Workflow, name_or_id, - ignore_missing=ignore_missing) - - def create_execution(self, **attrs): - """Create a new execution from attributes - - :param workflow_name: The name of target workflow to execute. - :param dict attrs: Keyword arguments which will be used to create - a :class:`~openstack.workflow.v2.execution.Execution`, - comprised of the properties on the Execution class. - - :returns: The results of execution creation - :rtype: :class:`~openstack.workflow.v2.execution.Execution` - """ - return self._create(_execution.Execution, **attrs) - - def get_execution(self, *attrs): - """Get a execution - - :param workflow_name: The name of target workflow to execute. - :param execution: The value can be either the ID of a execution or a - :class:`~openstack.workflow.v2.execution.Execution` instance. - - :returns: One :class:`~openstack.workflow.v2.execution.Execution` - :raises: :class:`~openstack.exceptions.ResourceNotFound` when no - execution matching the criteria could be found. - """ - return self._get(_execution.Execution, *attrs) - - def executions(self, **query): - """Retrieve a generator of executions - - :param kwargs \*\*query: Optional query parameters to be sent to - restrict the executions to be returned. Available parameters - include: - - * limit: Requests at most the specified number of items be - returned from the query. - * marker: Specifies the ID of the last-seen execution. Use the - limit parameter to make an initial limited request and use - the ID of the last-seen execution from the response as the - marker parameter value in a subsequent limited request. - - :returns: A generator of execution instances. - """ - return self._list(_execution.Execution, paginated=True, **query) - - def delete_execution(self, value, ignore_missing=True): - """Delete an execution - - :param value: The value can be either the name of a execution or a - :class:`~openstack.workflow.v2.execute.Execution` - instance. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the execution does not exist. - When set to ``True``, no exception will be set when - attempting to delete a nonexistent execution. - - :returns: ``None`` - """ - return self._delete(_execution.Execution, value, - ignore_missing=ignore_missing) - - def find_execution(self, name_or_id, ignore_missing=True): - """Find a single execution - - :param name_or_id: The name or ID of an execution. - :param bool ignore_missing: When set to ``False`` - :class:`~openstack.exceptions.ResourceNotFound` will be - raised when the resource does not exist. - When set to ``True``, None will be returned when - attempting to find a nonexistent resource. - :returns: One :class:`~openstack.compute.v2.execution.Execution` or - None - """ - return self._find(_execution.Execution, name_or_id, - ignore_missing=ignore_missing) diff --git a/openstack/workflow/v2/execution.py b/openstack/workflow/v2/execution.py deleted file mode 100644 index d54160f1..00000000 --- a/openstack/workflow/v2/execution.py +++ /dev/null @@ -1,66 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import resource2 as resource -from openstack.workflow import workflow_service - - -class Execution(resource.Resource): - resource_key = 'execution' - resources_key = 'executions' - base_path = '/executions' - service = workflow_service.WorkflowService() - - # capabilities - allow_create = True - allow_list = True - allow_get = True - allow_delete = True - - _query_mapping = resource.QueryParameters( - 'marker', 'limit', 'sort_keys', 'sort_dirs', 'fields', 'params', - 'include_output') - - #: The name of the workflow - workflow_name = resource.Body("workflow_name") - #: The ID of the workflow - workflow_id = resource.Body("workflow_id") - #: A description of the workflow execution - description = resource.Body("description") - #: A reference to the parent task execution - task_execution_id = resource.Body("task_execution_id") - #: Status can be one of: IDLE, RUNNING, SUCCESS, ERROR, or PAUSED - status = resource.Body("state") - #: An optional information string about the status - status_info = resource.Body("state_info") - #: A JSON structure containing workflow input values - # TODO(briancurtin): type=dict - input = resource.Body("input") - #: The output of the workflow - output = resource.Body("output") - #: The time at which the Execution was created - created_at = resource.Body("created_at") - #: The time at which the Execution was updated - updated_at = resource.Body("updated_at") - - def create(self, session, prepend_key=True): - request = self._prepare_request(requires_id=False, - prepend_key=prepend_key) - - request_body = request.body["execution"] - response = session.post(request.uri, - endpoint_filter=self.service, - json=request_body, - headers=request.headers) - - self._translate_response(response, has_body=True) - return self diff --git a/openstack/workflow/v2/workflow.py b/openstack/workflow/v2/workflow.py deleted file mode 100644 index 6624c87b..00000000 --- a/openstack/workflow/v2/workflow.py +++ /dev/null @@ -1,72 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import resource2 as resource -from openstack.workflow import workflow_service - - -class Workflow(resource.Resource): - resource_key = 'workflow' - resources_key = 'workflows' - base_path = '/workflows' - service = workflow_service.WorkflowService() - - # capabilities - allow_create = True - allow_list = True - allow_get = True - allow_delete = True - - _query_mapping = resource.QueryParameters( - 'marker', 'limit', 'sort_keys', 'sort_dirs', 'fields') - - #: The name of this Workflow - name = resource.Body("name") - #: The inputs for this Workflow - input = resource.Body("input") - #: A Workflow definition using the Mistral v2 DSL - definition = resource.Body("definition") - #: A list of values associated with a workflow that users can use - #: to group workflows by some criteria - # TODO(briancurtin): type=list - tags = resource.Body("tags") - #: Can be either "private" or "public" - scope = resource.Body("scope") - #: The ID of the associated project - project_id = resource.Body("project_id") - #: The time at which the workflow was created - created_at = resource.Body("created_at") - #: The time at which the workflow was created - updated_at = resource.Body("updated_at") - - def create(self, session, prepend_key=True): - request = self._prepare_request(requires_id=False, - prepend_key=prepend_key) - - headers = { - "Content-Type": 'text/plain' - } - kwargs = { - "data": self.definition, - } - - scope = "?scope=%s" % self.scope - uri = request.uri + scope - - request.headers.update(headers) - response = session.post(uri, - endpoint_filter=self.service, - json=None, - headers=request.headers, **kwargs) - - self._translate_response(response, has_body=False) - return self diff --git a/openstack/workflow/version.py b/openstack/workflow/version.py deleted file mode 100644 index 4834e952..00000000 --- a/openstack/workflow/version.py +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from openstack import resource2 as resource -from openstack.workflow import workflow_service - - -class Version(resource.Resource): - resource_key = 'version' - resources_key = 'versions' - base_path = '/' - service = workflow_service.WorkflowService( - version=workflow_service.WorkflowService.UNVERSIONED - ) - - # capabilities - allow_list = True - - # Properties - links = resource.Body('links') - status = resource.Body('status') diff --git a/openstack/workflow/workflow_service.py b/openstack/workflow/workflow_service.py deleted file mode 100644 index 8adc89a6..00000000 --- a/openstack/workflow/workflow_service.py +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from openstack import service_filter - - -class WorkflowService(service_filter.ServiceFilter): - """The workflow service.""" - - valid_versions = [service_filter.ValidVersion('v2')] - - def __init__(self, version=None): - """Create a workflow service.""" - super(WorkflowService, self).__init__( - service_type='workflowv2', - version=version - ) diff --git a/post_test_hook.sh b/post_test_hook.sh deleted file mode 100755 index 567dd1f7..00000000 --- a/post_test_hook.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# This is a script that kicks off a series of functional tests against a -# OpenStack devstack cloud. This script is intended to work as a gate -# in project-config for the Python SDK. - -DIR=$(cd $(dirname "$0") && pwd) - -echo "Running SDK functional test suite" -sudo -H -u stack -i <=2.0.0 # Apache-2.0 -jsonpatch>=1.1 # BSD -six>=1.9.0 # MIT -stevedore>=1.20.0 # Apache-2.0 -os-client-config>=1.28.0 # Apache-2.0 -keystoneauth1!=3.0.0,>=2.21.0 # Apache-2.0 -deprecation>=1.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d006218f..00000000 --- a/setup.cfg +++ /dev/null @@ -1,50 +0,0 @@ -[metadata] -name = openstacksdk -summary = An SDK for building applications to work with OpenStack -description-file = - README.rst -author = OpenStack -author-email = openstack-dev@lists.openstack.org -home-page = http://developer.openstack.org/sdks/python/openstacksdk/ -classifier = - Environment :: OpenStack - Intended Audience :: Information Technology - Intended Audience :: System Administrators - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.3 - Programming Language :: Python :: 3.5 - -[files] -packages = - openstack - -[build_sphinx] -source-dir = doc/source -build-dir = doc/build -all_files = 1 -warning-is-error = 1 - -[upload_sphinx] -upload-dir = doc/build/html - -[compile_catalog] -directory = openstack/locale -domain = python-openstacksdk - -[update_catalog] -domain = python-openstacksdk -output_dir = openstack/locale -input_file = openstack/locale/python-openstacksdk.pot - -[extract_messages] -keywords = _ gettext ngettext l_ lazy_gettext -mapping_file = babel.cfg -output_file = openstack/locale/python-openstacksdk.pot - -[wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 566d8443..00000000 --- a/setup.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT -import setuptools - -# In python < 2.7.4, a lazy loading of package `pbr` will break -# setuptools if some other modules registered functions in `atexit`. -# solution from: http://bugs.python.org/issue15881#msg170215 -try: - import multiprocessing # noqa -except ImportError: - pass - -setuptools.setup( - setup_requires=['pbr>=2.0.0'], - pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 318d0b14..00000000 --- a/test-requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 - -beautifulsoup4>=4.6.0 # MIT -coverage!=4.4,>=4.0 # Apache-2.0 -fixtures>=3.0.0 # Apache-2.0/BSD -mock>=2.0 # BSD -python-subunit>=0.0.18 # Apache-2.0/BSD -openstackdocstheme>=1.11.0 # Apache-2.0 -os-testr>=0.8.0 # Apache-2.0 -requests>=2.14.2 # Apache-2.0 -requests-mock>=1.1 # Apache-2.0 -sphinx>=1.6.2 # BSD -testrepository>=0.0.18 # Apache-2.0/BSD -testscenarios>=0.4 # Apache-2.0/BSD -testtools>=1.4.0 # MIT diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 789758b4..00000000 --- a/tox.ini +++ /dev/null @@ -1,49 +0,0 @@ -[tox] -minversion = 1.6 -envlist = py35,py27,pypy,pep8 -skipsdist = True - -[testenv] -usedevelop = True -install_command = pip install -U {opts} {packages} -setenv = - VIRTUAL_ENV={envdir} -deps = -r{toxinidir}/test-requirements.txt -commands = ostestr {posargs} - -[testenv:examples] -setenv = OS_TEST_PATH=./openstack/tests/examples -passenv = OS_* - -[functionalbase] -setenv = OS_TEST_PATH=./openstack/tests/functional -passenv = OS_* - -[testenv:functional] -basepython = python2.7 -setenv = {[functionalbase]setenv} -passenv = {[functionalbase]passenv} - -[testenv:functional3] -basepython = python3.4 -setenv = {[functionalbase]setenv} -passenv = {[functionalbase]passenv} - -[testenv:pep8] -commands = flake8 - -[testenv:venv] -commands = {posargs} - -; If this fails for you, you may be running an old version of tox. -; Run 'pip install tox' to install a newer version of tox. -[testenv:cover] -commands = python setup.py test --coverage --coverage-package-name=openstack --testr-args='{posargs}' - -[testenv:docs] -commands = python setup.py build_sphinx - -[flake8] -ignore=D100,D101,D102,D103,D104,D105,D200,D202,D204,D205,D211,D301,D400,D401 -show-source = True -exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build