118 Commits

Author SHA1 Message Date
Zuul
dea9c3043a Merge "Use v2 API by default" 2025-12-09 14:42:16 +00:00
Juan Larriba
2d965f9459 Use v2 API by default
CloudKitty's v1 API has been deprecated for a while, but the CLI
continued to use that as a default, keeping v2 as optional. This patch
changes that behaviour, switching to use the more modern and currently
maintained v2 as default, while v1 is still available via the
--os-rating-api-version parameter.

Change-Id: I4ca8c4f69b022af53d9f7ec71f3a2efadfc9163e
Signed-off-by: Juan Larriba <jlarriba@redhat.com>
2025-12-09 12:57:43 +01:00
Zuul
a41e96b0e3 Merge "Replace os-client-config" 2025-12-08 16:24:58 +00:00
Pedro Henrique
f8da9dab78 Add support to rating rules with start and end
It was introduced the concept of start and end periods in
Cloudkitty rating rules. Therefore to make Cloudkitty CLI
compatible with the Cloudkitty REST API, we need to add
those new available attributes in the CLI as well.

Change-Id: I0cd9b61fa81232d235c959da551a7840465fae88
Signed-off-by: Pedro Henrique <phpm13@gmail.com>
2025-09-02 12:22:05 -03:00
Takashi Kajinami
2240208aa5 Replace os-client-config
It was deprecated[1] after the code was merged into openstacksdk[2].

[1] https://review.opendev.org/c/openstack/os-client-config/+/549307
[2] https://review.opendev.org/c/openstack/openstacksdk/+/518128

Change-Id: I47f1ebf037d2e93bf8901d1c9e21b75532c93918
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
2025-07-01 01:16:40 +09:00
Zuul
8e6f9aee06 Merge "Replace distutils" 2024-10-14 15:18:32 +00:00
Takashi Kajinami
ca7a0b1be2 Replace distutils
distutils was deprecated in Python 3.10 and was removed in Python
3.12 [1].

[1] https://docs.python.org//3.10/library/distutils.html

Change-Id: Iade3ecba97cb35f0afcb8e9fbde8dd1095b6fb47
2024-10-02 23:37:11 +09:00
Takashi Kajinami
247b3ee51d Remove logic for Python < 3
... because Python 2 support was removed long ago.

Change-Id: I5ac3c2d3d41651274abc98435180efadad3dffd1
2024-09-03 16:34:53 +09:00
Zuul
79a4606ce2 Merge "add group by time help to CLI" 2024-06-26 12:16:31 +00:00
Matt Crees
6ee36ef0e3 Fix reprocessing POST request
The POST request for triggering reprocessing needs to be made to
``/v2/task/reprocesses``. This is the same as for other requests, so we
can drop ``url_for_post``.

Change-Id: If630d4f313c875733dbe1937ff7ca625821e04af
2024-04-23 17:01:09 +01:00
Rafael Weingärtner
98c13304bd add group by time help to CLI
Change-Id: I2176ab207f94b6f986ebc32371f85c47b097a116
2024-04-11 09:41:40 -03:00
Rafael Weingärtner
244f229af7 Fix passenv declaration in tox.ini and function tests python env
While running the tests with the latest tox I was getting the following error message:
```
failed with pass_env values cannot contain whitespace, use comma to have multiple values in a single line'

```

That error is happening because of the passenv declaration. This patch is proposing a fix for that.

Besides the `tox` issue, we also needed to create a patch for the use of virtual env inside DevStack.
This patches presents a solution to run tests using the virtual env of DevStack.

Change-Id: Id8249ebb15d4047dcc6181908eae66eb39722863
2023-08-31 20:18:31 -03:00
Zuul
6bd44e7413 Merge "Introduce reprocessing task API in the CLI" 2022-08-08 15:20:10 +00:00
Rafael Weingärtner
187b0ce70c Introduce the patch scope API in the CLI
Change-Id: I8134020c409bc6c3e80bf996890e6609e1a763b9
2022-08-08 10:49:42 -03:00
Rafael Weingärtner
277b47779f Introduce reprocessing task API in the CLI
Change-Id: Ieab5df4deb9cbf5eddfc8eca3b028942f6303abd
2022-08-08 10:46:50 -03:00
Sam Morrison
783cc22662 Add response_format to list of available args for v2 summary API
This was added in cloudkitty with commit
6ba9d45ea6

Change-Id: Id091ee9f61c2863ed3ea1aaf5d967edf417df22a
2022-02-11 13:16:01 +11:00
wu.shiming
64ab6b412a Replace deprecated assertRaisesRegexp
The assertRaisesRegexp method has been deprecated since it was renamed
to assertRaisesRegex in Python 3.2.

https://docs.python.org/3/library/unittest.html#deprecated-aliases

Change-Id: Ibab4d14764372298cc0055f168ff44eabdc873f0
2021-11-09 09:04:34 +08:00
wu.shiming
647f561532 Replace deprecated import of ABCs from collections
ABCs in collections should be imported from collections.abc and direct
import from collections is deprecated since Python 3.3.

Change-Id: I871810bbe95a3cd10f8a8df42c99e747a6dd463b
2021-08-13 17:15:35 +08:00
Pierre Riteau
61ef2c337e Fix creation of hashmap mapping with a zero cost
A cost of 0.0 was interpreted as a False value, making the check think
the cost argument was missing.

Change-Id: I5f86540221b80667fc63b8b54659092c637b7353
Story: 2009047
Task: 42814
2021-07-12 19:31:06 +02:00
Rafael Weingärtner
a15f11a7d2 Fix create_threshold method when using cost as 0
When using 0 as the cost, the `create_threshold` method
throws an exception. That happens because 0 (zero) is evaluated
to False. Therefore, we need to change the validation method to
check if the values are None.

Change-Id: Iedd541c0ad16db0d11d6e6de332eddf880af1698
2020-12-11 10:25:10 -03:00
Justin Ferrieu
2a3dd279dc Add support for GET /v2/dataframes API endpoint to the client
Support for the ``GET /v2/dataframes`` endpoint has been added
to the client. A new ``dataframes get`` CLI command is also available.

Story: 2005890
Task: 36384
Depends-On: https://review.opendev.org/#/c/679636
Change-Id: Idfe93025e0f740906d0f53f33547c7746fc15169
2020-09-08 12:49:29 +00:00
Zuul
e9a6c22cef Merge "Remove six" 2020-08-31 17:58:31 +00:00
jacky06
61dc82cb54 Remove six
We don't need this in a Python 3-only world.

Change-Id: Ibeb506281e88b44d454497d06f9187308859ac9c
2020-05-10 23:08:12 +08:00
Sean McGinnis
e69f9d5452 Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I9bf0a8fbb7b4f22aa2f5b5ed0836d11cac27552b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 11:57:46 -05:00
Zuul
f4b1a3f224 Merge "Add support for v2/rating/modules endpoints" 2020-02-10 10:16:26 +00:00
Luka Peschke
9c3bd770f2 Fix tox environments
Work items:

* Removed the globale-requirements constraint. Since python-cloudkittyclient
  is now part of the global requirements, the upstream requirements
  file can't be used anymore.

* Add cliff to docs requirements.

* Change cloudkittyclient namespace names: Having a dot in a namespace
  name causes the "autoprogram-cliff" to use the "application mode".

Change-Id: I8020d816b3397550fbcbd42cc14a9861bca7ae80
2019-12-17 15:10:17 +01:00
Luka Peschke
d28c5bc4dd Improve HTTP error formatting
This improves formatting for HTTP errors. keystoneauth's HttpErrors
are now caught an re-formatted to include the body of the http response.

Work items:

* Introduce the "http_error_formatter" function decorator, which catches
  an re-formats keystoneauths HttpErrors.

* Introduce the "format_http_errors" class decorator, which applies the
  "http_error_formatter" to all functions of a class.

* Add an "HttpDecoratorMeta" to the "BaseManager" class. This will decorate
  all functions of classes inheriting from "BaseManager" with the
  "http_error_formatter" decorator.

Change-Id: I6735f1fa8d876a87e2b7d4aaa533d5a32b085735
2019-11-28 11:52:40 +01:00
Luka Peschke
584046761a Adapt functional tests to python3
A test looking for a regex in an argparse error message is failing when ran
on python3. Since this is now the default python runtime for devstack-based
jobs, this updates the message.

Change-Id: Id3372998715f13f7641d11a4a1d9d16629acfd18
Story: 2006896
Task: 37530
2019-11-18 10:28:23 +01:00
Quentin Anglade
e599ac9f84 Add support for v2/rating/modules endpoints
This adds support for the new v2 API rating modules endpoints. Unit tests included.

Change-Id: Ie116c518f30128b49c3991f36101db7535af7db1
Story: 2006572
Task: 36680
2019-09-30 16:36:16 +02:00
Justin Ferrieu
c8d7a9e1c5 Add support for POST /v2/dataframes API endpoint to the client
Support for the ``/v2/dataframes`` endpoint has been added to the client.
A new ``dataframes add`` CLI command is also available.

Change-Id: I7fe9072d7280f251edc865a653a0b9ed2ab26c90
Story: 2005890
Task: 35970
2019-08-27 11:50:32 +00:00
Justin Ferrieu
d660bef837 Add support for PUT /v2/scope API endpoint to the client
This allows to reset the state of one or several scopes through the API via
the client library and cli tool.

Change-Id: I69ce9a1c2ee0d8a6dd191a39e5c843e0baa1290f
Story: 2005395
Task: 30794
2019-07-22 11:42:15 +00:00
Luka Peschke
c138f409b1 Add support for /v2/summary to the client
This allows to get a summary through the v2 API endpoint via the client
library and cli tool.

Depends-On: https://review.opendev.org/#/c/660608/
Change-Id: Id63f2419fe3a1eb518a0ffa7ea5fa572b18df651
Story: 2005664
Task: 30960
2019-06-27 14:49:34 +00:00
Luka Peschke
7e7d25dd78 Add support for /v2/scope API endpoint to the client
This allows to retrieve the state of one or several scopes through the API via
the client library and cli tool.

Change-Id: I53995062fe76100f6dfcc672af482f653cc85bde
Story: 2005395
Task: 30795
Depends-On: https://review.opendev.org/#/c/658073/
2019-06-25 13:52:56 +00:00
Luka Peschke
d2fb83e64c Adapt the client for the v2 API
This adds a v2 client class allowing to add support for upcoming
v2 API endpoints. The v2 client class implements all v1 endpoints.
The cloudkitty API version can be specified with the
"--os-rating-api-version" option or the "OS_RATING_API_VERSION"
environment variable.

Change-Id: If38730da3baed59c93543a08f8a4989f919611db
2019-05-15 08:59:03 +00:00
Luka Peschke
de96c61985 Fix the rating.get_quotation method
This updates the rating.get_quotation method of the client. Tests on this
method have been added.

Depends-On: https://review.openstack.org/#/c/648062/
Change-Id: Ie2de0162311c2d162c1573042187ac4e628bd966
2019-03-28 14:57:44 +00:00
Luka Peschke
a7e687f740 Asserting 'summary get' returns nothing in functional tests
Since no data is available in devstack in our functional test environment,
we make the assertion that 'summary get' returns nothing. This is prone to
update if more complete test scenarios are implemented.

Change-Id: Ic80e39f0d2a75882762ebd6a0dba46033c9fd7f4
2019-03-28 13:41:45 +01:00
Luka Peschke
e9a92a2941 Fix "cloudkitty report tenant list" command
This fixes the "cloudkitty report tenant list": command, by transforming each
element of the list returned by CliTenantList's take_action method
into a tuple.

Change-Id: Iba1401b0cb4319a668d449139c8d20fc011cf178
Story: 2004149
Task: 27622
2018-10-23 11:27:13 +02:00
Zuul
a9eb87c436 Merge "Add `insecure and cacert` options to the client." 2018-09-07 10:00:10 +00:00
Luka Peschke
fff37a84fa Add `insecure and cacert` options to the client.
The client does support SSL authentication through keystoneauth right now. In
CLI mode, this is done through the "--os-cert" and "--os-cacert" options, or
through environment variables.

However, when the client is used as a python library,this is done through
requests' "verify" parameter, which is not very explicit.

This adds two parameters to the client

Change-Id: I68969c658724f53c85c47ab6098a3e2165f5925d
Story: 2003689
Task: 26224
2018-09-06 20:50:59 +02:00
Matthias Bastian
81cdcba4f3 Consider interface and region options with OSC
The --os-interface/OS_INTERFACE and --os-region-name/OS_REGION_NAME
options were considered by cloudkitty CLI but ignored when using the OSC
integration.

Change-Id: I36dc3616fba59c9b2e77da75abe0f76db7ddb7e4
2018-09-06 12:35:59 +02:00
Luka Peschke
d070f6a68c Rewrite of the client
The client has been completely rewritten in order to use cliff. The code
should be easier to maintain: authentication is now entirely handled by
keystoneauth, CloudKitty's client and CK's OSC plugin use the exact same
classes (no code duplication).

New features for users:

  * Client-side CSV report generation: It is possible for users to generate
    CSV reports with the new client. There is a default format, but reports
    may also be configured through a yaml config file. (see documentation)

  * The documentation has been improved. (A few examples on how to use the
    python library + complete API bindings and CLI reference).

  * It is now possible to use the client without Keystone authentication (this
    requires that CK's API is configured to use the noauth auth strategy).

  * Various features are brought by cliff: completion, command output formatting
    (table, shell, yaml, json...).

New features for developpers:

  * Python 2.7/3.5 compatible 'python-cloudkittyclient' module.

  * Integration tests (for 'openstack rating' and 'cloudkitty') have been
    added. These allow to create gate jobs running against a CK devstack

  * Tests are now ran with stestr instead of testr, which allows a better
    control over execution.

  * The dependency list has been reduced and upper constraints have been set.

Change-Id: I7c6afa46138d499b37b8be3d049b23ab5302a928
Task: 6589
Story: 2001614
2018-06-15 12:08:21 +02:00
Kiran_totad
bf30936048 Remove log translations
Log messages are no longer being translated. This removes all use of the
_LE, _LI, and _LW translation markers to simplify logging and to avoid
confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: Ic22cf715a70e9e1ff734944015d2f8a1ab2dbef8
2018-01-23 17:20:16 +00:00
Aaron-DH
56e6f689bb Add --all-tenants when get total/summary
Use `cloudkitty total-get --all-tenants` to get total
rate of all_tenants. Same with summary-get

Depends-On: 8cf7332162ad30bcdb2c8dfd10a3d348601c2870
Change-Id: I1efcbb8eff77c5f8d358a02178b1f99204b6cba7
2017-01-24 11:05:54 +08:00
Jenkins
40ddf6a470 Merge "Delete unnecessary utf-8 coding" 2017-01-22 15:36:25 +00:00
Jenkins
287dd57185 Merge "Improve User experience" 2017-01-22 15:24:57 +00:00
Jenkins
416a717ebc Merge "Remove white space between print () in cliutils.py" 2017-01-19 09:57:32 +00:00
Maxime Cottret
efb2b0949a Improve User experience
This patch adds access to new REST API for config and service
metadata retrieval.

The following work has been done:

* Create new manager for config retrieval
* Create new Resource and CRUD manager for service info retrieval
* Add managers to client
* Add new CLI command and openstack client entries

Change-Id: I43f572202b1cd3832a820f46f7c7b44a0d998406
Depends-on: https://review.openstack.org/#/c/406180/
2017-01-18 14:48:17 +00:00
Jenkins
a567600b77 Merge "Add client for get summary report" 2017-01-18 14:32:18 +00:00
Aaron-DH
e402ce676c Add client for get summary report
Use commands as follows to get summary:
  -- cloudkitty summary-get
  -- openstack rating summary-get

Change-Id: I07da26cb31a03104493ab749efffd73ba8d17d62
Implements: blueprint price-groupby-fields
2017-01-16 18:59:38 +08:00
zhangguoqing
cdbcafd142 Remove white space between print () in cliutils.py
There is a white space in line [print (*, then we remove it.

REF. https://review.openstack.org/#/c/387303/

Change-Id: I6762b7d1d9f573d62e7466da134addd51e0b4163
2017-01-04 02:33:38 +00:00