Commit Graph

99 Commits

Author SHA1 Message Date
Stephen Finucane a6f81a736c Blacken openstackclient.api
Black used with the '-l 79 -S' flags.

A future change will ignore this commit in git-blame history by adding a
'git-blame-ignore-revs' file.

Change-Id: I1df5bc4c35f02147fe5ac5b4073f0e01e7d51c2f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-05-10 10:51:30 +01:00
songwenping c2df9215e1 Remove usage of six
With python3.x, classes can use 'metaclass=' instead of
'six.add_metaclass', 'six.iteritems' and 'six.iterkeys' can
be replaced by 'items' and 'keys', 'six.moves.urllib.parse'
can be replaced by 'urllib.parse', 'six.StringIO' and
'six.moves.cStringIO' can be replaced by 'io.StringIO',
'six.text_type' and 'six.string_type' are just 'str'.

Change-Id: I84848c0bf8ab3c36dd821141191e2725e4e3b58b
2020-10-07 02:15:25 +00:00
Zuul 831dd3fe12 Merge "Make container list --all work" 2020-06-09 00:21:52 +00:00
Pete Zaitcev 41a2e82939 Make container list --all work
The caller in openstackclient/object/v1/object.py passed a keyword
argument full_listing, but the eventual callee container_list()
expected all_data. So, --all did not work at all.

The issue passed undetected because --all did not have a test,
so we added a unit test.

In addition, exisiting tests were using a test set that did
not look like the real container listing, so we changed
LIST_CONTAINER_RESP to be realistic.

Change-Id: Id0604bcab25892e43c26cd6656b2b2eef5daa69b
2020-05-16 14:40:28 +00:00
Pete Zaitcev f6ee42cd32 Cleanup: remove a useless reference to "object"
The method "object_list" does not have an argument "object",
so we were using a built-in class "object" by mistake.

Change-Id: I74687659223d31d3c3c119eee5874edff30634fd
2020-05-15 11:24:25 -05:00
Simon Merrick d6022f96df Add storage policy option to create container command
+ Add CLI option to specify swift storage policy
 + Add CLI flag to specify container uses public read ACLS
 + Show storage policy in container show data

Change-Id: I08ffa0d98bd39d467aa415771675f59bd77768ff
2020-02-19 10:08:48 +13:00
Sean McGinnis 69db9fe73c
Raise flake8-import-order version to latest
We had this library capped at a release that is a few years old. Now
that we have dropped py2 testing, we can pick up the latest version.

This uncovered a few things to clean up. Mostly the fact that mock is
now a part of the StdLib unittest since Python 3.3.

Change-Id: I27484dd4c25378413ff16e97a35a1a46062357bc
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-01-10 14:21:47 -06:00
lihaijing d15bbada73 Replace six.iteritems() with .items()
1. As mentioned in [1], we should avoid using six.iteritems to achieve
   iterators. We can use dict.items instead, as it will return iterators
   in PY3 as well. And dict.items/keys will more readable.

2. In py2, the performance about list should be negligible,
   see the link [2].

[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: I4b9edb326444264c0f6c4ad281acaac356a07e85
Implements: blueprint replace-iteritems-with-items
2020-01-09 18:41:29 +09:00
Dean Troyer 6fcc2608b1 Remove token_endpoint auth type
The token_endpoint was a compatibility auth type to maintain support
for the --url global option that dated back to the beginning of
OpenStack CLI auth.  The common keystoneauth library implements
'admin_token' which provides the same functionality using
--endpoint rather than --url.

Change-Id: I1b9fbb96e447889a41b705324725a2ffc8ecfd9f
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-08-27 11:08:50 -05:00
Andreas Jaeger c609b98c40 Update api-ref location
The api documentation is now published on docs.openstack.org instead
of developer.openstack.org. Update all links that are changed to the
new location.

Note that redirects will be set up as well but let's point now to the
new location.

For details, see:
http://lists.openstack.org/pipermail/openstack-discuss/2019-July/007828.html

Change-Id: I1572a21632740b4d9a233a6a31c49e3bac5394ef
2019-07-22 20:55:43 +02:00
Dean Troyer 1b2595a959 Remove code migrated to osc-lib long ago
* Remove openstackclient.api.utils and use osc_lib.api.utils
* Remove openstackclient.common.clientmanager.ClientManager.auth_ref
* Remove openstackclient.common.commandmanager

Change-Id: I67e1dbc53cc0b37967c0011bcb2fc09bdef62d94
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-05-16 19:19:58 -05:00
Tim Burke 415b48056d Before writing object data to stdout, re-open it in binary mode
Otherwise, you can hit TypeErrors on Python3.

Change-Id: I9a891508886feddac3982ce593bd95130392e035
Closes-Bug: 1775482
2019-04-10 14:34:40 -05:00
Zuul 2ab3396f19 Merge "trivial: remove commented-out code" 2018-12-30 14:30:28 +00:00
liuyamin 4f66f66b6c Fix i18n issue
This patch fix some i18n issues in the files vapi/compute_v2.py.

Change-Id: Ic4da472ca585a35ce64512cf0e72e2fe9d4c9d6e
2018-11-13 17:05:05 +08:00
Chen a4fcae2ac2 trivial: remove commented-out code
These comments have existed from the beginning. But they seem to
be meaningless.

Change-Id: Ic38272ecfb321d77219d477634e9e29b968e7f00
2018-09-28 19:20:07 +08:00
Nobuto Murata 860639a548 Support --community in openstack image list
"--community" was added to "image create" and "image set" previously,
but was missed in "image list".

Change-Id: I959fdd7f67ae62c8326659ce52389228152ec019
Story: 2001925
Task: 14453
2018-07-24 22:48:01 +00:00
Dean Troyer 53e7aab7ed Re-implement novaclient bits removed in 10.0
a)

/os-floating-ips was removed in Compute API 2.36 and from novaclient's
Python API in 10.0

Add to api.computev2:
floating_ip_add()
floating_ip_remove()

Convert add floating IP command to nova-net/neutron split:
"server add floating ip"
"server remove floating ip"

b)

/os-hosts was removed in Compute API 2.43 and from novaclient's
Python API in 10.0.

Add to api.computev2:
host_list()
host_set()
host_show()

Convert host commands to use intenal api:
"host list"
"host set"
"host show"

c)

The introduction of the Network-style commands into the server group
broke cliff's autoprogram directive as it executes the get_parser() methods
without fully initializing the Command object.

NOTE: This is really three reviews squashed to get through the gate in one pass.

Depends-on: Id6de87211d6c4ea8fd14aa9203d8d5b17e9e2f04
Change-Id: I5116086f9a9e4b2b31a744bf8f4558c79f0bfe59
2018-03-13 09:10:45 -05:00
Dean Troyer 2c2c16ba55 Remove a bunch of things we promised to remove in 2H 2017
Change-Id: I060559fe13e354fe87551cd9dd82774bddb54640
2017-11-30 15:35:42 -06:00
Honza Pokorny ae35a29169 Allow objects to be streamed to stdout
Change-Id: Icd8de6b2122fe77926d93da9bda08f56c3672a7a
2017-07-05 20:08:18 -03:00
Vu Cong Tuan b52bbe1eec Trivial fix typos
Change-Id: I72a1da209df38e226ec02d9dbd0142ed4020c0d2
2017-05-30 16:38:27 +07:00
Dean Troyer 589a65c3fe Fix Nova-net netowrk commands
In cleaning up functional tests for nova-net, I discovered some
problems in network create:
* --subnet option is required in network create command
* Switch API to use /os-networks rather than /os-tenant-networks as this
  is what we were actually using via novaclient
* Fix functional tests for nova-net
* Normalize some private function names in network/v2/network.py

Change-Id: I426b864406756d58d140575a3a45ee9aee67ce84
2017-04-27 20:36:00 +00:00
Dean Troyer 107cad200a Low-level Compute v2 API: floating ip pool
api.compute.APIv2 floating ip pool function.

novaclient 8.0 is now released without support for the previously
deprecated nova-net functions, so include a new low-level REST
implementation of the removed APIs.

Also includes a handful of cleanups that the previous security group and
floating IP reviews missed.

Change-Id: I20116ec4fc1113857d8d917bfb30fa3170d05b9f
2017-04-18 08:57:34 -05:00
Dean Troyer b2783dc3c4 Low-level Compute v2 API: network
api.compute.APIv2 network functions.

novaclient 8.0 is now released without support for the previously
deprecated nova-net functions, so include a new low-level REST
implementation of the removed APIs.

Change-Id: If230f128e91cda44461fe93c976cac2aecec2252
2017-04-17 19:45:21 -05:00
Jenkins b0ce95745d Merge "Low-level Compute v2 API: floating ip" 2017-04-17 21:14:05 +00:00
Dean Troyer e6ea45b283 Low-level Compute v2 API: floating ip
api.compute.APIv2 floating ip functions.

novaclient 8.0 is now released without support for the previously
deprecated nova-net functions, so include a new low-level REST
implementation of the removed APIs.

Change-Id: Ic461b8d15e072e0534dcd73fff6857581d83c89b
2017-04-11 02:10:26 -05:00
Dean Troyer 1bf6706ad1 Low-level Compute v2 API: security group rules
api.compute.APIv2 security group rule functions.

novaclient 8.0 is now released without support for the previously
deprecated nova-net functions, so include a new low-level REST
implementation of the removed APIs.

Change-Id: Ieabd61113bc6d3562738686f52bb06aa84fca765
2017-04-11 02:08:57 -05:00
Dean Troyer 4289ddd47a Low-level Compute v2 API: security group
api.compute.APIv2 starts with security group functions.

novaclient 8.0 is now released without support for the previously
deprecated nova-net functions, so include a new low-level REST
implementation of the removed APIs.

Change-Id: Id007535f0598226a8202716232313e37fe6247f9
2017-04-11 02:08:04 -05:00
Jordan Pittier 1cdc1319d6 Make 'object save' fast again
'openstack object save' is critically slow to download big objects. While
we 'stream' (chunked download) the data, the default chunks_size
is 1 byte [1], which is terribly inefficient.

[1] : http://docs.python-requests.org/en/master/api/#requests.Response.iter_content

Closes-Bug: 1654645


Change-Id: I2223e5897346acd2f2c1fae638d1193cff833c19
2017-01-09 16:19:29 +00:00
Imtiaz Chowdhury 1bd2bf67da Fixes image api URL endpoint for certain scenario
openstackclient fails to get image list when the image api endpoint
has 'v2' substring in the URL. Instead of checking whether the api
endpoint URL terminates with '/v2', the current logic is checking
whether 'v2' appears anywhere in the endpoint string.

This issue was discovered on a production setup where certain
server names had 'v2' in their names. For example, when a hostname
is gopher.dev20.com, the image list APIs fail.

This commit updates the unit test to reflect this scenario. Without
the change in openstackclient/api/image_v2.py, all the unit tests
fail.

Co-Authored-By: sergio.carvalho@workday.com
Change-Id: I26b85afd646938272dbabe8e045b337b7df58c7d
Closes-Bug: 1652827
2017-01-04 18:14:10 +00:00
Rajasi Kulkarni 78312ca9af Add option "--name" to command "openstack object create"
Option "--name" can be used to set as the object name of
the file to be uploaded in the container. Similar to option
"--object-name" in command "swift upload". Added unit test case
to ensure an exception is raised when using option "--name" for
uploading multiple objects.

Change-Id: Ied7827841f6ca1cf9d4b48e304cbe5d62eda38ab
Closes-Bug: #1607972
2016-09-26 22:42:10 -04:00
Dean Troyer 110a62f277 Add importing file to import warnings
Add the Python file doing the import to the warnings emitted by
the modules moved to osc-lib. Users will at least have a hint as
to which package is out-of-date.

Change-Id: I633b440c30b2b15cfde7a9013e30dfa39ab200bc
2016-08-30 09:21:02 -05:00
shizhihui f996138a0d Standardize import format
According to the rule in
http://docs.openstack.org/developer/hacking/#imports
I modify some irregular import format.

Change-Id: Ibf29ccaf3ddec4a956334cc3368ebee7a66e282c
2016-07-22 19:24:02 +08:00
ji-xuepeng 17f177bb71 remove unused LOG
This is to remove unused LOG to keep code clean.

Change-Id: Ic544157b19cefb4120381f3314334c60a9020baf
2016-07-09 23:23:38 +08:00
Dean Troyer d324530532 osc-lib: api.auth
Move auth plugin checking to osc-lib.

Change-Id: I673d9c2d6e8bbf724c3000459a729e831d747814
2016-06-30 08:57:59 -05:00
Dean Troyer ccbb2dd1e8 Remove OSCGenericPassword plugin
The need for this has passed plus with 3.0 we can take the breakage hit,
if any.

Change-Id: Ic019842f00033d2cd67b75f036e7e817e4b7c075
2016-06-22 13:54:32 -05:00
Dean Troyer cefe715031 Fix token/endpoint auth plugin
[This is not quite reduced from the original proposed fix as some
changes have merged that complicate the switch to OSC_Config and
v2 auth broke anyway.]

Fix the --os-token --os-url breakage in the switch to ksa.

Closes-bug: 1593664
Change-Id: I3ac23234fbf647fb145c7bd151d53c5c105462bf
2016-06-21 14:54:31 -05:00
Alvaro Lopez Garcia 099a2c38b9 Refactor setting defaults for some scope parameters
The code is setting defaults for some scope parameters, cheking if the
name ends with some specific substring (namely ending in "password")
causing failures in some plugins that end with the same string, but do
not allow those parameters (like "user_domain_id" in "v3oidcpassword").

Closes-Bug: #1582774
Change-Id: Id7036db3b783b135353d035dc4c1df7c808d6474
2016-06-21 08:55:30 +02:00
Alvaro Lopez Garcia 78ae57112c Refactor check_valid_auth_options function
The functions check_valid_auth_options() function was relying on the name
for checking the set of required options, but this could cause errors
with external auth plugins. If somebody defines an auth plugin plugin
named "footoken" the check function would check for a "token" option,
even if the plugin has not defined that option. This change tries to
improve this situation, cheking for some options only if they have been
defined in the plugin.

Change-Id: I4255f2e7d4d23449c95be957ea7b6b60983f2608
2016-06-21 08:54:36 +02:00
Dolph Mathews fe0c8e955b Do not prompt for scope options with default scoped tokens
This changes the scope validation to occur after a token has already
been created.

Previous flow:

1. Validate authentication options.
2. Validate authorization options if the command requires a scope.
3. Create a token (using authentication + authorization options)
4. Run command.

This means that scope was being checked, even if a default scope was
applied in step 3 by Keystone.

New flow:

1. Validate authentication options.
2. Create token (using authentication + authorization options)
3  Validate authorization options if the command requires a scope and
   the token is not scoped.
4. Run command.

Change-Id: Idae368a11249f425b14b891fc68b4176e2b3e981
Closes-Bug: 1592062
2016-06-17 12:37:15 -04:00
Huanxuan Ao f25a3519c5 Fix missing i18n supports in api/ and shell.py
Change-Id: I28d79d7f44b27d2b600dedad2a3601180650ad83
Partial-bug: #1574965
2016-06-14 11:03:56 -05:00
Dean Troyer e5e29a8fef osc-lib: utils
Use osc-lib directly for utils.

Leave openstackclient.common.utils for deprecation period.

Change-Id: I5bd9579abc4e07f45219ccd0565626e6667472f7
2016-06-13 10:50:44 -05:00
Dean Troyer d20c863ebc osc-lib: exceptions
Use osc-lib directly for exceptions.

Leave openstackclient.common.exceptions for deprecation period.

Change-Id: Iea3e862302372e1b31ccd27f69db59b4953ca828
2016-06-13 10:50:01 -05:00
Navid Pustchi 6ae0d2e8a5 Moving authentication from keystoneclient to keystoneauth
Currently OpenStackClient uses keystoneclient for authentication.
This change will update OpenStackClient to use keystoneauth for
authentication.

All dependant test have been updated.

Updating how auth_ref is set in the tests to use KSA fixtures had
some racy side-effects.  The user_role_list tests failed when they
picked up an auth_ref that was a fixture.  This exposed a weakness
in ListUserRole that needed to be fixed at the same time re
handling of unscoped tokens and options.

Change-Id: I4ddb2dbbb3bf2ab37494468eaf65cef9213a6e00
Closes-Bug: 1533369
2016-06-09 18:00:40 +02:00
Madhu Mohan Nelemane a4d4e81c88 Avoid TypeError on message object additions
Change-Id: I634c1e158e93eeb55ab17fef8a0715b6678dffec
Closes-Bug: #1575787
2016-05-19 18:07:53 -07:00
Dao Cong Tien 67a8947ea2 Fix typos in docstrings and comments
Change-Id: Ic2dc057dca87212f715970f8325956c42f62ea9f
2016-04-06 10:30:39 +07:00
Jenkins 77f2e98466 Merge "Clean up unnecessary import of urlparse module" 2016-03-01 23:51:00 +00:00
Yang Hongyang 059f54eee4 Clean up unnecessary import of urlparse module
six.moves.urllib already covers the py2 and py3 compatibility issues
of urlparse module, use six.moves.urllib.parse.urlparse is enough.

Change-Id: I785f4f872850e5d770fdcf4c0d3392be3978cc4a
2016-03-01 22:06:53 +08:00
Yang Hongyang 8b17a1fa5b Trivial: Update image_list v2 docs
This api doc is clearly copied from v1, we should update it to reflact v2 API.
Added 'shared' param description.

Change-Id: I73d36e3a2a0448c28edab788a9340fd46177f8ef
2016-03-01 18:48:09 +08:00
ting.wang e47c83d47a Py3 replace dict.iteritems with six.iteritems
All dict.iteritems in osc are replaced with six.iteritems
except this one.
So fix it to add py3 compatibility.

Change-Id: I1aa51399a36e650d262d839ce2b4ec04d3f91db2
2016-02-24 10:14:56 +08:00
Brandon Palm 11a8f911af Use instanceof instead of type
Adjusted conditional statements to use instanceof when
comparing variables. Instanceof supports inheritance type
checking better than type.

Change-Id: I4ee0004934dc2322d43ef07e797a6811e39a812c
Closes-Bug: 1548530
2016-02-22 16:23:23 -06:00