Commit Graph

409 Commits

Author SHA1 Message Date
Pavlo Shchelokovskyy f3207bdf3f Fix availability zone list command
there are two problems currently:
- SDK's `availability_zones()` returns a generator that raises errors
  only when actually accessing its items
- the error raised is the sdk exception, not nova one, and thus is not
  being handled correctly

As a result, currently nova AZs can not be listed by non-admins.

Story: 2010989
Task: 49220
Change-Id: Ia299faea85857d3fc3a9b539800f3483f84ccbc0
2023-12-07 16:24:34 +00:00
Stephen Finucane c7e3529dea Add pagination helpers
Add some pagination helpers to configure pagination parameters for
various commands. Two pagination schemes are supported, based on what we
currently support across OSC commands: marker-based pagination and
offset-based pagination.

Change-Id: I551bb4c3ff0568c6df5244a1d0f0669497bee58f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-11-03 23:16:18 +00:00
Stephen Finucane 601d9717c2 Remove project purge image commands
This was still using glanceclient-style calls despite us having switched
all image command to SDK way back in 5.2.0 (Ussuri). It therefore hasn't
worked since then, so we remove without deprecation.

Change-Id: Ibea79ea10bb272cba194debfe4bcbaeebf3875b7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-08-28 13:52:23 +01:00
Stephen Finucane b87b57551b Migrate 'extension list' to SDK
Migrate the block storage aspects of this command to SDK. This means the
'extension list' command, like the 'availability zone list' command
previously, is now using SDK entirely.

While we're here, we also make some fixes to the unit tests for the
network and compute aspects of the command. While we migrated the
network and compute extension commands from neutronclient and novaclient
respectively some time back, we never fully updated the tests. Do this
now.

Change-Id: I631a6a09dfd9d614b1dd7b322dcee8490a52cc43
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/885132
2023-08-28 13:51:34 +01:00
Stephen Finucane 44cf963d8e Migrate 'availability zone list' to SDK
This is a bit of an odd one. Because this is a "common" command, there
are three clients in play here: a compute client, a block storage
client, and a networking client. The networking aspects of this command
are already using SDK though the tests were mistakenly using a fake
version of the legacy neutron client (albeit one with the correct SDK
properties). We were still using legacy clients for the other two.
Correct the networking tests and migrate the compute and block storage
aspects of the command.

Change-Id: I292e1a712bca97e1270e8a97606e02a8a44c2954
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-08-28 13:51:33 +01:00
Jan Hartkopf f29e3ccc37 Add --skip-resource option to project cleanup
Story: 2010370
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/878646
Change-Id: I9eb10cfd8612fa9faf2a734a517078b12a9ca3c3
Signed-off-by: Jan Hartkopf <jhartkopf@inovex.de>
2023-08-21 11:47:24 +02:00
Stephen Finucane 7d80f9e962 Blacken openstack.common
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: Ifcb3c798666d74d596b8ecb3d6d507f782de7ba5
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-05-10 10:51:30 +01:00
Zuul 65b667af20 Merge "Add auto-approve option to project cleanup" 2023-03-20 12:07:44 +00:00
Zuul 43f04c874f Merge "Drop default from ask_user_yesno question" 2023-02-22 12:32:22 +00:00
Dr. Jens Harbott 7506eb8e0c Add auto-approve option to project cleanup
Sometimes it is useful to be able to use the project cleanup function in
scripts and having to add "echo y | openstack" isn't really nice.

Signed-off-by: Dr. Jens Harbott <harbott@osism.tech>
Change-Id: I3ded9982769b4568b6dcfc49bc31ba67a6227839
2023-02-15 09:42:45 +01:00
Dr. Jens Harbott 69182a04b2 Drop default from ask_user_yesno question
There is no default for ask_user_yesno() since an empty answer instead
just repeats the question. Drop the unnecessary parameter.

Change-Id: I207bccbcbd31f831765e74a20c503b695790c0f5
2022-12-27 13:03:14 +01:00
Stephen Finucane 5afe48040c Fix really long help strings
Each command should have a summary line followed by a longer
description, if needed. Some commands were not following this. Fix them.

Change-Id: If1ce7654037d192626460f34c069ea0979919b9b
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-12-12 18:04:01 +00:00
Zuul 837cbfbcdb Merge "quota: Deprecate "force" behavior for network quotas" 2022-11-05 09:24:51 +00:00
Zuul b0b47472d8 Merge "quota: Fix issues with delete quota command" 2022-11-05 09:24:49 +00:00
Zuul c458ad4692 Merge "quota: Trivial style fixups" 2022-11-05 09:09:21 +00:00
Zuul 6898bc0ae3 Merge "quota: Deprecate 'quota show --class', 'quota set --class' arguments" 2022-11-05 09:09:19 +00:00
Zuul 1e37c12b16 Merge "quota: Allow showing project-specific quotas" 2022-11-05 09:09:16 +00:00
Zuul ccd9356550 Merge "quota: Add 'quota show --usage' option" 2022-10-12 11:22:09 +00:00
Zuul 351b2b1074 Merge "quota: Simplify logic used to list, show quotas" 2022-10-12 11:14:20 +00:00
Stephen Finucane 09ff9a0f4c quota: Deprecate "force" behavior for network quotas
In change Idc1b99492d609eb699d0a6bef6cd760458a774f6, we added a
'--check-limit' option to enable "no force" behavior for network quotas.
This was already the default for compute quotas. Provide a path for
harmonizing the behavior of the two options by instead using a
'--no-force' option which will become the eventual default for the
network quotas also.

Change-Id: I25828a3d68e2e900f498e17a0d01fb70be77548e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-10-11 16:52:08 +01:00
Stephen Finucane 2da4aa99aa quota: Fix issues with delete quota command
We were passing a project object rather than just the ID. Also correct a
typo in the call to delete network quotas.

Change-Id: I2292db7932ec01026f0e54014e3d02218792617a
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-10-11 16:41:28 +01:00
Zuul 8be0c641e1 Merge "quota: Add support for detailed volume quotas" 2022-10-07 17:05:55 +00:00
Zuul eac38feef0 Merge "quota: Add 'quota delete' command" 2022-10-07 16:37:20 +00:00
Stephen Finucane 1ff839da76 quota: Trivial style fixups
Change-Id: I4522b54676033dced2b47477238ceb551e11d04a
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-09-30 12:40:18 +01:00
Stephen Finucane b62021260c quota: Deprecate 'quota show --class', 'quota set --class' arguments
This doesn't do anything special in nova and cinder and is not supported
in neutron. For the 'quota show' command, people should use the
'--default' argument instead.

Change-Id: I0dd38e5cb252a01d5817ed168be040b21b35e348
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-09-30 12:40:18 +01:00
Stephen Finucane 00e7019022 quota: Allow showing project-specific quotas
Add '--compute', '--network' and '--volume' options to the 'quota show'
command, along with a default '--all' option, allowing us to restrict
quotas shown to an individual service.

Change-Id: I122b765df01887b8d916ee6567ffb7768fcb4392
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-09-30 12:40:18 +01:00
Stephen Finucane 04e68e0d5a quota: Add 'quota show --usage' option
Provide an more sane way to get usage information for a particular
project's quotas. This requires using the 'Lister' command type since
the 'ShowOne' command type only allows for simple key-value pair output.

We also add a note indicating that the '<project>' argument is optional.

Change-Id: Ic7342cf08f024cc690049414c5eef5b9a7594677
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-09-30 12:40:15 +01:00
Stephen Finucane 47e667e71d quota: Simplify logic used to list, show quotas
This is prep work for some changes we're introducing in a later change.

Change-Id: I27a59bc1d57e6815fb166fb99ea2af88f08b68a9
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-09-30 12:33:29 +01:00
Stephen Finucane 44443f7856 quota: Add support for detailed volume quotas
We were stating that this was not supported. That is not true. Correct
the oversight.

Change-Id: Ib9d9db641a18e142be0a1eccff783e7cccdf2db5
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-09-30 10:55:47 +01:00
Stephen Finucane 45bec041b2 quota: Add 'quota delete' command
We had previously indicated that people use 'quota set' for unsetting a
project's quotas, however, there was nothing that actually allowed us to
do this. Correct that oversight.

Change-Id: I04057e766b8ccf94bf219972249b68dc2bb796d4
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-09-30 10:54:11 +01:00
ryanKor 62c52f5e61 config: Also mask non-prefix config
The 'config show' command will show information about your current
configuration. When using a 'cloud.yaml' file and the 'OS_CLOUD'
environment variable, the output of this will look like so:

  $ openstack config show
  +---------------------------------------------+----------------------------------+
  | Field                                       | Value                            |
  +---------------------------------------------+----------------------------------+
  | additional_user_agent                       | [('osc-lib', '2.6.0')]           |
  | api_timeout                                 | None                             |
  | auth.auth_url                               | https://example.com:13000        |
  | auth.password                               | <redacted>                       |
  | auth.project_domain_id                      | default                          |
  | auth.project_id                             | c73b7097d07c46f78eb4b4dcfbac5ca8 |
  | auth.project_name                           | test-project                     |
  | auth.user_domain_name                       | example.com                      |
  | auth.username                               | john-doe                         |
  ...

All of the 'auth.'-prefixed values are extracted from the corresponding
entry in the 'clouds.yaml' file. You'll note that the 'auth.password'
value is not shown. Instead, it is masked and replaced with
'<redacted>'.

However, a 'clouds.yaml' file is not the only way to configure these
tools. You can also use old school environment variables. By using an
openrc file from Horizon (or the clouds2env tool [1]), we will set
various 'OS_'-prefixed environment variables. When you use the 'config
show' command with these environment variables set, we will see all of
these values appear in the output *without* an 'auth.' prefix. Scanning
down we will see the password value is not redacted.

  $ openstack config show
  +---------------------------------------------+----------------------------------+
  | Field                                       | Value                            |
  +---------------------------------------------+----------------------------------+
  | additional_user_agent                       | [('osc-lib', '2.6.0')]           |
  | api_timeout                                 | None                             |
  ...
  | password                                    | secret-password                  |
  ...

This will also happen if using tokens. This is obviously incorrect.
These should be masked also. Make it so. This involves enhancing our
fake config generation code to generate config that looks like it came
from environment variables.

Change-Id: I560b928e5e6bcdcd89c409e0678dfc0d0b056c0e
Story: 2008816
Task: 42260
2022-08-01 19:54:44 +09:00
Zuul ccd877dd40 Merge "Fix typos" 2022-05-16 09:36:14 +00:00
Rodolfo Alonso Hernandez 1c6d396ba3 Allow "--force" flag in quota network commands
This flag allows to set a new Neutron quota resource limit without
checking first the current resource usage. The new limit will be
set anyway. This flag was used only by the compute engine.

Related-Bug: #1953170
Change-Id: I7084f8208b804236ac99e6842db7a45854ce54d7
2022-03-17 02:38:07 +00:00
Zuul e000fd5f0d Merge "Add network update quota "limit_check" parameter" 2022-02-03 15:53:02 +00:00
Rodolfo Alonso Hernandez bef70397a3 Add network update quota "limit_check" parameter
This new parameter commands the Neutron server to first check the
resource usage before setting the new quota limit. If the resource
usage is below the new limit, the Neutron server will raise an
exception.

Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/806254
Depends-On: https://review.opendev.org/c/openstack/neutron/+/801470

Partial-Bug: #1936408
Change-Id: Idc1b99492d609eb699d0a6bef6cd760458a774f6
2021-12-07 17:49:26 +00:00
Cyril Roelandt 43639e1118 Fix typos
Change-Id: Idd502c8df21da79ff3b9339870f38378f5337879
2021-10-26 15:53:51 +02:00
Stephen Finucane 30612bf622 Remove 'get_osc_show_columns_for_sdk_resource' duplicates
There were a number of 'get_osc_show_columns_for_sdk_resource' defined
in-tree. However, osc-lib has provided this method for some time (since
2.2.0, June 2020 [1] - our minimum version is currently 2.3.0) so
there's no need to provide our own copies. Remove them.

[1] https://github.com/openstack/osc-lib/commit/29a0c5a5

Change-Id: I25695f4f9a379dd691b7eaa1e3247164668ae77e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-10-21 17:14:45 +01:00
Zuul 782e4d0f97 Merge "Add support for token caching" 2021-04-09 23:29:03 +00:00
Artem Goncharov 119d2fae25 project cleanup
New implementation of the project cleanup based on the sdk.project_cleanup.
It is implemented as an additional OSC operation and will ideally obsolete the 
`openstack project purge` giving flexibility to extend services support, 
parallelization, filters, etc.

Change-Id: Ie08877f182379f73e5ec5ad4daaf84b3092c829c
2021-02-02 08:14:34 +00:00
youngho choi 6f616a29b3 Add support '--progress' option for 'image create'
openstack-client doesn’t support the upload progress bar.

This patch shows progressbar when create image
if you added '--progress' option like a python-glanceclient.

like this.
[=============================>] 100%
+------------------+---------------------------+
| Field            | Value                     |
+------------------+---------------------------+
| container_format | bare                      |
| created_at       | 2020-09-06T20:44:40Z      |
...

How to use
Add the'--progress' option on the 'openstack image create' command.

Code was written by referring to 'python-glanceclient' project
on stable/ussuri branch

Change-Id: Ic3035b49da10b6555066eee607a14a5b73797c00
task: 40003
story: 2007777
2021-01-04 17:25:34 +00:00
Artem Goncharov 30d5f14a70 Add support for token caching
SDK starts caching token in keyring (when available and configured). A
small change is required in OSC not to reject this state.
Overall this helps avoiding reauthentication upon next openstack call.
If token is not valid anymore automatically reauthentication is done.

Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/735352
Depends-On: https://review.opendev.org/c/openstack/osc-lib/+/765650
Change-Id: I47261a32bd3b106a589974d3de5bf2a6ebd57263
2020-12-05 15:40:24 +01:00
Zuul 30828112cf Merge "Remove None valued network quota entries" 2020-12-01 13:51:20 +00: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
asarfaty e9bd4ef007 Remove None valued network quota entries
Since the openstack SDK still has the neutron-lbaas entries in the network quota,
but those are already deprecated [1], the 'opentack quota show' command shows those
as None value.
This fix removes those empty deprecated values from the output.

[1] https://review.opendev.org/#/c/658494/
Change-Id: I8dbdba2a029ea8e6a268ddf29627e1466a7e3a8a
2020-09-22 05:12:09 +00:00
Felix Yan 82ebddca00 Fix compatibility issue in 5.3
The offending entry point object looks like:
EntryPoint(name='compute', value='openstackclient.compute.client',
group='openstack.cli.base')

Story: 2007917
Task: 40323
Change-Id: I0f3cc62e23efdc14203ce6645581d5ba5dbf7fa0
2020-07-14 08:06:55 -05:00
Zuul 42692264f7 Merge "switch to stevedore for entry points" 2020-07-07 06:23:55 +00:00
Zuul d0741d7853 Merge "Add '--force; parameter to 'openstack quota set'" 2020-07-06 20:50:24 +00:00
Doug Hellmann 870cf01148 switch to stevedore for entry points
Importing pkg_resources scans every installed distribution to find
all of the entry points. Stevedore is adding a new caching layer using
importlib.metadata, which will not.  Switching to the stevedore should
eventually speed up load times, especially for command line apps. This
change makes the switch now to ensure API compatibility.

We were already using stevedore for tests, so this moves the dependency
from test-requirements.txt to requirements.txt and raises the minimum
version to something more recent.

Change-Id: I3e3632783bc745979b6db73e610df8a77ffaceb0
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2020-07-06 08:44:31 -04:00
Zuul d3691b81c6 Merge "Allow os quota list query to filter by project" 2020-06-29 22:22:25 +00:00
hackertron b328cf74df Add '--force; parameter to 'openstack quota set'
The compute service allows us to to force set a quota, setting a
quota value that is less than the amount of the resource currently
consumed. Expose this feature by way of a '--force' boolean
parameter.

Change-Id: I1d1ac1ac46f49f64794ffc8631e166935537966c
2020-04-14 22:59:52 +02:00