def test_create_shadow_table_by_table_instance(self):
     table_name = 'test_create_shadow_table_by_table_instance'
     table = Table(table_name, self.meta,
                   Column('id', Integer, primary_key=True),
                   Column('a', Integer), Column('b', String(256)))
     table.create()
     utils.create_shadow_table(self.engine, table=table)
     self.assertTrue(utils.check_shadow_table(self.engine, table_name))
Пример #2
0
 def test_create_shadow_table_by_table_instance(self):
     table_name = 'test_create_shadow_table_by_table_instance'
     table = Table(table_name, self.meta,
                   Column('id', Integer, primary_key=True),
                   Column('a', Integer),
                   Column('b', String(256)))
     table.create()
     utils.create_shadow_table(self.engine, table=table)
     self.assertTrue(utils.check_shadow_table(self.engine, table_name))
Пример #3
0
 def test_create_duplicate_shadow_table(self):
     table_name = 'test_create_duplicate_shadow_table'
     table = Table(table_name, self.meta,
                   Column('id', Integer, primary_key=True),
                   Column('a', Integer))
     table.create()
     utils.create_shadow_table(self.engine, table_name=table_name)
     self.assertRaises(exception.ShadowTableExists,
                       utils.create_shadow_table,
                       self.engine, table_name=table_name)
Пример #4
0
 def test_create_duplicate_shadow_table(self):
     table_name = 'test_create_duplicate_shadow_table'
     table = Table(table_name, self.meta,
                   Column('id', Integer, primary_key=True),
                   Column('a', Integer))
     table.create()
     utils.create_shadow_table(self.engine, table_name=table_name)
     self.assertRaises(exception.ShadowTableExists,
                       utils.create_shadow_table,
                       self.engine, table_name=table_name)
Пример #5
0
 def test_create_shadow_table_by_table_instance(self):
     table_name = 'abc'
     for key, engine in self.engines.items():
         meta = MetaData()
         meta.bind = engine
         table = Table(table_name, meta,
                       Column('id', Integer, primary_key=True),
                       Column('a', Integer), Column('b', String(256)))
         table.create()
         utils.create_shadow_table(engine, table=table)
         self.assertTrue(utils.check_shadow_table(engine, table_name))
Пример #6
0
    def test_create_shadow_table_not_supported_type(self):
        table_name = 'test_create_shadow_table_not_supported_type'
        table = Table(table_name, self.meta,
                      Column('id', Integer, primary_key=True),
                      Column('a', CustomType))
        table.create()

        utils.create_shadow_table(self.engine,
                                  table_name=table_name,
                                  a=Column('a', CustomType()))
        self.assertTrue(utils.check_shadow_table(self.engine, table_name))
 def test_create_shadow_table_by_table_instance(self):
     table_name = 'abc'
     for key, engine in self.engines.items():
         meta = MetaData()
         meta.bind = engine
         table = Table(table_name, meta,
                       Column('id', Integer, primary_key=True),
                       Column('a', Integer),
                       Column('b', String(256)))
         table.create()
         utils.create_shadow_table(engine, table=table)
         self.assertTrue(utils.check_shadow_table(engine, table_name))
 def test_create_duplicate_shadow_table(self):
     table_name = 'abc'
     for key, engine in self.engines.items():
         meta = MetaData()
         meta.bind = engine
         table = Table(table_name, meta,
                       Column('id', Integer, primary_key=True),
                       Column('a', Integer))
         table.create()
         utils.create_shadow_table(engine, table_name=table_name)
         self.assertRaises(exception.ShadowTableExists,
                           utils.create_shadow_table,
                           engine, table_name=table_name)
Пример #9
0
 def test_create_duplicate_shadow_table(self):
     table_name = 'abc'
     for key, engine in self.engines.items():
         meta = MetaData()
         meta.bind = engine
         table = Table(table_name, meta,
                       Column('id', Integer, primary_key=True),
                       Column('a', Integer))
         table.create()
         utils.create_shadow_table(engine, table_name=table_name)
         self.assertRaises(exception.ShadowTableExists,
                           utils.create_shadow_table,
                           engine, table_name=table_name)
Пример #10
0
    def test_create_shadow_table_not_supported_type(self):
        table_name = 'abc'
        engine = self.engines['sqlite']
        meta = MetaData()
        meta.bind = engine
        table = Table(table_name, meta,
                      Column('id', Integer, primary_key=True),
                      Column('a', CustomType))
        table.create()
        self.assertRaises(exception.NovaException,
                          utils.create_shadow_table,
                          engine, table_name=table_name)

        utils.create_shadow_table(engine, table_name=table_name,
                                  a=Column('a', CustomType()))
        self.assertTrue(utils.check_shadow_table(engine, table_name))
Пример #11
0
    def test_create_shadow_table_not_supported_type(self):
        if 'sqlite' in self.engines:
            table_name = 'test_create_shadow_table_not_supported_type'
            engine = self.engines['sqlite']
            meta = MetaData()
            meta.bind = engine
            table = Table(table_name, meta,
                          Column('id', Integer, primary_key=True),
                          Column('a', CustomType))
            table.create()

            # reflection of custom types has been fixed upstream
            if SA_VERSION < (0, 9, 0):
                self.assertRaises(exception.NovaException,
                                  utils.create_shadow_table,
                                  engine,
                                  table_name=table_name)

            shadow_table = utils.create_shadow_table(engine,
                                                     table_name=table_name,
                                                     a=Column(
                                                         'a', CustomType()))
            self.assertTrue(utils.check_shadow_table(engine, table_name))
            table.drop()
            shadow_table.drop()
    def test_create_shadow_table_not_supported_type(self):
        table_name = 'abc'
        engine = self.engines['sqlite']
        meta = MetaData()
        meta.bind = engine
        table = Table(table_name, meta,
                      Column('id', Integer, primary_key=True),
                      Column('a', CustomType))
        table.create()
        self.assertRaises(exception.NovaException,
                          utils.create_shadow_table,
                          engine, table_name=table_name)

        utils.create_shadow_table(engine, table_name=table_name,
                                  a=Column('a', CustomType()))
        self.assertTrue(utils.check_shadow_table(engine, table_name))
Пример #13
0
def upgrade(migrate_engine):
    meta = MetaData(bind=migrate_engine)

    pci_devices_uc_name = 'uniq_pci_devices0compute_node_id0address0deleted'
    pci_devices = Table('pci_devices', meta,
                        Column('created_at', DateTime(timezone=False)),
                        Column('updated_at', DateTime(timezone=False)),
                        Column('deleted_at', DateTime(timezone=False)),
                        Column('deleted', Integer, default=0, nullable=False),
                        Column('id', Integer, primary_key=True),
                        Column('compute_node_id', Integer, nullable=False),
                        Column('address', String(12), nullable=False),
                        Column('product_id', String(4)),
                        Column('vendor_id', String(4)),
                        Column('dev_type', String(8)),
                        Column('dev_id', String(255)),
                        Column('label', String(255), nullable=False),
                        Column('status', String(36), nullable=False),
                        Column('extra_info', Text, nullable=True),
                        Column('instance_uuid', String(36), nullable=True),
                        Index('ix_pci_devices_compute_node_id_deleted',
                              'compute_node_id', 'deleted'),
                        Index('ix_pci_devices_instance_uuid_deleted',
                              'instance_uuid', 'deleted'),
                        UniqueConstraint('compute_node_id',
                                         'address', 'deleted',
                                         name=pci_devices_uc_name),
                        mysql_engine='InnoDB',
                        mysql_charset='utf8')

    try:
        pci_devices.create()
        utils.create_shadow_table(migrate_engine, table=pci_devices)
    except Exception:
        LOG.exception(_("Exception while creating table 'pci_devices'."))
        raise

    try:
        compute_nodes = utils.get_table(migrate_engine, 'compute_nodes')
        pci_stats = Column('pci_stats', Text, nullable=True)
        compute_nodes.create_column(pci_stats)
        shadow_compute_nodes = utils.get_table(
            migrate_engine, api._SHADOW_TABLE_PREFIX + 'compute_nodes')
        shadow_compute_nodes.create_column(pci_stats.copy())
    except Exception:
        LOG.exception(_("Exception for adding pci stats to compute node."))
        raise
Пример #14
0
    def test_create_shadow_table_not_supported_type(self):
        table_name = 'test_create_shadow_table_not_supported_type'
        table = Table(table_name, self.meta,
                      Column('id', Integer, primary_key=True),
                      Column('a', CustomType))
        table.create()

        # reflection of custom types has been fixed upstream
        if SA_VERSION < (0, 9, 0):
            self.assertRaises(oslodbutils.ColumnError,
                              utils.create_shadow_table,
                              self.engine, table_name=table_name)

        utils.create_shadow_table(self.engine,
                                  table_name=table_name,
                                  a=Column('a', CustomType()))
        self.assertTrue(utils.check_shadow_table(self.engine, table_name))
Пример #15
0
    def test_create_shadow_table_not_supported_type(self):
        table_name = 'test_create_shadow_table_not_supported_type'
        table = Table(table_name, self.meta,
                      Column('id', Integer, primary_key=True),
                      Column('a', CustomType))
        table.create()

        # reflection of custom types has been fixed upstream
        if SA_VERSION < (0, 9, 0):
            self.assertRaises(oslodbutils.ColumnError,
                              utils.create_shadow_table,
                              self.engine, table_name=table_name)

        utils.create_shadow_table(self.engine,
                                  table_name=table_name,
                                  a=Column('a', CustomType()))
        self.assertTrue(utils.check_shadow_table(self.engine, table_name))
Пример #16
0
    def test_create_shadow_table_not_supported_type(self):
        if "sqlite" in self.engines:
            table_name = "test_create_shadow_table_not_supported_type"
            engine = self.engines["sqlite"]
            meta = MetaData()
            meta.bind = engine
            table = Table(table_name, meta, Column("id", Integer, primary_key=True), Column("a", CustomType))
            table.create()
            self.assertRaises(exception.NovaException, utils.create_shadow_table, engine, table_name=table_name)

            shadow_table = utils.create_shadow_table(engine, table_name=table_name, a=Column("a", CustomType()))
            self.assertTrue(utils.check_shadow_table(engine, table_name))
            table.drop()
            shadow_table.drop()
Пример #17
0
 def test_create_shadow_table_by_table_instance(self):
     table_name = "test_create_shadow_table_by_table_instance"
     for key, engine in self.engines.items():
         meta = MetaData()
         meta.bind = engine
         table = Table(
             table_name,
             meta,
             Column("id", Integer, primary_key=True),
             Column("a", Integer),
             Column("b", String(256)),
         )
         table.create()
         shadow_table = utils.create_shadow_table(engine, table=table)
         self.assertTrue(utils.check_shadow_table(engine, table_name))
         table.drop()
         shadow_table.drop()
Пример #18
0
    def test_create_shadow_table_not_supported_type(self):
        if "sqlite" in self.engines:
            table_name = "test_create_shadow_table_not_supported_type"
            engine = self.engines["sqlite"]
            meta = MetaData()
            meta.bind = engine
            table = Table(table_name, meta, Column("id", Integer, primary_key=True), Column("a", CustomType))
            table.create()

            # reflection of custom types has been fixed upstream
            if SA_VERSION < (0, 9, 0):
                self.assertRaises(oslodbutils.ColumnError, utils.create_shadow_table, engine, table_name=table_name)

            shadow_table = utils.create_shadow_table(engine, table_name=table_name, a=Column("a", CustomType()))
            self.assertTrue(utils.check_shadow_table(engine, table_name))
            table.drop()
            shadow_table.drop()
Пример #19
0
    def test_create_shadow_table_not_supported_type(self):
        if 'sqlite' in self.engines:
            table_name = 'test_create_shadow_table_not_supported_type'
            engine = self.engines['sqlite']
            meta = MetaData()
            meta.bind = engine
            table = Table(table_name, meta,
                          Column('id', Integer, primary_key=True),
                          Column('a', CustomType))
            table.create()

            # reflection of custom types has been fixed upstream
            if SA_VERSION < (0, 9, 0):
                self.assertRaises(exception.NovaException,
                                  utils.create_shadow_table,
                                  engine, table_name=table_name)

            shadow_table = utils.create_shadow_table(engine,
                table_name=table_name,
                a=Column('a', CustomType())
            )
            self.assertTrue(utils.check_shadow_table(engine, table_name))
            table.drop()
            shadow_table.drop()
Пример #20
0
def upgrade(migrate_engine):
    # Upgrade operations go here. Don't create your own engine;
    # bind migrate_engine to your metadata
    meta = MetaData()
    meta.bind = migrate_engine

    # Add 'user_id' column to quota_usages table and its shadow table.
    quota_usages = utils.get_table(migrate_engine, 'quota_usages')
    user_id = Column('user_id',
                     String(length=255))
    quota_usages.create_column(user_id)

    shadow_quota_usages = utils.get_table(migrate_engine,
                                db._SHADOW_TABLE_PREFIX + 'quota_usages')
    user_id = Column('user_id',
                     String(length=255))
    shadow_quota_usages.create_column(user_id)

    # Add 'user_id' column to reservations table and its shadow table.
    reservations = utils.get_table(migrate_engine, 'reservations')
    user_id = Column('user_id',
                     String(length=255))
    reservations.create_column(user_id)

    shadow_reservations = utils.get_table(migrate_engine,
                                db._SHADOW_TABLE_PREFIX + 'reservations')
    user_id = Column('user_id',
                     String(length=255))
    shadow_reservations.create_column(user_id)

    if migrate_engine.name == 'mysql' or migrate_engine.name == 'postgresql':
        indexes = [
            Index('ix_quota_usages_user_id_deleted',
                  quota_usages.c.user_id, quota_usages.c.deleted),
            Index('ix_reservations_user_id_deleted',
                  reservations.c.user_id, reservations.c.deleted)
        ]
        for index in indexes:
            index.create(migrate_engine)

    uniq_name = "uniq_project_user_quotas0user_id0project_id0resource0deleted"
    project_user_quotas = Table('project_user_quotas', meta,
                        Column('id', Integer, primary_key=True,
                               nullable=False),
                        Column('created_at', DateTime),
                        Column('updated_at', DateTime),
                        Column('deleted_at', DateTime),
                        Column('deleted', Integer),
                        Column('user_id',
                               String(length=255),
                               nullable=False),
                        Column('project_id',
                               String(length=255),
                               nullable=False),
                        Column('resource',
                               String(length=255),
                               nullable=False),
                        Column('hard_limit', Integer, nullable=True),
                        UniqueConstraint('user_id', 'project_id', 'resource',
                                         'deleted', name=uniq_name),
                        Index('project_user_quotas_project_id_deleted_idx',
                              'project_id', 'deleted'),
                        Index('project_user_quotas_user_id_deleted_idx',
                              'project_id', 'deleted'),
                        mysql_engine='InnoDB',
                        mysql_charset='utf8',
                        )

    try:
        project_user_quotas.create()
        utils.create_shadow_table(migrate_engine, table=project_user_quotas)
    except Exception:
        LOG.exception("Exception while creating table 'project_user_quotas'")
        meta.drop_all(tables=[project_user_quotas])
        raise
Пример #21
0
def upgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    groups = Table(
        'instance_groups',
        meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Integer),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('user_id', String(length=255)),
        Column('project_id', String(length=255)),
        Column('uuid', String(length=36), nullable=False),
        Column('name', String(length=255)),
        UniqueConstraint('uuid',
                         'deleted',
                         name='uniq_instance_groups0uuid0deleted'),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
    )

    group_metadata = Table(
        'instance_group_metadata',
        meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Integer),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('key', String(length=255)),
        Column('value', String(length=255)),
        Column('group_id',
               Integer,
               ForeignKey('instance_groups.id'),
               nullable=False),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
    )

    group_policy = Table(
        'instance_group_policy',
        meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Integer),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('policy', String(length=255)),
        Column('group_id',
               Integer,
               ForeignKey('instance_groups.id'),
               nullable=False),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
    )

    group_member = Table(
        'instance_group_member',
        meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Integer),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('instance_id', String(length=255)),
        Column('group_id',
               Integer,
               ForeignKey('instance_groups.id'),
               nullable=False),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
    )

    tables = [groups, group_metadata, group_policy, group_member]

    # create all of the tables
    for table in tables:
        table.create()
        utils.create_shadow_table(migrate_engine, table=table)

    indexes = [
        Index('instance_group_metadata_key_idx', group_metadata.c.key),
        Index('instance_group_member_instance_idx',
              group_member.c.instance_id),
        Index('instance_group_policy_policy_idx', group_policy.c.policy)
    ]

    # Common indexes
    if migrate_engine.name == 'mysql' or migrate_engine.name == 'postgresql':
        for index in indexes:
            index.create(migrate_engine)
def upgrade(migrate_engine):
    meta = MetaData(bind=migrate_engine)

    domain_quota = Table('domain_quotas', meta,
            Column('id', Integer, primary_key=True, nullable=False),
            Column('created_at', DateTime),
            Column('updated_at', DateTime),
            Column('deleted_at', DateTime),
            Column('deleted', Integer),
            Column('domain_id', String(255)),
            Column('resource', String(255), nullable=False),
            Column('hard_limit', Integer()),
            mysql_engine='InnoDB',
            mysql_charset='utf8')

    domain_quota_usage = Table('domain_quota_usages', meta,
            Column('id', Integer, primary_key=True, nullable=False),
            Column('created_at', DateTime),
            Column('updated_at', DateTime),
            Column('deleted_at', DateTime),
            Column('deleted', Integer),
            Column('domain_id', String(255)),
            Column('resource', String(255), nullable=False),
            Column('in_use', Integer, nullable=False),
            Column('reserved', Integer, nullable=False),
            Column('until_refresh', Integer),
            mysql_engine='InnoDB',
            mysql_charset='utf8')

    domain_reservation = Table('domain_reservations', meta,
        Column('id', Integer, primary_key=True, nullable=False),
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Integer),
        Column('uuid', String(length=36), nullable=False),
        Column('domain_id', String(255)),
        Column('usage_id', Integer, nullable=False),
        Column('resource', String(length=255)),
        Column('delta', Integer, nullable=False),
        Column('expire', DateTime),
        mysql_engine='InnoDB',
        mysql_charset='utf8'
    )

    tables = [domain_quota, domain_quota_usage, domain_reservation]

    for table in tables:
        try:
            table.create()
            utils.create_shadow_table(migrate_engine, table=table)
        except Exception:
            LOG.info(repr(table))
            LOG.exception(_('Exception while creating table.'))
            raise

    indexes = [
               Index('domain_quotas_domain_id_deleted_idx',
                     'domain_id', 'deleted'),

               #DomainQuotaUsages
               Index('ix_domain_quota_usages_domain_id', 'domain_id'),

               #DomainReservation
               Index('ix_domain_reservations_id', 'domain_id'),
               Index('domain_reservations_uuid_idx', 'uuid'),
               ]

    # Common indexes
    # for index in indexes:
    #    print "<<<<<<<<<<<<<<<INDEXES>>>>>>>>>>>>>>>>>>>"
    #    print index
    #    index.create(migrate_engine)

    fkeys = [
             [[domain_reservation.c.usage_id],
                  [domain_quota_usage.c.id],
                  'domain_reservations_ibfk_1']
             ]

    for fkey_pair in fkeys:
        if migrate_engine.name == 'mysql':
            # For MySQL we name our fkeys explicitly so they match Folsom
            fkey = ForeignKeyConstraint(columns=fkey_pair[0],
                                   refcolumns=fkey_pair[1],
                                   name=fkey_pair[2])
            fkey.create()
        elif migrate_engine.name == 'postgresql':
            # PostgreSQL names things like it wants (correct and compatible!)
            fkey = ForeignKeyConstraint(columns=fkey_pair[0],
                                   refcolumns=fkey_pair[1])
            fkey.create()

    uniq_name = "uniq_domain_quotas0domain_id0resource0deleted"
    uc_domain_quota = UniqueConstraint("domain_id", "resource", "deleted",
                                       table=domain_quota, name=uniq_name)
    uc_domain_quota.create()
def upgrade(migrate_engine):
    utils.create_shadow_table(migrate_engine, "security_group_default_rules")
Пример #24
0
def upgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    groups = Table('instance_groups', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Integer),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('user_id', String(length=255)),
        Column('project_id', String(length=255)),
        Column('uuid', String(length=36), nullable=False),
        Column('name', String(length=255)),
        UniqueConstraint('uuid', 'deleted',
                         name='uniq_instance_groups0uuid0deleted'),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
    )

    group_metadata = Table('instance_group_metadata', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Integer),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('key', String(length=255)),
        Column('value', String(length=255)),
        Column('group_id', Integer, ForeignKey('instance_groups.id'),
               nullable=False),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
    )

    group_policy = Table('instance_group_policy', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Integer),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('policy', String(length=255)),
        Column('group_id', Integer, ForeignKey('instance_groups.id'),
               nullable=False),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
    )

    group_member = Table('instance_group_member', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Integer),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('instance_id', String(length=255)),
        Column('group_id', Integer, ForeignKey('instance_groups.id'),
               nullable=False),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
    )

    tables = [groups, group_metadata, group_policy, group_member]

    # create all of the tables
    for table in tables:
        table.create()
        utils.create_shadow_table(migrate_engine, table=table)

    indexes = [
        Index('instance_group_metadata_key_idx', group_metadata.c.key),
        Index('instance_group_member_instance_idx',
              group_member.c.instance_id),
        Index('instance_group_policy_policy_idx', group_policy.c.policy)
    ]

    # Common indexes
    if migrate_engine.name == 'mysql' or migrate_engine.name == 'postgresql':
        for index in indexes:
            index.create(migrate_engine)
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    sm_backend_config = Table('sm_backend_config',
                              meta,
                              Column('created_at', DateTime),
                              Column('updated_at', DateTime),
                              Column('deleted_at', DateTime),
                              Column('deleted', Boolean),
                              Column('id',
                                     Integer,
                                     primary_key=True,
                                     nullable=False),
                              Column('flavor_id',
                                     Integer,
                                     ForeignKey('sm_flavors.id'),
                                     nullable=False),
                              Column('sr_uuid', String(length=255)),
                              Column('sr_type', String(length=255)),
                              Column('config_params', String(length=2047)),
                              mysql_engine='InnoDB',
                              mysql_charset='utf8')

    sm_flavors = Table('sm_flavors',
                       meta,
                       Column('created_at', DateTime),
                       Column('updated_at', DateTime),
                       Column('deleted_at', DateTime),
                       Column('deleted', Boolean),
                       Column('id', Integer, primary_key=True, nullable=False),
                       Column('label', String(length=255)),
                       Column('description', String(length=255)),
                       mysql_engine='InnoDB',
                       mysql_charset='utf8')

    sm_volume = Table('sm_volume',
                      meta,
                      Column('created_at', DateTime),
                      Column('updated_at', DateTime),
                      Column('deleted_at', DateTime),
                      Column('deleted', Boolean),
                      Column('id',
                             String(length=36),
                             primary_key=True,
                             nullable=False,
                             autoincrement=False),
                      Column('backend_id',
                             Integer,
                             ForeignKey('sm_backend_config.id'),
                             nullable=False),
                      Column('vdi_uuid', String(length=255)),
                      mysql_engine='InnoDB',
                      mysql_charset='utf8')

    virtual_storage_arrays = Table('virtual_storage_arrays',
                                   meta,
                                   Column('created_at', DateTime),
                                   Column('updated_at', DateTime),
                                   Column('deleted_at', DateTime),
                                   Column('deleted', Boolean),
                                   Column('id',
                                          Integer,
                                          primary_key=True,
                                          nullable=False),
                                   Column('display_name', String(length=255)),
                                   Column('display_description',
                                          String(length=255)),
                                   Column('project_id', String(length=255)),
                                   Column('availability_zone',
                                          String(length=255)),
                                   Column('instance_type_id',
                                          Integer,
                                          nullable=False),
                                   Column('image_ref', String(length=255)),
                                   Column('vc_count', Integer, nullable=False),
                                   Column('vol_count', Integer,
                                          nullable=False),
                                   Column('status', String(length=255)),
                                   mysql_engine='InnoDB',
                                   mysql_charset='utf8')

    volumes = Table('volumes', meta, autoload=True)

    volume_metadata = Table('volume_metadata',
                            meta,
                            Column('created_at', DateTime),
                            Column('updated_at', DateTime),
                            Column('deleted_at', DateTime),
                            Column('deleted', Boolean),
                            Column('id',
                                   Integer,
                                   primary_key=True,
                                   nullable=False),
                            Column('volume_id',
                                   String(length=36),
                                   ForeignKey('volumes.id'),
                                   nullable=False),
                            Column('key', String(length=255)),
                            Column('value', String(length=255)),
                            mysql_engine='InnoDB',
                            mysql_charset='utf8')

    volume_type_extra_specs = Table('volume_type_extra_specs',
                                    meta,
                                    Column('created_at', DateTime),
                                    Column('updated_at', DateTime),
                                    Column('deleted_at', DateTime),
                                    Column('deleted', Boolean),
                                    Column('id',
                                           Integer,
                                           primary_key=True,
                                           nullable=False),
                                    Column('volume_type_id',
                                           Integer,
                                           ForeignKey('volume_types.id'),
                                           nullable=False),
                                    Column('key', String(length=255)),
                                    Column('value', String(length=255)),
                                    mysql_engine='InnoDB',
                                    mysql_charset='utf8')

    volume_types = Table('volume_types',
                         meta,
                         Column('created_at', DateTime),
                         Column('updated_at', DateTime),
                         Column('deleted_at', DateTime),
                         Column('deleted', Boolean),
                         Column('id',
                                Integer,
                                primary_key=True,
                                nullable=False),
                         Column('name', String(length=255)),
                         mysql_engine='InnoDB',
                         mysql_charset='utf8')

    tables = [
        sm_flavors, sm_backend_config, sm_volume, virtual_storage_arrays,
        volume_metadata, volume_types, volume_type_extra_specs
    ]

    for table in tables:
        try:
            table.create()
            utils.create_shadow_table(migrate_engine, table.name)
        except Exception:
            LOG.info(repr(table))
            LOG.exception(_('Exception while creating table.'))
            raise
Пример #26
0
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    sm_backend_config = Table('sm_backend_config', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Boolean),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('flavor_id', Integer, ForeignKey('sm_flavors.id'),
               nullable=False),
        Column('sr_uuid', String(length=255)),
        Column('sr_type', String(length=255)),
        Column('config_params', String(length=2047)),
        mysql_engine='InnoDB',
        mysql_charset='utf8'
    )

    sm_flavors = Table('sm_flavors', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Boolean),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('label', String(length=255)),
        Column('description', String(length=255)),
        mysql_engine='InnoDB',
        mysql_charset='utf8'
    )

    sm_volume = Table('sm_volume', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Boolean),
        Column('id', String(length=36), primary_key=True,
                  nullable=False, autoincrement=False),
        Column('backend_id', Integer, ForeignKey('sm_backend_config.id'),
               nullable=False),
        Column('vdi_uuid', String(length=255)),
        mysql_engine='InnoDB',
        mysql_charset='utf8'
    )

    virtual_storage_arrays = Table('virtual_storage_arrays', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Boolean),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('display_name', String(length=255)),
        Column('display_description', String(length=255)),
        Column('project_id', String(length=255)),
        Column('availability_zone', String(length=255)),
        Column('instance_type_id', Integer, nullable=False),
        Column('image_ref', String(length=255)),
        Column('vc_count', Integer, nullable=False),
        Column('vol_count', Integer, nullable=False),
        Column('status', String(length=255)),
        mysql_engine='InnoDB',
        mysql_charset='utf8'
    )

    volumes = Table('volumes', meta, autoload=True)

    volume_metadata = Table('volume_metadata', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Boolean),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('volume_id', String(length=36), ForeignKey('volumes.id'),
               nullable=False),
        Column('key', String(length=255)),
        Column('value', String(length=255)),
        mysql_engine='InnoDB',
        mysql_charset='utf8'
    )

    volume_type_extra_specs = Table('volume_type_extra_specs', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Boolean),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('volume_type_id', Integer, ForeignKey('volume_types.id'),
               nullable=False),
        Column('key', String(length=255)),
        Column('value', String(length=255)),
        mysql_engine='InnoDB',
        mysql_charset='utf8'
    )

    volume_types = Table('volume_types', meta,
        Column('created_at', DateTime),
        Column('updated_at', DateTime),
        Column('deleted_at', DateTime),
        Column('deleted', Boolean),
        Column('id', Integer, primary_key=True, nullable=False),
        Column('name', String(length=255)),
        mysql_engine='InnoDB',
        mysql_charset='utf8'
    )

    tables = [
        sm_flavors,
        sm_backend_config,
        sm_volume,
        virtual_storage_arrays,
        volume_metadata,
        volume_types,
        volume_type_extra_specs]

    for table in tables:
        try:
            table.create()
            utils.create_shadow_table(migrate_engine, table.name)
        except Exception:
            LOG.info(repr(table))
            LOG.exception(_('Exception while creating table.'))
            raise
Пример #27
0
def upgrade(migrate_engine):
    utils.create_shadow_table(migrate_engine, 'security_group_default_rules')