Commit Graph

87 Commits

Author SHA1 Message Date
Hervé Beraud c40f0cc32b Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Change-Id: I95e8d9564cda2e6a06a3f40b0de6991acb07dd4c
2024-01-27 00:26:23 +09:00
Thomas Herve 13e90a0ab5 Properly pass the CA to requests
We store the CA in request.cert, but it's not compatible with a cert. To
pass the CA to requests, we need to set the verify argument.

Change-Id: Id0f39e3253b1486db8ae2da3d7dc6c0fdb41062a
2018-10-04 15:00:22 +02:00
Thomas Herve d19198c65e Revert "Fix The header X-PROJECT-ID missing bug"
This reverts commit a0b6a79a3c.

It's not a backward compatible change.

Change-Id: I0a568649e860da58586b9a74917bdc8b6c809bfc
2017-03-07 15:56:36 +00:00
zengjianfang a0b6a79a3c Fix The header X-PROJECT-ID missing bug
This patch fixex X-PROJECT-ID missing bug.

Change-Id: I8c13160f24f51a3f6588aefadae9ef8ff2519e1a
Co-Authored-By: XueFeng Liu <liu.xuefeng1@zte.com.cn>
Closes-Bug: #1668830
2017-03-07 16:23:33 +08:00
Rui Chen 35404c7a74 Set client module __version__
According to PEP 396, the version of client library
should be set in xxxclient.__version__, that help
python-openstackclient command "module list" to get
the right plugin module versions.

Change-Id: Iea53e561ab197f4ef1b4855422c748417d808fab
Partial-Bug: #1662058
2017-02-06 16:16:22 +08:00
miaohb c8674dbaa6 Remove unnecessary utf8 coding format in the head of files
The line of "coding: utf-8" is added by some editors automatically.
It is useless, can be removed.

Change-Id: I50ded5ec5140cfbcfdaa1a09ac816e6c88969000
2017-01-05 09:20:30 +08:00
Kevin_Zheng 1b2e966586 Fix typos in zaqarclient
Fix typos in zaqarclient

Change-Id: I2e7120ef1e729a1935c84527d7b4b2dad858dab3
Co-Autored-By: ZhaoBo <zhaobo6@huawei.com>
2016-12-21 14:02:25 +00:00
Jenkins c731f7e3c2 Merge "Delete deprecated directory openstack/common" 2016-12-08 08:39:28 +00:00
wangxiyuan 476f48ebdd Fix CI failure
Functional test CI is broken.

Change-Id: Ia06f6306ac9b1fbbd5b9630f9b2972a85b1ea096
2016-12-01 16:50:28 +08:00
xianming mao 8c7afbe89a Delete deprecated directory openstack/common
Directory openstack/common has been out of date,so we can delete it,
and we should also delete this directory in flake8 exclude list.

Change-Id: I98af8dd332807343730b81a7f2c8422b63e6c38d
2016-11-24 11:49:10 +00:00
wangxiyuan 2396dadeae Fix the CI failure
Zaqar client's unit test is broken by requests after its version 2.12.0.
This patch fixes it.

Change-Id: I9f24e21923d41115555df033dcb5fd84975ba301
2016-11-16 21:06:36 +00:00
Fei Long Wang ca76a31311 Support keystone session when creating client
Currently, Zaqar client doesn't support passing in Keystone
session for authentation. This patch add that support, so
that user can create Zaqar client like:
z = zaqarclient.Client(session=session)

Change-Id: Idbd81678714534116d3f3cf8a395a704b1f61542
2016-11-03 14:31:09 +13:00
Cao Xuan Hoang de078d7d1f Files with no code must be left completely empty
As per OpenStack licensing guide lines [1]:
[H104] Files with no code shouldn't contain any license header nor
comments, and must be left completely empty.

[1] http://docs.openstack.org/developer/hacking/#openstack-licensing

Change-Id: I2df3d796aabbd2d283520b207bee3a80e663ecb4
2016-10-21 13:41:32 +07:00
Fei Long Wang 632ede8ef2 Support SSL and Insecure
Currently, Zaqarclient doesn't support SSL and insecure very well.
This patch fix it.

Implement blueprint: support-ssl-insecure

Change-Id: I2247fbbabc3afb7b5dccc2b48cd4e96864013a7e
2016-10-20 15:52:36 +13:00
gecong1973 89ad44d746 Change assertTrue(isinstance()) by optimal assert
Some of tests use different method of
assertTrue(isinstance(A, B)) or assertEqual(type(A), B).
The correct way is to use assertIsInstance(A, B) provided
by testtools

Change-Id: Ic741b987fa184b9e9efb22750b8d8245c6c62676
2016-10-08 10:08:44 +08:00
Dan Prince 51246e1a8c Create a websocket transport
This patch adds a new WebsocketTransport class that will help
consolidate common websocket client code that is useful
for connecting to and subscribing to Zaqar queues via
websockets.

We are already using a similar client within TripleO and
it makes sense to have it live in zaqarclient where it
can be shared and used by multiple projects.

Change-Id: Ia2a8deb599252d8308e44d595eb2bf443999aaad
2016-07-19 08:43:24 -04:00
Tang Chen cf7425be7e Use osc-lib instead of openstackclient
osc-lib is a package of common support modules for writing
OSC plugins. All common functions, classes such as exceptions,
utils, logs and so on have been moved from openstackclient to
osc-lib.

So use osc-lib instead of openstackclient.

Change-Id: Ic158ee6d74f73b4629f9f35f6f29e5a4e99b5258
2016-06-24 13:14:33 +08:00
wangxiyuan eeba0f3b8c Ensure the float value of api version could work
Now if we pass a float value of api version such as "v1.0" or
"v2.0", client will raise a DriverLoadFailure error. Because
that client can't match a sutiable API entry.

So we should ensure that that some value like "v1.0" could
work as "v1".

Change-Id: I9631a083fd96a535153b6029b95a1d3c8d9966a2
Closes-bug: #1572616
2016-05-20 10:49:24 +08:00
Fei Long Wang 15ef3386c0 Support /ping and /health for v2
Now Zaqar supports /ping and /health API, but they're missing
in zaqar client. This patch will fix it.

Change-Id: I34b454c486a7b4c693a540890eee48f162a07605
2016-04-08 16:13:50 +12:00
Fei Long Wang 8ca747746c Add support for subscription create v2
This patch adds the support for subscription create, which includes
the CLI support and the lib support. Besides, to make the functional
test work for subscription create, this patch also adds the lib
support for subscription get, delete, update and list to make things
easier.

Change-Id: Ie3ac27b731f41ea6023976aab3c1afbc283d659d
2016-01-11 09:31:55 +13:00
Jenkins d80f715edf Merge "Make sure queue create works for cli" 2015-12-18 00:03:51 +00:00
Fei Long Wang 74e29b1b73 Make sure queue create works for cli
This's a regression issue introduced by

I4f2f2f240404b2619ba0ee75a99fecd0ad10040e

Though we support lazy creation for queue, but it doesn't make
sense there's no result after creating the queue explicitly from cli.
So this patch introduces a new parameter named force_create to make
sure make sure the queue create is called each time when it's called
from command line interface.

Closes-Bug: #1517812

Change-Id: I72477f39da27bfa3e2bec3b876152a494b318744
2015-12-18 08:42:26 +13:00
dynarro 947ac048a9 Added support to claims
Zaqarclient v2 currently has missing features such as 'claims',
'flavors', and 'pools' that are needed in order to start implementing
a subscription management. I added support to claims as a priorital
step.

Co-Authored-By: MD NADEEM<md.nadeem@nectechnologies.in>
Change-Id: Id16e2f6a390e8387cce4545b9a03181ba03da3ce
2015-12-16 16:42:21 +13:00
Fei Long Wang bc123ad738 Refactor the test for v2 queues and messages
Change-Id: I8f5cc7f7e0ceefa1e8b4341ccc211f647df86876
2015-12-04 01:55:27 +00:00
Fei Long Wang b0d412ed2c Add `pool` support for v2
This patch is targeting for the library layer, the cli support
will be tracked by another patch.

Change-Id: Ic0a44a5d3e0990cf065c4f959e4ef76712ce1882
2015-11-27 13:19:03 -03:00
Fei Long Wang 1ef4a95ed6 Add `flavor` support for v2
This patch is targeting for the library layer, the cli support
will be tracked by another patch.

Change-Id: I284db15b66360f4bae317239a90743b4965bd016
2015-11-27 13:15:41 -03:00
Md Nadeem 0bc9791787 Fix client UnauthorizedError
Zaqar server threw UnauthorizedError when client
try to execute any cli command.

This patch fixes the issue and changes the default
authorization backend from noauth to keystone.

Change-Id: I88c2f5aa914b5fb40b6dc16a256d3e385d9aaa23
Closes-Bug: #1491738
2015-11-20 12:30:18 -05:00
dynarro 313f175471 Added support to v2
Zaqarclient v2 currently has missing features that involve the
management of subscriptions, but in order to these to work it is
necessary to add other features such as 'queues', 'messages',
'claims', 'pools' and 'flavors'. I added 'queues' and 'messages' as a
priorital step before start working with the other features and with
subscriptions as well.

Change-Id: Iea082cbf9e1d0e4a745bc10e41e1206af6132fad
2015-11-11 06:04:54 +13:00
Jenkins 00c7e0efea Merge "Fix order of arguments in assertEqual" 2015-10-11 23:00:25 +00:00
MD NADEEM 7adf35effc Fix order of arguments in assertEqual
Some tests used incorrect order assertEqual(observed, expected).

The correct order expected by testtools is
assertEqual(expected, observed).

This patch fix the issue in some test file of zaqarclient.
The review is generated part-wise to ease review process.
Partial-Bug: #1259292

Change-Id: I3f51e3a400d1c408e6c65b9ed503efd414b3d5ed
2015-09-29 08:40:28 +00:00
MD NADEEM 5b35d7626a Fix order of arguments in assertEqual
Some tests used incorrect order assertEqual(observed, expected).

The correct order expected by testtools is
assertEqual(expected, observed).

This patch fix the issue in the module /tests/unit/queues/v1 of zaqarclient.
Partial-Bug: #1259292

Change-Id: Ia5969d904012647f29b5047e37cad9ce3a77a489
2015-09-28 20:42:46 +09:00
Flavio Percoco 863371ba46 Allow for authentication in functional tests
Allow for authenticating when running zaqarclient's functional tests so
that they can also be used in the gate and keystone mechanism can be
tested functionally

Change-Id: I0f1fd4374125d4b489f3804b79a672b39c714421
2015-09-10 14:14:38 +02:00
Flavio Percoco bf841b56cf Pass `group` in pool's functional tests
The `group` key was missing in the pool's functional tests. This commit
adds it, otherwise these tests will fail.

Change-Id: I02c0ed870a04e1280ae4e4213e6751fc8e04caeb
2015-09-09 19:24:46 +02:00
Flavio Percoco baf6fa7eb8 v1.1 and v2 claims return document not list
The current claims code doesn't work on v1.1 and v2 because on claims
creation it expects a list rather than a document. This patch fixes this
issue in a backwards compatible way.

Change-Id: I64e824227f148297aba4c27bbd2053d5bab483c5
Closes-bug: #1489863
2015-08-31 15:29:36 +02:00
OpenStack Proposal Bot 8a81c44f14 Updated from global requirements
This change introduces new requirements and fixes new checks by
the `hacking` module.

Change-Id: I3b98d5038c516b3115d7247fa0f4ea1189b33dff
Co-Authored-By: Victoria Martinez de la Cruz <victoria@redhat.com>
2015-08-27 13:19:58 +02:00
Thomas Herve 0047c54116 Fix handling of 1.1 API
This fixes various behaviors of the client talking to the v1.1 API, and
enables functional tests for queues.

Change-Id: Icd30e32a17247790dfd57d6420d67f9140020db6
Closes-Bug: #1446677
Closes-Bug: #1446679
2015-04-27 16:36:03 +02:00
dynarro f5f35d4bfd Gets 'pool' data if the resource exists
Pool instances can be created by just passing the name. They both
check at construction time whether the resource exist in the server or
not. If the resource doesn't exist, it'll attempt to create one.

Zaqarclient does not call anymore the 'pool_create' directly. It calls
'pool_get' first, which ensures the resource exists. if not, a 'pool'
will be created.

Change-Id: I8f18b5031c80cfd5744ba3b0b7058654934f44b4
Partial-Bug: #1396063
2014-11-27 15:01:57 +01:00
dynarro 2cb7e9054f Makes health return True or False
API returns a 204 for the health check with no body content.
The function should have returned  True if http result was a 204,
or else a False.

I solved the problem by making the function return false in case of an
error.

Change-Id: I02771f5aa61db4ed83da952245744cb3a6163a26
Closes-bug: #1288986
2014-11-13 11:18:56 +01:00
Victoria Martínez de la Cruz 369ac1ebb4 Adds encapsulation control to the client
https://review.openstack.org/#/c/108795/ adds the requirement
to encapsulate messages in JSON objects in API v1.1

This change adds that control to the Zaqar client maintaining
backwards compatibility with v1

Change-Id: I1723b843320ebcf2722fb4f6fcaaa6e1c63248e9
2014-10-28 10:34:27 -03:00
Flavio Percoco f96846d323 Cleanup technical debt
* Unused variable
* Not necessary trailing /

Change-Id: I65c8801b44ff8870426a03fdab2710a67b8a20cc
2014-09-17 17:07:58 +02:00
Flavio Percoco 434d487773 Always pass a project_id
Since v1.1, the `X_PROJECT-ID` became a required header. This patch adds
a way to specify the project id regardless of the backend. In order to
pass the project id, it's necessary to pass the `os_project_id` option
in the `auth_opts` dictionary. For example:

  auth_opts = {'options': {'os_project_id': 'yadayada'}}

Partially-Implements blueprint: api-v1.1

Change-Id: If72b758e634dc1e6bc1e1cc0c63361e8a43861bb
2014-09-17 17:07:58 +02:00
Flavio Percoco 75b8ca3b71 Fix functional tests
Do not append the version suffix to the URL. The request transport will
take care of that.

Change-Id: If5cd729ce2d2b28d9f8522cedaa15bea032b4a82
2014-09-17 16:41:30 +02:00
Flavio Percoco a3e8adf561 Add support for flavor to the client library
This patch adds support for flavors to the client library. Flavors are
an admin endpoint, which means pool's rules apply to them.

Since flavors were added since 1.1, this patch also adds a version
decorator that will help making sure features are accessible just if the
api_version the client has been instantiated with matches the version
the feature was added into.

Note that the core module does not use the version decorator. There are
2 reasons for this:

    1. Users accessing the core module should know what they're doing
    2. If the transport loads the spec for the API version it was
    instantiated with. If that spec does not contain a specific action,
    the whole operation will fail before hitting the wire.

Partially-Implements blueprint: api-v1.1

Change-Id: I92dbe417655a9eeefb030481a81a67840a63dd0e
2014-09-17 16:39:25 +02:00
Flavio Percoco 680e314c0e Rename `shard` to `pool`
The server's shard feature has been renamed to pool. This patch reflects
that change in the client library. The patch keeps old `shard*` methods
and functions for backwards compatibility and it also raises a
deprecation warning whenever they are used. These functions will be
removed right after k-1

Change-Id: I842bfbcf075845750bc4fff345086636cc775371
Closes-bug: #1348196
2014-09-17 16:39:23 +02:00
Flavio Percoco 062507d09a Add support for `pop` implemented in v1.1
This patch implements pop in the client library. Pop is a new operation
that has been implemented in v1.1. It allows a client to remove N
messages from the top of queue. Although pop is a query parameter in the
server, it has been implemented as if it were an action.

Partially-Implements blueprint: api-v1.1

Change-Id: I29b771a6167185033821139bd795311f1a25a5e1
2014-09-17 10:13:49 +02:00
Flavio Percoco bde63a2f66 Add support for bulk message delete in v1
Bulk message delete was missing in the client. This patch implements
that feature for both v1 and v1.1.

Change-Id: Ief73fe5f67ae71d396c6122048c26020ea9592bb
2014-09-16 18:29:22 +02:00
Flavio Percoco 0a125f7bc2 Start adding support for v1.1
This patch adds basic support for the API version 1.1. It basically
re-uses the specs and implementations from v1 since the API hasn't
really changed much.

Future patches will add support for the new methods and other changes.

Partially-Implements blueprint: api-v1.1

Change-Id: I40d02d6c2d3b932725f35204708d79785f59116b
2014-09-09 16:14:06 +02:00
Flavio Percoco 11c3310d11 Rename Marconi to Zaqar
This patch renames every package, file, match of Marconi in the codebase
to Zaqar *except* for the .gitreview file, which will have to be updated
*after* I8e587af588d9be0b5ebbab4b0f729b106a2ae537 lands.

Implements blueprint: project-rename

Change-Id: I0c82be81f74d022ab609eea8f40ac2c0635374b1
2014-08-04 16:55:10 +02:00
Sriram Madapusi Vasudevan 11e18a4524 Throw exceptions on erroneous status codes
This patch aims to additional exception checking
on receiving other erroneous status codes apart from
400 and 404.

Change-Id: I184c2c0627c457d9c49a84e9e8313a0c88617ec1
2014-06-09 10:09:47 -04:00
Flavio Percoco ddd41adab1 Don't stream by default
Current `_Iterator` streams data from the server by default. This
behavior, although useful, shouldn't be considered a sane default. A
good example is when using `limit` on listing operations. If the default
is to stream, the limit will be ignored because the server client will
get everything from the server until there's anything left to consume.
This behavior can also be harmful if not used carefully.

This patch adds a `stream` method to the iterator and makes using this
behavior an explicit operation. The user has to opt-in for data
streaming.

Change-Id: Ib1af24960dff97cb956990d4caf88705f2f7a0d5
2014-04-22 13:20:58 +02:00