From 8500612141da33e84c3bb1b7463e609ce1566567 Mon Sep 17 00:00:00 2001 From: "Jay Lau (Guangya Liu)" Date: Tue, 30 Dec 2014 23:26:57 -0500 Subject: [PATCH] Add replication controller to magnum db Change-Id: Id3fc6b0b81bc097f3e90d2f98e28b8f0c29ce429 --- .../versions/2581ebaf0cb2_initial_migration.py | 16 ++++++++++++++++ magnum/db/sqlalchemy/models.py | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/magnum/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py b/magnum/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py index e0526ebdae..62c9a63200 100644 --- a/magnum/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py +++ b/magnum/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py @@ -116,6 +116,21 @@ def upgrade(): mysql_ENGINE='InnoDB', mysql_DEFAULT_CHARSET='UTF8' ) + op.create_table( + 'replicationcontroller', + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('uuid', sa.String(length=36), nullable=True), + sa.Column('name', sa.String(length=255), nullable=True), + sa.Column('bay_uuid', sa.String(length=36), nullable=True), + sa.Column('images', sa.Text(), nullable=False), + sa.Column('selector', sa.Text(), nullable=True), + sa.Column('replicas', sa.Integer(), nullable=True), + sa.PrimaryKeyConstraint('id'), + mysql_ENGINE='InnoDB', + mysql_DEFAULT_CHARSET='UTF8' + ) # end Alembic commands @@ -126,6 +141,7 @@ def downgrade(): op.drop_table('node') op.drop_table('service') op.drop_table('pod') + op.drop_table('replicationcontroller') # We should probably remove the drops later ;-) # raise NotImplementedError(('Downgrade from initial migration is' # ' unsupported.')) diff --git a/magnum/db/sqlalchemy/models.py b/magnum/db/sqlalchemy/models.py index 3df65332bb..bfe7a4e68f 100644 --- a/magnum/db/sqlalchemy/models.py +++ b/magnum/db/sqlalchemy/models.py @@ -207,3 +207,21 @@ class Service(Base): selector = Column(JSONEncodedDict) ip = Column(String(36)) port = Column(Integer()) + + +class ReplicationController(Base): + """Represents a pod replication controller.""" + + __tablename__ = 'replicationcontroller' + __table_args__ = ( + schema.UniqueConstraint('uuid', + name='uniq_replicationcontroller0uuid'), + table_args() + ) + id = Column(Integer, primary_key=True) + uuid = Column(String(36)) + name = Column(String(255)) + bay_uuid = Column(String(36)) + images = Column(JSONEncodedList) + selector = Column(JSONEncodedDict) + replicas = Column(Integer())