Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
582b52b1b8 | ||
|
|
4d0eb4c55a | ||
|
|
3e9b0d678e | ||
|
|
b34b746d1c | ||
|
|
baf0133c5b | ||
| e5bd6e00cb | |||
| 827d474cc4 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -26,7 +26,7 @@ pip-log.txt
|
||||
.coverage
|
||||
.tox
|
||||
nosetests.xml
|
||||
.stestr/
|
||||
.testrepository
|
||||
.venv
|
||||
|
||||
# Translations
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[gerrit]
|
||||
host=review.openstack.org
|
||||
host=review.opendev.org
|
||||
port=29418
|
||||
project=openstack/python-watcherclient.git
|
||||
defaultbranch=stable/rocky
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
[DEFAULT]
|
||||
test_path=./watcherclient/tests/functional
|
||||
top_dir=./
|
||||
test_path=${OS_TEST_PATH:-./watcherclient/tests/functional}
|
||||
top_dir=./
|
||||
7
.testr.conf
Normal file
7
.testr.conf
Normal file
@@ -0,0 +1,7 @@
|
||||
[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./watcherclient/tests} $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
11
.zuul.yaml
11
.zuul.yaml
@@ -1,13 +1,18 @@
|
||||
- project:
|
||||
templates:
|
||||
- openstack-lower-constraints-jobs
|
||||
- openstack-python-jobs
|
||||
- openstack-python35-jobs
|
||||
- openstack-python36-jobs
|
||||
- publish-openstack-docs-pti
|
||||
- publish-openstack-sphinx-docs
|
||||
- check-requirements
|
||||
- openstackclient-plugin-jobs
|
||||
check:
|
||||
jobs:
|
||||
- watcherclient-tempest-functional:
|
||||
voting: false
|
||||
- openstack-tox-lower-constraints
|
||||
- openstack-tox-cover:
|
||||
voting: false
|
||||
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-tox-lower-constraints
|
||||
|
||||
@@ -157,7 +157,7 @@ watcher action list
|
||||
[--quote {all,minimal,none,nonnumeric}]
|
||||
[--action-plan <action-plan>] [--audit <audit>]
|
||||
[--detail] [--limit <limit>] [--sort-key <field>]
|
||||
[--sort-dir <direction>] [--marker <marker>]
|
||||
[--sort-dir <direction>]
|
||||
|
||||
List information on retrieved actions.
|
||||
|
||||
@@ -186,10 +186,6 @@ List information on retrieved actions.
|
||||
``--sort-dir <direction>``
|
||||
Sort direction: "asc" (the default) or "desc".
|
||||
|
||||
``--marker <marker>``
|
||||
UUID of the last action in the previous page; displays
|
||||
list of actions after "marker".
|
||||
|
||||
.. _watcher_action_show:
|
||||
|
||||
watcher action show
|
||||
@@ -299,8 +295,7 @@ watcher actionplan list
|
||||
[--fit-width] [--print-empty] [--noindent]
|
||||
[--quote {all,minimal,none,nonnumeric}]
|
||||
[--audit <audit>] [--detail] [--limit <limit>]
|
||||
[--marker <actionplan>] [--sort-key <field>]
|
||||
[--sort-dir <direction>]
|
||||
[--sort-key <field>] [--sort-dir <direction>]
|
||||
|
||||
List information on retrieved action plans.
|
||||
|
||||
@@ -320,10 +315,6 @@ List information on retrieved action plans.
|
||||
0 for no limit. Default is the maximum number used by
|
||||
the Watcher API Service.
|
||||
|
||||
``--marker <actionplan>``
|
||||
The last actionplan UUID of the previous page;
|
||||
displays list of actionplans after "marker".
|
||||
|
||||
``--sort-key <field>``
|
||||
Action Plan field that will be used for sorting.
|
||||
|
||||
@@ -475,7 +466,7 @@ Delete audit command.
|
||||
**Positional arguments:**
|
||||
|
||||
``<audit>``
|
||||
UUID or name of the audit
|
||||
UUID of the audit
|
||||
|
||||
**Optional arguments:**
|
||||
|
||||
@@ -541,7 +532,7 @@ Show detailed information about a given audit.
|
||||
**Positional arguments:**
|
||||
|
||||
``<audit>``
|
||||
UUID or name of the audit
|
||||
UUID of the audit
|
||||
|
||||
**Optional arguments:**
|
||||
|
||||
@@ -565,7 +556,7 @@ Update audit command.
|
||||
**Positional arguments:**
|
||||
|
||||
``<audit>``
|
||||
UUID or name of the audit.
|
||||
UUID of the audit.
|
||||
|
||||
``<op>``
|
||||
Operation: 'add', 'replace', or 'remove'.
|
||||
@@ -689,7 +680,7 @@ watcher audittemplate list
|
||||
[--detail] [--goal <goal>]
|
||||
[--strategy <strategy>] [--limit <limit>]
|
||||
[--sort-key <field>]
|
||||
[--sort-dir <direction>][--marker <marker>]
|
||||
[--sort-dir <direction>]
|
||||
|
||||
List information on retrieved audit templates.
|
||||
|
||||
@@ -718,10 +709,6 @@ List information on retrieved audit templates.
|
||||
``--sort-dir <direction>``
|
||||
Sort direction: "asc" (the default) or "desc".
|
||||
|
||||
``--marker <marker>``
|
||||
UUID of the last audittemplate in the previous page; displays
|
||||
list of audittemplates after "marker".
|
||||
|
||||
.. _watcher_audittemplate_show:
|
||||
|
||||
watcher audittemplate show
|
||||
@@ -794,7 +781,7 @@ watcher goal list
|
||||
[--print-empty] [--noindent]
|
||||
[--quote {all,minimal,none,nonnumeric}] [--detail]
|
||||
[--limit <limit>] [--sort-key <field>]
|
||||
[--sort-dir <direction>][--marker <marker>]
|
||||
[--sort-dir <direction>]
|
||||
|
||||
List information on retrieved goals.
|
||||
|
||||
@@ -817,10 +804,6 @@ List information on retrieved goals.
|
||||
``--sort-dir <direction>``
|
||||
Sort direction: "asc" (the default) or "desc".
|
||||
|
||||
``--marker <marker>``
|
||||
UUID of the last goal in the previous page; displays
|
||||
list of goals after "marker".
|
||||
|
||||
.. _watcher_goal_show:
|
||||
|
||||
watcher goal show
|
||||
@@ -858,7 +841,7 @@ watcher scoringengine list
|
||||
[--quote {all,minimal,none,nonnumeric}]
|
||||
[--detail] [--limit <limit>]
|
||||
[--sort-key <field>]
|
||||
[--sort-dir <direction>][--marker <marker>]
|
||||
[--sort-dir <direction>]
|
||||
|
||||
List information on retrieved scoring engines.
|
||||
|
||||
@@ -881,10 +864,6 @@ List information on retrieved scoring engines.
|
||||
``--sort-dir <direction>``
|
||||
Sort direction: "asc" (the default) or "desc".
|
||||
|
||||
``--marker <marker>``
|
||||
UUID of the last scoringengine in the previous page; displays
|
||||
list of scoringengines after "marker".
|
||||
|
||||
.. _watcher_scoringengine_show:
|
||||
|
||||
watcher scoringengine show
|
||||
@@ -982,7 +961,6 @@ watcher strategy list
|
||||
[--quote {all,minimal,none,nonnumeric}]
|
||||
[--goal <goal>] [--detail] [--limit <limit>]
|
||||
[--sort-key <field>] [--sort-dir <direction>]
|
||||
[--marker <marker>]
|
||||
|
||||
List information on retrieved strategies.
|
||||
|
||||
@@ -1008,10 +986,6 @@ List information on retrieved strategies.
|
||||
``--sort-dir <direction>``
|
||||
Sort direction: "asc" (the default) or "desc".
|
||||
|
||||
``--marker <marker>``
|
||||
UUID of the last strategy in the previous page; displays
|
||||
list of strategies after "marker".
|
||||
|
||||
.. _watcher_strategy_show:
|
||||
|
||||
watcher strategy show
|
||||
@@ -1036,28 +1010,3 @@ Show detailed information about a given strategy.
|
||||
``-h, --help``
|
||||
show this help message and exit
|
||||
|
||||
.. _watcher_strategy_state:
|
||||
|
||||
watcher strategy state
|
||||
----------------------
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
usage: watcher strategy state [-h] [-f {csv,html,json,table,value,yaml}]
|
||||
[-c COLUMN] [--max-width <integer>]
|
||||
[--fit-width] [--print-empty] [--noindent]
|
||||
[--quote {all,minimal,none,nonnumeric}]
|
||||
[--sort-column SORT_COLUMN]
|
||||
<strategy>
|
||||
|
||||
Retrieve information about strategy requirements.
|
||||
|
||||
**Positional arguments:**
|
||||
|
||||
``<strategy>``
|
||||
Name of the strategy
|
||||
|
||||
**Optional arguments:**
|
||||
|
||||
``-h, --help``
|
||||
show this help message and exit
|
||||
|
||||
@@ -79,9 +79,10 @@ six==1.11.0
|
||||
snowballstemmer==1.2.1
|
||||
Sphinx==1.6.5
|
||||
sphinxcontrib-websupport==1.0.1
|
||||
stestr==2.0.0
|
||||
stestr==1.0.0
|
||||
stevedore==1.28.0
|
||||
tempest==17.1.0
|
||||
testrepository==0.0.18
|
||||
testscenarios==0.4
|
||||
testtools==2.2.0
|
||||
traceback2==1.4.0
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
Babel!=2.4.0,>=2.5.3 # BSD
|
||||
cliff!=2.9.0,>=2.11.0 # Apache-2.0
|
||||
osc-lib>=1.10.0 # Apache-2.0
|
||||
oslo.i18n>=3.20.0 # Apache-2.0
|
||||
oslo.utils>=3.36.0 # Apache-2.0
|
||||
pbr!=2.1.0,>=3.1.1 # Apache-2.0
|
||||
PrettyTable<0.8,>=0.7.2 # BSD
|
||||
Babel!=2.4.0,>=2.3.4 # BSD
|
||||
cliff!=2.9.0,>=2.8.0 # Apache-2.0
|
||||
osc-lib>=1.8.0 # Apache-2.0
|
||||
oslo.i18n>=3.15.3 # Apache-2.0
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
PrettyTable<0.8,>=0.7.1 # BSD
|
||||
keystoneauth1>=3.4.0 # Apache-2.0
|
||||
six>=1.11.0 # MIT
|
||||
six>=1.10.0 # MIT
|
||||
PyYAML>=3.12 # MIT
|
||||
|
||||
@@ -9,8 +9,11 @@ mock>=2.0.0 # BSD
|
||||
openstackdocstheme>=1.18.1 # Apache-2.0
|
||||
oslotest>=3.2.0 # Apache-2.0
|
||||
python-subunit>=1.0.0 # Apache-2.0/BSD
|
||||
sphinx!=1.6.6,!=1.6.7,>=1.6.5 # BSD
|
||||
stestr>=2.0.0 # Apache-2.0
|
||||
sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD
|
||||
testrepository>=0.0.18 # Apache-2.0/BSD
|
||||
testscenarios>=0.4 # Apache-2.0/BSD
|
||||
testtools>=2.2.0 # MIT
|
||||
tempest>=17.1.0 # Apache-2.0
|
||||
|
||||
# Needed for pypi packaging
|
||||
wheel>=0.24.0 # MIT
|
||||
|
||||
20
tox.ini
20
tox.ini
@@ -6,14 +6,14 @@ skipsdist = True
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
install_command =
|
||||
constraints: pip install -U --force-reinstall -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||
constraints: pip install -U --force-reinstall -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/rocky} {opts} {packages}
|
||||
pip install -U {opts} {packages}
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
OS_TEST_PATH=./watcherclient/tests/unit
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = rm -f .testrepository/times.dbm
|
||||
stestr --test-path=./watcherclient/tests/unit run {posargs}
|
||||
stestr slowest
|
||||
python setup.py testr --slowest --testr-args='{posargs}'
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python3
|
||||
@@ -25,14 +25,9 @@ commands = {posargs}
|
||||
|
||||
[testenv:cover]
|
||||
basepython = python3
|
||||
setenv =
|
||||
PYTHON=coverage run --source watcherclient --parallel-mode
|
||||
commands =
|
||||
stestr run {posargs}
|
||||
coverage combine
|
||||
coverage html -d cover
|
||||
coverage xml -o cover/coverage.xml
|
||||
coverage report
|
||||
python setup.py testr --coverage --testr-args='{posargs}'
|
||||
coverage report
|
||||
|
||||
[testenv:docs]
|
||||
basepython = python3
|
||||
@@ -53,8 +48,9 @@ passenv =
|
||||
OS_AUTH_URL
|
||||
OS_IDENTITY_API_VERSION
|
||||
OS_IMAGE_API_VERSION
|
||||
commands = stestr --test-path=./watcherclient/tests/functional run --concurrency=1 {posargs}
|
||||
stestr slowest
|
||||
setenv =
|
||||
OS_TEST_PATH = ./watcherclient/tests/functional
|
||||
commands = python setup.py testr --slowest --testr-args='--concurrency=1 {posargs}'
|
||||
|
||||
[flake8]
|
||||
# E123, E125 skipped as they are invalid PEP-8.
|
||||
|
||||
@@ -354,15 +354,7 @@ class HTTPClient(VersionNegotiationMixin):
|
||||
# Read body into string if it isn't obviously image data
|
||||
body_str = None
|
||||
if resp.headers.get('Content-Type') != 'application/octet-stream':
|
||||
# decoding byte to string is necessary for Python 3 compatibility
|
||||
# this issues has not been found with Python 3 unit tests
|
||||
# because the test creates a fake http response of type str
|
||||
# the if statement satisfies test (str) and real (bytes) behavior
|
||||
body_list = [
|
||||
chunk.decode("utf-8") if isinstance(chunk, bytes)
|
||||
else chunk for chunk in body_iter
|
||||
]
|
||||
body_str = ''.join(body_list)
|
||||
body_str = ''.join([chunk for chunk in body_iter])
|
||||
self.log_http_response(resp, body_str)
|
||||
body_iter = six.StringIO(body_str)
|
||||
else:
|
||||
|
||||
@@ -47,6 +47,8 @@ _IDENTITY_API_VERSION_3 = ['3']
|
||||
class WatcherShell(app.App):
|
||||
"""Watcher command line interface."""
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.client = None
|
||||
|
||||
@@ -192,12 +194,12 @@ class WatcherShell(app.App):
|
||||
except Exception as e:
|
||||
if not logging.getLogger('').handlers:
|
||||
logging.basicConfig()
|
||||
LOG.error('Exception raised: %s', str(e))
|
||||
self.log.error('Exception raised: %s', str(e))
|
||||
|
||||
return ret_val
|
||||
|
||||
finally:
|
||||
LOG.info("END return value: %s", ret_val)
|
||||
self.log.info("END return value: %s", ret_val)
|
||||
|
||||
|
||||
def main(argv=sys.argv[1:]):
|
||||
|
||||
@@ -200,10 +200,19 @@ class CreateAudit(command.ShowOne):
|
||||
if k in field_list and v is not None)
|
||||
fields = common_utils.args_array_to_dict(fields, 'parameters')
|
||||
|
||||
if fields.get('goal'):
|
||||
if not uuidutils.is_uuid_like(fields['goal']):
|
||||
fields['goal'] = client.goal.get(fields['goal']).uuid
|
||||
|
||||
if fields.get('audit_template_uuid'):
|
||||
if not uuidutils.is_uuid_like(fields['audit_template_uuid']):
|
||||
fields['audit_template_uuid'] = client.audit_template.get(
|
||||
fields['audit_template_uuid']).uuid
|
||||
# optional
|
||||
if fields.get('strategy'):
|
||||
if not uuidutils.is_uuid_like(fields['strategy']):
|
||||
fields['strategy'] = client.strategy.get(
|
||||
fields['strategy']).uuid
|
||||
|
||||
audit = client.audit.create(**fields)
|
||||
if audit.strategy_name is None:
|
||||
|
||||
Reference in New Issue
Block a user