Commit graph

726 commits

Author SHA1 Message Date
Zuul
31251e33ec Merge "Handle NotFoundException when listing floating IPs" 2024-09-13 18:58:51 +00:00
Nate Johnston
b0936c5b30 Handle NotFoundException when listing floating IPs
Asking for floating IPs on an undercloud results in a NotFoundException.
Make openstackclient handle it gracefully.

No test is added for this because it would need to be a scenario test -
deploying a cloud without the foalting IP extension loaded.  I don't
think this edge case is worth an entire new job just to exercise it.

Change-Id: I73b544853376d98ab0dbb14e32fefc43c1a8a179
Story: 2006863
2024-09-13 11:34:05 +01:00
Stephen Finucane
f98006ca9d pre-commit: Migrate pyupgrade to ruff
Change-Id: Ic50d2a5e0bc9dcdfe29f382607135cab510cd396
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-09-12 18:08:23 +01:00
Stephen Finucane
519fa7aabc pre-commit: Migrate from black to ruff format
Change-Id: I28ca7d31d30272002799f3e2832105dc67c60538
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-08-29 15:55:39 +01:00
Stephen Finucane
17e6545fd4 trivial: Remove unnecessary trailing comma
Change-Id: I62402145c17f96626ec6e29598e32dee03a6038e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-08-29 15:55:39 +01:00
Stephen Finucane
209f8e9e17 network: Replace use of in-tree API client
None of these are actually supported by openstacksdk (intentionally so)
so we add our own manual implementations.

Change-Id: Ifd24f04ae4d1e56e0ce5ba0afe63828403bb7a6f
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-07-09 18:19:36 +01:00
Stephen Finucane
e0f7306011 network: Migrate 'port list' to compute SDK
We use the compute client here to look up server IDs when filtering by
'device_id'.

Change-Id: I76515eaa4ce4e7c7d0173d2e0a91d7564ba7041a
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-07-02 17:52:02 +01:00
Brian Haley
5483370981 Remove admin only text from 'port create' help text
Specifying a MAC address is only admin only for
'port set' [0], remove it from the 'port create'
help text.

[0] https://docs.openstack.org/api-ref/network/v2/index.html#ports

Change-Id: Ic3296dd03676b460b3d08b1bbaae6f1d132e839d
2024-05-24 16:38:50 -04:00
Zuul
5e5b89f906 Merge "Router flavor_id can be a name" 2024-05-08 19:43:44 +00:00
elajkat
2e7ba5e3dd Router flavor_id can be a name
Change-Id: I72fc21a1adb4790a2a51e9b37744ee1ee3d01f32
Partial-Bug: #2020823
2024-05-06 13:36:04 +02:00
Stephen Finucane
c5b772db76 trivial: Prepare for pyupgrade pre-commit hook
This change is entirely automated save for the update of some mocks from
'io.open' to '__builtins__.open').

We are keeping this change separate from addition of the actual hook so
that we can ignore the commit later.

Change-Id: I0a9d8736632084473b57b57b693322447d7be519
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-04-23 12:24:23 +01:00
Stephen Finucane
ee23995004 pre-commit: Bump versions
We fold in the new black changes also.

Change-Id: I326a0529b6b9f2aa9fbc33862567131839460797
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-04-23 12:22:26 +01:00
Zuul
147503f3c6 Merge "Add NUMA affinity policy options "socket"" 2024-04-15 13:00:49 +00:00
Zuul
54bb7477f2 Merge "Do not sort subnet dns_nameservers field" 2024-04-15 13:00:39 +00:00
Zuul
34ae192332 Merge "refectoring: remove duplicate declaration" 2024-04-12 01:55:18 +00:00
Zuul
51f173c8cc Merge "Add router default route BFD/ECMP options" 2024-04-05 15:55:03 +00:00
Zuul
79974668b8 Merge "Add support for managing external gateways" 2024-04-05 15:55:01 +00:00
Zuul
948034e6c1 Merge "router: Use plural form for storage of `--fixed_ip` argument" 2024-03-26 17:34:43 +00:00
Zuul
5f4236d7db Merge "Parse external-gateway argument in separate helper" 2024-03-26 17:34:41 +00:00
Youngjun
a4db11c62e refectoring: remove duplicate declaration
Change-Id: I0d9e3d25bc42df56be31defaea13bbe7aaa21caa
Signed-off-by: Youngjun <yj.yoo@okestro.com>
2024-03-13 10:04:04 +09:00
Frode Nordahl
7184e876a5
Add router default route BFD/ECMP options
Add the `--enable-default-route-bfd`, `--disable-default-route-bfd`
`--enable-default-route-ecmp` and `--disable-default-route-ecmp`
options for `router create` and `router set` commands.

Related-Bug: #2002687
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Change-Id: Ia5a196daa87d29445dc5514dcb91544f9d470795
2024-03-05 16:14:56 +01:00
Dmitrii Shcherbakov
16c695045c
Add support for managing external gateways
This change implements the logic to call the new API for managing
external gateways.

Relevant Neutron core change:
https://review.opendev.org/c/openstack/neutron/+/873593

Co-Authored-by: Frode Nordahl <frode.nordahl@canonical.com>
Related-Bug: #2002687
Change-Id: Ib45f30f552934a0a5c035c3b7fadfc0d522219ba
2024-03-05 16:14:56 +01:00
Frode Nordahl
58ad3cefa7
router: Use plural form for storage of `--fixed_ip` argument
The variable already takes multiple values, let's make it obvious
just by reading the code.

Related-Bug: #2002687
Change-Id: I294ee710d989d7a3a54331fca424e84708a2faab
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
2024-03-05 16:14:19 +01:00
Frode Nordahl
f696aee81d
Parse external-gateway argument in separate helper
This is to prepare for subsequent patches that will add support
for managing multiple gateways.

Related-Bug: #2002687
Change-Id: Ic088dca0b7cd83bd7568d775b4e70285ce72411d
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
2024-03-05 11:26:15 +01:00
Rodolfo Alonso Hernandez
966051cfe2 Add NUMA affinity policy options "socket"
Added a new port NUMA affinity policy option called "socket".

Depends-On: https://review.opendev.org/c/openstack/neutron/+/910594

Related-Bug: #2052786
Change-Id: Icff9070db68ba83b47b344d56ee93b235383b2f2
2024-02-24 11:15:45 +00:00
James Black
93b73e9b29 Bug Fix, Default SG Rule Custom SG
Currently the Default setting for CustomSG Rule
is set to True, this means all new SGs inherit
these rules, with no way for user to override
this behavior.

Closes Bug: #2054629

Change-Id: Icef7c91654dbced76a5492437e723c4e2a0f3102
2024-02-23 08:31:25 -08:00
Brian Haley
75ed315885 Do not sort subnet dns_nameservers field
When using table output format, the dns_nameservers field
of a subnet is sorted, but it should not be as the order
is important.

Created an UnsortedListColumn() class in subnet.py so the
output is correct.

Updated the unit test accordingly to verify the order is
correct when an entry is removed.

Change-Id: I60a15a944f83549738305dd025db38ff8e165be7
Closes-bug: #2053201
2024-02-14 17:28:04 -05:00
Stephen Finucane
c128ae1969 trivial: Don't ignore missing resources
An openstacksdk 'find_foo' proxy method will return None by default if a
resource is not found. You can change this behavior by setting
'ignore_missing=False'. We were doing this in most, but not all cases:
correct the issue.

In the event of calling 'image delete' with multiple images, it will no
longer fail on the first missing image and will instead attempt to
delete remaining images before failing.

Change-Id: I1e01d3c096dcaab731c28e496a182dd911229227
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-02-13 16:33:56 +00:00
Zuul
c29e05764b Merge "Add "hardware_offload_type" attribute to "port"" 2024-01-30 12:16:43 +00:00
Zuul
f0f811ce4b Merge "[codespell] fix typos in doc,tests and help messages" 2024-01-30 09:34:00 +00:00
Rodolfo Alonso Hernandez
0725bb474c Add "hardware_offload_type" attribute to "port"
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/892771
Related-Bug: #2013228

Change-Id: I2c6fd434be4ae8cc41edf45fefe150a41cbfe0bd
2024-01-24 14:33:23 +00:00
Zuul
4bafc32616 Merge "Fix clearing of dns_domain and description on a network by setting to empty strings" 2024-01-10 18:31:42 +00:00
Brian Haley
e7bc3d9b82 Fix --use-prefix-delegation subnet create argument
The --use-prefix-delegation argument when creating a
subnet should not take an argument of True/False, it
should simply trigger the code to set subnetpool_id
value to 'prefix_delegation'. Change action to correct
this.

Added unit test to cover missing checks.

Related-bug: #2028159
Change-Id: Ib7ee80100327b8611d4a354c7f4eb0e696c953da
2024-01-09 17:23:03 -05:00
Stephen Finucane
be3d438ed2 trivial: Place positional opts last
Change-Id: I5479e71223c8c224e0bba387348e740c997cc7bf
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-12-14 12:31:26 +00:00
Stephen Finucane
1b6b639c9f network: Clarify purpose of default sg rules
These only apply to newly created default security groups i.e. when you
create a new project. They do not apply to existing default security
groups.

Change-Id: Ie01bf47dd8a0392354d17d984b41c1fad504e659
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-12-14 12:30:03 +00:00
Zuul
2957f28ff1 Merge "tests: Enable logging fixture" 2023-12-05 18:43:13 +00:00
Florian Streibelt
ce0765facb
Fix clearing of dns_domain and description on a network by setting to empty strings
After setting a default dns_domain on a network

 openstack net set --dns-domain 'example.com.' <NETWORKID>

the setting could not be reverted back to an empty string using

 openstack net set --dns-domain '' <NETWORKID>

and the call also does not emit any error.

The same is true for the description of a network.

Reason was using the parsed argument directly as a condition instead of
comparing against None -- dropping the empty string as valid value.

The name parameter already accepted an empty string.

This change also adds a testcase for dns_domain, description and the
network name parameter, checking if the empty string is forwarded.

Change-Id: Ia7b9738205002b028c19e4f397411c86469cba1a
2023-11-24 12:36:07 +01:00
Rajesh Tailor
71839eb5fa [codespell] fix typos in doc,tests and help messages
Change-Id: I4823782daa1af3872bc22603147e3073152cc777
2023-11-21 11:31:07 +05:30
Stephen Finucane
c08d6e0391 parseactions: Use ArgumentError, not ArgumentTypeError
If you use the former, you get a pretty error message when there's a
failure. If you use the latter, you get an ugly traceback when used with
the '--debug' flag.

Without this change:

  $ openstack flavor create ... --property '' foo
  ...
  Traceback (most recent call last):
    File "/tmp/venv/lib/python3.11/site-packages/cliff/app.py", line 402, in run_subcommand
      parsed_args = cmd_parser.parse_args(sub_argv)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/argparse.py", line 1862, in parse_args
      args, argv = self.parse_known_args(args, namespace)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/argparse.py", line 1895, in parse_known_args
      namespace, args = self._parse_known_args(args, namespace)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/argparse.py", line 2107, in _parse_known_args
      start_index = consume_optional(start_index)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/argparse.py", line 2047, in consume_optional
      take_action(action, args, option_string)
    File "/usr/lib64/python3.11/argparse.py", line 1971, in take_action
      action(self, namespace, argument_values, option_string)
    File "/tmp/venv/lib/python3.11/site-packages/osc_lib/cli/parseractions.py", line 45, in __call__
      raise argparse.ArgumentTypeError(msg % str(values))
  argparse.ArgumentTypeError: Expected 'key=value' type, but got:
  clean_up CreateFlavor: Expected 'key=value' type, but got:

With this change:

  $ openstack flavor create ... --property '' foo
  ...
  usage: openstack flavor create [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN]
                                 [--noindent] [--prefix PREFIX] [--max-width <integer>]
                                 [--fit-width] [--print-empty] [--id <id>]
                                 [--ram <size-mb>] [--disk <size-gb>]
                                 [--ephemeral <size-gb>] [--swap <size-mb>]
                                 [--vcpus <vcpus>] [--rxtx-factor <factor>]
                                 [--public | --private] [--property <key=value>]
                                 [--project <project>] [--description <description>]
                                 [--project-domain <project-domain>]
                                 <flavor-name>
  openstack flavor create: error: argument --property: Expected 'key=value' type, but got:
  clean_up CreateFlavor:

Change-Id: I9e78b35ad9d016d7a33655141ec579397c5344c0
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-11-15 11:33:19 +00:00
Stephen Finucane
89a8f72960 tests: Enable logging fixture
Quieten the output of our test runs significantly.

Change-Id: Ie32c919bb987eb0b9bc4c5b2ec54ee20a6841c03
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-11-13 17:31:07 +00:00
Slawek Kaplonski
7b99b57165 Add support for default security group rule CRUDs
Change-Id: I1c18c2ec5eb4923e1ab8b3fc6199ef6f329b4a4d
2023-10-19 16:04:22 +02:00
Zuul
98fbc56603 Merge "Fix --security-group for port list" 2023-10-11 15:59:22 +00:00
Stephen Finucane
fb2e0ced6e tests: Explicitly specify port fields for output
Rather than excluding the few fields we don't want, explicitly indicate
the ones we do want. We were already in-effect doing this in our tests,
so this is simply moving the definition from tests to the main code.

Note that this is a problem in the tests for virtually all commands
that will be seen as the SDK continues to evolve and new fields are
added to existing resources. This is a problem that be solved over
time though, rather than in a big bang commit.

Change-Id: Iaa64e97450f5c73cab2e2c3b0c741aec1495b4f1
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-09-12 08:33:20 +00:00
Miguel Lavalle
f8f174c458 Add the flavor-id option to router create
The --flavor-id option is added to the router create command. The
flavor_id attribute has been supported by the Neutron API for router
POST operations since a long time ago [0].

Partial-Bug: #2020823

[0] https://review.opendev.org/c/openstack/neutron-lib/+/494289

Change-Id: If88499533a92c09e67b0827d1d64156682a3bb8e
2023-08-17 10:03:28 -05:00
Bence Romsics
22d1a26d1d Neutron port hints
Introduce the hints port attribute that allows passing in backend
specific hints mainly to allow backend specific performance tuning.

Enable:
  openstack port create --hint ALIAS=VALUE
  openstack port set --hint ALIAS=VALUE
  openstack port unset --hints

Required neutron extension:
  port-hints
  port-hint-ovs-tx-steering

Valid hint aliases and values:
  ovs-tx-steering=hash
  ovs-tx-steering=thread

The same hints in JSON format, as expected by the Neutron API:
  {"openvswitch": {"other_config": {"tx-steering": "hash"}}}
  {"openvswitch": {"other_config": {"tx-steering": "thread"}}}

Change-Id: I4c7142909b1e4fb26fc77ad9ba08ec994cc450b2
Depends-On: https://review.opendev.org/c/openstack/neutron/+/873113
Partial-Bug: #1990842
Related-Change (server side): https://review.opendev.org/c/openstack/neutron/+/873113
Related-Change (spec): https://review.opendev.org/c/openstack/neutron-specs/+/862133
2023-05-24 13:08:15 +02:00
Stephen Finucane
6475dc58e8 Blacken openstackclient.network
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: I8048746dbc2ef0cb582f68934734db4c1153d779
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-05-10 10:51:30 +01:00
Artem Goncharov
a675c61e46 Fix pep issue in the network service provider
pep gods started complaining (correctfully) about spacing in the old
command. Apply `black -l 79` on the file to make it looking nice and
passing checks.

Change-Id: I716f6a1496fc552b32809c7eb744283f3a3cd5a4
2023-04-20 11:15:37 +02:00
Rodolfo Alonso Hernandez
f1cf3a10b5 Show Network QoS rules one per line
The command "network show qos policy <qos>" now shows the QoS rules
printed one per line.

Example: https://paste.opendev.org/show/bgam6amfLUVheAMhDxB3/
Change-Id: I65a99da16056902a822804e29b2dd9376a72e091
2023-03-28 18:18:49 +02:00
Johannes Kulik
aa227f8d16 Fix --security-group for port list
"openstack port list --security-group <id>" was using a filter that
didn't exist in `openstacksdk`: "security_groups". Up until version
1.0.1, `openstacksdk` did not support filtering `Port` objects by
security groups. Later versions will support the filtering (via [1]),
but the filter is called the same way the attribute on the `Port` object
is called: `security_group_ids`.

We're not bumping the `openstacksdk` version here, because the feature
we're using [1] is merged too recently and a bump of min requirements
thus unlikely. `openstackclient` continue to work with older versions of
`openstacksdk` - the "--security-group" filter will just do nothing like
before.

[1] https://review.opendev.org/c/openstack/openstacksdk/+/866008

Change-Id: I07088484592e99ce0a12b67d68a3e47ae7c7af81
2023-03-20 15:19:46 +01:00
Zuul
02acd27c6a Merge "Add port ranges on floating ip portforwardings cli" 2023-02-22 12:32:14 +00:00