<div dir="ltr">Hi,<div>1.) The migration files are responsible to create the schema during deployment, and there is a helper utility for it neutron-db-manage (see [1], actually similar tools exists for all openstack projects at least I know many)</div><div>With this tool you can generate an empty migration template (see the neutron-db-manage revision command for help)</div><div>The Neutron migration scripts can be found here: <a href="https://opendev.org/openstack/neutron/src/branch/master/neutron/db/migration/alembic_migrations/versions">https://opendev.org/openstack/neutron/src/branch/master/neutron/db/migration/alembic_migrations/versions</a></div><div>Of course there fill be a similar tree for all Networking projects.</div><div>(NOTE: Since perhaps Ocata we have only expand scripts to make upgrade easier for example)</div><div>Devstack and other deployment tools upgrade the db, but with neutron-db-manage you can do it manually with neutron-db-manage upgrade heads, you can check in the db after it if the schema is as you expected.</div><div><br></div><div>2.) For Neutron the schema again written under models, here: <a href="https://opendev.org/openstack/neutron/src/branch/master/neutron/db/models">https://opendev.org/openstack/neutron/src/branch/master/neutron/db/models</a>, it looks like a duplication as it is nearly the same as the migration script, but this code will be used by Neutron itself not only during the deployment or upgrade.</div><div>For some stadium projects it is possible as I remember the *_db file contains the schema description and the code that actually uses the db to fetch or store values in it, like bgpvpn (See [2]).</div><div>In Neutron (and in many other Openstack projects, if not all) we have another layer over the the which is the OVO (Oslo Versioned Objects), and that is used in most places and that hides the actual accessing of the db with high level python classes (see: <a href="https://opendev.org/openstack/neutron/src/branch/master/neutron/objects">https://opendev.org/openstack/neutron/src/branch/master/neutron/objects</a> )</div><div><br></div><div>[1]: <a href="https://docs.openstack.org/neutron/latest/contributor/alembic_migrations.html">https://docs.openstack.org/neutron/latest/contributor/alembic_migrations.html</a></div><div>[2]: <a href="https://opendev.org/openstack/networking-bgpvpn/src/branch/master/networking_bgpvpn/neutron/db/bgpvpn_db.py">https://opendev.org/openstack/networking-bgpvpn/src/branch/master/networking_bgpvpn/neutron/db/bgpvpn_db.py</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Igor Zhukov <<a href="mailto:fsb4000@yandex.ru">fsb4000@yandex.ru</a>> ezt írta (időpont: 2022. aug. 25., Cs, 2:48):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Lajos.<br>
Thank you.<br>
I have a progress. I think my fake extension works.<br>
<br>
I added <br>
```<br>
extensions.register_custom_supported_check(<br>
"vpc_extension", lambda: True, plugin_agnostic=False<br>
)<br>
```<br>
to<br>
```<br>
class Vpc(api_extensions.ExtensionDescriptor):<br>
extensions.register_custom_supported_check(<br>
"vpc_extension", lambda: True, plugin_agnostic=False<br>
)<br>
...<br>
```<br>
<br>
and I use ml2 extension driver without any new plugin. <a href="https://github.com/openstack/neutron/blob/master/neutron/tests/unit/plugins/ml2/drivers/ext_test.py#L44" rel="noreferrer" target="_blank">https://github.com/openstack/neutron/blob/master/neutron/tests/unit/plugins/ml2/drivers/ext_test.py#L44</a><br>
<br>
I tested it with python neutronclientapi. So I can change my new attribute (neutron.update_network(id, {'network': {'new_attribute': some string }})) <br>
and I see my changes (neutron.list_networks(name='demo-net'))<br>
<br>
I'm close to the end.<br>
Now I'm using modifed `TestExtensionDriver(TestExtensionDriverBase):`. It works but It stores the data locally. <br>
And I want to use class TestDBExtensionDriver(TestExtensionDriverBase): (<a href="https://github.com/openstack/neutron/blob/master/neutron/tests/unit/plugins/ml2/drivers/ext_test.py#L169" rel="noreferrer" target="_blank">https://github.com/openstack/neutron/blob/master/neutron/tests/unit/plugins/ml2/drivers/ext_test.py#L169</a>)<br>
<br>
I tried to use it but I got such errors in neutron-server.log: "Table 'neutron.myextension.networkextensions' doesn't exist"<br>
How can I create a new table?<br>
I saw <a href="https://docs.openstack.org/neutron/latest/contributor/alembic_migrations.html" rel="noreferrer" target="_blank">https://docs.openstack.org/neutron/latest/contributor/alembic_migrations.html</a> and <a href="https://github.com/openstack/neutron-vpnaas/tree/master/neutron_vpnaas/db" rel="noreferrer" target="_blank">https://github.com/openstack/neutron-vpnaas/tree/master/neutron_vpnaas/db</a> but I still don't understand.<br>
I mean I think some of the neutron_vpnaas/db files are generated. Are neutron_vpnaas/db/migration/alembic_migrations/versions generated?<br>
Which files I should create(their names, I think I can copy from neutron_vpnaas/db/) and what commands to type to create one new table: <a href="https://github.com/openstack/neutron/blob/master/neutron/tests/unit/plugins/ml2/drivers/ext_test.py#L136-L144" rel="noreferrer" target="_blank">https://github.com/openstack/neutron/blob/master/neutron/tests/unit/plugins/ml2/drivers/ext_test.py#L136-L144</a> ?<br>
<br>
<br>
> Hi Igor,The line which is interesting for you: "Extension vpc_extension not supported by any of loaded plugins"<br>
> In core Neutron for ml2 there is a list of supported extension aliases:<br>
> <a href="https://opendev.org/openstack/neutron/src/branch/master/neutron/plugins/ml2/plugin.py#L200-L239" rel="noreferrer" target="_blank">https://opendev.org/openstack/neutron/src/branch/master/neutron/plugins/ml2/plugin.py#L200-L239</a><br>
> <br>
> And there is a similar for l3 also:<br>
> <a href="https://opendev.org/openstack/neutron/src/branch/master/neutron/services/l3_router/l3_router_plugin.py#L98-L110" rel="noreferrer" target="_blank">https://opendev.org/openstack/neutron/src/branch/master/neutron/services/l3_router/l3_router_plugin.py#L98-L110</a><br>
> <br>
> Or similarly for QoS:<br>
> <a href="https://opendev.org/openstack/neutron/src/branch/master/neutron/services/qos/qos_plugin.py#L76-L90" rel="noreferrer" target="_blank">https://opendev.org/openstack/neutron/src/branch/master/neutron/services/qos/qos_plugin.py#L76-L90</a><br>
> <br>
> So you need a plugin that uses the extension.<br>
> <br>
> Good luck :-)<br>
> Lajos Katona (lajoskatona)<br>
> <br>
> Igor Zhukov <<a href="mailto:fsb4000@yandex.ru" target="_blank">fsb4000@yandex.ru</a>> ezt írta (időpont: 2022. aug. 23., K, 16:04):<br>
> <br>
>> Hi again!<br>
>><br>
>> Do you know how to debug ML2 extension drivers?<br>
>><br>
>> I created folder with two python files: vpc/extensions/vpc.py and vpc/plugins/ml2/drivers/vpc.py (also empty __init__.py files)<br>
>><br>
>> I added to neuron.conf<br>
>><br>
>> api_extensions_path = /path/to/vpc/extensions<br>
>><br>
>> and I added to ml2_ini.conf<br>
>><br>
>> extension_drivers = port_security, vpc.plugins.ml2.drivers.vpc:VpcExtensionDriver<br>
>><br>
>> and my neutron.server.log has:<br>
>><br>
>> INFO neutron.plugins.ml2.managers [-] Configured extension driver names: ['port_security', 'vpc_neutron.plugins.ml2.drivers.vpc:VpcExtensionDriver']<br>
>><br>
>> WARNING stevedore.named [-] Could not load vpc_neutron.plugins.ml2.drivers.vpc:VpcExtensionDriver<br>
>><br>
>> ....<br>
>><br>
>> INFO neutron.api.extensions [req-fd226631-b0cd-4ff8-956b-9470e7f26ebe - - - - -] Extension vpc_extension not supported by any of loaded plugins<br>
>><br>
>> How can I find why the extension driver could not be loaded?<br>
>><br>
>>> Hi,The fake_extension is used only in unit tests to test the extension framework, i.e. :<br>
>><br>
>>> <a href="https://opendev.org/openstack/neutron/src/branch/master/neutron/tests/unit/plugins/ml2/drivers/ext_test.py#L37" rel="noreferrer" target="_blank">https://opendev.org/openstack/neutron/src/branch/master/neutron/tests/unit/plugins/ml2/drivers/ext_test.py#L37</a><br>
>><br>
>>><br>
>><br>
>>> If you would like to write an API extension check neutron-lib/api/definitions/ (and you can find the extensions "counterpart" under neutron/extensions in neutron repository)<br>
>><br>
>>><br>
>><br>
>>> You can also check other Networking projects like networking-bgvpn, neutron-dynamic-routing to have examples of API extensions.<br>
>><br>
>>> If you have an extension under neutron/extensions and there's somebody who uses it (see [1]) you will see it is loaded in neutron servers logs (something like this: "Loaded extension: address-group") and you can find it in the output of openstack extension list --network<br>
>><br>
>>><br>
>><br>
>>> [1]: <a href="https://opendev.org/openstack/neutron/src/branch/master/neutron/plugins/ml2/plugin.py#L200" rel="noreferrer" target="_blank">https://opendev.org/openstack/neutron/src/branch/master/neutron/plugins/ml2/plugin.py#L200</a><br>
>><br>
>>><br>
>><br>
>>> Best wishes<br>
>><br>
>>> Lajos Katona<br>
>><br>
>>><br>
>><br>
>>> Igor Zhukov <<a href="mailto:fsb4000@yandex.ru" target="_blank">fsb4000@yandex.ru</a>> ezt írta (időpont: 2022. aug. 22., H, 19:41):<br>
>><br>
>>><br>
>><br>
>>>> Hi all!<br>
>><br>
>>>><br>
>><br>
>>>> Sorry for a complete noob question but I can't figure it out 😿<br>
>><br>
>>>><br>
>><br>
>>>> So if I want to add Fake ML2 extension what should I do?<br>
>><br>
>>>><br>
>><br>
>>>> I have neutron server installed and I have the file: <a href="https://github.com/openstack/neutron/blob/master/neutron/tests/unit/plugins/ml2/extensions/fake_extension.py" rel="noreferrer" target="_blank">https://github.com/openstack/neutron/blob/master/neutron/tests/unit/plugins/ml2/extensions/fake_extension.py</a><br>
>><br>
>>>><br>
>><br>
>>>> How to configure neutron server, where should I put the file, should I create another files? How can I test that it works?<br>
</blockquote></div>