Add Host Mapping table to API Database
This patch creates the host_mappings table in the API database for cellsv2. This table will contain mapping of compute hosts to cells. Change-Id: I1bd35434ce186e1fb49d56c621bff3f09aa90138 Implements: blueprint cells-host-mapping
This commit is contained in:
parent
00d343f0c4
commit
f71099f502
@ -0,0 +1,43 @@
|
||||
# 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 migrate.changeset.constraint import ForeignKeyConstraint
|
||||
from migrate import UniqueConstraint
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy import DateTime
|
||||
from sqlalchemy import Index
|
||||
from sqlalchemy import Integer
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import String
|
||||
from sqlalchemy import Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
cell_mappings = Table('cell_mappings', meta, autoload=True)
|
||||
host_mappings = Table('host_mappings', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('cell_id', Integer, nullable=False),
|
||||
Column('host', String(length=255), nullable=False),
|
||||
UniqueConstraint('host',
|
||||
name='uniq_host_mappings0host'),
|
||||
Index('host_idx', 'host'),
|
||||
ForeignKeyConstraint(columns=['cell_id'],
|
||||
refcolumns=[cell_mappings.c.id]),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
host_mappings.create(checkfirst=True)
|
@ -56,3 +56,16 @@ class InstanceMapping(API_BASE):
|
||||
cell_id = Column(Integer, ForeignKey('cell_mappings.id'),
|
||||
nullable=False)
|
||||
project_id = Column(String(255), nullable=False)
|
||||
|
||||
|
||||
class HostMapping(API_BASE):
|
||||
"""Contains mapping of a compute host to which cell it is in"""
|
||||
__tablename__ = "host_mappings"
|
||||
__table_args__ = (Index('host_idx', 'host'),
|
||||
schema.UniqueConstraint('host',
|
||||
name='uniq_host_mappings0host'))
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
cell_id = Column(Integer, ForeignKey('cell_mappings.id'),
|
||||
nullable=False)
|
||||
host = Column(String(255), nullable=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user