Retire the python-congressclient project
Recently the TC has worked on determining the criteria for when an OpenStack project should be retired. When there was not a PTL nominee for the Congress project, that triggered the TC to review the project health per [1], and the TC has determined [2] that development work on the project has ceased. This decision was announced in the openstack-discuss mailing list in April 2020 [3]. This commit retires the repository per the process for governance removal in the Victoria cycle as specified in the Mandatory Repository Retirement resolution [4] and detailed in the infra manual [5]. Should interest in developing Congress as part of OpenStack revive, please revert this commit to have the project rejoin the list of active projects. The community wishes to express our thanks and appreciation to all of those who have contributed to the Congress project over the years. [1] https://governance.openstack.org/tc/reference/dropping-projects.html [2] http://eavesdrop.openstack.org/irclogs/%23openstack-tc/latest.log.html#t2020-04-20T15:36:59 [3] http://lists.openstack.org/pipermail/openstack-discuss/2020-April/014292.html [4] https://governance.openstack.org/tc/resolutions/20190711-mandatory-repository-retirement.html [5] https://docs.opendev.org/opendev/infra-manual/latest/drivers.html#retiring-a-project Change-Id: Ib13d3325a5497064d037b007e9823609f836988d
This commit is contained in:
parent
5863c2bdf6
commit
1388136246
@ -1,7 +0,0 @@
|
||||
[run]
|
||||
branch = True
|
||||
source = congressclient
|
||||
omit = congressclient/tests/*
|
||||
|
||||
[report]
|
||||
ignore_errors = True
|
56
.gitignore
vendored
56
.gitignore
vendored
@ -1,56 +0,0 @@
|
||||
# Congress build/runtime artifacts
|
||||
subunit.log
|
||||
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
dist
|
||||
build
|
||||
eggs
|
||||
parts
|
||||
bin
|
||||
var
|
||||
sdist
|
||||
develop-eggs
|
||||
.installed.cfg
|
||||
.eggs
|
||||
/lib
|
||||
/lib64
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
.tox
|
||||
.stestr/
|
||||
|
||||
# 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
|
||||
*.swo
|
||||
*.swn
|
3
.mailmap
3
.mailmap
@ -1,3 +0,0 @@
|
||||
# Format is:
|
||||
# <preferred e-mail> <other e-mail 1>
|
||||
# <preferred e-mail> <other e-mail 2>
|
@ -1,4 +0,0 @@
|
||||
[DEFAULT]
|
||||
test_path=./congressclient/tests
|
||||
top_dir=./
|
||||
|
@ -1,8 +0,0 @@
|
||||
- project:
|
||||
templates:
|
||||
- check-requirements
|
||||
- openstack-lower-constraints-jobs
|
||||
- openstack-python3-ussuri-jobs
|
||||
- release-notes-jobs-python3
|
||||
- openstackclient-plugin-jobs
|
||||
- publish-openstack-docs-pti
|
@ -1,16 +0,0 @@
|
||||
If you would like to contribute to the development of OpenStack,
|
||||
you must follow the steps in this page:
|
||||
|
||||
https://docs.openstack.org/infra/manual/developers.html
|
||||
|
||||
Once those steps have been completed, changes to OpenStack
|
||||
should be submitted for review via the Gerrit tool, following
|
||||
the workflow documented at:
|
||||
|
||||
https://docs.openstack.org/infra/manual/developers.html#development-workflow
|
||||
|
||||
Pull requests submitted through GitHub will be ignored.
|
||||
|
||||
Bugs should be filed on Launchpad, not GitHub:
|
||||
|
||||
https://bugs.launchpad.net/python-congressclient
|
@ -1,4 +0,0 @@
|
||||
python-congressclient Style Commandments
|
||||
===============================================
|
||||
|
||||
Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/
|
175
LICENSE
175
LICENSE
@ -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.
|
12
Makefile
12
Makefile
@ -1,12 +0,0 @@
|
||||
|
||||
TOPDIR=$(CURDIR)
|
||||
SRCDIR=$(TOPDIR)/congressclient
|
||||
|
||||
all: docs
|
||||
|
||||
clean: rm -Rf $(TOPDIR)/doc/html/*
|
||||
|
||||
docs: $(TOPDIR)/doc/source/*.rst
|
||||
sphinx-build -b html $(TOPDIR)/doc/source $(TOPDIR)/doc/html
|
||||
|
||||
|
61
NEWS
61
NEWS
@ -1,61 +0,0 @@
|
||||
1.0.4 - XXXX-XX-XX
|
||||
------------------
|
||||
- Add new CLI command to trigger a datasource to poll
|
||||
- congress datasource request-refresh Trigger a datasource to poll.
|
||||
|
||||
1.0.3 - 2015-03-30
|
||||
------------------
|
||||
|
||||
- Add new CLI commands to manage datasources/drivers
|
||||
- congress datasource create Create a datasource.
|
||||
- congress datasource delete Delete a datasource.
|
||||
- congress driver config show List driver tables.
|
||||
- congress driver list List drivers.
|
||||
- congress driver schema show List datasource tables.
|
||||
- All api commands now use uuids instead of names and the cli
|
||||
now looks up their ids when needed thou allows the user to still use
|
||||
the name for convenience.
|
||||
|
||||
|
||||
1.0.2 - 2015-01-15
|
||||
------------------
|
||||
- Add new CLI comment to create/delete policy
|
||||
- congress policy create Create a policy.
|
||||
- congress policy delete Delete a policy.
|
||||
- Restructure simulate API to pass query/sequence/action_policy in body instead of URI.
|
||||
|
||||
|
||||
1.0.1 - 2014-12-05
|
||||
------------------
|
||||
- Add missing CLI command
|
||||
- openstack congress policy rule show
|
||||
- python34 compatibility
|
||||
- New CLI command to simulate results of rule
|
||||
- openstack congress policy simulate Show the result of simulation.
|
||||
- Add new CLI command to check the status of a datasource
|
||||
- openstack congress datasource status list
|
||||
- Add new CLI for viewing schemas
|
||||
- openstack congress datasource table schema show Show schema for datasource table.
|
||||
- openstack congress datasource schema show Show schema for datasource.
|
||||
- Add CLI for creating/deleting policies
|
||||
- openstack congress policy create
|
||||
- openstack congress policy delete
|
||||
|
||||
|
||||
|
||||
1.0.0 - 2014-09-29
|
||||
------------------
|
||||
- First release
|
||||
- python-openstackclient integration
|
||||
- CLI
|
||||
- keystone catalog and auth
|
||||
- Support for the following CLI commands:
|
||||
- openstack congress datasource list List Datasources.
|
||||
- openstack congress datasource row list List datasource rows.
|
||||
- openstack congress datasource table list List datasource tables.
|
||||
- openstack congress policy list List Policy.
|
||||
- openstack congress policy row list List policy rows.
|
||||
- openstack congress policy rule create Create a policy rule.
|
||||
- openstack congress policy rule delete Delete a policy rule.
|
||||
- openstack congress policy rule list List policy rules.
|
||||
- openstack congress policy table list List policy tables.
|
108
README.rst
108
README.rst
@ -1,100 +1,14 @@
|
||||
===============================
|
||||
python-congressclient
|
||||
===============================
|
||||
==========================
|
||||
Welcome to Congress Client
|
||||
==========================
|
||||
|
||||
.. only::html
|
||||
This project is no longer maintained.
|
||||
|
||||
.. image:: https://governance.openstack.org/tc/badges/python-congressclient.svg
|
||||
:target: https://governance.openstack.org/tc/reference/tags/index.html
|
||||
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".
|
||||
|
||||
.. only::latex
|
||||
|
||||
.. image:: python-congressclient.svg
|
||||
|
||||
|
||||
.. Change things from this point on
|
||||
|
||||
Client for Congress
|
||||
|
||||
* Free software: Apache license
|
||||
* Documentation: https://docs.openstack.org/python-congressclient/latest/
|
||||
* Source: https://opendev.org/openstack/python-congressclient
|
||||
* Bugs: https://bugs.launchpad.net/python-congressclient
|
||||
|
||||
|
||||
Client for Standalone Congress
|
||||
------------------------------
|
||||
Install the Congress CLI by cloning the repository and running the setup file.
|
||||
The master repository always contains the latest source code, so if you are
|
||||
installing and testing a specific branch of Congress, clone the matching branch
|
||||
of the python-congressclient.
|
||||
|
||||
To execute CLI commands to standalone Congress installed with noauth:
|
||||
|
||||
* Install python-openstackclient::
|
||||
|
||||
$ pip install python-openstackclient
|
||||
|
||||
* Clone master repository & install python-congressclient::
|
||||
|
||||
$ git clone https://github.com/openstack/python-congressclient.git
|
||||
$ cd python-congressclient
|
||||
$ python setup.py install
|
||||
|
||||
* (Optional) Clone a branch; for example, if you are using the Ocata version of OpenStack and Congress::
|
||||
|
||||
$ git clone -b stable/ocata https://github.com/openstack/python-congressclient.git
|
||||
$ cd python-congressclient
|
||||
$ python setup.py install
|
||||
|
||||
* Read the HTML documentation. Install python-sphinx and the oslosphinx extension if missing::
|
||||
|
||||
$ sudo pip install sphinx
|
||||
$ sudo pip install oslosphinx
|
||||
|
||||
Build the docs
|
||||
$ make docs
|
||||
|
||||
Open doc/html/index.html in a browser
|
||||
|
||||
* To execute CLI commands::
|
||||
|
||||
$ cd python-congressclient
|
||||
|
||||
For example:
|
||||
$ export CONGRESS_URL="http://127.0.0.1:1789"
|
||||
$ openstack --os-token foo --os-url $CONGRESS_URL
|
||||
(openstack) congress policy create test_policy
|
||||
+--------------+--------------------------------------+
|
||||
| Field | Value |
|
||||
+--------------+--------------------------------------+
|
||||
| abbreviation | test_ |
|
||||
| description | |
|
||||
| id | 8595f24a-7d74-45ee-8168-0b3e937b8419 |
|
||||
| kind | nonrecursive |
|
||||
| name | test_policy |
|
||||
| owner_id | user |
|
||||
+--------------+--------------------------------------+
|
||||
|
||||
(openstack) congress policy rule create test_policy "p(5)"
|
||||
+---------+--------------------------------------+
|
||||
| Field | Value |
|
||||
+---------+--------------------------------------+
|
||||
| comment | None |
|
||||
| id | 5ce7fb18-a227-447e-bec8-93e99c0052a5 |
|
||||
| name | None |
|
||||
| rule | p(5) |
|
||||
+---------+--------------------------------------+
|
||||
|
||||
(openstack) congress policy rule list test_policy
|
||||
// ID: 5ce7fb18-a227-447e-bec8-93e99c0052a5
|
||||
// Name: None
|
||||
p(5)
|
||||
|
||||
(openstack) exit
|
||||
$
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* TODO
|
||||
For any further questions, please email
|
||||
openstack-discuss@lists.openstack.org or join #openstack-dev on
|
||||
Freenode.
|
||||
|
@ -1,21 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES 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
|
||||
|
||||
__all__ = ['__version__']
|
||||
|
||||
version_info = pbr.version.VersionInfo('python-congressclient')
|
||||
try:
|
||||
__version__ = version_info.version_string()
|
||||
except AttributeError:
|
||||
__version__ = None
|
@ -1,67 +0,0 @@
|
||||
# Copyright 2013 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.
|
||||
#
|
||||
|
||||
"""argparse Custom Actions"""
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
class KeyValueAction(argparse.Action):
|
||||
"""A custom action to parse arguments as key=value pairs
|
||||
|
||||
Ensures that ``dest`` is a dict
|
||||
"""
|
||||
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
# Make sure we have an empty dict rather than None
|
||||
if getattr(namespace, self.dest, None) is None:
|
||||
setattr(namespace, self.dest, {})
|
||||
|
||||
# Add value if an assignment else remove it
|
||||
if '=' in values:
|
||||
getattr(namespace, self.dest, {}).update([values.split('=', 1)])
|
||||
else:
|
||||
getattr(namespace, self.dest, {}).pop(values, None)
|
||||
|
||||
|
||||
class RangeAction(argparse.Action):
|
||||
"""A custom action to parse a single value or a range of values
|
||||
|
||||
Parses single integer values or a range of integer values delimited
|
||||
by a colon and returns a tuple of integers:
|
||||
'4' sets ``dest`` to (4, 4)
|
||||
'6:9' sets ``dest`` to (6, 9)
|
||||
"""
|
||||
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
range = values.split(':')
|
||||
if len(range) == 0:
|
||||
# Nothing passed, return a zero default
|
||||
setattr(namespace, self.dest, (0, 0))
|
||||
elif len(range) == 1:
|
||||
# Only a single value is present
|
||||
setattr(namespace, self.dest, (int(range[0]), int(range[0])))
|
||||
elif len(range) == 2:
|
||||
# Range of two values
|
||||
if int(range[0]) <= int(range[1]):
|
||||
setattr(namespace, self.dest, (int(range[0]), int(range[1])))
|
||||
else:
|
||||
msg = ("Invalid range, %s is not less than %s" %
|
||||
(range[0], range[1]))
|
||||
raise argparse.ArgumentError(self, msg)
|
||||
else:
|
||||
# Too many values
|
||||
msg = "Invalid range, too many values"
|
||||
raise argparse.ArgumentError(self, msg)
|
@ -1,140 +0,0 @@
|
||||
# Copyright 2012-2013 OpenStack, LLC.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import importlib
|
||||
import os
|
||||
|
||||
from congressclient import exceptions
|
||||
|
||||
|
||||
def env(*vars, **kwargs):
|
||||
"""Search for the first defined of possibly many env vars
|
||||
|
||||
Returns the first environment variable defined in vars, or
|
||||
returns the default defined in kwargs.
|
||||
"""
|
||||
for v in vars:
|
||||
value = os.environ.get(v, None)
|
||||
if value:
|
||||
return value
|
||||
return kwargs.get('default', '')
|
||||
|
||||
|
||||
def import_class(import_str):
|
||||
"""Returns a class from a string including module and class
|
||||
|
||||
:param import_str: a string representation of the class name
|
||||
:rtype: the requested class
|
||||
"""
|
||||
mod_str, _sep, class_str = import_str.rpartition('.')
|
||||
mod = importlib.import_module(mod_str)
|
||||
return getattr(mod, class_str)
|
||||
|
||||
|
||||
def get_client_class(api_name, version, version_map):
|
||||
"""Returns the client class for the requested API version
|
||||
|
||||
:param api_name: the name of the API, e.g. 'compute', 'image', etc
|
||||
:param version: the requested API version
|
||||
:param version_map: a dict of client classes keyed by version
|
||||
:rtype: a client class for the requested API version
|
||||
"""
|
||||
try:
|
||||
client_path = version_map[str(version)]
|
||||
except (KeyError, ValueError):
|
||||
msg = "Invalid %s client version '%s'. must be one of: %s" % (
|
||||
(api_name, version, ', '.join(version_map.keys())))
|
||||
raise exceptions.UnsupportedVersion(msg)
|
||||
|
||||
return import_class(client_path)
|
||||
|
||||
|
||||
def format_long_dict_list(data):
|
||||
"""Return a formatted string.
|
||||
|
||||
:param data: a list of dicts
|
||||
:rtype: a string formatted to {a:b, c:d}, {e:f, g:h}
|
||||
"""
|
||||
newdata = [str({str(key): str(value) for key, value in d.iteritems()})
|
||||
for d in data]
|
||||
return ',\n'.join(newdata) + '\n'
|
||||
|
||||
|
||||
def format_dict(data):
|
||||
"""Return a formatted string.
|
||||
|
||||
:param data: a dict
|
||||
:rtype: a string formatted to {a:b, c:d}
|
||||
"""
|
||||
if not isinstance(data, dict):
|
||||
return str(data)
|
||||
return str({str(key): str(value) for key, value in data.items()})
|
||||
|
||||
|
||||
def format_list(data):
|
||||
"""Return a formatted strings
|
||||
|
||||
:param data: a list of strings
|
||||
:rtype: a string formatted to a,b,c
|
||||
"""
|
||||
|
||||
return ', '.join(data)
|
||||
|
||||
|
||||
def get_dict_properties(item, fields, mixed_case_fields=[], formatters={}):
|
||||
"""Return a tuple containing the item properties.
|
||||
|
||||
:param item: a single dict resource
|
||||
:param fields: tuple of strings with the desired field names
|
||||
:param mixed_case_fields: tuple of field names to preserve case
|
||||
:param formatters: dictionary mapping field names to callables
|
||||
to format the values
|
||||
"""
|
||||
row = []
|
||||
for field in fields:
|
||||
if field in mixed_case_fields:
|
||||
field_name = field.replace(' ', '_')
|
||||
else:
|
||||
field_name = field.lower().replace(' ', '_')
|
||||
data = item[field_name] if field_name in item else ''
|
||||
if field in formatters:
|
||||
row.append(formatters[field](data))
|
||||
else:
|
||||
row.append(data)
|
||||
return tuple(row)
|
||||
|
||||
|
||||
def get_resource_id_from_name(name, results):
|
||||
# FIXME(arosen): move to common lib and add tests...
|
||||
name_match = None
|
||||
id_match = None
|
||||
double_name_match = False
|
||||
for result in results['results']:
|
||||
if result['id'] == name:
|
||||
id_match = result['id']
|
||||
if result['name'] == name:
|
||||
if name_match:
|
||||
double_name_match = True
|
||||
name_match = result['id']
|
||||
if not double_name_match and name_match:
|
||||
return name_match
|
||||
if double_name_match and not id_match:
|
||||
# NOTE(arosen): this should only occur is using congress
|
||||
# as admin and multiple projects use the same datsource name.
|
||||
raise exceptions.Conflict(
|
||||
"Multiple resources have this name %s. Please specify id." % name)
|
||||
if id_match:
|
||||
return id_match
|
||||
|
||||
raise exceptions.NotFound("Resource %s not found" % name)
|
@ -1,464 +0,0 @@
|
||||
# Copyright 2010 Jacob Kaplan-Moss
|
||||
# Copyright 2011 Nebula, Inc.
|
||||
# Copyright 2013 Alessio Ababilov
|
||||
# Copyright 2013 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.
|
||||
|
||||
"""
|
||||
Exception definitions.
|
||||
"""
|
||||
|
||||
import inspect
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
from congressclient.i18n import _
|
||||
|
||||
|
||||
class ClientException(Exception):
|
||||
"""The base exception class for all exceptions this library raises."""
|
||||
pass
|
||||
|
||||
|
||||
class MissingArgs(ClientException):
|
||||
"""Supplied arguments are not sufficient for calling a function."""
|
||||
def __init__(self, missing):
|
||||
self.missing = missing
|
||||
msg = _("Missing arguments: %s") % ", ".join(missing)
|
||||
super(MissingArgs, self).__init__(msg)
|
||||
|
||||
|
||||
class ValidationError(ClientException):
|
||||
"""Error in validation on API client side."""
|
||||
pass
|
||||
|
||||
|
||||
class UnsupportedVersion(ClientException):
|
||||
"""User is trying to use an unsupported version of the API."""
|
||||
pass
|
||||
|
||||
|
||||
class CommandError(ClientException):
|
||||
"""Error in CLI tool."""
|
||||
pass
|
||||
|
||||
|
||||
class AuthorizationFailure(ClientException):
|
||||
"""Cannot authorize API client."""
|
||||
pass
|
||||
|
||||
|
||||
class ConnectionRefused(ClientException):
|
||||
"""Cannot connect to API service."""
|
||||
pass
|
||||
|
||||
|
||||
class AuthPluginOptionsMissing(AuthorizationFailure):
|
||||
"""Auth plugin misses some options."""
|
||||
def __init__(self, opt_names):
|
||||
super(AuthPluginOptionsMissing, self).__init__(
|
||||
_("Authentication failed. Missing options: %s") %
|
||||
", ".join(opt_names))
|
||||
self.opt_names = opt_names
|
||||
|
||||
|
||||
class AuthSystemNotFound(AuthorizationFailure):
|
||||
"""User has specified an AuthSystem that is not installed."""
|
||||
def __init__(self, auth_system):
|
||||
super(AuthSystemNotFound, self).__init__(
|
||||
_("AuthSystemNotFound: %s") % repr(auth_system))
|
||||
self.auth_system = auth_system
|
||||
|
||||
|
||||
class NoUniqueMatch(ClientException):
|
||||
"""Multiple entities found instead of one."""
|
||||
pass
|
||||
|
||||
|
||||
class EndpointException(ClientException):
|
||||
"""Something is rotten in Service Catalog."""
|
||||
pass
|
||||
|
||||
|
||||
class EndpointNotFound(EndpointException):
|
||||
"""Could not find requested endpoint in Service Catalog."""
|
||||
pass
|
||||
|
||||
|
||||
class AmbiguousEndpoints(EndpointException):
|
||||
"""Found more than one matching endpoint in Service Catalog."""
|
||||
def __init__(self, endpoints=None):
|
||||
super(AmbiguousEndpoints, self).__init__(
|
||||
_("AmbiguousEndpoints: %s") % repr(endpoints))
|
||||
self.endpoints = endpoints
|
||||
|
||||
|
||||
class HttpError(ClientException):
|
||||
"""The base exception class for all HTTP exceptions."""
|
||||
http_status = 0
|
||||
message = _("HTTP Error")
|
||||
|
||||
def __init__(self, message=None, details=None,
|
||||
response=None, request_id=None,
|
||||
url=None, method=None, http_status=None):
|
||||
self.http_status = http_status or self.http_status
|
||||
self.message = message or self.message
|
||||
self.details = details
|
||||
self.request_id = request_id
|
||||
self.response = response
|
||||
self.url = url
|
||||
self.method = method
|
||||
formatted_string = "%s (HTTP %s)" % (self.message, self.http_status)
|
||||
if request_id:
|
||||
formatted_string += " (Request-ID: %s)" % request_id
|
||||
super(HttpError, self).__init__(formatted_string)
|
||||
|
||||
|
||||
class HTTPRedirection(HttpError):
|
||||
"""HTTP Redirection."""
|
||||
message = _("HTTP Redirection")
|
||||
|
||||
|
||||
class HTTPClientError(HttpError):
|
||||
"""Client-side HTTP error.
|
||||
|
||||
Exception for cases in which the client seems to have erred.
|
||||
"""
|
||||
message = _("HTTP Client Error")
|
||||
|
||||
|
||||
class HttpServerError(HttpError):
|
||||
"""Server-side HTTP error.
|
||||
|
||||
Exception for cases in which the server is aware that it has
|
||||
erred or is incapable of performing the request.
|
||||
"""
|
||||
message = _("HTTP Server Error")
|
||||
|
||||
|
||||
class MultipleChoices(HTTPRedirection):
|
||||
"""HTTP 300 - Multiple Choices.
|
||||
|
||||
Indicates multiple options for the resource that the client may follow.
|
||||
"""
|
||||
|
||||
http_status = 300
|
||||
message = _("Multiple Choices")
|
||||
|
||||
|
||||
class BadRequest(HTTPClientError):
|
||||
"""HTTP 400 - Bad Request.
|
||||
|
||||
The request cannot be fulfilled due to bad syntax.
|
||||
"""
|
||||
http_status = 400
|
||||
message = _("Bad Request")
|
||||
|
||||
|
||||
class Unauthorized(HTTPClientError):
|
||||
"""HTTP 401 - Unauthorized.
|
||||
|
||||
Similar to 403 Forbidden, but specifically for use when authentication
|
||||
is required and has failed or has not yet been provided.
|
||||
"""
|
||||
http_status = 401
|
||||
message = _("Unauthorized")
|
||||
|
||||
|
||||
class PaymentRequired(HTTPClientError):
|
||||
"""HTTP 402 - Payment Required.
|
||||
|
||||
Reserved for future use.
|
||||
"""
|
||||
http_status = 402
|
||||
message = _("Payment Required")
|
||||
|
||||
|
||||
class Forbidden(HTTPClientError):
|
||||
"""HTTP 403 - Forbidden.
|
||||
|
||||
The request was a valid request, but the server is refusing to respond
|
||||
to it.
|
||||
"""
|
||||
http_status = 403
|
||||
message = _("Forbidden")
|
||||
|
||||
|
||||
class NotFound(HTTPClientError):
|
||||
"""HTTP 404 - Not Found.
|
||||
|
||||
The requested resource could not be found but may be available again
|
||||
in the future.
|
||||
"""
|
||||
http_status = 404
|
||||
message = _("Not Found")
|
||||
|
||||
|
||||
class MethodNotAllowed(HTTPClientError):
|
||||
"""HTTP 405 - Method Not Allowed.
|
||||
|
||||
A request was made of a resource using a request method not supported
|
||||
by that resource.
|
||||
"""
|
||||
http_status = 405
|
||||
message = _("Method Not Allowed")
|
||||
|
||||
|
||||
class NotAcceptable(HTTPClientError):
|
||||
"""HTTP 406 - Not Acceptable.
|
||||
|
||||
The requested resource is only capable of generating content not
|
||||
acceptable according to the Accept headers sent in the request.
|
||||
"""
|
||||
http_status = 406
|
||||
message = _("Not Acceptable")
|
||||
|
||||
|
||||
class ProxyAuthenticationRequired(HTTPClientError):
|
||||
"""HTTP 407 - Proxy Authentication Required.
|
||||
|
||||
The client must first authenticate itself with the proxy.
|
||||
"""
|
||||
http_status = 407
|
||||
message = _("Proxy Authentication Required")
|
||||
|
||||
|
||||
class RequestTimeout(HTTPClientError):
|
||||
"""HTTP 408 - Request Timeout.
|
||||
|
||||
The server timed out waiting for the request.
|
||||
"""
|
||||
http_status = 408
|
||||
message = _("Request Timeout")
|
||||
|
||||
|
||||
class Conflict(HTTPClientError):
|
||||
"""HTTP 409 - Conflict.
|
||||
|
||||
Indicates that the request could not be processed because of conflict
|
||||
in the request, such as an edit conflict.
|
||||
"""
|
||||
http_status = 409
|
||||
message = _("Conflict")
|
||||
|
||||
|
||||
class Gone(HTTPClientError):
|
||||
"""HTTP 410 - Gone.
|
||||
|
||||
Indicates that the resource requested is no longer available and will
|
||||
not be available again.
|
||||
"""
|
||||
http_status = 410
|
||||
message = _("Gone")
|
||||
|
||||
|
||||
class LengthRequired(HTTPClientError):
|
||||
"""HTTP 411 - Length Required.
|
||||
|
||||
The request did not specify the length of its content, which is
|
||||
required by the requested resource.
|
||||
"""
|
||||
http_status = 411
|
||||
message = _("Length Required")
|
||||
|
||||
|
||||
class PreconditionFailed(HTTPClientError):
|
||||
"""HTTP 412 - Precondition Failed.
|
||||
|
||||
The server does not meet one of the preconditions that the requester
|
||||
put on the request.
|
||||
"""
|
||||
http_status = 412
|
||||
message = _("Precondition Failed")
|
||||
|
||||
|
||||
class RequestEntityTooLarge(HTTPClientError):
|
||||
"""HTTP 413 - Request Entity Too Large.
|
||||
|
||||
The request is larger than the server is willing or able to process.
|
||||
"""
|
||||
http_status = 413
|
||||
message = _("Request Entity Too Large")
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
try:
|
||||
self.retry_after = int(kwargs.pop('retry_after'))
|
||||
except (KeyError, ValueError):
|
||||
self.retry_after = 0
|
||||
|
||||
super(RequestEntityTooLarge, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class RequestUriTooLong(HTTPClientError):
|
||||
"""HTTP 414 - Request-URI Too Long.
|
||||
|
||||
The URI provided was too long for the server to process.
|
||||
"""
|
||||
http_status = 414
|
||||
message = _("Request-URI Too Long")
|
||||
|
||||
|
||||
class UnsupportedMediaType(HTTPClientError):
|
||||
"""HTTP 415 - Unsupported Media Type.
|
||||
|
||||
The request entity has a media type which the server or resource does
|
||||
not support.
|
||||
"""
|
||||
http_status = 415
|
||||
message = _("Unsupported Media Type")
|
||||
|
||||
|
||||
class RequestedRangeNotSatisfiable(HTTPClientError):
|
||||
"""HTTP 416 - Requested Range Not Satisfiable.
|
||||
|
||||
The client has asked for a portion of the file, but the server cannot
|
||||
supply that portion.
|
||||
"""
|
||||
http_status = 416
|
||||
message = _("Requested Range Not Satisfiable")
|
||||
|
||||
|
||||
class ExpectationFailed(HTTPClientError):
|
||||
"""HTTP 417 - Expectation Failed.
|
||||
|
||||
The server cannot meet the requirements of the Expect request-header field.
|
||||
"""
|
||||
http_status = 417
|
||||
message = _("Expectation Failed")
|
||||
|
||||
|
||||
class UnprocessableEntity(HTTPClientError):
|
||||
"""HTTP 422 - Unprocessable Entity.
|
||||
|
||||
The request was well-formed but was unable to be followed due to semantic
|
||||
errors.
|
||||
"""
|
||||
http_status = 422
|
||||
message = _("Unprocessable Entity")
|
||||
|
||||
|
||||
class InternalServerError(HttpServerError):
|
||||
"""HTTP 500 - Internal Server Error.
|
||||
|
||||
A generic error message, given when no more specific message is suitable.
|
||||
"""
|
||||
http_status = 500
|
||||
message = _("Internal Server Error")
|
||||
|
||||
|
||||
# NotImplemented is a python keyword.
|
||||
class HttpNotImplemented(HttpServerError):
|
||||
"""HTTP 501 - Not Implemented.
|
||||
|
||||
The server either does not recognize the request method, or it lacks
|
||||
the ability to fulfill the request.
|
||||
"""
|
||||
http_status = 501
|
||||
message = _("Not Implemented")
|
||||
|
||||
|
||||
class BadGateway(HttpServerError):
|
||||
"""HTTP 502 - Bad Gateway.
|
||||
|
||||
The server was acting as a gateway or proxy and received an invalid
|
||||
response from the upstream server.
|
||||
"""
|
||||
http_status = 502
|
||||
message = _("Bad Gateway")
|
||||
|
||||
|
||||
class ServiceUnavailable(HttpServerError):
|
||||
"""HTTP 503 - Service Unavailable.
|
||||
|
||||
The server is currently unavailable.
|
||||
"""
|
||||
http_status = 503
|
||||
message = _("Service Unavailable")
|
||||
|
||||
|
||||
class GatewayTimeout(HttpServerError):
|
||||
"""HTTP 504 - Gateway Timeout.
|
||||
|
||||
The server was acting as a gateway or proxy and did not receive a timely
|
||||
response from the upstream server.
|
||||
"""
|
||||
http_status = 504
|
||||
message = _("Gateway Timeout")
|
||||
|
||||
|
||||
class HttpVersionNotSupported(HttpServerError):
|
||||
"""HTTP 505 - HttpVersion Not Supported.
|
||||
|
||||
The server does not support the HTTP protocol version used in the request.
|
||||
"""
|
||||
http_status = 505
|
||||
message = _("HTTP Version Not Supported")
|
||||
|
||||
|
||||
# _code_map contains all the classes that have http_status attribute.
|
||||
_code_map = dict(
|
||||
(getattr(obj, 'http_status', None), obj)
|
||||
for name, obj in six.iteritems(vars(sys.modules[__name__]))
|
||||
if inspect.isclass(obj) and getattr(obj, 'http_status', False)
|
||||
)
|
||||
|
||||
|
||||
def from_response(response, method, url):
|
||||
"""Returns an instance of :class:`HttpError` or subclass based on response.
|
||||
|
||||
:param response: instance of `requests.Response` class
|
||||
:param method: HTTP method used for request
|
||||
:param url: URL used for request
|
||||
"""
|
||||
|
||||
req_id = response.headers.get("x-openstack-request-id")
|
||||
# NOTE(hdd) true for older versions of nova and cinder
|
||||
if not req_id:
|
||||
req_id = response.headers.get("x-compute-request-id")
|
||||
kwargs = {
|
||||
"http_status": response.status_code,
|
||||
"response": response,
|
||||
"method": method,
|
||||
"url": url,
|
||||
"request_id": req_id,
|
||||
}
|
||||
if "retry-after" in response.headers:
|
||||
kwargs["retry_after"] = response.headers["retry-after"]
|
||||
|
||||
content_type = response.headers.get("Content-Type", "")
|
||||
if content_type.startswith("application/json"):
|
||||
try:
|
||||
body = response.json()
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
if isinstance(body, dict) and isinstance(body.get("error"), dict):
|
||||
error = body["error"]
|
||||
kwargs["message"] = error.get("message")
|
||||
kwargs["details"] = error.get("details")
|
||||
elif content_type.startswith("text/"):
|
||||
kwargs["details"] = response.text
|
||||
|
||||
try:
|
||||
cls = _code_map[response.status_code]
|
||||
except KeyError:
|
||||
if 500 <= response.status_code < 600:
|
||||
cls = HttpServerError
|
||||
elif 400 <= response.status_code < 500:
|
||||
cls = HTTPClientError
|
||||
else:
|
||||
cls = HttpError
|
||||
return cls(**kwargs)
|
@ -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.
|
||||
|
||||
"""oslo_i18n integration module for novaclient.
|
||||
|
||||
See https://docs.openstack.org/oslo.i18n/latest/user/usage.html.
|
||||
|
||||
"""
|
||||
|
||||
import oslo_i18n
|
||||
|
||||
|
||||
_translators = oslo_i18n.TranslatorFactory(domain='congressclient')
|
||||
|
||||
# The primary translation function using the well-known name "_"
|
||||
_ = _translators.primary
|
@ -1,55 +0,0 @@
|
||||
# Copyright 2014 VMWare.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# 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 Governance service."""
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from congressclient.common import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_POLICY_API_VERSION = '1'
|
||||
API_VERSION_OPTION = 'os_policy_api_version'
|
||||
API_NAME = 'congressclient'
|
||||
API_VERSIONS = {
|
||||
'1': 'congressclient.v1.client.Client',
|
||||
}
|
||||
|
||||
|
||||
def make_client(instance):
|
||||
"""Returns a congress service client."""
|
||||
congress_client = utils.get_client_class(
|
||||
API_NAME,
|
||||
instance._api_version[API_NAME],
|
||||
API_VERSIONS)
|
||||
LOG.debug('instantiating congress client: %s', congress_client)
|
||||
return congress_client(session=instance.session,
|
||||
auth=None,
|
||||
interface='publicURL',
|
||||
service_type='policy',
|
||||
region_name=instance._region_name)
|
||||
|
||||
|
||||
def build_option_parser(parser):
|
||||
"""Hook to add global options."""
|
||||
parser.add_argument(
|
||||
'--os-policy-api-version',
|
||||
metavar='<policy-api-version>',
|
||||
default=utils.env(
|
||||
'OS_POLICY_API_VERSION',
|
||||
default=DEFAULT_POLICY_API_VERSION),
|
||||
help=('Policy API version, default=%s (Env: OS_POLICY_API_VERSION)' %
|
||||
DEFAULT_POLICY_API_VERSION))
|
||||
return parser
|
@ -1,42 +0,0 @@
|
||||
# Copyright 2015 Huawei.
|
||||
# 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.
|
||||
|
||||
"""List API versions implemenations"""
|
||||
|
||||
from cliff import lister
|
||||
from oslo_log import log as logging
|
||||
|
||||
from congressclient.common import utils
|
||||
|
||||
|
||||
class ListAPIVersions(lister.Lister):
|
||||
"""List API Versions."""
|
||||
|
||||
log = logging.getLogger(__name__ + '.ListAPIVersions')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
return super(ListAPIVersions, self).get_parser(prog_name)
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
# set default max-width
|
||||
if parsed_args.max_width == 0:
|
||||
parsed_args.max_width = 80
|
||||
client = self.app.client_manager.congressclient
|
||||
data = client.list_api_versions()['versions']
|
||||
# sort API by id
|
||||
data.sort(key=lambda item: item.get('id'))
|
||||
columns = ['id', 'status', 'updated']
|
||||
return (columns,
|
||||
(utils.get_dict_properties(s, columns) for s in data))
|
@ -1,389 +0,0 @@
|
||||
# Copyright 2012-2013 OpenStack, LLC.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Datasource action implemenations"""
|
||||
|
||||
from cliff import command
|
||||
from cliff import lister
|
||||
from cliff import show
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from congressclient.common import parseractions
|
||||
from congressclient.common import utils
|
||||
|
||||
|
||||
class ListDatasources(lister.Lister):
|
||||
"""List Datasources."""
|
||||
|
||||
log = logging.getLogger(__name__ + '.ListDatasources')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ListDatasources, self).get_parser(prog_name)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
# set default max-width
|
||||
if parsed_args.max_width == 0:
|
||||
parsed_args.max_width = 80
|
||||
client = self.app.client_manager.congressclient
|
||||
data = client.list_datasources()['results']
|
||||
# Type is always None, so disabling it for now.
|
||||
columns = ['id', 'name', 'enabled', 'driver', 'config']
|
||||
formatters = {'config': utils.format_dict}
|
||||
return (columns,
|
||||
(utils.get_dict_properties(s, columns,
|
||||
formatters=formatters)
|
||||
for s in data))
|
||||
|
||||
|
||||
class ListDatasourceTables(lister.Lister):
|
||||
"""List datasource tables."""
|
||||
|
||||
log = logging.getLogger(__name__ + '.ListDatasourceTables')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ListDatasourceTables, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'datasource_name',
|
||||
metavar="<datasource>",
|
||||
help="Name or ID of the datasource")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug('take_action(%s)' % parsed_args)
|
||||
# set default max-width
|
||||
if parsed_args.max_width == 0:
|
||||
parsed_args.max_width = 80
|
||||
client = self.app.client_manager.congressclient
|
||||
name_or_id = parsed_args.datasource_name
|
||||
data = client.list_datasource_tables(name_or_id)['results']
|
||||
columns = ['id']
|
||||
formatters = {'DatasourceTables': utils.format_list}
|
||||
return (columns,
|
||||
(utils.get_dict_properties(s, columns,
|
||||
formatters=formatters)
|
||||
for s in data))
|
||||
|
||||
|
||||
class ShowDatasourceStatus(show.ShowOne):
|
||||
"""List status for datasource."""
|
||||
|
||||
log = logging.getLogger(__name__ + '.ShowDatasourceStatus')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShowDatasourceStatus, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'datasource_name',
|
||||
metavar="<datasource>",
|
||||
help="Name or ID of the datasource")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug('take_action(%s)' % parsed_args)
|
||||
# set default max-width
|
||||
if parsed_args.max_width == 0:
|
||||
parsed_args.max_width = 80
|
||||
client = self.app.client_manager.congressclient
|
||||
datasource_id = parsed_args.datasource_name
|
||||
data = client.list_datasource_status(datasource_id)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
class ShowDatasourceActions(lister.Lister):
|
||||
"""List supported actions for datasource."""
|
||||
|
||||
log = logging.getLogger(__name__ + '.ShowDatasourceActions')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShowDatasourceActions, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'datasource_name',
|
||||
metavar="<datasource>",
|
||||
help="Name or ID of the datasource")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug('take_action(%s)' % parsed_args)
|
||||
# as we know output it's long, limit column length here
|
||||
if parsed_args.max_width == 0:
|
||||
parsed_args.max_width = 80
|
||||
|
||||
client = self.app.client_manager.congressclient
|
||||
datasource_id = parsed_args.datasource_name
|
||||
data = client.list_datasource_actions(datasource_id)
|
||||
formatters = {'args': utils.format_long_dict_list}
|
||||
newdata = [{'action': x['name'],
|
||||
'args': x['args'],
|
||||
'description': x['description']}
|
||||
for x in data['results']]
|
||||
columns = ['action', 'args', 'description']
|
||||
return (columns, (utils.get_dict_properties(s,
|
||||
columns,
|
||||
formatters=formatters)
|
||||
for s in newdata))
|
||||
|
||||
|
||||
class ShowDatasourceSchema(lister.Lister):
|
||||
"""Show schema for datasource."""
|
||||
|
||||
log = logging.getLogger(__name__ + '.ShowDatasourceSchema')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShowDatasourceSchema, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'datasource_name',
|
||||
metavar="<datasource>",
|
||||
help="Name or ID of the datasource")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug('take_action(%s)' % parsed_args)
|
||||
# set default max-width
|
||||
if parsed_args.max_width == 0:
|
||||
parsed_args.max_width = 80
|
||||
client = self.app.client_manager.congressclient
|
||||
datasource_id = parsed_args.datasource_name
|
||||
data = client.show_datasource_schema(datasource_id)
|
||||
formatters = {'columns': utils.format_long_dict_list}
|
||||
newdata = [{'table': x['table_id'],
|
||||
'columns': x['columns']}
|
||||
for x in data['tables']]
|
||||
columns = ['table', 'columns']
|
||||
return (columns,
|
||||
(utils.get_dict_properties(s, columns,
|
||||
formatters=formatters)
|
||||
for s in newdata))
|
||||
|
||||
|
||||
class ShowDatasourceTableSchema(lister.Lister):
|
||||
"""Show schema for datasource table."""
|
||||
|
||||
log = logging.getLogger(__name__ + '.ShowDatasourceTableSchema')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShowDatasourceTableSchema, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'datasource_name',
|
||||
metavar="<datasource>",
|
||||
help="Name or ID of the datasource")
|
||||
parser.add_argument(
|
||||
'table_name',
|
||||
metavar="<table-name>",
|
||||
help="Name of the table")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug('take_action(%s)' % parsed_args)
|
||||
# set default max-width
|
||||