Skip to content

Commit 14c8266

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Neutron: Move bgpvpn osc client code from neutronclient"
2 parents 224f854 + eb95ef5 commit 14c8266

18 files changed

Lines changed: 3341 additions & 1 deletion

doc/source/contributor/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
command-errors
1313
command-logs
1414
plugins
15+
osc-plugin-migration
1516
humaninterfaceguide
1617
api/modules
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
.. _neutron-cli-migration:
2+
3+
===========================================
4+
Migrating Project Client OSC Plugins to OSC
5+
===========================================
6+
7+
The guide documents the process for migrating project client OSC plugins from
8+
the project client into ``python-openstackclient``. It focuses on neutron client
9+
and clients for special networking services that were previously implemented as
10+
external OSC plugins (e.g., BGP VPN, TaaS, etc.), but it should apply to any
11+
project client's OSC plugin.
12+
13+
Background
14+
==========
15+
16+
Historically, advanced Neutron services provided their CLI commands through
17+
``python-neutronclient`` as OSC plugins. As the old python-xclient libraries
18+
were deprecated and their functionality were moved to python-openstackclient
19+
these plugins were also decided to move to python-openstackclient, see the
20+
2025 October PTG etherpad:
21+
https://etherpad.opendev.org/p/oct2025-ptg-neutron#L156
22+
23+
These migrated commands become part of the core OSC codebase but are
24+
organized in separate subdirectories under ``openstackclient/network/v2/``
25+
to maintain clear separation and ownership.
26+
27+
Migration Steps
28+
===============
29+
30+
1. Create the Command Module Directory
31+
---------------------------------------
32+
33+
Create a new python module under ``openstackclient/network/v2/`` for your
34+
service with apropriate name, for example for tap-as-a-service ``taas``.
35+
36+
2. Migrate the Command Classes
37+
-------------------------------
38+
39+
Copy or migrate your command implementation files from the neutronclient
40+
plugin to the new directory. Each command should inherit from the appropriate
41+
base class (i.e.: ``command.Command``, ``command.Lister``, or
42+
``command.ShowOne``).
43+
44+
3. Register Entry Points in pyproject.toml
45+
-------------------------------------------
46+
47+
Add entry points for your commands in ``pyproject.toml`` under a dedicated
48+
group. The group name should be the same as the module name under
49+
``network/v2``.
50+
51+
Example for BGP VPN:
52+
53+
.. code-block:: toml
54+
55+
[project.entry-points."openstack.network.v2.bgpvpn"]
56+
bgpvpn_create = "openstackclient.network.v2.bgpvpn.bgpvpn:CreateBgpvpn"
57+
bgpvpn_delete = "openstackclient.network.v2.bgpvpn.bgpvpn:DeleteBgpvpn"
58+
bgpvpn_list = "openstackclient.network.v2.bgpvpn.bgpvpn:ListBgpvpn"
59+
bgpvpn_show = "openstackclient.network.v2.bgpvpn.bgpvpn:ShowBgpvpn"
60+
bgpvpn_set = "openstackclient.network.v2.bgpvpn.bgpvpn:SetBgpvpn"
61+
bgpvpn_unset = "openstackclient.network.v2.bgpvpn.bgpvpn:UnsetBgpvpn"
62+
63+
4. Register the Service in API_EXTENSIONS
64+
------------------------------------------
65+
66+
Add your service name to the ``API_EXTENSIONS`` tuple in
67+
``openstackclient/network/client.py``:
68+
69+
.. code-block:: python
70+
71+
API_EXTENSIONS = ('taas', 'bgpvpn', '<your_service>')
72+
73+
This tells OSC to load the entry points from your dedicated group.
74+
75+
5. Ignore the Old Neutronclient Plugin
76+
---------------------------------------
77+
78+
To prevent conflicts with the old neutronclient plugin (if users still have
79+
it installed), add the old plugin module to the ``IGNORED_MODULES`` tuple in
80+
``openstackclient/shell.py``:
81+
82+
.. code-block:: python
83+
84+
IGNORED_MODULES = (
85+
'neutron_taas.taas_client.osc',
86+
'neutronclient.osc.v2.taas',
87+
'neutronclient.osc.v2.networking_bgpvpn',
88+
'neutronclient.osc.v2.<your_old_plugin>',
89+
)
90+
91+
6. Add Unit Tests
92+
-----------------
93+
94+
Create unit tests under ``openstackclient/tests/unit/network/v2/<service_name>/``.

openstackclient/network/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
API_VERSION_OPTION = 'os_network_api_version'
2626
API_NAME = 'network'
2727
API_VERSIONS = ('2.0', '2')
28-
API_EXTENSIONS = ('fwaas', 'taas')
28+
API_EXTENSIONS = ('bgpvpn', 'fwaas', 'taas')
2929

3030

3131
def make_client(instance: Any) -> Any:

openstackclient/network/v2/bgpvpn/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)