summaryrefslogtreecommitdiff
path: root/ceilometerclient/common/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* Drop use of 'oslo' namespace packageDoug Hellmann2015-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | The Oslo libraries have moved all of their code out of the 'oslo' namespace package into per-library packages. The namespace package was retained during kilo for backwards compatibility, but will be removed by the liberty-2 milestone. This change removes the use of the namespace package, replacing it with the new package names. The patches in the libraries will be put on hold until application patches have landed, or L2, whichever comes first. At that point, new versions of the libraries without namespace packages will be released as a major version update. Please merge this patch, or an equivalent, before L2 to avoid problems with those library releases. Blueprint: remove-namespace-packages https://blueprints.launchpad.net/oslo-incubator/+spec/remove-namespace-packages Change-Id: I1f539cf9f5d6f48e10cac381c13eeb5fa314abd4
* Use oslo_utils instead of deprecated oslo.utilsDina Belova2015-05-111-2/+2
| | | | Change-Id: Ie4c55f33d18294924701032031cf78539ee3b23b
* Support unicode for alarmZhiQiang Fan2015-02-061-2/+2
| | | | | | | | | | | | | | We're using ceilometer.common.utils.print_dict() for displaying alarm, but assume only contain ascii characters, which will cause UnicodeEncodeError when alarm's name or description has unicode characters. The oslo-incubator.cliutils.print_dict() is more friendly to unicode, but it has no sort option, and has different line wrap strategy. Since the upstream improvement can be low progress, this patch adds unicode support based on current code. Change-Id: Ia58d5813c6f80cb8b44bf7636e1efc0cdd6e6d5b Closes-Bug: #1412300
* Add Sample API supportZhiQiang Fan2015-02-051-1/+2
| | | | | | | | | | Sample API has been implemented in Ceilometer for a long time, but CLI is lack of such support, this patch implements Sample CLI. Implements blueprint cli-samples-api Change-Id: I67152c636526dad3ec27e06058ff73ad969ae2b9 DocImpact
* Allow all pep8 checksDina Belova2015-01-121-2/+1
| | | | | | | Fix H405 pep8 issue. H904 issue check was ignored, although there were no places in client code violating this rule. Change-Id: If3b84eb8abb03511d7f77cabfa2955f472a60f23
* Alarm TimeConstraint display incorrectRohit Jaiswal2014-11-251-4/+6
| | | | | | | Added test case for print_dict function Change-Id: I3ab8a4e25f946b409ede2a598a5b9cf8593a044e Closes-Bug: #1395110
* switch to oslo.utilsgordon chung2014-09-291-12/+11
| | | | | | | oslo.utils is released and corresponding code in oslo-incubator has been removed. Change-Id: Ic3a13380809a8b00c979e5ac405b4084f486a31d
* Fix hacking rules: H302,H305,H307,H402ZhiQiang Fan2014-06-111-1/+2
| | | | | | | | | | Currently, OpenStack Proposal Bot tries to update requirements with global requirements, while the upgraded hacking has introduced some new rules which are not fully handled by current code. This patch fixes some simple rules which are quite straight-forward. Change-Id: If8334f69fb1ad34fbbd6ad898e0e92eb3f81e95a
* Fix exception handling of CLIliu-sheng2014-05-231-3/+3
| | | | | | | | | | | Because exc.Unauthorized exception has been removed for commit "Remove out-dated exceptions"(https://review.openstack.org/#/c/93852/). but it still in use in ceilometerclient.shell.CeilometerShell#main(). This patch replace exc.Unauthorized with exc.HTTPUnauthorized. And other three places of exc.NotFound are in use too. Change-Id: I3e010db20cb6f6636126cceed5c62a9817213739 Closes-bug: #1321649
* Adds alarm time constraint support to ceilometer CLIUros Jovanovic2014-03-261-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Time constraints can be specified for create and update families of commands with the following format: --time-constraint name=constraint1;start='0 11 * * *';duration=300 This switch can be specified multiple times in the case of multiple time constraints. With update commands, time constraints are updated by name, e.g. --time-constraint name=constraint1;duration=500 updates the constraint 'constraint1' with a new duration 500. Time constraints can be removed with update commands using the switch --remove-time-constraint=constraint1,constraint2 . Example of display outputs: > ceilometer alarm-list +--------------------------------------+-------+-------------------+---------+------------+----------------------------+--------------------------------------------------------------+ | Alarm ID | Name | State | Enabled | Continuous | Alarm condition | Time constraints | +--------------------------------------+-------+-------------------+---------+------------+----------------------------+--------------------------------------------------------------+ | 2ead776d-2fc7-47a2-b0bb-0f88dcefa457 | test2 | insufficient data | True | False | cpu == 50.0 during 1 x 60s | cons1 at 0 11 * * * for 300s, cons2 at 0 23 * * * for 600s | +--------------------------------------+-------+-------------------+---------+------------+----------------------------+--------------------------------------------------------------+ > ceilometer alarm-show -a +---------------------------+-----------------------------------------------------------------------+ | Property | Value | +---------------------------+-----------------------------------------------------------------------+ | alarm_actions | [] | | alarm_id | 2ead776d-2fc7-47a2-b0bb-0f88dcefa457 | | comparison_operator | eq | | description | Alarm when cpu is eq a avg of 50.0 over 60 seconds | | enabled | True | | evaluation_periods | 1 | | exclude_outliers | False | | insufficient_data_actions | [] | | meter_name | cpu | | name | test2 | | ok_actions | [] | | period | 60 | | project_id | 962f75ad22c24cbf99d40d7b82718505 | | query | | | repeat_actions | False | | state | insufficient data | | statistic | avg | | threshold | 50.0 | | time_constraints | [{name: cons1, | | | description: Time constraint at 0 11 * * * lasting for 300 seconds, | | | start: 0 11 * * *, | | | duration: 300}, | | | {name: cons2, | | | description: Time constraint at 0 23 * * * lasting for 600 seconds, | | | start: 0 23 * * *, | | | duration: 600}] | | type | threshold | | user_id | 76f335df8e2f4c7e9e8185e26ea85759 | +---------------------------+-----------------------------------------------------------------------+ > ceilometer alarm-history -a 2ead776d-2fc7-47a2-b0bb-0f88dcefa457 +----------+----------------------------+--------------------------------------------------------------------------------+ | Type | Timestamp | Detail | +----------+----------------------------+--------------------------------------------------------------------------------+ | creation | 2014-03-06T07:41:35.362050 | name: test2 | | | | description: Alarm when cpu is eq a avg of 50.0 over 60 seconds | | | | type: threshold | | | | rule: cpu == 50.0 during 1 x 60s | | | | time_constraints: cons1 at 0 11 * * * for 300s, cons2 at 0 23 * * * for 600s | +----------+----------------------------+--------------------------------------------------------------------------------+ Change-Id: I3953276537b4526e46e5e6d229d6fa154f8ab0fc Closes-Bug: #1288246
* Python 3: fix format_nested_list_of_dict()Cyril Roelandt2014-02-101-1/+1
| | | | | | | | In this function, we mean to add actual values, not a map object. In Python 2, map() did not return a map object, so this worked as expected, but not in Python3. Change-Id: Icc6467b7846d62c189765fdfd9dce1e30db7eb55
* Merge "Update client to display data type of traits"Jenkins2014-01-281-6/+8
|\
| * Update client to display data type of traitsJohn Herndon2014-01-241-6/+8
| | | | | | | | | | | | fixes bug 1268032 Change-Id: I47dfd3208fb3f7e5e5e2b33bd9b00c688d8283cd
* | Using common methods from oslo cliutilsJia Dong2014-01-241-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | There are some common methods in cliutils we can use in ceilometerclient: arg, env, unauthenticated, isunauthenticated. + Replaces utils.env to add alias env from cliutils. + Removes unused methods in utils: env To use methods from clituils. partially implements blueprint common-client-library-2 Change-Id: I295cc80635ed15c91e2832acb315e9deede09516
* | Using common method 'bool_from_string' from oslo strutilsllg82122014-01-221-4/+0
|/ | | | | | | | | Using common method 'bool_from_string' from oslo strutils to replace utils.string_to_bool. partially implements blueprint common-client-library-2 Change-Id: I101eb89174ac229aa1025bc4aea8b1c0c5594705
* Support the Event APIJohn Herndon2014-01-101-0/+15
| | | | | | | | | | | | This patch adds support for the currently available Event API, including events, event types, and traits. Add an optional data type to the query, ex: ceilometer list-events -q 'hostname=string::localhost" bp extend-client-operations Change-Id: Icea9bd67f8ee4ff2bf9da9ff6894218689580eb3
* Python 3: use six.moves.zip() rather than itertools.izip()Cyril Roelandt2013-12-191-2/+1
| | | | | | This ensures compatibility with both Python 2 and Python 3. Change-Id: Id9838b7517f939e5ee3e3a8c37ae5ec2e9b1d18b
* Ceilometer UnicodeEncodeError when update or show alarm fixChenZheng2013-10-301-0/+3
| | | | | | | | | | Fix display bug in ceilometer alarm-update ceilometer alarm-show when encounter a alarm with not unicode attributes. Change-Id: I0af0f1d6b8393c7117eb5b56fba3d5e1f4935ff1 Closes-bug: #1245317
* Fix order of sample listfujioka yuuichi2013-10-281-13/+15
| | | | | | | | | | | Samples of "ceilometer sample-list" are sorted by Resource ID and Volume. Expected order is Timestamp. This pache fixes this problem. Change-Id: I338014e5868b2176a3afd549e13d0dd6118b3ac1 Closes-Bug: #1227495
* align the order of parameters for urlencode()Kui Shi2013-10-151-1/+1
| | | | | | | | | | | | | | | | | In Python 3.3, hash randomization is enabled by default. It causes the iteration order of dicts and sets to be unpredictable and differ across Python runs. In the test case, the fixed expecting string will not match the test result, it is relying on the dict order. This change transforms the input dict to a sequence of two-element list, with fixed order, and update the related expecitng string / fixture in test cases. Partial Implement: blueprint py33-support Change-Id: I6dccde9e584be8335a6375f5fbad5c5cbd7b9b6d
* replace basetring/xrangeKui Shi2013-10-141-1/+1
| | | | | | | | | basetring --> six.string_types xrange --> six.moves.xrange Partial Implement: blueprint py33-support Change-Id: Iedc2cd66ec65c0e4685e56a3bfbf8e9d38fd0072
* replace dict.keys() with list(dict)Kui Shi2013-10-141-1/+1
| | | | | | Partial Implement: blueprint py33-support Change-Id: I774e5a25d25ef19ffc217910987f2c9b68d13cd3
* Use six.iteritems() for dictKui Shi2013-10-141-2/+3
| | | | | | | | | Fix the error: AttributeError: 'dict' object has no attribute 'iteritems' Partial Implement: blueprint py33-support Change-Id: I5dff17d1df01d6583f882f818434804d65726c51
* Translate print statement to print functionKui Shi2013-10-141-3/+4
| | | | | | | | | Use "from __future__ import print_function" docs.python.org/3/howto/pyporting.html#from-future-import-print-function Partial Implement: blueprint py33-support Change-Id: I92fc07257851795a9972c8273d3278c8679d6628
* Allow to update an alarm partiallyMehdi Abaakouk2013-10-011-0/+9
| | | | | | | | | | | | | The patch allow to only modify a part of an alarm instead of force to set the full alarm description. This permit to an application that have been written code around alarm with ceilometerclient 1.0.4 and ceilometer pre havana-3. To update alarm without any change with this and ceilometer >= havana-3 (ie: heat). Fixes bug #1231303 Change-Id: I20250131d05d20bfadbca450dfe6b8237f4b7183
* Help messages: specify which options are requiredCyril Roelandt2013-09-251-0/+7
| | | | | | Closes-Bug: #1223283 Change-Id: I080fa73bd45a1f9f442dbcdfa65fdc24e30521da
* Improve the CM shell client alarm visualisationMehdi Abaakouk2013-09-251-2/+4
| | | | | | | | | | | | | | | | | | | This change aim to get a better alarm representation in shell. In alarm-list: * it add a short sentence to describe the alarm rule * it remove project_id/user_id because it always show the same id for all alarm for end-user In alarm-show, it show alarm rule attributes as alarm properties instead of a unparsable json in the rule property. example of short sentence for column 'Alarm condition': * combinated states (AND) of 8babd6a2-c457-42d0-9eb5-cdfb3cb50203, d0e11a94-8f59-48a9-8f6d-b0d68aaac8d0 * cpu_util >= 50.0 during 1 x 60s Change-Id: If4df2dc08f9f4cb7796fd98308c7d62e311d1138
* Merge "Replace OpenStack LLC with OpenStack Foundation"Jenkins2013-09-231-1/+1
|\
| * Replace OpenStack LLC with OpenStack FoundationZhiQiang Fan2013-09-201-1/+1
| | | | | | | | | | Change-Id: Ia007da282714d8ee7337fd3b51f6dcc3b64d7ec3 Fixes-Bug: #1214176
* | Use the new alarm formatMehdi Abaakouk2013-09-201-0/+11
|/ | | | | | | | | | | The change sync the client API with the new alarm type and keep compatibility with the previous format of the alarm. It allows to create the new type of alarm: combination alarm. Implements blueprint alarming-logical-combination Change-Id: Ie62265023cadc20cf36a0d0b3775f4d984e324cf
* Allow to set matching_metadata with the cli1.0.2Mehdi Abaakouk2013-07-221-0/+13
| | | | | | | | | | | This change allows to set the matching_metadata of a alarm like this: ceilometer alarm-create --matching-metadata 'key=value' \ --matching-metadata 'key2=value2' --name 'alarm' ... Fixes bug #1201877 Change-Id: I22bf261b0a9580a06ae107ed45d082171f21fcc4
* Fix pep H306 (import order)Angus Salkeld2013-05-201-2/+0
| | | | | | | | Also remove some unused imports This is an effort to get the pep ignores to be closer to nova. Change-Id: I35612de45084fac0ae1c96dad84bb23cfade0e4f
* Restore compatibility with PrettyTable < 0.7.2Dirk Mueller2013-04-291-2/+4
| | | | | | | | PrettyTable 0.7.2 changed the default to print also tables when the result set is empty. Revert to previous default. Change-Id: I22ab7522227ef70929d31dd2c4aaff93c4c518c2
* v2 API: added resource-show.Lianhao Lu2013-03-291-9/+20
| | | | | | | | Added resource-show command for v2 API. blueprint more-cli-cmd. Change-Id: I9e0dcff63b2ac6650094d47a947a2deaaea2ba4d
* Add basic functionalityAngus Salkeld2012-11-091-0/+122
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>