aodhclient-1.1.1/0000775000175000017500000000000013327644151013654 5ustar zuulzuul00000000000000aodhclient-1.1.1/.coveragerc0000666000175000017500000000010713327643673016005 0ustar zuulzuul00000000000000[run] branch = True source = aodhclient [report] ignore_errors = True aodhclient-1.1.1/CONTRIBUTING.rst0000666000175000017500000000122513327643673016327 0ustar zuulzuul00000000000000If 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 If you already have a good understanding of how the system works and your OpenStack accounts are set up, you can skip to the development workflow section of this documentation to learn how changes to OpenStack should be submitted for review via the Gerrit tool: 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-aodhclient aodhclient-1.1.1/.testr.conf0000666000175000017500000000054113327643673015754 0ustar zuulzuul00000000000000[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:-./aodhclient/tests} $LISTOPT $IDOPTION test_id_option=--load-list $IDFILE test_list_option=--list aodhclient-1.1.1/AUTHORS0000664000175000017500000000276513327644151014736 0ustar zuulzuul00000000000000Andreas Jaeger Cao Xuan Hoang Chaozhe.Chen Doug Hellmann Eyal Hanxi Liu Jon Schlueter Julien Danjou KATO Tomoyuki Kevin_Zheng Matthias Bastian Mehdi ABAAKOUK Mehdi Abaakouk Mehdi Abaakouk Monty Taylor Nguyen Hai OpenStack Release Bot PanFengyun Pradeep Kilambi Rui Yuan Dou Stéphane Albert Swapnil Kulkarni (coolsvap) Thomas Bechtold Tony Breeds Tovin Seven Zhao Lei ZhiQiang Fan Zi Lian Ji Zuul gord chung gordon chung houweichao lipan liusheng liyuanzhen rajat29 venkatamahesh xialinjuan xiaozhuangqing zhangguoqing zhangyangyang aodhclient-1.1.1/LICENSE0000666000175000017500000002363713327643673014706 0ustar zuulzuul00000000000000 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. aodhclient-1.1.1/tox.ini0000666000175000017500000000303113327643673015176 0ustar zuulzuul00000000000000[tox] minversion = 1.6 envlist = py35,py27,pypy,pep8 skipsdist = True [testenv] usedevelop = True setenv = VIRTUAL_ENV={envdir} AODH_CLIENT_EXEC_DIR={envdir}/bin AODH_ENDPOINT=http://localhost:8042 GNOCCHI_ENDPOINT=http://localhost:8041 passenv = GNOCCHI_* AODH_* OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE # NOTE(tonyb): This project has chosen to *NOT* consume upper-constraints.txt # NOTE(jd): the -e is on its own line so it is passed a separate argument to pip deps = .[test] http://tarballs.openstack.org/aodh/aodh-master.tar.gz#egg=aodh[mysql] commands = pifpaf run aodh -- python setup.py test --slowest --testr-args='{posargs}' [testenv:pep8] basepython = python3 deps = hacking<0.13,>=0.12 commands = flake8 [testenv:venv] basepython = python3 # Used by openstack-infra to build the doc deps = -r{toxinidir}/doc/requirements.txt commands = {posargs} [testenv:cover] basepython = python3 commands = python setup.py test --coverage --testr-args='{posargs}' coverage report [testenv:releasenotes] basepython = python3 commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html [testenv:docs] basepython = python3 deps = -r{toxinidir}/doc/requirements.txt commands = rm -rf doc/build sphinx-build -W -b html doc/source doc/build/html whitelist_externals = rm [testenv:debug] basepython = python3 commands = pifpaf --debug run aodh -- oslo_debug_helper {posargs} [flake8] show-source = True exclude=.venv,.git,.tox,dist,doc,*egg,build aodhclient-1.1.1/doc/0000775000175000017500000000000013327644151014421 5ustar zuulzuul00000000000000aodhclient-1.1.1/doc/requirements.txt0000666000175000017500000000007413327643673017720 0ustar zuulzuul00000000000000sphinx>=1.6.2 # BSD openstackdocstheme>=1.11.0 # Apache-2.0 aodhclient-1.1.1/doc/source/0000775000175000017500000000000013327644151015721 5ustar zuulzuul00000000000000aodhclient-1.1.1/doc/source/installation.rst0000666000175000017500000000013413327643673021164 0ustar zuulzuul00000000000000============ Installation ============ At the command line:: $ pip install aodhclient aodhclient-1.1.1/doc/source/conf.py0000666000175000017500000001024513327643673017234 0ustar zuulzuul00000000000000# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys BASE_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", "..")) sys.path.insert(0, ROOT) sys.path.insert(0, BASE_DIR) def gen_ref(ver, title, names): refdir = os.path.join(BASE_DIR, "ref") pkg = "aodhclient" if ver: pkg = "%s.%s" % (pkg, ver) refdir = os.path.join(refdir, ver) if not os.path.exists(refdir): os.makedirs(refdir) idxpath = os.path.join(refdir, "index.rst") with open(idxpath, "w") as idx: idx.write(("%(title)s\n" "%(signs)s\n" "\n" ".. toctree::\n" " :maxdepth: 1\n" "\n") % {"title": title, "signs": "=" * len(title)}) for name in names: idx.write(" %s\n" % name) rstpath = os.path.join(refdir, "%s.rst" % name) with open(rstpath, "w") as rst: rst.write(("%(title)s\n" "%(signs)s\n" "\n" ".. automodule:: %(pkg)s.%(name)s\n" " :members:\n" " :undoc-members:\n" " :show-inheritance:\n" " :noindex:\n") % {"title": " ".join([n.capitalize() for n in name.split("_")]), "signs": "=" * len(name), "pkg": pkg, "name": name}) gen_ref("v2", "Version 2 API", ["client"]) # -- General configuration ---------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'openstackdocstheme', #'sphinx.ext.intersphinx', ] # autodoc generation is a bit aggressive and a nuisance when doing heavy # text edit cycles. # execute "export SPHINX_DEBUG=1" in your terminal to disable # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # openstackdocstheme options repository_name = 'openstack/python-aodhclient' bug_project = 'python-aodhclient' bug_tag = '' project = u'aodhclient' copyright = u'2015, OpenStack Foundation' # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). add_module_names = True # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # -- Options for HTML output -------------------------------------------------- # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. # html_theme_path = ["."] # html_theme = '_theme' # html_static_path = ['static'] html_theme = 'openstackdocs' html_last_updated_fmt = '%Y-%m-%d %H:%M' # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = ['_theme'] # 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 = {'http://docs.python.org/': None} aodhclient-1.1.1/doc/source/api.rst0000666000175000017500000000064613327643673017244 0ustar zuulzuul00000000000000The :mod:`aodhclient` Python API ================================ .. module:: aodhclient :synopsis: A client for the Aodh API. .. currentmodule:: aodhclient Usage ----- To use aodhclient in a project:: >>> from aodhclient.v2 import client >>> aodh = client.Client(...) >>> aodh.alarm.list() Reference --------- For more information, see the reference: .. toctree:: :maxdepth: 2 ref/v2/index aodhclient-1.1.1/doc/source/index.rst0000666000175000017500000000221013327643673017567 0ustar zuulzuul00000000000000.. aodhclient documentation master file, created by sphinx-quickstart on Tue Jul 9 22:26:36 2013. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Python bindings to the Aodh API =============================== This is a client for Aodh API. There's :doc:`a Python API ` (the :mod:`aodhclient` module), and a :doc:`command-line script ` (installed as :program:`aodh`). Each implements the entire Aodh API. .. warning:: This is a new client to interact with Aodh API. There may be differences in functionality, syntax, and command line output when compared with the alarm functionality provided by ceilometerclient. .. seealso:: You may want to read the `Aodh Developer Guide`__ -- the overview, at least -- to get an idea of the concepts. By understanding the concepts this library should make more sense. __ https://docs.openstack.org/aodh/latest/ Contents -------- .. toctree:: :maxdepth: 2 installation shell api contributing Indices and tables ------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search` aodhclient-1.1.1/doc/source/contributing.rst0000666000175000017500000000011313327643673021167 0ustar zuulzuul00000000000000============ Contributing ============ .. include:: ../../CONTRIBUTING.rst aodhclient-1.1.1/doc/source/shell.rst0000666000175000017500000000477013327643673017604 0ustar zuulzuul00000000000000The :program:`aodh` shell utility ========================================= .. program:: aodh .. highlight:: bash The :program:`aodh` shell utility interacts with Aodh API from the command line. It supports the entirety of the Aodh API. You'll need to provide :program:`aodh` with your OpenStack credentials. You can do this with the ``--os-username``, ``--os-password``, ``--os-tenant-id`` and ``--os-auth-url`` options, but it's easier to just set them as environment variables: .. envvar:: OS_USERNAME Your OpenStack username. .. envvar:: OS_PASSWORD Your password. .. envvar:: OS_TENANT_NAME Project to work on. .. envvar:: OS_AUTH_URL The OpenStack auth server URL (keystone). For example, in Bash you would use:: export OS_USERNAME=user export OS_PASSWORD=pass export OS_TENANT_NAME=myproject export OS_AUTH_URL=http://auth.example.com:5000/v2.0 The command line tool will attempt to reauthenticate using your provided credentials for every request. You can override this behavior by manually supplying an auth token using ``--aodh-endpoint`` and ``--os-auth-token``. You can alternatively set these environment variables:: export AODH_ENDPOINT=http://aodh.example.org:8041 export OS_AUTH_PLUGIN=token export OS_AUTH_TOKEN=3bcc3d3a03f44e3d8377f9247b0ad155 Also, if the server doesn't support authentication, you can provide ``--os-auth-plugin`` aodh-noauth, ``--aodh-endpoint``, ``--user-id`` and ``--project-id``. You can alternatively set these environment variables:: export OS_AUTH_PLUGIN=aodh-noauth export AODH_ENDPOINT=http://aodh.example.org:8041 export AODH_USER_ID=99aae-4dc2-4fbc-b5b8-9688c470d9cc export AODH_PROJECT_ID=c8d27445-48af-457c-8e0d-1de7103eae1f From there, all shell commands take the form:: aodh [arguments...] Run :program:`aodh help` to get a full list of all possible commands, and run :program:`aodh help ` to get detailed help for that command. Examples -------- Create an alarm:: aodh alarm create -t gnocchi_resources_threshold --name alarm1 \ --metric cpu_util --threshold 5 --resource_id \ --resource_type generic --aggregation_method mean --project-id List alarms:: aodh alarm list List alarm with query parameters:: aodh alarm list --query "state=alarm and type=gnocchi_resources_threshold" Show an alarm's history:: aodh alarm-history show Search alarm history data:: aodh alarm-history search --query 'timestamp>"2016-03-09T01:22:35"' aodhclient-1.1.1/aodhclient.egg-info/0000775000175000017500000000000013327644151017460 5ustar zuulzuul00000000000000aodhclient-1.1.1/aodhclient.egg-info/pbr.json0000664000175000017500000000005613327644151021137 0ustar zuulzuul00000000000000{"git_version": "a5462e6", "is_release": true}aodhclient-1.1.1/aodhclient.egg-info/requires.txt0000664000175000017500000000045713327644151022066 0ustar zuulzuul00000000000000pbr>=1.4 cliff!=1.16.0,>=1.14.0 osc-lib>=1.0.1 oslo.i18n>=1.5.0 oslo.serialization>=1.4.0 oslo.utils>=2.0.0 keystoneauth1>=1.0.0 six pyparsing [test] coverage>=3.6 oslotest>=1.10.0 reno>=1.6.2 tempest>=10 testrepository>=0.0.18 testtools>=1.4.0 pifpaf[gnocchi]>=0.23 gnocchi[file,postgresql] mock>=1.2 aodhclient-1.1.1/aodhclient.egg-info/top_level.txt0000664000175000017500000000001313327644151022204 0ustar zuulzuul00000000000000aodhclient aodhclient-1.1.1/aodhclient.egg-info/SOURCES.txt0000664000175000017500000000432113327644151021344 0ustar zuulzuul00000000000000.coveragerc .testr.conf AUTHORS CONTRIBUTING.rst ChangeLog HACKING.rst LICENSE README.rst babel.cfg requirements.txt setup.cfg setup.py tox.ini aodhclient/__init__.py aodhclient/client.py aodhclient/exceptions.py aodhclient/i18n.py aodhclient/noauth.py aodhclient/osc.py aodhclient/shell.py aodhclient/utils.py aodhclient.egg-info/PKG-INFO aodhclient.egg-info/SOURCES.txt aodhclient.egg-info/dependency_links.txt aodhclient.egg-info/entry_points.txt aodhclient.egg-info/not-zip-safe aodhclient.egg-info/pbr.json aodhclient.egg-info/requires.txt aodhclient.egg-info/top_level.txt aodhclient/tests/__init__.py aodhclient/tests/functional/__init__.py aodhclient/tests/functional/base.py aodhclient/tests/functional/test_alarm.py aodhclient/tests/functional/test_alarm_history.py aodhclient/tests/functional/test_capabilities.py aodhclient/tests/unit/__init__.py aodhclient/tests/unit/test_alarm_cli.py aodhclient/tests/unit/test_alarm_history.py aodhclient/tests/unit/test_alarm_manager.py aodhclient/tests/unit/test_exceptions.py aodhclient/tests/unit/test_shell.py aodhclient/tests/unit/test_utils.py aodhclient/v2/__init__.py aodhclient/v2/alarm.py aodhclient/v2/alarm_cli.py aodhclient/v2/alarm_history.py aodhclient/v2/alarm_history_cli.py aodhclient/v2/base.py aodhclient/v2/capabilities.py aodhclient/v2/capabilities_cli.py aodhclient/v2/client.py doc/requirements.txt doc/source/api.rst doc/source/conf.py doc/source/contributing.rst doc/source/index.rst doc/source/installation.rst doc/source/shell.rst releasenotes/notes/.placeholder releasenotes/notes/add-pagination-support-fcdf1cef0cfa5ca9.yaml releasenotes/notes/merge-search-to-list-d44cd65ede348c3e.yaml releasenotes/notes/osc-support-9f9dae2d2203f307.yaml releasenotes/notes/remove-ceilometer-alarms-02049eef189c2812.yaml releasenotes/notes/split-alarm-query-and-list-5998020b88ddc9f5.yaml releasenotes/notes/support-get-set-state-interfaces-67419b925ffd6877.yaml releasenotes/source/conf.py releasenotes/source/index.rst releasenotes/source/mitaka.rst releasenotes/source/newton.rst releasenotes/source/ocata.rst releasenotes/source/pike.rst releasenotes/source/queens.rst releasenotes/source/unreleased.rst releasenotes/source/_static/.placeholder releasenotes/source/_templates/.placeholderaodhclient-1.1.1/aodhclient.egg-info/PKG-INFO0000664000175000017500000000312613327644151020557 0ustar zuulzuul00000000000000Metadata-Version: 2.1 Name: aodhclient Version: 1.1.1 Summary: Python client library for Aodh Home-page: https://docs.openstack.org/python-aodhclient/latest/ Author: OpenStack Author-email: openstack-dev@lists.openstack.org License: UNKNOWN Description: ========== aodhclient ========== Python bindings to the OpenStack Aodh API This is a client for OpenStack Aodh API. There's a `Python API `_ (the aodhclient module), and a `command-line script `_ (installed as aodh). Each implements the entire OpenStack Aodh API. * Free software: Apache license * Release notes: https://releases.openstack.org/teams/telemetry.html * Documentation: https://docs.openstack.org/python-aodhclient/latest/ * Source: https://git.openstack.org/cgit/openstack/python-aodhclient * Bugs: https://bugs.launchpad.net/python-aodhclient Platform: UNKNOWN Classifier: Environment :: OpenStack Classifier: Intended Audience :: Information Technology Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Provides-Extra: test aodhclient-1.1.1/aodhclient.egg-info/not-zip-safe0000664000175000017500000000000113327644122021704 0ustar zuulzuul00000000000000 aodhclient-1.1.1/aodhclient.egg-info/dependency_links.txt0000664000175000017500000000000113327644151023526 0ustar zuulzuul00000000000000 aodhclient-1.1.1/aodhclient.egg-info/entry_points.txt0000664000175000017500000000144713327644151022764 0ustar zuulzuul00000000000000[console_scripts] aodh = aodhclient.shell:main [keystoneauth1.plugin] aodh-noauth = aodhclient.noauth:AodhNoAuthLoader [openstack.alarming.v2] alarm create = aodhclient.v2.alarm_cli:CliAlarmCreate alarm delete = aodhclient.v2.alarm_cli:CliAlarmDelete alarm list = aodhclient.v2.alarm_cli:CliAlarmList alarm show = aodhclient.v2.alarm_cli:CliAlarmShow alarm state get = aodhclient.v2.alarm_cli:CliAlarmStateGet alarm state set = aodhclient.v2.alarm_cli:CliAlarmStateSet alarm update = aodhclient.v2.alarm_cli:CliAlarmUpdate alarm-history search = aodhclient.v2.alarm_history_cli:CliAlarmHistorySearch alarm-history show = aodhclient.v2.alarm_history_cli:CliAlarmHistoryShow alarming capabilities list = aodhclient.v2.capabilities_cli:CliCapabilitiesList [openstack.cli.extension] metric = aodhclient.osc aodhclient-1.1.1/releasenotes/0000775000175000017500000000000013327644151016345 5ustar zuulzuul00000000000000aodhclient-1.1.1/releasenotes/source/0000775000175000017500000000000013327644151017645 5ustar zuulzuul00000000000000aodhclient-1.1.1/releasenotes/source/mitaka.rst0000666000175000017500000000023213327643673021654 0ustar zuulzuul00000000000000=================================== Mitaka Series Release Notes =================================== .. release-notes:: :branch: origin/stable/mitaka aodhclient-1.1.1/releasenotes/source/queens.rst0000666000175000017500000000022313327643673021706 0ustar zuulzuul00000000000000=================================== Queens Series Release Notes =================================== .. release-notes:: :branch: stable/queens aodhclient-1.1.1/releasenotes/source/conf.py0000666000175000017500000002125113327643673021157 0ustar zuulzuul00000000000000# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'openstackdocstheme', 'reno.sphinxext', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # openstackdocstheme options repository_name = 'openstack/python-aodhclient' bug_project = 'python-aodhclient' bug_tag = '' project = u'Aodh Client Release Notes' copyright = u'2015-present, Aodh developers' # Release notes are version independent. # The short X.Y version. version = '' # The full version, including alpha/beta/rc tags. release = '' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # today = '' # Else, today_fmt is used as the format for a strftime call. # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all # documents. # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. # keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'openstackdocs' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. # html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%Y-%m-%d %H:%M' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. # html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. # html_additional_pages = {} # If false, no module index is generated. # html_domain_indices = True # If false, no index is generated. # html_use_index = True # If true, the index is split into individual pages for each letter. # html_split_index = False # If true, links to the reST sources are added to the pages. # html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'AodhClientReleaseNotestdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'PythonAodhClient.tex', u'Aodh Client Release Notes Documentation', u'Aodh developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. # latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. # latex_use_parts = False # If true, show page references after internal links. # latex_show_pagerefs = False # If true, show URL addresses after external links. # latex_show_urls = False # Documents to append as an appendix to all manuals. # latex_appendices = [] # If false, no module index is generated. # latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'pythonaodhclient', u'Aodh Client Release Notes Documentation', [u'Aodh developers'], 1) ] # If true, show URL addresses after external links. # man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'PythonAodhClient', u'Aodh Client Release Notes Documentation', u'Aodh developers', 'PythonAodhClient', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. # texinfo_appendices = [] # If false, no module index is generated. # texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. # texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. # texinfo_no_detailmenu = False # -- Options for Internationalization output ------------------------------ locale_dirs = ['locale/'] aodhclient-1.1.1/releasenotes/source/_static/0000775000175000017500000000000013327644151021273 5ustar zuulzuul00000000000000aodhclient-1.1.1/releasenotes/source/_static/.placeholder0000666000175000017500000000000013327643673023556 0ustar zuulzuul00000000000000aodhclient-1.1.1/releasenotes/source/newton.rst0000666000175000017500000000023213327643673021720 0ustar zuulzuul00000000000000=================================== Newton Series Release Notes =================================== .. release-notes:: :branch: origin/stable/newton aodhclient-1.1.1/releasenotes/source/_templates/0000775000175000017500000000000013327644151022002 5ustar zuulzuul00000000000000aodhclient-1.1.1/releasenotes/source/_templates/.placeholder0000666000175000017500000000000013327643673024265 0ustar zuulzuul00000000000000aodhclient-1.1.1/releasenotes/source/pike.rst0000666000175000017500000000021713327643673021341 0ustar zuulzuul00000000000000=================================== Pike Series Release Notes =================================== .. release-notes:: :branch: stable/pike aodhclient-1.1.1/releasenotes/source/unreleased.rst0000666000175000017500000000015313327643673022537 0ustar zuulzuul00000000000000============================ Current Series Release Notes ============================ .. release-notes:: aodhclient-1.1.1/releasenotes/source/ocata.rst0000666000175000017500000000023013327643673021473 0ustar zuulzuul00000000000000=================================== Ocata Series Release Notes =================================== .. release-notes:: :branch: origin/stable/ocata aodhclient-1.1.1/releasenotes/source/index.rst0000666000175000017500000000044113327643673021517 0ustar zuulzuul00000000000000Welcome to Aodh Client Release Notes documentation! =================================================== Contents ======== .. toctree:: :maxdepth: 2 unreleased queens pike ocata newton mitaka Indices and tables ================== * :ref:`genindex` * :ref:`search` aodhclient-1.1.1/releasenotes/notes/0000775000175000017500000000000013327644151017475 5ustar zuulzuul00000000000000aodhclient-1.1.1/releasenotes/notes/remove-ceilometer-alarms-02049eef189c2812.yaml0000666000175000017500000000047213327643673027354 0ustar zuulzuul00000000000000--- features: - | Ceilometer alarms are no longer supported. upgrade: - | Ceilometer alarms will need to be recreated as alarms that target Gnocchi as storage is not provided in Ceilometer anymore. You must downgrade client if you still continue to use Ceilometer storage in older deployments. aodhclient-1.1.1/releasenotes/notes/.placeholder0000666000175000017500000000000013327643673021760 0ustar zuulzuul00000000000000aodhclient-1.1.1/releasenotes/notes/merge-search-to-list-d44cd65ede348c3e.yaml0000666000175000017500000000046113327643673026712 0ustar zuulzuul00000000000000--- features: - The support for alarm search CLI has been dropped. New options for alarm list CLI(--filter and --query) has been added. The new option --query can be used to perform the same operation as the old alarm search CLI, and the new option --filter is used to perform filter query. aodhclient-1.1.1/releasenotes/notes/support-get-set-state-interfaces-67419b925ffd6877.yaml0000666000175000017500000000010113327643673031012 0ustar zuulzuul00000000000000--- features: - Add support of get/set alarm state interfaces. aodhclient-1.1.1/releasenotes/notes/osc-support-9f9dae2d2203f307.yaml0000666000175000017500000000012213327643673025100 0ustar zuulzuul00000000000000--- features: - Add support for using Aodh command with python-openstackclient. aodhclient-1.1.1/releasenotes/notes/add-pagination-support-fcdf1cef0cfa5ca9.yaml0000666000175000017500000000022113327643673027632 0ustar zuulzuul00000000000000--- features: - Add pagination support for aodhclient, users can now use limit, sort and marker when list alarms and show alarm histories. aodhclient-1.1.1/releasenotes/notes/split-alarm-query-and-list-5998020b88ddc9f5.yaml0000666000175000017500000000054713327643673027661 0ustar zuulzuul00000000000000--- upgrade: - Alarm list and query has been split into two separate functions in the SDK layer( CLI user still uses alarm list with --query or --filter as before). deprecations: - Calling alarm list function with query parameter has been deprecated and will be removed in python-aodhclient 0.7.0, please use alarm query function instead. aodhclient-1.1.1/setup.cfg0000666000175000017500000000406213327644151015501 0ustar zuulzuul00000000000000[metadata] name = aodhclient summary = Python client library for Aodh description-file = README.rst author = OpenStack author-email = openstack-dev@lists.openstack.org home-page = https://docs.openstack.org/python-aodhclient/latest/ classifier = Environment :: OpenStack Intended Audience :: Information Technology Intended Audience :: System Administrators License :: OSI Approved :: Apache Software License Operating System :: POSIX :: Linux Programming Language :: Python Programming Language :: Python :: 2 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.5 [files] packages = aodhclient [extras] test = coverage>=3.6 oslotest>=1.10.0 # Apache-2.0 reno>=1.6.2 # Apache2 tempest>=10 testrepository>=0.0.18 testtools>=1.4.0 pifpaf[gnocchi]>=0.23 gnocchi[postgresql,file] mock>=1.2 # BSD [entry_points] console_scripts = aodh = aodhclient.shell:main keystoneauth1.plugin = aodh-noauth = aodhclient.noauth:AodhNoAuthLoader openstack.cli.extension = metric = aodhclient.osc openstack.alarming.v2 = alarm create = aodhclient.v2.alarm_cli:CliAlarmCreate alarm list = aodhclient.v2.alarm_cli:CliAlarmList alarm show = aodhclient.v2.alarm_cli:CliAlarmShow alarm delete = aodhclient.v2.alarm_cli:CliAlarmDelete alarm update = aodhclient.v2.alarm_cli:CliAlarmUpdate alarm state get = aodhclient.v2.alarm_cli:CliAlarmStateGet alarm state set = aodhclient.v2.alarm_cli:CliAlarmStateSet alarm-history search = aodhclient.v2.alarm_history_cli:CliAlarmHistorySearch alarm-history show = aodhclient.v2.alarm_history_cli:CliAlarmHistoryShow alarming capabilities list = aodhclient.v2.capabilities_cli:CliCapabilitiesList [compile_catalog] directory = aodhclient/locale domain = aodhclient [update_catalog] domain = aodhclient output_dir = aodhclient/locale input_file = aodhclient/locale/aodhclient.pot [extract_messages] keywords = _ gettext ngettext l_ lazy_gettext mapping_file = babel.cfg output_file = aodhclient/locale/aodhclient.pot [wheel] universal = 1 [egg_info] tag_build = tag_date = 0 aodhclient-1.1.1/aodhclient/0000775000175000017500000000000013327644151015766 5ustar zuulzuul00000000000000aodhclient-1.1.1/aodhclient/exceptions.py0000666000175000017500000001224713327643673020541 0ustar zuulzuul00000000000000# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # 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 ClientException(Exception): """The base exception class for all exceptions this library raises.""" message = 'Unknown Error' http_status = 'N/A' def __init__(self, message=None, request_id=None, url=None, method=None): self.message = message or self.__class__.message self.request_id = request_id self.url = url self.method = method # NOTE(jd) for backward compat @property def code(self): return self.http_status def __str__(self): formatted_string = "%s (HTTP %s)" % (self.message, self.http_status) if self.request_id: formatted_string += " (Request-ID: %s)" % self.request_id return formatted_string class RetryAfterException(ClientException): """The base exception for ClientExceptions that use Retry-After header.""" def __init__(self, *args, **kwargs): try: self.retry_after = int(kwargs.pop('retry_after')) except (KeyError, ValueError): self.retry_after = 0 super(RetryAfterException, self).__init__(*args, **kwargs) class MutipleMeaningException(object): """An mixin for exception that can be enhanced by reading the details""" class CommandError(Exception): pass class BadRequest(ClientException): """HTTP 400 - Bad request: you sent some malformed data.""" http_status = 400 message = "Bad request" class Unauthorized(ClientException): """HTTP 401 - Unauthorized: bad credentials.""" http_status = 401 message = "Unauthorized" class Forbidden(ClientException): """HTTP 403 - Forbidden: your credentials don't give you access to this resource. """ http_status = 403 message = "Forbidden" class NotFound(ClientException): """HTTP 404 - Not found""" http_status = 404 message = "Not found" class MethodNotAllowed(ClientException): """HTTP 405 - Method Not Allowed""" http_status = 405 message = "Method Not Allowed" class NotAcceptable(ClientException): """HTTP 406 - Not Acceptable""" http_status = 406 message = "Not Acceptable" class Conflict(ClientException): """HTTP 409 - Conflict""" http_status = 409 message = "Conflict" class OverLimit(RetryAfterException): """HTTP 413 - Over limit: you're over the API limits for this time period. """ http_status = 413 message = "Over limit" class RateLimit(RetryAfterException): """HTTP 429 - Rate limit: you've sent too many requests for this time period. """ http_status = 429 message = "Rate limit" class NoUniqueMatch(Exception): pass class NotImplemented(ClientException): """HTTP 501 - Not Implemented: the server does not support this operation. """ http_status = 501 message = "Not Implemented" _error_classes = [BadRequest, Unauthorized, Forbidden, NotFound, MethodNotAllowed, NotAcceptable, Conflict, OverLimit, RateLimit, NotImplemented] _error_classes_enhanced = {} _code_map = dict( (c.http_status, (c, _error_classes_enhanced.get(c, []))) for c in _error_classes) def from_response(response, url, method=None): """Return an instance of one of the ClientException on an requests response. Usage:: resp, body = requests.request(...) if resp.status_code != 200: raise exception_from_response(resp) """ if response.status_code: cls, enhanced_classes = _code_map.get(response.status_code, (ClientException, [])) req_id = response.headers.get("x-openstack-request-id") content_type = response.headers.get("Content-Type", "").split(";")[0] kwargs = { 'method': method, 'url': url, 'request_id': req_id, } if "retry-after" in response.headers: kwargs['retry_after'] = response.headers.get('retry-after') if content_type == "application/json": try: body = response.json() except ValueError: pass else: desc = body.get('error_message', {}).get('faultstring') for enhanced_cls in enhanced_classes: if enhanced_cls.match.match(desc): cls = enhanced_cls break kwargs['message'] = desc elif content_type.startswith("text/"): kwargs['message'] = response.text if not kwargs.get('message'): kwargs.pop('message', None) exception = cls(**kwargs) if isinstance(exception, ClientException) and response.status_code: exception.http_status = response.status_code return exception aodhclient-1.1.1/aodhclient/osc.py0000666000175000017500000000346413327643673017145 0ustar zuulzuul00000000000000# Copyright 2014 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """OpenStackClient plugin for Telemetry Alarming service.""" from osc_lib import utils DEFAULT_ALARMING_API_VERSION = '2' API_VERSION_OPTION = 'os_alarming_api_version' API_NAME = "alarming" API_VERSIONS = { "2": "aodhclient.v2.client.Client", } def make_client(instance): """Returns an queues service client.""" version = instance._api_version[API_NAME] try: version = int(version) except ValueError: version = float(version) aodh_client = utils.get_client_class( API_NAME, version, API_VERSIONS) # NOTE(sileht): ensure setup of the session is done instance.setup_auth() return aodh_client(session=instance.session, interface=instance.interface, region_name=instance.region_name) def build_option_parser(parser): """Hook to add global options.""" parser.add_argument( '--os-alarming-api-version', metavar='', default=utils.env( 'OS_ALARMING_API_VERSION', default=DEFAULT_ALARMING_API_VERSION), help=('Queues API version, default=' + DEFAULT_ALARMING_API_VERSION + ' (Env: OS_ALARMING_API_VERSION)')) return parser aodhclient-1.1.1/aodhclient/shell.py0000666000175000017500000001541213327643673017464 0ustar zuulzuul00000000000000# Copyright 2012 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from __future__ import print_function import logging import os import sys import warnings from cliff import app from cliff import commandmanager from keystoneauth1 import exceptions from keystoneauth1 import loading from aodhclient import __version__ from aodhclient import client from aodhclient import noauth from aodhclient.v2 import alarm_cli from aodhclient.v2 import alarm_history_cli from aodhclient.v2 import capabilities_cli class AodhCommandManager(commandmanager.CommandManager): SHELL_COMMANDS = { "alarm create": alarm_cli.CliAlarmCreate, "alarm delete": alarm_cli.CliAlarmDelete, "alarm list": alarm_cli.CliAlarmList, "alarm show": alarm_cli.CliAlarmShow, "alarm update": alarm_cli.CliAlarmUpdate, "alarm state get": alarm_cli.CliAlarmStateGet, "alarm state set": alarm_cli.CliAlarmStateSet, "alarm-history show": alarm_history_cli.CliAlarmHistoryShow, "alarm-history search": alarm_history_cli.CliAlarmHistorySearch, "capabilities list": capabilities_cli.CliCapabilitiesList, } def load_commands(self, namespace): for name, command_class in self.SHELL_COMMANDS.items(): self.add_command(name, command_class) class AodhShell(app.App): def __init__(self): super(AodhShell, self).__init__( description='Aodh command line client', version=__version__, command_manager=AodhCommandManager('aodhclient'), deferred_help=True, ) self._client = None def build_option_parser(self, description, version): """Return an argparse option parser for this application. Subclasses may override this method to extend the parser with more global options. :param description: full description of the application :paramtype description: str :param version: version number for the application :paramtype version: str """ parser = super(AodhShell, self).build_option_parser( description, version, argparse_kwargs={'allow_abbrev': False}) # Global arguments, one day this should go to keystoneauth1 parser.add_argument( '--os-region-name', metavar='', dest='region_name', default=os.environ.get('OS_REGION_NAME'), help='Authentication region name (Env: OS_REGION_NAME)') parser.add_argument( '--os-interface', metavar='', dest='interface', choices=['admin', 'public', 'internal'], default=os.environ.get('OS_INTERFACE'), help='Select an interface type.' ' Valid interface types: [admin, public, internal].' ' (Env: OS_INTERFACE)') parser.add_argument( '--aodh-api-version', default=os.environ.get('AODH_API_VERSION', '2'), help='Defaults to env[AODH_API_VERSION] or 2.') loading.register_session_argparse_arguments(parser=parser) plugin = loading.register_auth_argparse_arguments( parser=parser, argv=sys.argv, default="password") if not isinstance(plugin, noauth.AodhNoAuthLoader): parser.add_argument( '--aodh-endpoint', metavar='', dest='endpoint', default=os.environ.get('AODH_ENDPOINT'), help='Aodh endpoint (Env: AODH_ENDPOINT)') return parser @property def client(self): # NOTE(sileht): we lazy load the client to not # load/connect auth stuffs if self._client is None: if hasattr(self.options, "endpoint"): endpoint_override = self.options.endpoint else: endpoint_override = None auth_plugin = loading.load_auth_from_argparse_arguments( self.options) session = loading.load_session_from_argparse_arguments( self.options, auth=auth_plugin) self._client = client.Client(self.options.aodh_api_version, session=session, interface=self.options.interface, region_name=self.options.region_name, endpoint_override=endpoint_override) return self._client def clean_up(self, cmd, result, err): if isinstance(err, exceptions.HttpError) and err.details: print(err.details, file=sys.stderr) def configure_logging(self): if self.options.debug: # --debug forces verbose_level 3 # Set this here so cliff.app.configure_logging() can work self.options.verbose_level = 3 super(AodhShell, self).configure_logging() root_logger = logging.getLogger('') # Set logging to the requested level if self.options.verbose_level == 0: # --quiet root_logger.setLevel(logging.ERROR) warnings.simplefilter("ignore") elif self.options.verbose_level == 1: # This is the default case, no --debug, --verbose or --quiet root_logger.setLevel(logging.WARNING) warnings.simplefilter("ignore") elif self.options.verbose_level == 2: # One --verbose root_logger.setLevel(logging.INFO) warnings.simplefilter("once") elif self.options.verbose_level >= 3: # Two or more --verbose root_logger.setLevel(logging.DEBUG) # Hide some useless message requests_log = logging.getLogger("requests") cliff_log = logging.getLogger('cliff') stevedore_log = logging.getLogger('stevedore') iso8601_log = logging.getLogger("iso8601") cliff_log.setLevel(logging.ERROR) stevedore_log.setLevel(logging.ERROR) iso8601_log.setLevel(logging.ERROR) if self.options.debug: requests_log.setLevel(logging.DEBUG) else: requests_log.setLevel(logging.ERROR) def main(args=None): if args is None: args = sys.argv[1:] return AodhShell().run(args) aodhclient-1.1.1/aodhclient/__init__.py0000666000175000017500000000123213327643673020107 0ustar zuulzuul00000000000000# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import pbr.version __version__ = pbr.version.VersionInfo( 'aodhclient').version_string() aodhclient-1.1.1/aodhclient/noauth.py0000666000175000017500000000500713327643673017652 0ustar zuulzuul00000000000000# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # 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 from keystoneauth1 import loading from keystoneauth1 import plugin class AodhNoAuthPlugin(plugin.BaseAuthPlugin): """No authentication plugin for Aodh This is a keystoneauth plugin that instead of doing authentication, it just fill the 'x-user-id' and 'x-project-id' headers with the user provided one. """ def __init__(self, user_id, project_id, roles, endpoint): self._user_id = user_id self._project_id = project_id self._endpoint = endpoint self._roles = roles def get_token(self, session, **kwargs): return '' def get_headers(self, session, **kwargs): return {'x-user-id': self._user_id, 'x-project-id': self._project_id, 'x-roles': self._roles} def get_user_id(self, session, **kwargs): return self._user_id def get_project_id(self, session, **kwargs): return self._project_id def get_endpoint(self, session, **kwargs): return self._endpoint class AodhOpt(loading.Opt): @property def argparse_args(self): return ['--%s' % o.name for o in self._all_opts] @property def argparse_default(self): # select the first ENV that is not false-y or return None for o in self._all_opts: v = os.environ.get('AODH_%s' % o.name.replace('-', '_').upper()) if v: return v return self.default class AodhNoAuthLoader(loading.BaseLoader): plugin_class = AodhNoAuthPlugin def get_options(self): options = super(AodhNoAuthLoader, self).get_options() options.extend([ AodhOpt('user-id', help='User ID', required=True), AodhOpt('project-id', help='Project ID', required=True), AodhOpt('roles', help='Roles', default="admin"), AodhOpt('aodh-endpoint', help='Aodh endpoint', dest="endpoint", required=True), ]) return options aodhclient-1.1.1/aodhclient/client.py0000666000175000017500000000310113327643673017623 0ustar zuulzuul00000000000000# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # 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 keystoneauth1 import adapter from oslo_utils import importutils from aodhclient import exceptions def Client(version, *args, **kwargs): module = 'aodhclient.v%s.client' % version module = importutils.import_module(module) client_class = getattr(module, 'Client') return client_class(*args, **kwargs) class SessionClient(adapter.Adapter): def request(self, url, method, **kwargs): kwargs.setdefault('headers', kwargs.get('headers', {})) # NOTE(sileht): The standard call raises errors from # keystoneauth, where we need to raise the aodhclient errors. raise_exc = kwargs.pop('raise_exc', True) resp = super(SessionClient, self).request(url, method, raise_exc=False, **kwargs) if raise_exc and resp.status_code >= 400: raise exceptions.from_response(resp, url, method) return resp aodhclient-1.1.1/aodhclient/i18n.py0000666000175000017500000000135513327643673017135 0ustar zuulzuul00000000000000# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import oslo_i18n as i18n _translators = i18n.TranslatorFactory(domain='aodhclient') # The primary translation function using the well-known name "_" _ = _translators.primary aodhclient-1.1.1/aodhclient/v2/0000775000175000017500000000000013327644151016315 5ustar zuulzuul00000000000000aodhclient-1.1.1/aodhclient/v2/capabilities.py0000666000175000017500000000142713327643673021336 0ustar zuulzuul00000000000000# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # 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 aodhclient.v2 import base class CapabilitiesManager(base.Manager): cap_url = "v2/capabilities/" def list(self): """List capabilities """ return self._get(self.cap_url).json() aodhclient-1.1.1/aodhclient/v2/base.py0000666000175000017500000000333013327643673017612 0ustar zuulzuul00000000000000# Copyright 2012-2015 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import six class Manager(object): DEFAULT_HEADERS = { "Accept": "application/json, */*", } def __init__(self, client): self.client = client def _set_default_headers(self, kwargs): headers = kwargs.get('headers', {}) for k, v in six.iteritems(self.DEFAULT_HEADERS): if k not in headers: headers[k] = v kwargs['headers'] = headers return kwargs def _get(self, *args, **kwargs): self._set_default_headers(kwargs) return self.client.api.get(*args, **kwargs) def _post(self, *args, **kwargs): self._set_default_headers(kwargs) return self.client.api.post(*args, **kwargs) def _put(self, *args, **kwargs): self._set_default_headers(kwargs) return self.client.api.put(*args, **kwargs) def _patch(self, *args, **kwargs): self._set_default_headers(kwargs) return self.client.api.patch(*args, **kwargs) def _delete(self, *args, **kwargs): self._set_default_headers(kwargs) return self.client.api.delete(*args, **kwargs) aodhclient-1.1.1/aodhclient/v2/__init__.py0000666000175000017500000000000013327643673020426 0ustar zuulzuul00000000000000aodhclient-1.1.1/aodhclient/v2/capabilities_cli.py0000666000175000017500000000153113327643673022161 0ustar zuulzuul00000000000000# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # 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 cliff import show from aodhclient import utils class CliCapabilitiesList(show.ShowOne): """List capabilities of alarming service""" def take_action(self, parsed_args): caps = utils.get_client(self).capabilities.list() return self.dict2columns(caps) aodhclient-1.1.1/aodhclient/v2/alarm_history.py0000666000175000017500000000356613327643673021570 0ustar zuulzuul00000000000000# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from oslo_serialization import jsonutils from aodhclient import utils from aodhclient.v2 import base class AlarmHistoryManager(base.Manager): url = "v2/alarms/%s/history" def get(self, alarm_id, limit=None, marker=None, sorts=None): """Get history of an alarm :param alarm_id: ID of the alarm :type alarm_id: str :param limit: maximum number of resources to return :type limit: int :param marker: the last item of the previous page; we return the next results after this value. :type marker: str :param sorts: list of resource attributes to order by. :type sorts: list of str """ pagination = utils.get_pagination_options(limit, marker, sorts) self.url = self.url % alarm_id if pagination: self.url = "%s?%s" % (self.url, pagination) return self._get(self.url).json() def search(self, query=None): """List of history matching corresponding query :param query: The query dictionary :type query: dict """ query = {'filter': query} if query else {} url = "v2/query/alarms/history" return self._post(url, headers={'Content-Type': "application/json"}, data=jsonutils.dumps(query)).json() aodhclient-1.1.1/aodhclient/v2/alarm_history_cli.py0000666000175000017500000000543213327643673022411 0ustar zuulzuul00000000000000# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # 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 cliff import lister from oslo_serialization import jsonutils from aodhclient import utils class CliAlarmHistorySearch(lister.Lister): """Show history for all alarms based on query""" COLS = ('alarm_id', 'timestamp', 'type', 'detail') def get_parser(self, prog_name): parser = super(CliAlarmHistorySearch, self).get_parser(prog_name) parser.add_argument("--query", help="Rich query supported by aodh, " "e.g. project_id!=my-id " "user_id=foo or user_id=bar"), return parser def take_action(self, parsed_args): query = None if parsed_args.query: query = jsonutils.dumps( utils.search_query_builder(parsed_args.query)) history = utils.get_client(self).alarm_history.search( query=query) return utils.list2cols(self.COLS, history) class CliAlarmHistoryShow(lister.Lister): """Show history for an alarm""" COLS = ('timestamp', 'type', 'detail', 'event_id') def get_parser(self, prog_name): parser = super(CliAlarmHistoryShow, self).get_parser(prog_name) parser.add_argument("alarm_id", help="ID of an alarm") parser.add_argument("--limit", type=int, metavar="", help="Number of resources to return " "(Default is server default)") parser.add_argument("--marker", metavar="", help="Last item of the previous listing. " "Return the next results after this value," "the supported marker is event_id.") parser.add_argument("--sort", action="append", metavar="", help="Sort of resource attribute. " "e.g. timestamp:desc") return parser def take_action(self, parsed_args): history = utils.get_client(self).alarm_history.get( alarm_id=parsed_args.alarm_id, sorts=parsed_args.sort, limit=parsed_args.limit, marker=parsed_args.marker) return utils.list2cols(self.COLS, history) aodhclient-1.1.1/aodhclient/v2/client.py0000666000175000017500000000254513327643673020165 0ustar zuulzuul00000000000000# Copyright 2012 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from aodhclient import client from aodhclient.v2 import alarm from aodhclient.v2 import alarm_history from aodhclient.v2 import capabilities class Client(object): """Client for the Aodh v2 API. :param string session: session :type session: :py:class:`keystoneauth.adapter.Adapter` """ def __init__(self, session=None, service_type='alarming', **kwargs): """Initialize a new client for the Aodh v2 API.""" self.api = client.SessionClient(session, service_type=service_type, **kwargs) self.alarm = alarm.AlarmManager(self) self.alarm_history = alarm_history.AlarmHistoryManager(self) self.capabilities = capabilities.CapabilitiesManager(self) aodhclient-1.1.1/aodhclient/v2/alarm_cli.py0000666000175000017500000005556013327643673020637 0ustar zuulzuul00000000000000# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # 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 argparse from cliff import command from cliff import lister from cliff import show from oslo_serialization import jsonutils from oslo_utils import strutils from oslo_utils import uuidutils from aodhclient import exceptions from aodhclient.i18n import _ from aodhclient import utils ALARM_TYPES = ['event', 'composite', 'gnocchi_resources_threshold', 'gnocchi_aggregation_by_metrics_threshold', 'gnocchi_aggregation_by_resources_threshold'] ALARM_STATES = ['ok', 'alarm', 'insufficient data'] ALARM_SEVERITY = ['low', 'moderate', 'critical'] ALARM_OPERATORS = ['lt', 'le', 'eq', 'ne', 'ge', 'gt'] ALARM_OP_MAP = dict(zip(ALARM_OPERATORS, ('<', '<=', '=', '!=', '>=', '>'))) ALARM_LIST_COLS = ['alarm_id', 'type', 'name', 'state', 'severity', 'enabled'] class CliAlarmList(lister.Lister): """List alarms""" @staticmethod def split_filter_param(param): key, eq_op, value = param.partition('=') if not eq_op: msg = 'Malformed parameter(%s). Use the key=value format.' % param raise ValueError(msg) return key, value def get_parser(self, prog_name): parser = super(CliAlarmList, self).get_parser(prog_name) exclusive_group = parser.add_mutually_exclusive_group() exclusive_group.add_argument("--query", help="Rich query supported by aodh, " "e.g. project_id!=my-id " "user_id=foo or user_id=bar") exclusive_group.add_argument('--filter', dest='filter', metavar='', type=self.split_filter_param, action='append', help='Filter parameters to apply on' ' returned alarms.') parser.add_argument("--limit", type=int, metavar="", help="Number of resources to return " "(Default is server default)") parser.add_argument("--marker", metavar="", help="Last item of the previous listing. " "Return the next results after this value," "the supported marker is alarm_id.") parser.add_argument("--sort", action="append", metavar="", help="Sort of resource attribute, " "e.g. name:asc") return parser def take_action(self, parsed_args): if parsed_args.query: if any([parsed_args.limit, parsed_args.sort, parsed_args.marker]): raise exceptions.CommandError( "Query and pagination options are mutually " "exclusive.") query = jsonutils.dumps( utils.search_query_builder(parsed_args.query)) alarms = utils.get_client(self).alarm.query(query=query) else: filters = dict(parsed_args.filter) if parsed_args.filter else None alarms = utils.get_client(self).alarm.list( filters=filters, sorts=parsed_args.sort, limit=parsed_args.limit, marker=parsed_args.marker) return utils.list2cols(ALARM_LIST_COLS, alarms) def _format_alarm(alarm): if alarm.get('composite_rule'): composite_rule = jsonutils.dumps(alarm['composite_rule'], indent=2) alarm['composite_rule'] = composite_rule return alarm for alarm_type in ALARM_TYPES: if alarm.get('%s_rule' % alarm_type): alarm.update(alarm.pop('%s_rule' % alarm_type)) if alarm["time_constraints"]: alarm["time_constraints"] = jsonutils.dumps(alarm["time_constraints"], sort_keys=True, indent=2) # only works for event alarm if isinstance(alarm.get('query'), list): query_rows = [] for q in alarm['query']: op = ALARM_OP_MAP.get(q['op'], q['op']) query_rows.append('%s %s %s' % (q['field'], op, q['value'])) alarm['query'] = ' AND\n'.join(query_rows) return alarm def _find_alarm_by_name(client, name): # then try to get entity as name query = jsonutils.dumps({"=": {"name": name}}) alarms = client.alarm.query(query) if len(alarms) > 1: msg = (_("Multiple alarms matches found for '%s', " "use an ID to be more specific.") % name) raise exceptions.NoUniqueMatch(msg) elif not alarms: msg = (_("Alarm %s not found") % name) raise exceptions.NotFound(msg) else: return alarms[0] def _find_alarm_id_by_name(client, name): alarm = _find_alarm_by_name(client, name) return alarm['alarm_id'] def _check_name_and_id_coexist(parsed_args, action): if parsed_args.id and parsed_args.name: raise exceptions.CommandError( "You should provide only one of " "alarm ID and alarm name(--name) " "to %s an alarm." % action) def _check_name_and_id_exist(parsed_args, action): if not parsed_args.id and not parsed_args.name: msg = (_("You need to specify one of " "alarm ID and alarm name(--name) " "to %s an alarm.") % action) raise exceptions.CommandError(msg) def _check_name_and_id(parsed_args, action): _check_name_and_id_coexist(parsed_args, action) _check_name_and_id_exist(parsed_args, action) def _add_name_to_parser(parser, required=False): parser.add_argument('--name', metavar='', required=required, help='Name of the alarm') return parser def _add_id_to_parser(parser): parser.add_argument("id", nargs='?', metavar='', help="ID or name of an alarm.") return parser class CliAlarmShow(show.ShowOne): """Show an alarm""" def get_parser(self, prog_name): return _add_name_to_parser( _add_id_to_parser( super(CliAlarmShow, self).get_parser(prog_name))) def take_action(self, parsed_args): _check_name_and_id(parsed_args, 'query') c = utils.get_client(self) if parsed_args.name: alarm = _find_alarm_by_name(c, parsed_args.name) else: if uuidutils.is_uuid_like(parsed_args.id): try: alarm = c.alarm.get(alarm_id=parsed_args.id) except exceptions.NotFound: # Maybe it's a name alarm = _find_alarm_by_name(c, parsed_args.id) else: alarm = _find_alarm_by_name(c, parsed_args.id) return self.dict2columns(_format_alarm(alarm)) class CliAlarmCreate(show.ShowOne): """Create an alarm""" create = True def get_parser(self, prog_name): parser = _add_name_to_parser( super(CliAlarmCreate, self).get_parser(prog_name), required=self.create) parser.add_argument('-t', '--type', metavar='', required=self.create, choices=ALARM_TYPES, help='Type of alarm, should be one of: ' '%s.' % ', '.join(ALARM_TYPES)) parser.add_argument('--project-id', metavar='', help='Project to associate with alarm ' '(configurable by admin users only)') parser.add_argument('--user-id', metavar='', help='User to associate with alarm ' '(configurable by admin users only)') parser.add_argument('--description', metavar='', help='Free text description of the alarm') parser.add_argument('--state', metavar='', choices=ALARM_STATES, help='State of the alarm, one of: ' + str(ALARM_STATES)) parser.add_argument('--severity', metavar='', choices=ALARM_SEVERITY, help='Severity of the alarm, one of: ' + str(ALARM_SEVERITY)) parser.add_argument('--enabled', type=strutils.bool_from_string, metavar='{True|False}', help=('True if alarm evaluation is enabled')) parser.add_argument('--alarm-action', dest='alarm_actions', metavar='', action='append', help=('URL to invoke when state transitions to ' 'alarm. May be used multiple times')) parser.add_argument('--ok-action', dest='ok_actions', metavar='', action='append', help=('URL to invoke when state transitions to ' 'OK. May be used multiple times')) parser.add_argument('--insufficient-data-action', dest='insufficient_data_actions', metavar='', action='append', help=('URL to invoke when state transitions to ' 'insufficient data. May be used multiple ' 'times')) parser.add_argument( '--time-constraint', dest='time_constraints', metavar='