VMWare Edge driver database model and migration
Add database model, API, and alembic migration for VMWare Edge loadbalancer driver This patch adds the models for the v1 driver. Change-Id: I6ef7aa0a5572bbeee4023a308f9bd7a1c025bd2f Partially-Implements: blueprint vmware-nsx-v
This commit is contained in:
parent
4dcbedf1bf
commit
b2cb6b58c9
@ -0,0 +1,68 @@
|
||||
# Copyright 2015 VMware, 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.
|
||||
|
||||
"""edge_driver
|
||||
|
||||
Revision ID: 4ba00375f715
|
||||
Revises: lbaasv2_tls
|
||||
Create Date: 2015-02-03 20:35:54.830634
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4ba00375f715'
|
||||
down_revision = 'lbaasv2_tls'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'nsxv_edge_pool_mappings',
|
||||
sa.Column('pool_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_pool_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('pool_id')
|
||||
)
|
||||
op.create_table(
|
||||
'nsxv_edge_vip_mappings',
|
||||
sa.Column('pool_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_app_profile_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('edge_vse_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_fw_rule_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('pool_id')
|
||||
)
|
||||
op.create_table(
|
||||
'nsxv_edge_monitor_mappings',
|
||||
sa.Column('monitor_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_monitor_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['monitor_id'], ['healthmonitors.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('monitor_id'),
|
||||
sa.UniqueConstraint('monitor_id', 'edge_id',
|
||||
name='uniq_nsxv_edge_monitor_mappings')
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('nsxv_edge_pool_mappings')
|
||||
op.drop_table('nsxv_edge_vip_mappings')
|
||||
op.drop_table('nsxv_edge_monitor_mappings')
|
@ -1 +1 @@
|
||||
lbaasv2_tls
|
||||
4ba00375f715
|
||||
|
94
neutron_lbaas/services/loadbalancer/drivers/vmware/db.py
Normal file
94
neutron_lbaas/services/loadbalancer/drivers/vmware/db.py
Normal file
@ -0,0 +1,94 @@
|
||||
# Copyright 2015 VMware, 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_lbaas.services.loadbalancer.drivers.vmware import models
|
||||
|
||||
|
||||
def add_nsxv_edge_pool_mapping(context, pool_id, edge_id, edge_pool_id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
mapping = models.NsxvEdgePoolMapping()
|
||||
mapping.pool_id = pool_id
|
||||
mapping.edge_id = edge_id
|
||||
mapping.edge_pool_id = edge_pool_id
|
||||
session.add(mapping)
|
||||
|
||||
|
||||
def get_nsxv_edge_pool_mapping(context, pool_id):
|
||||
return(context.session.query(models.NsxvEdgePoolMapping).
|
||||
filter_by(pool_id=pool_id).first())
|
||||
|
||||
|
||||
def delete_nsxv_edge_pool_mapping(context, pool_id):
|
||||
session = context.session
|
||||
mapping = (session.query(models.NsxvEdgePoolMapping).filter_by(
|
||||
pool_id=pool_id))
|
||||
for m in mapping:
|
||||
session.delete(m)
|
||||
|
||||
|
||||
def add_nsxv_edge_vip_mapping(context, pool_id, edge_id, edge_app_profile_id,
|
||||
edge_vse_id, edge_fw_rule_id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
mapping = models.NsxvEdgeVipMapping()
|
||||
mapping.pool_id = pool_id
|
||||
mapping.edge_id = edge_id
|
||||
mapping.edge_app_profile_id = edge_app_profile_id
|
||||
mapping.edge_vse_id = edge_vse_id
|
||||
mapping.edge_fw_rule_id = edge_fw_rule_id
|
||||
session.add(mapping)
|
||||
|
||||
|
||||
def get_nsxv_edge_vip_mapping(context, pool_id):
|
||||
return(context.session.query(models.NsxvEdgeVipMapping).
|
||||
filter_by(pool_id=pool_id).first())
|
||||
|
||||
|
||||
def delete_nsxv_edge_vip_mapping(context, pool_id):
|
||||
session = context.session
|
||||
mapping = (session.query(models.NsxvEdgeVipMapping).filter_by(
|
||||
pool_id=pool_id))
|
||||
for m in mapping:
|
||||
session.delete(m)
|
||||
|
||||
|
||||
def add_nsxv_edge_monitor_mapping(context, monitor_id, edge_id,
|
||||
edge_monitor_id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
mapping = models.NsxvEdgeMonitorMapping()
|
||||
mapping.monitor_id = monitor_id
|
||||
mapping.edge_id = edge_id
|
||||
mapping.edge_monitor_id = edge_monitor_id
|
||||
session.add(mapping)
|
||||
|
||||
|
||||
def get_nsxv_edge_monitor_mapping(context, monitor_id, edge_id):
|
||||
return(context.session.query(models.NsxvEdgeMonitorMapping).
|
||||
filter_by(monitor_id=monitor_id, edge_id=edge_id).first())
|
||||
|
||||
|
||||
def get_nsxv_edge_monitor_mapping_all(context, monitor_id):
|
||||
return(context.session.query(models.NsxvEdgeMonitorMapping).
|
||||
filter_by(monitor_id=monitor_id).all())
|
||||
|
||||
|
||||
def delete_nsxv_edge_monitor_mapping(context, monitor_id, edge_id):
|
||||
session = context.session
|
||||
mapping = (session.query(models.NsxvEdgeMonitorMapping).filter_by(
|
||||
monitor_id=monitor_id, edge_id=edge_id))
|
||||
for m in mapping:
|
||||
session.delete(m)
|
54
neutron_lbaas/services/loadbalancer/drivers/vmware/models.py
Normal file
54
neutron_lbaas/services/loadbalancer/drivers/vmware/models.py
Normal file
@ -0,0 +1,54 @@
|
||||
# Copyright 2015 VMware, 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.db import model_base
|
||||
import sqlalchemy as sql
|
||||
|
||||
|
||||
class NsxvEdgePoolMapping(model_base.BASEV2):
|
||||
"""Represents the connection between Edges and pools."""
|
||||
__tablename__ = 'nsxv_edge_pool_mappings'
|
||||
|
||||
pool_id = sql.Column(sql.String(36), sql.ForeignKey('pools.id'),
|
||||
primary_key=True)
|
||||
edge_id = sql.Column(sql.String(36), nullable=False)
|
||||
edge_pool_id = sql.Column(sql.String(36), nullable=False)
|
||||
|
||||
|
||||
class NsxvEdgeVipMapping(model_base.BASEV2):
|
||||
"""Represents the connection between Edges and VIPs."""
|
||||
__tablename__ = 'nsxv_edge_vip_mappings'
|
||||
|
||||
pool_id = sql.Column(sql.String(36), sql.ForeignKey('pools.id'),
|
||||
primary_key=True)
|
||||
edge_id = sql.Column(sql.String(36), nullable=False)
|
||||
edge_app_profile_id = sql.Column(sql.String(36), nullable=False)
|
||||
edge_vse_id = sql.Column(sql.String(36), nullable=False)
|
||||
edge_fw_rule_id = sql.Column(sql.String(36), nullable=False)
|
||||
|
||||
|
||||
class NsxvEdgeMonitorMapping(model_base.BASEV2):
|
||||
"""Represents the connection between Edges and pool monitors."""
|
||||
__tablename__ = 'nsxv_edge_monitor_mappings'
|
||||
|
||||
__table_args__ = (sql.schema.UniqueConstraint(
|
||||
'monitor_id', 'edge_id',
|
||||
name='uniq_nsxv_edge_monitor_mappings'),)
|
||||
|
||||
monitor_id = sql.Column(sql.String(36),
|
||||
sql.ForeignKey('healthmonitors.id'),
|
||||
primary_key=True)
|
||||
edge_id = sql.Column(sql.String(36), nullable=False, primary_key=True)
|
||||
edge_monitor_id = sql.Column(sql.String(36), nullable=False)
|
Loading…
Reference in New Issue
Block a user