Merge "[OVN] Add DB tables for OVN backend"
This commit is contained in:
commit
b4ccac6773
@ -1 +1 @@
|
||||
86274d77933e
|
||||
f4b9654dd40c
|
||||
|
@ -0,0 +1,74 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.engine import reflection
|
||||
|
||||
|
||||
"""ovn backend
|
||||
|
||||
Revision ID: f4b9654dd40c
|
||||
Revises: 86274d77933e
|
||||
Create Date: 2019-11-25 13:09:31.367837
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f4b9654dd40c'
|
||||
down_revision = '86274d77933e'
|
||||
|
||||
OVN_REVISION_NUMBERS = 'ovn_revision_numbers'
|
||||
OVN_HASH_RING = 'ovn_hash_ring'
|
||||
|
||||
|
||||
def upgrade():
|
||||
inspector = reflection.Inspector.from_engine(op.get_bind())
|
||||
table_names = inspector.get_table_names()
|
||||
if OVN_REVISION_NUMBERS in table_names and OVN_HASH_RING in table_names:
|
||||
op.alter_column(OVN_REVISION_NUMBERS, 'revision_number',
|
||||
nullable=False, server_default='0',
|
||||
existing_type=sa.BIGINT(), existing_nullable=False)
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
OVN_REVISION_NUMBERS,
|
||||
sa.Column('standard_attr_id', sa.BigInteger, nullable=True),
|
||||
sa.Column('resource_uuid', sa.String(36), nullable=False, index=True),
|
||||
sa.Column('resource_type', sa.String(36), nullable=False, index=True),
|
||||
sa.Column('revision_number', sa.BigInteger, nullable=False,
|
||||
server_default='0'),
|
||||
sa.Column('created_at', sa.DateTime, nullable=False,
|
||||
default=sa.func.now()),
|
||||
sa.Column('updated_at', sa.TIMESTAMP, default=sa.func.now(),
|
||||
onupdate=sa.func.now(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
['standard_attr_id'], ['standardattributes.id'],
|
||||
ondelete='SET NULL'),
|
||||
sa.PrimaryKeyConstraint('resource_uuid', 'resource_type')
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
OVN_HASH_RING,
|
||||
sa.Column('node_uuid', sa.String(36), nullable=False, index=True),
|
||||
sa.Column('group_name', sa.String(length=256), nullable=False,
|
||||
index=True),
|
||||
sa.Column('hostname', sa.String(length=256), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime, nullable=False,
|
||||
default=sa.func.now()),
|
||||
sa.Column('updated_at', sa.DateTime, nullable=False,
|
||||
default=sa.func.now()),
|
||||
sa.PrimaryKeyConstraint('node_uuid', 'group_name'),
|
||||
)
|
63
neutron/db/models/ovn.py
Normal file
63
neutron/db/models/ovn.py
Normal file
@ -0,0 +1,63 @@
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import sqlite
|
||||
|
||||
|
||||
class OVNRevisionNumbers(model_base.BASEV2):
|
||||
__tablename__ = 'ovn_revision_numbers'
|
||||
|
||||
standard_attr_id = sa.Column(
|
||||
sa.BigInteger().with_variant(sa.Integer(), 'sqlite'),
|
||||
sa.ForeignKey('standardattributes.id', ondelete='SET NULL'),
|
||||
nullable=True)
|
||||
resource_uuid = sa.Column(sa.String(36), nullable=False, index=True)
|
||||
resource_type = sa.Column(sa.String(36), nullable=False, index=True)
|
||||
revision_number = sa.Column(
|
||||
sa.BigInteger().with_variant(sa.Integer(), 'sqlite'),
|
||||
server_default='0', default=0, nullable=False)
|
||||
created_at = sa.Column(
|
||||
sa.DateTime().with_variant(
|
||||
sqlite.DATETIME(truncate_microseconds=True), 'sqlite'),
|
||||
default=sa.func.now(), nullable=False)
|
||||
updated_at = sa.Column(sa.TIMESTAMP, default=sa.func.now(),
|
||||
onupdate=sa.func.now(), nullable=True)
|
||||
|
||||
__table_args__ = (
|
||||
sa.PrimaryKeyConstraint(
|
||||
resource_uuid, resource_type,
|
||||
name='ovn_revision_numbers0resource_uuid0resource_type'),
|
||||
model_base.BASEV2.__table_args__
|
||||
)
|
||||
|
||||
|
||||
class OVNHashRing(model_base.BASEV2):
|
||||
__tablename__ = 'ovn_hash_ring'
|
||||
|
||||
node_uuid = sa.Column(sa.String(36), nullable=False, index=True)
|
||||
group_name = sa.Column(sa.String(256), nullable=False, index=True)
|
||||
hostname = sa.Column(sa.String(256), nullable=False)
|
||||
created_at = sa.Column(sa.DateTime(), default=sa.func.now(),
|
||||
nullable=False)
|
||||
updated_at = sa.Column(sa.DateTime(), default=sa.func.now(),
|
||||
nullable=False)
|
||||
__table_args__ = (
|
||||
sa.PrimaryKeyConstraint(
|
||||
node_uuid, group_name,
|
||||
name='ovn_hash_ring0node_uuid0group_name'),
|
||||
model_base.BASEV2.__table_args__
|
||||
)
|
Loading…
Reference in New Issue
Block a user