¡@

Home 

OpenStack Study: 557edfc53098_new_service_types.py

OpenStack Index

**** CubicPower OpenStack Study ****

def upgrade(active_plugins=None, options=None):

    if not migration.should_run(active_plugins, migration_for_plugins):

        return

    op.create_table(

        'providerresourceassociations',

        sa.Column('provider_name', sa.String(length=255), nullable=False),

        sa.Column('resource_id', sa.String(length=36),

                  nullable=False, unique=True),

    )

    # dropping unused tables

    op.drop_table('servicedefinitions')

    op.drop_table('servicetypes')

**** CubicPower OpenStack Study ****

def downgrade(active_plugins=None, options=None):

    if not migration.should_run(active_plugins, migration_for_plugins):

        return

    op.create_table(

        'servicetypes',

        sa.Column('id', sa.String(length=36), nullable=False),

        sa.Column('tenant_id', sa.String(length=255)),

        sa.Column('name', sa.String(255)),

        sa.Column('description', sa.String(255)),

        sa.Column('default', sa.Boolean(), nullable=False, default=False),

        sa.Column('num_instances', sa.Integer, default=0),

        sa.PrimaryKeyConstraint('id')

    )

    op.create_table(

        'servicedefinitions',

        sa.Column('id', sa.String(length=36), nullable=False),

        sa.Column('service_class', sa.String(255)),

        sa.Column('plugin', sa.String(255)),

        sa.Column('driver', sa.String(255)),

        sa.Column('service_type_id', sa.String(36),

                  sa.ForeignKey('servicetypes.id',

                                ondelete='CASCADE')),

        sa.PrimaryKeyConstraint('id', 'service_class')

    )

    op.drop_table('providerresourceassociations')