コード例 #1
0
ファイル: add_images_tables.py プロジェクト: yebinama/glance
def _add_images_table():
    op.create_table('images',
                    Column('id', String(length=36), nullable=False),
                    Column('name', String(length=255), nullable=True),
                    Column('size', BigInteger(), nullable=True),
                    Column('status', String(length=30), nullable=False),
                    Column('is_public', Boolean(), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    Column('deleted_at', DateTime(), nullable=True),
                    Column('deleted', Boolean(), nullable=False),
                    Column('disk_format', String(length=20), nullable=True),
                    Column('container_format',
                           String(length=20),
                           nullable=True),
                    Column('checksum', String(length=32), nullable=True),
                    Column('owner', String(length=255), nullable=True),
                    Column('min_disk', Integer(), nullable=False),
                    Column('min_ram', Integer(), nullable=False),
                    Column('protected',
                           Boolean(),
                           server_default=sql.false(),
                           nullable=False),
                    Column('virtual_size', BigInteger(), nullable=True),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('checksum_image_idx', 'images', ['checksum'], unique=False)
    op.create_index('ix_images_deleted', 'images', ['deleted'], unique=False)
    op.create_index('ix_images_is_public',
                    'images', ['is_public'],
                    unique=False)
    op.create_index('owner_image_idx', 'images', ['owner'], unique=False)
コード例 #2
0
def define_artifacts_table(meta):
    artifacts = Table('artifacts',
                      meta,
                      Column('id', String(36), primary_key=True,
                             nullable=False),
                      Column('name', String(255), nullable=False),
                      Column('type_name', String(255), nullable=False),
                      Column('type_version_prefix', BigInteger(),
                             nullable=False),
                      Column('type_version_suffix', String(255)),
                      Column('type_version_meta', String(255)),
                      Column('version_prefix', BigInteger(), nullable=False),
                      Column('version_suffix', String(255)),
                      Column('version_meta', String(255)),
                      Column('description', Text()),
                      Column('visibility', String(32), nullable=False),
                      Column('state', String(32), nullable=False),
                      Column('owner', String(255), nullable=False),
                      Column('created_at', DateTime(), nullable=False),
                      Column('updated_at', DateTime(),
                             nullable=False),
                      Column('deleted_at', DateTime()),
                      Column('published_at', DateTime()),
                      mysql_engine='InnoDB',
                      extend_existing=True)

    Index('ix_artifact_name_and_version', artifacts.c.name,
          artifacts.c.version_prefix, artifacts.c.version_suffix)
    Index('ix_artifact_type', artifacts.c.type_name,
          artifacts.c.type_version_prefix, artifacts.c.type_version_suffix)
    Index('ix_artifact_state', artifacts.c.state)
    Index('ix_artifact_owner', artifacts.c.owner)
    Index('ix_artifact_visibility', artifacts.c.visibility)

    return artifacts
コード例 #3
0
def get_images_table(meta):
    """
    Returns the Table object for the images table that
    corresponds to the images table definition of this version.
    """
    images = Table('images',
                   meta,
                   Column('id', Integer(), primary_key=True, nullable=False),
                   Column('name', String(255)),
                   Column('disk_format', String(20)),
                   Column('container_format', String(20)),
                   Column('size', BigInteger()),
                   Column('status', String(30), nullable=False),
                   Column('is_public',
                          Boolean(),
                          nullable=False,
                          default=False,
                          index=True),
                   Column('location', Text()),
                   Column('created_at', DateTime(), nullable=False),
                   Column('updated_at', DateTime()),
                   Column('deleted_at', DateTime()),
                   Column('deleted',
                          Boolean(),
                          nullable=False,
                          default=False,
                          index=True),
                   mysql_engine='InnoDB',
                   useexisting=True)

    return images
コード例 #4
0
def _add_artifact_blobs_table():
    op.create_table('artifact_blobs',
                    Column('id', String(length=36), nullable=False),
                    Column('artifact_id', String(length=36), nullable=False),
                    Column('size', BigInteger(), nullable=False),
                    Column('checksum', String(length=32), nullable=True),
                    Column('name', String(length=255), nullable=False),
                    Column('item_key', String(length=329), nullable=True),
                    Column('position', Integer(), nullable=True),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=False),
                    ForeignKeyConstraint(
                        ['artifact_id'],
                        ['artifacts.id'],
                    ),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_artifact_blobs_artifact_id',
                    'artifact_blobs', ['artifact_id'],
                    unique=False)
    op.create_index('ix_artifact_blobs_name',
                    'artifact_blobs', ['name'],
                    unique=False)
コード例 #5
0
def _add_storage_services_table():
    op.create_table('storage_services',
                    Column('id', String(36), nullable=False),
                    Column('name', String(30), nullable=True),
                    Column('schema', String(10), nullable=False),
                    Column('port', String(10), nullable=False),
                    Column('host', String(30), nullable=False),
                    Column('endpoint', String(100), nullable=False),
                    Column('status', String(30), nullable=False),
                    Column('total_size', BigInteger(), nullable=False),
                    Column('avail_size', BigInteger(), nullable=False),
                    Column('disk_wwn', String(50), nullable=False),
                    Column('file_system_uuid', String(50), nullable=False),
                    Column('storage_dir', String(100), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime()),
                    Column('deleted_at', DateTime()),
                    Column('deleted', Boolean(), nullable=False,
                           default=False),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_storageServices_endpoint',
                    'storage_services', ['endpoint'],
                    unique=False)
    op.create_index('ix_storageServices_status',
                    'storage_services', ['status'],
                    unique=False)
    op.create_index('ix_storageServices_avail_size',
                    'storage_services', ['avail_size'],
                    unique=False)
    op.create_index('ix_storageServices_file_system_uuid',
                    'storage_services', ['file_system_uuid'],
                    unique=False)
    op.create_index('ix_storageServices_disk_wwn',
                    'storage_services', ['disk_wwn'],
                    unique=False)
    op.create_index('ix_storageServices_updated_at',
                    'storage_services', ['updated_at'],
                    unique=False)
    op.create_index('ix_storageServices_deleted',
                    'storage_services', ['deleted'],
                    unique=False)
コード例 #6
0
def _add_artifacts_table():
    op.create_table('artifacts',
                    Column('id', String(length=36), nullable=False),
                    Column('name', String(length=255), nullable=False),
                    Column('type_name', String(length=255), nullable=False),
                    Column('type_version_prefix', BigInteger(),
                           nullable=False),
                    Column('type_version_suffix',
                           String(length=255),
                           nullable=True),
                    Column('type_version_meta',
                           String(length=255),
                           nullable=True),
                    Column('version_prefix', BigInteger(), nullable=False),
                    Column('version_suffix', String(length=255),
                           nullable=True),
                    Column('version_meta', String(length=255), nullable=True),
                    Column('description', Text(), nullable=True),
                    Column('visibility', String(length=32), nullable=False),
                    Column('state', String(length=32), nullable=False),
                    Column('owner', String(length=255), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=False),
                    Column('deleted_at', DateTime(), nullable=True),
                    Column('published_at', DateTime(), nullable=True),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_artifact_name_and_version',
                    'artifacts', ['name', 'version_prefix', 'version_suffix'],
                    unique=False)
    op.create_index('ix_artifact_owner', 'artifacts', ['owner'], unique=False)
    op.create_index('ix_artifact_state', 'artifacts', ['state'], unique=False)
    op.create_index(
        'ix_artifact_type',
        'artifacts',
        ['type_name', 'type_version_prefix', 'type_version_suffix'],
        unique=False)
    op.create_index('ix_artifact_visibility',
                    'artifacts', ['visibility'],
                    unique=False)
コード例 #7
0
def upgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    # No changes to SQLite stores are necessary, since
    # there is no BIG INTEGER type in SQLite. Unfortunately,
    # running the Python 005_size_big_integer.py migration script
    # on a SQLite datastore results in an error in the sa-migrate
    # code that does the workarounds for SQLite not having
    # ALTER TABLE MODIFY COLUMN ability

    dialect = migrate_engine.url.get_dialect().name

    if not dialect.startswith('sqlite'):
        (get_images_table, ) = from_migration_import('003_add_disk_format',
                                                     ['get_images_table'])

        images = get_images_table(meta)
        images.columns['size'].alter(type=BigInteger())
コード例 #8
0
def define_artifact_blobs_table(meta):
    artifact_blobs = Table('artifact_blobs',
                           meta,
                           Column('id', String(36), primary_key=True,
                                  nullable=False),
                           Column('artifact_id', String(36),
                                  ForeignKey('artifacts.id'),
                                  nullable=False),
                           Column('size', BigInteger(), nullable=False),
                           Column('checksum', String(32)),
                           Column('name', String(255), nullable=False),
                           Column('item_key', String(329)),
                           Column('position', Integer()),
                           Column('created_at', DateTime(), nullable=False),
                           Column('updated_at', DateTime(),
                                  nullable=False),
                           mysql_engine='InnoDB',
                           extend_existing=True)
    Index('ix_artifact_blobs_artifact_id',
          artifact_blobs.c.artifact_id)
    Index('ix_artifact_blobs_name',
          artifact_blobs.c.name)
    return artifact_blobs