|
| 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>/``. |
0 commit comments