diff --git a/blazar/db/migration/alembic_migrations/versions/e069c014356d_add_floatingip.py b/blazar/db/migration/alembic_migrations/versions/e069c014356d_add_floatingip.py new file mode 100644 index 00000000..c5919173 --- /dev/null +++ b/blazar/db/migration/alembic_migrations/versions/e069c014356d_add_floatingip.py @@ -0,0 +1,54 @@ +# Copyright 2019 OpenStack Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""add-floatingip + +Revision ID: e069c014356d +Revises: 35b314cd39ee +Create Date: 2019-01-10 10:15:47.874521 + +""" + +# revision identifiers, used by Alembic. +revision = 'e069c014356d' +down_revision = '9593f3656974' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('floatingips', + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.Column('id', sa.String(length=36), nullable=False), + sa.Column('floating_network_id', sa.String(length=255), + nullable=False), + sa.Column('subnet_id', sa.String(length=255), + nullable=False), + sa.Column('floating_ip_address', sa.String(length=255), + nullable=False), + sa.Column('reservable', sa.Boolean(), + server_default=sa.text(u'true'), nullable=False), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('subnet_id', 'floating_ip_address')) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('floatingips') + # ### end Alembic commands ### diff --git a/blazar/db/sqlalchemy/models.py b/blazar/db/sqlalchemy/models.py index 14bd445a..cf506375 100644 --- a/blazar/db/sqlalchemy/models.py +++ b/blazar/db/sqlalchemy/models.py @@ -244,3 +244,20 @@ class ComputeHostExtraCapability(mb.BlazarBase): def to_dict(self): return super(ComputeHostExtraCapability, self).to_dict() + + +# Floating IP + +class FloatingIP(mb.BlazarBase): + """A table for Floating IP resource.""" + + __tablename__ = 'floatingips' + + id = _id_column() + floating_network_id = sa.Column(sa.String(255), nullable=False) + subnet_id = sa.Column(sa.String(255), nullable=False) + floating_ip_address = sa.Column(sa.String(255), nullable=False) + reservable = sa.Column(sa.Boolean, nullable=False, + server_default=sa.true()) + + __table_args__ = (sa.UniqueConstraint('subnet_id', 'floating_ip_address'),)