[openstack-dev] [Neutron][DB] neutron DB migration scripts

Zang, Rui rui.zang at intel.com
Tue May 26 01:35:03 UTC 2015


Hi Henry,

Your replies are very helpful! Thank you very much.
Some minor replies in line.

Thanks,
Rui Zang

> -----Original Message-----
> From: Henry Gessau [mailto:gessau at cisco.com]
> Sent: Monday, May 25, 2015 10:25 PM
> To: OpenStack Development Mailing List (not for usage questions)
> Subject: Re: [openstack-dev] [Neutron][DB] neutron DB migration scripts
> 
> On Mon, May 25, 2015, Zang, Rui <rui.zang at intel.com> wrote:
> > Greetings,
> >
> > Forgive my alembic ignorance. I am writing some vender specific code that
> wants to create new DB tables for neutron. I have read the
> neutron/db/migration/README file, but still have something unclear.
> > My current understanding is that for DB tables creation, I have to do
> "something" with neutron/db/migration/ .
> >
> > What I have done were:
> > - Copied neutron/db/migration/alembic.ini to $my_plugin_directory
> 
> Are you sure you needed to do this step? I have never needed to.
> 
[Zang, Rui]  I guess you meant that I did not need to *copy* this alembic.ini file.
But I still need this file for neutron-db-manage command, right?


> > - Ran `neutron-db-manage --config-file /etc/neutron/neutron.conf --config-
> file $my_plugin_directory/alembic.ini revision -m "my plugin init ops" --
> autogenerate`. This autogenerate command generated a
> neutron/db/migrations/alembic_migrations/versions/
> ee78798e4af_my_plugin_init_ops.py file. But this file is completely irrelevant
> with my targeted changes.
> 
> Yes, unfortunately the autogenerate currently generates commands to drop all
> the FWaaS, LBaaS and VPNaaS tables since their models are not in the neutron
> tree. You can and should delete all these commands that are not related to
> your new models.
> 
> We have been meaning to fix the autogeneration so that it handles the *aaS
> tables correctly, but it is a little tricky.
> 
> > So I replaced the upgrade() method with the DB table creation code.
> 
> If you import your models file in neutron/db/migration/models/head.py then
> autogenerate should generate the commands for your schemas (in addition to
> the drops for *aaS).
> 
> > - Then ran `neutron-db-manager upgrade` to upgrade to  revision
> ee78798e4af manually, I saw the tables were created.
> >
> > So the questions are:
> > * there are scripts in neutron/db/migration/alembic_migrations/ that
> without a revision prefix, like l3_init_ops.py, they are not in the "versions"
> directory. What are they for?
> 
> They are used by the start migration (havana_initial) and some corner cases.
> You shouldn't need them.
> 
> > * Should I just keep the "ee78798e4af_my_plugin_init_ops.py" file?
> 
> Yes, after modifying it so that it contains only commands for your tables.
> 
> > Seems the metadata files are no longer usable.
> 
> What metadata files?
> 
[Zang, Rui] I meant the "alembic.ini" file and the neutron.conf file

> > * I assume if the revision file ("ee78798e4af_my_plugin_init_ops.py" in my
> case) is already there before devstack is started, the new tables will be created
> by devstack as other tables, right?
> 
> Yes.
> 
> > * Anything what I did wrong or missing?
> 
> You were not too far off. I hope my answers helped.
> 
> > Thanks,
> > Rui Zang
> 
> 
> _________________________________________________________________
> _________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



More information about the OpenStack-dev mailing list