Compare commits

...

22 Commits
2.1.1 ... 2.2.0

Author SHA1 Message Date
Alexander Chadin
db7a5e4bc9 Allow CLI to pass goal and strategy names
This patch set removes additional type verification
for goal and strategy entities to let CLI pass goal
and strategy names straight to API.

Depends-On: I89a9c7661616f49639151869055d8f5ebe723d5f
Change-Id: I323a66dd5bdef6f33d5fd5c60c99e1b4dcd7a7e0
Closes-Bug: #1794233
2018-10-02 13:58:48 +03:00
Andreas Jaeger
825e5cb081 Use templates lower-constraints, remove cover
Use openstack-lower-constraints-jobs template

Remove jobs that are part of the templates.

Remove cover job, this one is not working at all and always fails. If
anybody wants to enable it again, they can add the openstack-cover-jobs
template and fix it - I couldn't find an easy way to fix it without
knowledge of this repo.

Change-Id: I3b50c8384507d22339ed11f556dbe32181fe0518
2018-09-08 15:40:46 +02:00
Zuul
a8185c7067 Merge "add python 3.6 unit test job" 2018-09-03 10:26:54 +00:00
Zuul
4a0b0e76b4 Merge "switch documentation job to new PTI" 2018-09-03 10:26:53 +00:00
Zuul
1918d3f26b Merge "import zuul job settings from project-config" 2018-08-28 07:52:55 +00:00
Zuul
2ca6b6b421 Merge "Switch to stestr" 2018-08-28 02:42:24 +00:00
zhangyangyang
1086b23454 Switch to stestr
According to Openstack summit session [1],
stestr is maintained project to which all Openstack projects should migrate.
Let's switch to stestr as other projects have already moved to it.

[1] https://etherpad.openstack.org/p/YVR-python-pti

Change-Id: Ie5133b8e627f762402df38969aee15f48d192520
2018-08-20 11:08:43 +08:00
Nguyen Hai
535b9da7d2 add python 3.6 unit test job
This is a mechanically generated patch to add a unit test job running
under Python 3.6 as part of the python3-first goal.

See the python3-first goal document for details:
https://governance.openstack.org/tc/goals/stein/python3-first.html

Change-Id: I5f1f5655c5a4ea9dfbfba1397ad0207fbdf53c58
Story: #2002586
Task: #24344
2018-08-19 00:58:24 +09:00
Nguyen Hai
34a4ad3041 switch documentation job to new PTI
This is a mechanically generated patch to switch the documentation
jobs to use the new PTI versions of the jobs as part of the
python3-first goal.

See the python3-first goal document for details:
https://governance.openstack.org/tc/goals/stein/python3-first.html

Change-Id: Ia23c18578c4fa2854ed706a96b79f700bd751c43
Story: #2002586
Task: #24344
2018-08-19 00:58:23 +09:00
Nguyen Hai
39d4c1e944 import zuul job settings from project-config
This is a mechanically generated patch to complete step 1 of moving
the zuul job settings out of project-config and into each project
repository.

Because there will be a separate patch on each branch, the branch
specifiers for branch-specific jobs have been removed.

Because this patch is generated by a script, there may be some
cosmetic changes to the layout of the YAML file(s) as the contents are
normalized.

See the python3-first goal document for details:
https://governance.openstack.org/tc/goals/stein/python3-first.html

Change-Id: I05e014be3cdc08d35d3a1efef6fae418bd4511c8
Story: #2002586
Task: #24344
2018-08-19 00:57:31 +09:00
Alexander Chadin
c1fd569b76 fix watcher actionplan show command
This patch set is intended for Python 3.x support and replace
itervalues() method with values().

Change-Id: I6852239d2d6634a4304c87a1694e64479f560de1
Closes-Bug: #1786784
2018-08-13 17:31:02 +03:00
Zuul
eed22ea2bb Merge "Add audit name to CLI help doc" 2018-08-03 08:03:15 +00:00
Zuul
47241e0462 Merge "Add --marker help info" 2018-08-03 01:47:22 +00:00
Zuul
88d122a21f Merge "Update watcher strategy state in CLI" 2018-08-03 01:46:51 +00:00
Yumeng Bao
5e928b80be Update watcher strategy state in CLI
Change-Id: Ie77336207c9affcf2c9a0ef0247cf5adef38c87f
2018-08-02 05:40:55 +00:00
Yumeng Bao
723ad12afa Add --marker help info
Change-Id: Ia132e45d7f9665a386d1e40360a75c4234aecc7d
2018-08-02 11:12:33 +08:00
chenke
3926dcc541 Organize the use of 'log' and replace 'log' with LOG
Change-Id: I42ddf63dd73559e43efce401f3912c4b9413a6d4
2018-07-31 11:25:25 +08:00
Zuul
c557e45ae2 Merge "Add --marker help info" 2018-07-30 07:34:55 +00:00
Zuul
0b8dba2cb9 Merge "Fix watherclient error in py3" 2018-07-27 09:27:56 +00:00
licanwei
496f4c1365 Add audit name to CLI help doc
Change-Id: I9749bb679d66a65de3d4abe3564109bf4a8f8ccd
2018-07-26 18:36:09 -07:00
zhurong
2551ff0934 Fix watherclient error in py3
watchercliet will raise error:
Recoverable error: sequence item 0: expected str instance, bytes found

This patch fix this.

Change-Id: I6fe21766f320b0a09a14202203a5d0451175e1d3
2018-07-26 11:37:35 +08:00
licanwei
adc812746c Add --marker help info
Change-Id: I34c1a83f49b101d5ef85e1a19858b9d2b59c921d
2018-07-22 23:20:29 -07:00
13 changed files with 104 additions and 60 deletions

2
.gitignore vendored
View File

@@ -26,7 +26,7 @@ pip-log.txt
.coverage
.tox
nosetests.xml
.testrepository
.stestr/
.venv
# Translations

View File

@@ -1,3 +1,3 @@
[DEFAULT]
test_path=${OS_TEST_PATH:-./watcherclient/tests/functional}
top_dir=./
test_path=./watcherclient/tests/functional
top_dir=./

View File

@@ -1,7 +0,0 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-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

View File

@@ -1,9 +1,13 @@
- project:
templates:
- openstack-lower-constraints-jobs
- openstack-python-jobs
- openstack-python35-jobs
- openstack-python36-jobs
- publish-openstack-docs-pti
- check-requirements
- openstackclient-plugin-jobs
check:
jobs:
- watcherclient-tempest-functional:
voting: false
- openstack-tox-lower-constraints
gate:
jobs:
- openstack-tox-lower-constraints

View File

@@ -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>]
[--sort-dir <direction>] [--marker <marker>]
List information on retrieved actions.
@@ -186,6 +186,10 @@ 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
@@ -295,7 +299,8 @@ watcher actionplan list
[--fit-width] [--print-empty] [--noindent]
[--quote {all,minimal,none,nonnumeric}]
[--audit <audit>] [--detail] [--limit <limit>]
[--sort-key <field>] [--sort-dir <direction>]
[--marker <actionplan>] [--sort-key <field>]
[--sort-dir <direction>]
List information on retrieved action plans.
@@ -315,6 +320,10 @@ 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.
@@ -466,7 +475,7 @@ Delete audit command.
**Positional arguments:**
``<audit>``
UUID of the audit
UUID or name of the audit
**Optional arguments:**
@@ -532,7 +541,7 @@ Show detailed information about a given audit.
**Positional arguments:**
``<audit>``
UUID of the audit
UUID or name of the audit
**Optional arguments:**
@@ -556,7 +565,7 @@ Update audit command.
**Positional arguments:**
``<audit>``
UUID of the audit.
UUID or name of the audit.
``<op>``
Operation: 'add', 'replace', or 'remove'.
@@ -680,7 +689,7 @@ watcher audittemplate list
[--detail] [--goal <goal>]
[--strategy <strategy>] [--limit <limit>]
[--sort-key <field>]
[--sort-dir <direction>]
[--sort-dir <direction>][--marker <marker>]
List information on retrieved audit templates.
@@ -709,6 +718,10 @@ 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
@@ -781,7 +794,7 @@ watcher goal list
[--print-empty] [--noindent]
[--quote {all,minimal,none,nonnumeric}] [--detail]
[--limit <limit>] [--sort-key <field>]
[--sort-dir <direction>]
[--sort-dir <direction>][--marker <marker>]
List information on retrieved goals.
@@ -804,6 +817,10 @@ 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
@@ -841,7 +858,7 @@ watcher scoringengine list
[--quote {all,minimal,none,nonnumeric}]
[--detail] [--limit <limit>]
[--sort-key <field>]
[--sort-dir <direction>]
[--sort-dir <direction>][--marker <marker>]
List information on retrieved scoring engines.
@@ -864,6 +881,10 @@ 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
@@ -961,6 +982,7 @@ 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.
@@ -986,6 +1008,10 @@ 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
@@ -1010,3 +1036,28 @@ 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

View File

@@ -69,7 +69,6 @@ pyperclip==1.6.0
python-dateutil==2.5.3
python-mimeparse==1.6.0
python-subunit==1.0.0
-e git://git.openstack.org/openstack/python-watcherclient@104894958882a4877dad6f469361d2adb41d0b59#egg=python_watcherclient
pytz==2018.3
PyYAML==3.12
requests==2.18.4
@@ -80,10 +79,9 @@ six==1.11.0
snowballstemmer==1.2.1
Sphinx==1.6.5
sphinxcontrib-websupport==1.0.1
stestr==1.0.0
stestr==2.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

View File

@@ -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.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
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
keystoneauth1>=3.4.0 # Apache-2.0
six>=1.10.0 # MIT
six>=1.11.0 # MIT
PyYAML>=3.12 # MIT

View File

@@ -9,11 +9,8 @@ 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.2 # BSD
testrepository>=0.0.18 # Apache-2.0/BSD
sphinx!=1.6.6,!=1.6.7,>=1.6.5 # BSD
stestr>=2.0.0 # Apache-2.0
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

18
tox.ini
View File

@@ -10,10 +10,10 @@ install_command =
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
python setup.py testr --slowest --testr-args='{posargs}'
stestr --test-path=./watcherclient/tests/unit run {posargs}
stestr slowest
[testenv:pep8]
basepython = python3
@@ -25,9 +25,14 @@ commands = {posargs}
[testenv:cover]
basepython = python3
setenv =
PYTHON=coverage run --source watcherclient --parallel-mode
commands =
python setup.py testr --coverage --testr-args='{posargs}'
coverage report
stestr run {posargs}
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
coverage report
[testenv:docs]
basepython = python3
@@ -48,9 +53,8 @@ passenv =
OS_AUTH_URL
OS_IDENTITY_API_VERSION
OS_IMAGE_API_VERSION
setenv =
OS_TEST_PATH = ./watcherclient/tests/functional
commands = python setup.py testr --slowest --testr-args='--concurrency=1 {posargs}'
commands = stestr --test-path=./watcherclient/tests/functional run --concurrency=1 {posargs}
stestr slowest
[flake8]
# E123, E125 skipped as they are invalid PEP-8.

View File

@@ -354,7 +354,15 @@ 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':
body_str = ''.join([chunk for chunk in body_iter])
# 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)
self.log_http_response(resp, body_str)
body_iter = six.StringIO(body_str)
else:

View File

@@ -47,8 +47,6 @@ _IDENTITY_API_VERSION_3 = ['3']
class WatcherShell(app.App):
"""Watcher command line interface."""
log = logging.getLogger(__name__)
def __init__(self, **kwargs):
self.client = None
@@ -194,12 +192,12 @@ class WatcherShell(app.App):
except Exception as e:
if not logging.getLogger('').handlers:
logging.basicConfig()
self.log.error('Exception raised: %s', str(e))
LOG.error('Exception raised: %s', str(e))
return ret_val
finally:
self.log.info("END return value: %s", ret_val)
LOG.info("END return value: %s", ret_val)
def main(argv=sys.argv[1:]):

View File

@@ -70,7 +70,7 @@ class ShowActionPlan(command.ShowOne):
yaml_format.YAMLFormatter().emit_one(
column_names=list(resource.capitalize()
for resource in formatted_global_efficacy),
data=[value for value in formatted_global_efficacy.itervalues()],
data=[value for value in formatted_global_efficacy.values()],
stdout=out,
parsed_args=parsed_args,
)

View File

@@ -200,19 +200,10 @@ 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: