-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[run] | ||
omit = | ||
*/test/* | ||
|
||
[report] | ||
exclude_lines = | ||
pragma: no cover | ||
def __repr__ | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: python | ||
python: | ||
- '3.6' | ||
env: | ||
- TOXENV=py36 | ||
- TOXENV=flake8 | ||
- TOXENV=build | ||
install: | ||
- pip install tox | ||
script: tox | ||
services: | ||
- postgresql | ||
deploy: | ||
provider: pypi | ||
user: rmb938 | ||
password: | ||
secure: kmyrXVrwj6et8AiC9a6llLU26gIFPVa/DJSGt9uluZpI2RLrNCPLJhJYR81y1f8muNw1wvIubxyeXDYC1206kiSRZ8cyV6amvpUnXVuvB/YYlCwFMlrdJbbsKBtz3IepfoZVPiZa6YQLeuWFde9s7v43uxMOSx28eEDrZ5PporjTw1BWHK1OSaZ9iM9Z+HOWt6qizDfldJo27IJh5/505pDBQTVfP+2Xk8r2sIY5i+BpBkWfLgGfgnRfT4TaPPIZcyhjIMOIUlt9vy/Fmgm2PJeOaEk5L4cD7JOiQAxSyVcrAFKCg3u+xEy3609dmg2JeqF0FFfn4qmMoaAYX78qihbZONoKKYRq0i/iydx9QtgMkFovz/N8TzdK5vpfxccnXiNKTylMrO1RrD+kf3wKdl+m8v2yk7ewi9DXejnxhDRl+ndTiE06ONXQCMmD1ITF/zW9vdcvpWKLwETzbjJbHWRahIHCosk8Idaa8+Wu+MQoLXUJRA6JRRbUJVKCR5ANb38uPTnI4Wu+HzyJmE+9mAEiUZmPN+5EQdIaDUcypC3iPKddVD9x6aQJnWz9xlcParfjSGQaI5fHAUSvth7iBh6DeVDhJMyrVtwo4rJNF0OgiaKOtiLoV+vqvCBi5Dqy25ZI6MxIWC1MeP+lt0KpjIBO6o5yXtArAH1XlCYgieI= | ||
on: | ||
tags: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
--- | ||
version: "3" | ||
services: | ||
postgres: | ||
image: postgres:alpine | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- pgdata:/var/lib/postgresql/data | ||
volumes: | ||
pgdata: {} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Generic single-database configuration. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from __future__ import with_statement | ||
|
||
from alembic import context | ||
from sqlalchemy import engine_from_config, pool | ||
|
||
# this is the Alembic Config object, which provides | ||
# access to the values within the .ini file in use. | ||
config = context.config | ||
|
||
# add your model's MetaData object here | ||
# for 'autogenerate' support | ||
# from myapp import mymodel | ||
# target_metadata = mymodel.Base.metadata | ||
target_metadata = None | ||
|
||
|
||
# other values from the config, defined by the needs of env.py, | ||
# can be acquired: | ||
# my_important_option = config.get_main_option("my_important_option") | ||
# ... etc. | ||
|
||
|
||
def run_migrations_offline(): | ||
"""Run migrations in 'offline' mode. | ||
This configures the context with just a URL | ||
and not an Engine, though an Engine is acceptable | ||
here as well. By skipping the Engine creation | ||
we don't even need a DBAPI to be available. | ||
Calls to context.execute() here emit the given string to the | ||
script output. | ||
""" | ||
url = config.get_main_option("sqlalchemy.url") | ||
context.configure( | ||
url=url, target_metadata=target_metadata, literal_binds=True) | ||
|
||
with context.begin_transaction(): | ||
context.run_migrations() | ||
|
||
|
||
def run_migrations_online(): | ||
"""Run migrations in 'online' mode. | ||
In this scenario we need to create an Engine | ||
and associate a connection with the context. | ||
""" | ||
connectable = engine_from_config( | ||
config.get_section(config.config_ini_section), | ||
prefix='sqlalchemy.', | ||
poolclass=pool.NullPool) | ||
|
||
with connectable.connect() as connection: | ||
context.configure( | ||
connection=connection, | ||
target_metadata=target_metadata | ||
) | ||
|
||
with context.begin_transaction(): | ||
context.run_migrations() | ||
|
||
|
||
if context.is_offline_mode(): | ||
run_migrations_offline() | ||
else: | ||
run_migrations_online() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""${message} | ||
|
||
Revision ID: ${up_revision} | ||
Revises: ${down_revision | comma,n} | ||
Create Date: ${create_date} | ||
|
||
""" | ||
from alembic import op | ||
import sqlalchemy_utils as sau | ||
import sqlalchemy as sa | ||
${imports if imports else ""} | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = ${repr(up_revision)} | ||
down_revision = ${repr(down_revision)} | ||
branch_labels = ${repr(branch_labels)} | ||
depends_on = ${repr(depends_on)} | ||
|
||
|
||
def upgrade(): | ||
${upgrades if upgrades else "pass"} | ||
|
||
|
||
def downgrade(): | ||
${downgrades if downgrades else "pass"} |
38 changes: 38 additions & 0 deletions
38
ingredients_db/alembic/versions/1fdbfd6b0eea_create_instance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""create instance | ||
Revision ID: 1fdbfd6b0eea | ||
Revises: b129792f908b | ||
Create Date: 2017-09-17 13:17:52.136597 | ||
""" | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils as sau | ||
from alembic import op | ||
# revision identifiers, used by Alembic. | ||
from sqlalchemy import ForeignKey | ||
from sqlalchemy.dialects.postgresql import HSTORE | ||
|
||
from ingredients_db.models.instance import InstanceState | ||
|
||
revision = '1fdbfd6b0eea' | ||
down_revision = 'b129792f908b' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
'instances', | ||
sa.Column('id', sau.UUIDType, ForeignKey('networkable_entities.id'), primary_key=True), | ||
sa.Column('name', sa.String, nullable=False), | ||
sa.Column('tags', HSTORE), | ||
sa.Column('state', sa.Enum(InstanceState), default=InstanceState.BUILDING, nullable=False), | ||
|
||
sa.Column('project_id', sau.UUIDType, sa.ForeignKey('projects.id', ondelete='RESTRICT'), nullable=False), | ||
sa.Column('image_id', sau.UUIDType, sa.ForeignKey('images.id', ondelete='SET NULL')) | ||
|
||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('instances') |
49 changes: 49 additions & 0 deletions
49
ingredients_db/alembic/versions/3ce1572cbc6b_create_tasks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""create tasks | ||
Revision ID: 3ce1572cbc6b | ||
Revises: 1fdbfd6b0eea | ||
Create Date: 2017-09-24 12:13:14.977009 | ||
""" | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils as sau | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
from ingredients_db.models.task import TaskState | ||
|
||
revision = '3ce1572cbc6b' | ||
down_revision = None | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
'tasks', | ||
sa.Column('id', sau.UUIDType, server_default=sa.text("uuid_generate_v4()"), primary_key=True), | ||
sa.Column('name', sa.String, nullable=False), | ||
sa.Column('state', sa.Enum(TaskState), default=TaskState.PENDING, nullable=False), | ||
sa.Column('error_message', sa.Text), | ||
|
||
sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False), | ||
sa.Column('updated_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), | ||
nullable=False), | ||
sa.Column('stopped_at', sau.ArrowType(timezone=True)), | ||
) | ||
op.create_table( | ||
'taskable_entities', | ||
sa.Column('id', sau.UUIDType, server_default=sa.text("uuid_generate_v4()"), primary_key=True), | ||
sa.Column('type', sa.String, nullable=False), | ||
|
||
sa.Column('current_task_id', sau.UUIDType, sa.ForeignKey('tasks.id')), | ||
|
||
sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False, index=True), | ||
sa.Column('updated_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), | ||
nullable=False) | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('taskable_entities') | ||
op.drop_table('tasks') |
31 changes: 31 additions & 0 deletions
31
ingredients_db/alembic/versions/458762cd0419_create_user.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""create user | ||
Revision ID: 458762cd0419 | ||
Revises: 3ce1572cbc6b | ||
Create Date: 2017-09-16 09:24:55.054833 | ||
""" | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils as sau | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '458762cd0419' | ||
down_revision = '3ce1572cbc6b' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
'users', | ||
sa.Column('id', sau.UUIDType, server_default=sa.text("uuid_generate_v4()"), primary_key=True), | ||
sa.Column('username', sa.String, unique=True, nullable=False), | ||
sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False), | ||
sa.Column('updated_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), | ||
nullable=False) | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('users') |
50 changes: 50 additions & 0 deletions
50
ingredients_db/alembic/versions/52923fe51ede_create_image.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""create image | ||
Revision ID: 52923fe51ede | ||
Revises: f422a466b0a8 | ||
Create Date: 2017-09-17 09:55:58.239260 | ||
""" | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils as sau | ||
from alembic import op | ||
|
||
from ingredients_db.models.images import ImageVisibility, ImageState | ||
|
||
# revision identifiers, used by Alembic. | ||
|
||
revision = '52923fe51ede' | ||
down_revision = 'f422a466b0a8' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
'images', | ||
sa.Column('id', sau.UUIDType, sa.ForeignKey('taskable_entities.id'), primary_key=True), | ||
|
||
sa.Column('name', sa.String, nullable=False), | ||
sa.Column('file_name', sa.String, unique=True, nullable=False), | ||
sa.Column('locked', sa.Boolean, default=False, nullable=False), | ||
|
||
sa.Column('state', sa.Enum(ImageState), default=ImageState.CREATING, nullable=False), | ||
sa.Column('visibility', sa.Enum(ImageVisibility), default=ImageVisibility.PRIVATE, nullable=False), | ||
|
||
sa.Column('project_id', sau.UUIDType, sa.ForeignKey('projects.id', ondelete='RESTRICT'), nullable=False), | ||
) | ||
|
||
op.create_table( | ||
'image_members', | ||
sa.Column('image_id', sau.UUIDType, sa.ForeignKey('images.id', ondelete='CASCADE'), nullable=False, | ||
primary_key=True), | ||
sa.Column('project_id', sau.UUIDType, sa.ForeignKey('projects.id', ondelete='CASCADE'), nullable=False, | ||
primary_key=True), | ||
|
||
sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False, index=True), | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('image_members') | ||
op.drop_table('images') |
41 changes: 41 additions & 0 deletions
41
ingredients_db/alembic/versions/9d6460001e00_create_network.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""create network | ||
Revision ID: 9d6460001e00 | ||
Revises: 52923fe51ede | ||
Create Date: 2017-09-17 10:17:05.262655 | ||
""" | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils as sau | ||
from alembic import op | ||
from sqlalchemy import ForeignKey | ||
|
||
# revision identifiers, used by Alembic. | ||
from ingredients_db.models.network import NetworkState | ||
from ingredients_db.types import IPv4Network | ||
|
||
revision = '9d6460001e00' | ||
down_revision = '52923fe51ede' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
'networks', | ||
sa.Column('id', sau.UUIDType, ForeignKey('taskable_entities.id'), primary_key=True), | ||
sa.Column('name', sa.String, unique=True, nullable=False), | ||
|
||
sa.Column('port_group', sa.String, unique=True, nullable=False), | ||
|
||
sa.Column('state', sa.Enum(NetworkState), default=NetworkState.CREATING, nullable=False), | ||
|
||
sa.Column('cidr', IPv4Network, nullable=False), | ||
sa.Column('pool_start', sau.IPAddressType, nullable=False), | ||
sa.Column('pool_end', sau.IPAddressType, nullable=False), | ||
|
||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('networks') |
41 changes: 41 additions & 0 deletions
41
ingredients_db/alembic/versions/b129792f908b_create_network_port.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""create network port | ||
Revision ID: b129792f908b | ||
Revises: 9d6460001e00 | ||
Create Date: 2017-09-17 13:16:53.698284 | ||
""" | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils as sau | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'b129792f908b' | ||
down_revision = '9d6460001e00' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
'network_ports', | ||
sa.Column('id', sau.UUIDType, server_default=sa.text("uuid_generate_v4()"), primary_key=True), | ||
|
||
sa.Column('network_id', sau.UUIDType, sa.ForeignKey('networks.id', ondelete='RESTRICT'), nullable=False), | ||
sa.Column('ip_address', sau.IPAddressType), | ||
|
||
sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False, index=True), | ||
sa.Column('updated_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), | ||
nullable=False) | ||
) | ||
|
||
op.create_table( | ||
'networkable_entities', | ||
sa.Column('id', sau.UUIDType, sa.ForeignKey('taskable_entities.id'), primary_key=True), | ||
sa.Column('network_port_id', sau.UUIDType, sa.ForeignKey('network_ports.id', ondelete='SET NULL')), | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('networkable_entities') | ||
op.drop_table('network_ports') |
Oops, something went wrong.