tacker/tacker/db/migration
Trinh Nguyen 422055b9ba Implement VNFFG support for NS
This patch will add VNFFG support for NS. In NSD, users can
describe VNFDs and nested VNFFGDs inside. When NS is created,
VNFs and VNFFGs are also created too.

Work items of this patch:
1. Add sample nsd templates
2. Update NFVO plugin to adapt VNFFGD template extraction
    from NSD and create VNFFGs using that template
3. Modify Mistral workflow to create/delete VNFFGs using NSD

User guide, defref will be added in following patches.

Co-Authored-By: Cong Phuoc Hoang <hoangphuocbk2.07@gmail.com>

Change-Id: Id5827e66aec0231bf27e87fc96d8fc6bc5cb9c26
Partially-implements: blueprint vnffg-ns
2018-07-19 02:53:34 +00:00
..
alembic_migrations Implement VNFFG support for NS 2018-07-19 02:53:34 +00:00
models Implement NSD Support - Add CRUD operations for NSD 2017-01-16 22:03:09 +05:30
README Removes downgrade from db migration scripts 2017-03-02 08:39:11 +05:30
__init__.py Device refactor Part1: Rename device db name 2016-08-15 23:54:06 +08:00
alembic.ini Correct path to migration scripts in alembic.ini 2017-02-08 23:59:55 -08:00
cli.py fix various typos in different messages 2018-02-10 22:01:04 +01:00
purge_tables.py tacker-db-manage purge_deleted command error 2016-12-08 17:50:57 +05:30

README

# Copyright 2012 New Dream Network, LLC (DreamHost)
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
#
# @author Mark McClain (DreamHost)

The migrations in the alembic/versions contain the changes needed to migrate
from older Tacker releases to newer versions. A migration occurs by executing
a script that details the changes needed to upgrade the database. The
migration scripts are ordered so that multiple scripts can run sequentially to
update the database. The scripts are executed by Tacker's migration wrapper
which uses the Alembic library to manage the migration.  Tacker supports
migration from Folsom or later.


If you are a deployer or developer and want to migrate from Folsom to Grizzly
or later you must first add version tracking to the database:

$ tacker-db-manage --config-file /path/to/tacker.conf \
 --config-file /path/to/plugin/config.ini stamp folsom

You can then upgrade to the latest database version via:
$ tacker-db-manage --config-file /path/to/tacker.conf \
 --config-file /path/to/plugin/config.ini upgrade head

To check the current database version:
$ tacker-db-manage --config-file /path/to/tacker.conf \
 --config-file /path/to/plugin/config.ini current

To create a script to run the migration offline:
$ tacker-db-manage --config-file /path/to/tacker.conf \
 --config-file /path/to/plugin/config.ini upgrade head --sql

To run the offline migration between specific migration versions:
$ tacker-db-manage --config-file /path/to/tacker.conf \
--config-file /path/to/plugin/config.ini upgrade \
<start version>:<end version> --sql

Upgrade the database incrementally:
$ tacker-db-manage --config-file /path/to/tacker.conf \
--config-file /path/to/plugin/config.ini upgrade --delta <# of revs>


DEVELOPERS:
A database migration script is required when you submit a change to Tacker
that alters the database model definition.  The migration script is a special
python file that includes code to upgrade the database to match the
changes in the model definition. Alembic will execute these scripts in order to
provide a linear migration path between revision. The tacker-db-manage command
can be used to generate migration template for you to complete.  The operations
in the template are those supported by the Alembic migration library.

$ tacker-db-manage --config-file /path/to/tacker.conf \
--config-file /path/to/plugin/config.ini revision \
-m "description of revision" \
--autogenerate

This generates a prepopulated template with the changes needed to match the
database state with the models.  You should inspect the autogenerated template
to ensure that the proper models have been altered.

In rare circumstances, you may want to start with an empty migration template
and manually author the changes necessary for an upgrade.  You can
create a blank file via:

$ tacker-db-manage --config-file /path/to/tacker.conf \
--config-file /path/to/plugin/config.ini revision \
-m "description of revision"

The migration timeline should remain linear so that there is a clear path when
upgrading.  To verify that the timeline does branch, you can run this command:
$ tacker-db-manage --config-file /path/to/tacker.conf \
--config-file /path/to/plugin/config.ini check_migration

If the migration path does branch, you can find the branch point via:
$ tacker-db-manage --config-file /path/to/tacker.conf \
--config-file /path/to/plugin/config.ini history