26 Commits

Author SHA1 Message Date
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
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
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
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
Slawek Kaplonski
b26b7f3440 Allow to send extra attributes in Neutron related commands
To deprecate and drop support for neutronclient CLI and use only
OSC we need feature parity between OSC and neutronclient.
Last missing piece here is possibility to send in POST/PUT requests
unknown parameters to the Neutron server.
This patch adds such possibility to the OSC.

Change-Id: Iba09297c2be9fb9fa0be1b3dc65755277b79230e
2021-05-26 09:29:15 +02: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
Eric Fried
cd6c285cc6 neutron: autogenerate docs
$namespace = openstack.network.v2

The subcommand documents for $namespace were hardcoded and thus prone to
drift over time. This commit removes the hardcoded content and uses the
autoprogram-cliff directive to generate them automatically from the
subcommand configuration classes.

This one turned out to be quite involved, because we support both
neutron and nova-network. When running in a real cloud, the command
classes detect whether the neutron service is present, assume
nova-network if that service is not found, and only add parser options
relevant to the detected service. But the docs need to present both sets
of options. This was easy enough when they were hardcoded, but required
a bit of additional infrastructure for generated docs.

Change-Id: I426261eb1d86bcc68656aabd61f10b7f082da402
2019-11-01 14:24:30 -05:00
Pierre Hanselmann
b8754e15e7 Add dns-domain support to Network object
Add "dns-domain" parameter to Network class. Also check
backend extensions and send an error message in case of
an argument (like dns-domain) is sent and the extension is
missing (dns-integration in this case).

Change-Id: I7303658c27d9b9f2d8381ccea0b29e96909cab54
Closes-Bug: 1633214
Partial-Bug: 1547736
2018-04-23 08:37:27 +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
Hongbin Lu
8b31e2bc48 Show detailed message of neutron exception
This patch improves the error message by retrieving the more details
from the exception instance. Otherwise, the real error message won't
be displayed (unless using --debug in the command).

Change-Id: I8ba694bda86f7cc8362e301b2044d9b610dde49c
2017-11-14 23:25:52 +00:00
Jordan Pittier
52279b1b04 network.common.NetworkAndComputeShowOne: catch HttpException
Problem: if a user issue the cmd 'openstack floating ip create public'
and has already maxed his quota for FIP, OSC exits with a not so useful
message:

>jordan@jordan-XPS13-9333:~ $ openstack floating ip create public
>HttpException: Conflict

This patches catch the HttpException earlier and prints a more
verbose message:

> jordan@jordan-XPS13-9333:~ $ openstack floating ip create public
> Error while executing command: Quota exceeded for resources: ['floatingip']

Change-Id: I7c87524d871d230d92f007c32e06439b34c7194a
2016-11-10 16:30:23 +01:00
Huanxuan Ao
5e06d6a3a6 Change to plural form of object in multi delete error message in networkv2
Usually, the error message of multi delete is:
"'result' of 'total' 'objects' failed to delete"
the objects is a plural form.
To match the other multi delete error messages
in OSC, change the object in delete error message
in networkv2 to a plural form. Just add a 's' in
the message.

Change-Id: I17e0735d025bb61014db709d2639813565015b3d
2016-07-14 18:34:19 +08:00
Tang Chen
047cb68493 Standardize logger usage
Use file logger for all command specific logs.

This patch also fixes some usage that doesn't
follow rules in:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html

After this patch, all self.log and self.app.log
will be standardized to LOG().

NOTE: In shell.py, we got the log in class OpenStackShell,
      which is also known as self.app.log in other classes.
      This logger is used to record non-command-specific logs.
      So we leave it as-is.

Change-Id: I114f73ee6c7e84593d71e724bc1ad00d343c1896
Implements: blueprint log-usage
2016-06-20 15:16:51 +00:00
Dean Troyer
9e2b8e6730 osc-lib: command
Leave command.py and test_command.py as a sanity check during the
deprecation period.

Change-Id: I24e1b755cbfbcbcaeb5273ec0c9706b82384fc85
2016-06-13 11:00:22 -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
Tang Chen
5a3a7867a8 Trivial: Fix i18n support in network/common.py
Some missing i18n problems in network.

Change-Id: I45a09a6ada1aad5a64256c0d0a0a2b6e250df670
2016-05-31 20:31:28 +08:00
Tang Chen
56f9227063 Enhance exception handling for "network delete" command
This patch rework "network delete" command following the
rules in doc/source/command-errors.rst.

In "network delete" command, there are multiple REST API
calls, and we should make as many of them as possible.
And log error for each one, give a better error message.
Also return a non-zero exit code.

Change-Id: I39ae087dd7bd08d049d513abfa6c5cab2bd13b2b
Partial-Bug: #1556719
2016-04-14 13:54:14 +08:00
Jenkins
bb153b705a Merge "Refactor security group rule delete to use SDK" 2016-02-18 09:03:27 +00:00
Richard Theis
04e45bbacd Add NetworkAndCompute Lister and ShowOne classes
This patch set introduces the NetworkAndComputeLister and
NetworkAndComputeShowOne classes which are related to the
NetworkAndComputeCommand class.  These classes are for commands
that must support neutron and nova network.  The new classes
allows both the parser and actions to be unique.

Change-Id: I1b59264cd40aaf1062f4e8db233ccb7fd0e95f0e
Partial-Bug: #1519511
Partial-Bug: #1519512
Related-to: blueprint neutron-client
2016-02-12 07:14:32 -06:00
Richard Theis
a29c9732d7 Refactor security group rule delete to use SDK
Refactored the 'os security group rule delete' command to use the
SDK when neutron is enabled, but continue to use the nova client
when nova network is enabled.

This patch set also introduces new FakeSecurityGroupRule classes
for testing network and compute security group rules. And fixes
were made to the network FakeSecurityGroup class.

Change-Id: I8d0917925aa464e8255defae95a2a2adfb6cfb75
Partial-Bug: #1519512
Related-to: blueprint neutron-client
2016-02-10 10:38:35 -06:00
Richard Theis
580b0aff88 Refactor security group delete to use SDK
Refactored the 'os security group delete' command to use the SDK
when neutron is enabled, but continue to use the nova client when
nova network is enabled.

This patch set introduces a new NetworkAndComputeCommand class
to be used for commands that must support neutron and nova network.
The new class allows both the parser and actions to be unique.
The current DeleteSecurityGroup class is now a subclass of this
new class and has moved under the network v2 commands.

This patch set also introduces a new FakeSecurityGroup class for
testing security groups.

And finally, this patch set updates the command documentation
for security group and security group rule to indicate that
Network v2 is also used.

Change-Id: Ic21376b86b40cc6d97f360f3760ba5beed154537
Partial-Bug: #1519511
Related-to: blueprint neutron-client
2016-02-02 09:04:51 -06:00
Terry Howe
7aa6e5e36c SDK integration extensions and server create networks
Finish up the SDK integration with server create network and port
find and extension list.

Change-Id: I18dbada784d8aa92a45a937f251023ddf899c53e
2015-12-09 11:39:20 -07:00
Tang Chen
4be716eb27 Migrate network client to SDK.
The previous patches have migrate all network commands to
the new version using sdk. This patch will remove the
temporary method, and implement a new make_client() to
create sdk network client.

And also, find() in openstackclient/network/common.py must
support sdk. The logic of this function will become much
easier than before, so this patch also removes two useless
test cases of find().

This patch will also remove the patched methods in tests.

Change-Id: Ic2f7bca073beb9757172d16f95d9b82c48cbbc12
Implements: blueprint neutron-client
Co-Authored-By: Terry Howe <terrylhowe@gmail.com>
Co-Authored-By: Tang Chen <tangchen@cn.fujitsu.com>
2015-12-09 09:30:29 +08:00
Tang Chen
a2047d3f9f Trivial: Fix typo in find() in network.
Change-Id: Ic54fbb9160adefe3d025d537125e125128f75ee6
2015-11-27 16:52:56 +08:00
Terry Howe
a065dd09e4 Allow network find to use alternate name
Add the name_attr to the network find method so it can search
for things like floating_ip_address for floating IP addresses
rather than just id.

Change-Id: I827e3745b06397a54555d1286e477bf2e05bf789
2014-07-07 06:11:58 -06:00
Terry Howe
8f59524c3e Network CRUD
bp/neutron
https://wiki.openstack.org/wiki/OpenStackClient/Commands#Network_2

Change-Id: I89ee083154afa544b03587e84becace36d9d522a
2014-06-24 15:00:25 -06:00