The first place to look is in Products/ZenModel/migrate
. For starters, examine the code in migrate.Migrate
and note the Step
class - this is what you will subclass when writing your migration code. The migrate.Migrate.Migration.main()
method is what is called from the zenmigrate.py
script and is what fires off the whole process.
To further understand the process, note the global variable allSteps
: this is appended to every time Migrate.Step is instantiated.
But, you ask, how does my code get into allSteps
?
Once your migration code is complete, you will do a couple things: add your file to the migrate directory and then add an import statement to migrate/__init__.py
. When migrate.Migrate is imported in the zenmigrate.py
script, the __init__.py
code is run. Each module imported by this file has a class that gets instantiated at the end of its module (see the Migrate.Step.__init__()
method). It is through this mechanism that each custom migration module in the migrate directory is added to allSteps
(sorted by name and version number).
When migrate.Migrate.main()
is called, allSteps
is iterated and checks are performed to see if each migration step needs to be run or not. main()
calls cutover()
, which calls migrate()
, and this is where the actual work of migration occurs, where your code gets executed.