<div dir="ltr">Some comments inline.<div><br></div><div>Salvatore<br><div class="gmail_extra"><br><div class="gmail_quote">On 6 July 2015 at 20:00, Paul Michali <span dir="ltr"><<a href="mailto:pc@michali.net" target="_blank">pc@michali.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I have some urgent requests about migration that I'm hoping to get some info on. I'm working on a bug where I need to add two (related) fields to a table for VPNaaS. Here's the objectives related to migration...</div><div><br></div><div>1) create local_v4_ip and lcoal_v6_ip fields in the vpnservice table</div><div>2) for each entry in the vpnservice table:</div><div>    2.1) Get the router.gw_port.fixed_ips list</div><div>    2.2) Determine the version of each fixed IP and store the first of each version (if any) into the appropriate new field.</div><div><br></div><div>I have created a migration file, and I changed the down_revision to be the number of the revision that is the first in the migration chain in the VPN repo.</div><div><br></div><div>Here are the many questions I have...</div><div><br></div><div>When I look in the VPN repo, the HEAD file has the version 'kilo', which is not the current head. </div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Shouldn't it the version number of the first file in the migration chain?</div></div></blockquote><div><br></div><div>It should indeed. How are you generating the revision script? Using neutron-db-manage it should be updated automatically [1]</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>For my commit, I'm assuming I change the HEAD file to use my migration file's version?</div></div></blockquote><div><br></div><div>You can do that manually too, yes.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>I set HEAD to my migration file, and my file has a down revision of the previous head's revision. If I run 'neutron-db-manage --config-file ../neutron/etc/neutron.conf --config-file ../neutron/etc/neutron/plugins/ml2/ml2_conf.ini check_migration' there is no output so I guess that is OK.</div><div><br></div><div>As I develop my new migration file, is there a way that I can test it (running neutron-db-migration, maybe)?</div></div></blockquote><div><br></div><div>When I test migrations I usually dump the database, run the migration with neutron-db-manage upgrade HEAD (I think it's not necessary to specify HEAD), and restore the db from the dump if the migration fails.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Is there a way to run the migration file under the debugger, as well (importing pdb, for example)?</div></div></blockquote><div><br></div><div>The migration process is just like any python application, so I guess you can debug it with pdb. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>In the migration, I can add the columns needed. What's the best way to fill out those fields - using raw SQL queries or create a Session object and access the VpnService object's router object?</div></div></blockquote><div><br></div><div>If the default value for the column is not enough, and you need to specify a value which depends on other values in the same row I would prefer plain SQL statements, but if that become cumbersome I guess it's ok to use sqlalchemy's session.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>I see there is some op.bind() call and then engine.execute(), but could use some help on the best way to extract the needed queries (I need to access the vpnservice's router, and then access the (Port) gw_port relationship, and from that access the (IPAllocation) fixed_ips list).</div></div></blockquote><div><br></div><div>Perhaps you can point us to the review pages on gerrit, and we can provide detailed comments there.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Appreciate any advise here on how to debug the migration stuff...</div><div><br></div><div>Paul Michali (pc_m)</div></div></blockquote><div><br></div><div>[1] <a href="http://git.openstack.org/cgit/openstack/neutron/tree/neutron/db/migration/cli.py#n124">http://git.openstack.org/cgit/openstack/neutron/tree/neutron/db/migration/cli.py#n124</a> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>
<br>__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div></div></div>