def upgrade(migrate_engine): meta.bind = migrate_engine rbac = Table('rbac', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('project_id', UUID(), nullable=False, unique=False), Column('object_id', UUID(), nullable=False, unique=False), Column('target_tenant', UUID(), nullable=False, unique=False), Column('rbac_action', String(255), nullable=False, unique=False), mysql_engine='InnoDB', mysql_charset='utf8') rbac.create(checkfirst=True)
def downgrade(migrate_engine): meta.bind = migrate_engine tsigkeys_table = Table('tsigkeys', meta, autoload=True) domains_table = Table('domains', meta, autoload=True) records_table = Table('records', meta, autoload=True) tsigkeys_moniker_id = Column('moniker_id', UUID()) tsigkeys_moniker_id.drop(tsigkeys_table) domains_moniker_id = Column('moniker_id', UUID()) domains_moniker_id.drop(domains_table) records_moniker_id = Column('moniker_id', UUID()) records_moniker_id.drop(records_table)
def upgrade(migrate_engine): meta.bind = migrate_engine records_table = Table('records', meta, autoload=True) recordset_id = Column('designate_recordset_id', UUID()) recordset_id.create(records_table)
def upgrade(migrate_engine): meta.bind = migrate_engine domains_table = Table('domains', meta, autoload=True) # Get the default pool_id from the config file default_pool_id = cfg.CONF['service:central'].default_pool_id # Create the pool_id column pool_id_column = Column('pool_id', UUID(), default=default_pool_id, nullable=True) pool_id_column.create(domains_table, populate_default=True) # Alter the table to drop default value after populating it domains_table.c.pool_id.alter(default=None) dialect = migrate_engine.url.get_dialect().name if dialect.startswith('sqlite'): # Add missing unique index constraint = UniqueConstraint('name', 'deleted', name='unique_domain_name', table=domains_table) constraint.create()
def upgrade(migrate_engine): meta.bind = migrate_engine keys = Enum(name='key', *ZONE_ATTRIBUTE_KEYS) domain_attributes_table = Table( 'domain_attributes', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('key', keys), Column('value', String(255), nullable=False), Column('domain_id', UUID(), nullable=False), UniqueConstraint('key', 'value', 'domain_id', name='unique_attributes'), ForeignKeyConstraint(['domain_id'], ['domains.id'], ondelete='CASCADE'), mysql_engine='INNODB', mysql_charset='utf8' ) domains_table = Table('domains', meta, autoload=True) types = Enum(name='types', metadata=meta, *ZONE_TYPES) types.create() # Add type and transferred_at to domains type_ = Column('type', types, default='PRIMARY', server_default='PRIMARY') transferred_at = Column('transferred_at', DateTime, default=None) type_.create(domains_table, populate_default=True) transferred_at.create(domains_table, populate_default=True) domain_attributes_table.create() dialect = migrate_engine.url.get_dialect().name if dialect.startswith('sqlite'): constraint = UniqueConstraint( 'name', 'deleted', name='unique_domain_name', table=domains_table) # Add missing unique index constraint.create()
def downgrade(migrate_engine): meta.bind = migrate_engine records_table = Table('records', meta, autoload=True) managed_resource_id = Column('managed_resource_id', UUID(), default=None, nullable=True) managed_resource_id.drop(records_table) managed_resource_type = Column('managed_resource_type', Unicode(50), default=None, nullable=True) managed_resource_type.drop(records_table) managed_resource = Column('managed_resource', Boolean(), default=False) managed_resource.drop(records_table)
def upgrade(migrate_engine): meta.bind = migrate_engine status_enum = Enum(name='service_statuses', metadata=meta, *SERVICE_STATES) status_enum.create() service_status_table = Table('service_statuses', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime), Column('updated_at', DateTime), Column('service_name', String(40), nullable=False), Column('hostname', String(255), nullable=False), Column('heartbeated_at', DateTime, nullable=True), Column('status', status_enum, nullable=False), Column('stats', Text, nullable=False), Column('capabilities', Text, nullable=False), ) service_status_table.create()
# 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 sqlalchemy import Integer, String, DateTime, UniqueConstraint from sqlalchemy.schema import Table, Column, MetaData from designate.openstack.common import timeutils from designate import utils from designate.sqlalchemy.types import UUID meta = MetaData() quotas = Table('quotas', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime(), default=timeutils.utcnow), Column('updated_at', DateTime(), onupdate=timeutils.utcnow), Column('version', Integer(), default=1, nullable=False), Column('tenant_id', String(36), nullable=False), Column('resource', String(32), nullable=False), Column('hard_limit', Integer(), nullable=False), UniqueConstraint('tenant_id', 'resource', name='unique_quota')) def upgrade(migrate_engine): meta.bind = migrate_engine quotas.create()
from sqlalchemy import Integer, String, DateTime, Unicode, UniqueConstraint, \ Enum, ForeignKeyConstraint from sqlalchemy.schema import Table, Column, MetaData from designate import utils from designate.sqlalchemy.types import UUID POOL_PROVISIONERS = ['UNMANAGED'] meta = MetaData() pools = Table("pools", meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime(), default=lambda: timeutils.utcnow()), Column('updated_at', DateTime(), onupdate=lambda: timeutils.utcnow()), Column('version', Integer(), default=1, nullable=False), Column('name', String(50), nullable=False), Column('description', Unicode(160)), Column('tenant_id', String(36), nullable=True), Column('provisioner', Enum(name='pool_provisioner', *POOL_PROVISIONERS), nullable=False,
Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('key', String(50)), Column('value', String(255), nullable=False), Column('zone_id', UUID, nullable=False), UniqueConstraint('key', 'value', 'zone_id', name='unique_attributes'), ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'), mysql_engine='InnoDB', mysql_charset='utf8' ) zone_masters = Table('zone_masters', metadata, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('host', String(32), nullable=False), Column('port', Integer(), nullable=False), Column('zone_id', UUID(), nullable=False), UniqueConstraint('host', 'port', 'zone_id', name='unique_masters'), ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'), mysql_engine='InnoDB', mysql_charset='utf8' )
from migrate import ForeignKeyConstraint from migrate.changeset.constraint import UniqueConstraint from designate.openstack.common import timeutils from designate import utils from designate.sqlalchemy.types import UUID RECORD_TYPES = [ 'A', 'AAAA', 'CNAME', 'MX', 'SRV', 'TXT', 'SPF', 'NS', 'PTR', 'SSHFP' ] meta = MetaData() recordsets_table = Table('recordsets', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime(), default=timeutils.utcnow), Column('updated_at', DateTime(), onupdate=timeutils.utcnow), Column('version', Integer(), default=1, nullable=False), Column('tenant_id', String(36), default=None,
# 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 sqlalchemy import MetaData, Table, Column, String, Integer from oslo_config import cfg from designate.sqlalchemy.types import UUID CONF = cfg.CONF metadata = MetaData() domains = Table('domains', metadata, Column('id', Integer, primary_key=True, autoincrement=True), Column('designate_id', UUID(), nullable=False), Column('name', String(255), nullable=False, unique=True), Column('master', String(255), nullable=True), Column('last_check', Integer(), default=None, nullable=True), Column('type', String(6), nullable=False), Column('notified_serial', Integer(), default=None, nullable=True), Column('account', String(40), default=None, nullable=True), mysql_engine='InnoDB', mysql_charset='utf8')
from sqlalchemy import Integer, String, DateTime, Enum from sqlalchemy.schema import Table, Column, MetaData from oslo_utils import timeutils from designate import utils from designate.sqlalchemy.types import UUID meta = MetaData() TASK_STATUSES = ['ACTIVE', 'PENDING', 'DELETED', 'ERROR', 'COMPLETE'] TASK_TYPES = ['IMPORT'] zone_tasks_table = Table('zone_tasks', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('version', Integer(), default=1, nullable=False), Column('tenant_id', String(36), default=None, nullable=True), Column('domain_id', UUID(), nullable=True), Column('task_type', Enum(name='task_types', *TASK_TYPES), nullable=True), Column('message', String(160), nullable=True), Column('status', Enum(name='resource_statuses', *TASK_STATUSES), nullable=False, server_default='ACTIVE', default='ACTIVE'), mysql_engine='INNODB', mysql_charset='utf8')
from sqlalchemy import Enum, Integer, String, DateTime from sqlalchemy.schema import Table, Column, MetaData from designate.openstack.common import timeutils from designate import utils from designate.sqlalchemy.types import UUID meta = MetaData() TSIG_ALGORITHMS = [ 'hmac-md5', 'hmac-sha1', 'hmac-sha224', 'hmac-sha256', 'hmac-sha384', 'hmac-sha512' ] tsigkeys = Table( 'tsigkeys', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime(), default=timeutils.utcnow), Column('updated_at', DateTime(), onupdate=timeutils.utcnow), Column('version', Integer(), default=1, nullable=False), Column('name', String(255), nullable=False, unique=True), Column('algorithm', Enum(name='tsig_algorithms', *TSIG_ALGORITHMS), nullable=False), Column('secret', String(255), nullable=False)) def upgrade(migrate_engine): meta.bind = migrate_engine tsigkeys.create()
UniqueConstraint('name', 'deleted', 'pool_id', name='unique_domain_name'), ForeignKeyConstraint(['parent_domain_id'], ['domains.id'], ondelete='SET NULL'), Index('zone_deleted', 'deleted'), Index('zone_tenant_deleted', 'tenant_id', 'deleted'), Index('reverse_name_deleted', 'reverse_name', 'deleted'), Index('zone_created_at', 'created_at'), mysql_engine='InnoDB', mysql_charset='utf8', ) domain_attributes = Table('domain_attributes', metadata, Column('id', UUID(), primary_key=True), Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime), Column('updated_at', DateTime), Column('key', Enum(name='key', *ZONE_ATTRIBUTE_KEYS)), Column('value', String(255), nullable=False), Column('domain_id', UUID(), nullable=False), UniqueConstraint('key', 'value', 'domain_id', name='unique_attributes'), ForeignKeyConstraint(['domain_id'], ['domains.id'], ondelete='CASCADE'), mysql_engine='INNODB', mysql_charset='utf8' )
Column('key', String(50)), Column('value', String(255), nullable=False), Column('zone_id', UUID, nullable=False), UniqueConstraint('key', 'value', 'zone_id', name='unique_attributes'), ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'), mysql_engine='InnoDB', mysql_charset='utf8') zone_masters = Table('zone_masters', metadata, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('host', String(32), nullable=False), Column('port', Integer(), nullable=False), Column('zone_id', UUID(), nullable=False), UniqueConstraint('host', 'port', 'zone_id',
from oslo_log import log as logging from oslo_utils import timeutils from sqlalchemy.schema import MetaData, Table, Column, ForeignKeyConstraint from sqlalchemy import DateTime, Integer, String, select from designate import utils from designate.sqlalchemy.types import UUID LOG = logging.getLogger() meta = MetaData() zone_masters_table = Table('zone_masters', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('host', String(32), nullable=False), Column('port', Integer(), nullable=False), Column('zone_id', UUID(), nullable=False),
# 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 sqlalchemy import Integer, String, DateTime, Enum, ForeignKey from sqlalchemy.schema import Table, Column, MetaData from designate.sqlalchemy.types import UUID TASK_STATUSES = ['ACTIVE', 'PENDING', 'DELETED', 'ERROR', 'COMPLETE'] meta = MetaData() zone_transfer_requests = Table('zone_transfer_requests', meta, Column('id', UUID(), primary_key=True), Column('domain_id', UUID, ForeignKey('domains.id'), nullable=False), Column('key', String(255), nullable=False), Column('description', String(255), nullable=True), Column('tenant_id', String(36), nullable=False), Column('target_tenant_id', String(36), nullable=True), Column( 'status', Enum(name='resource_statuses',
from sqlalchemy import ForeignKey, Enum, Integer, String, DateTime, Text from sqlalchemy.schema import Column, MetaData from designate.openstack.common import timeutils from designate.openstack.common.uuidutils import generate_uuid from designate.storage.impl_sqlalchemy.migrate_repo.utils import Table from designate.storage.impl_sqlalchemy.migrate_repo.utils import create_tables from designate.storage.impl_sqlalchemy.migrate_repo.utils import drop_tables from designate.sqlalchemy.types import Inet from designate.sqlalchemy.types import UUID meta = MetaData() RECORD_TYPES = ['A', 'AAAA', 'CNAME', 'MX', 'SRV', 'TXT', 'NS'] servers = Table('servers', meta, Column('id', UUID(), default=generate_uuid, primary_key=True), Column('created_at', DateTime(), default=timeutils.utcnow), Column('updated_at', DateTime(), onupdate=timeutils.utcnow), Column('version', Integer(), default=1, nullable=False), Column('name', String(255), nullable=False, unique=True), Column('ipv4', Inet(), nullable=False, unique=True), Column('ipv6', Inet(), default=None, unique=True)) domains = Table('domains', meta, Column('id', UUID(), default=generate_uuid, primary_key=True), Column('created_at', DateTime(), default=timeutils.utcnow), Column('updated_at', DateTime(), onupdate=timeutils.utcnow), Column('version', Integer(), default=1, nullable=False), Column('tenant_id', String(36), default=None, nullable=True), Column('name', String(255), nullable=False, unique=True), Column('email', String(36), nullable=False),
from designate.sqlalchemy.types import UUID RESOURCE_STATUSES = ['ACTIVE', 'PENDING', 'DELETED'] RECORD_TYPES = [ 'A', 'AAAA', 'CNAME', 'MX', 'SRV', 'TXT', 'SPF', 'NS', 'PTR', 'SSHFP' ] TSIG_ALGORITHMS = [ 'hmac-md5', 'hmac-sha1', 'hmac-sha224', 'hmac-sha256', 'hmac-sha384', 'hmac-sha512' ] meta = MetaData() blacklists = Table('blacklists', meta, Column('id', UUID(), primary_key=True), Column('created_at', DateTime()), Column('updated_at', DateTime()), Column('version', Integer(), nullable=False), Column('pattern', String(255), nullable=False), Column('description', Unicode(160)), UniqueConstraint('pattern', name='pattern'), mysql_engine='INNODB', mysql_charset='utf8') domains = Table('domains', meta, Column('id', UUID(), primary_key=True), Column('created_at', DateTime()), Column('updated_at', DateTime()), Column('version', Integer(), nullable=False),
Column('key', String(50)), Column('value', String(255), nullable=False), Column('zone_id', UUID, nullable=False), UniqueConstraint('key', 'value', 'zone_id', name='unique_attributes'), ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'), mysql_engine='InnoDB', mysql_charset='utf8') zone_masters = Table('zone_masters', metadata, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('host', String(32), nullable=False), Column('port', Integer(), nullable=False), Column('zone_id', UUID(), nullable=False), UniqueConstraint('host', 'port', 'zone_id',
default='CREATE', server_default='CREATE', nullable=False), Column('pool_id', UUID, default=None, nullable=True), Column('reverse_name', String(255), nullable=False), UniqueConstraint('name', 'deleted', 'pool_id', name='unique_domain_name'), ForeignKeyConstraint(['parent_domain_id'], ['domains.id'], ondelete='SET NULL'), mysql_engine='InnoDB', mysql_charset='utf8', ) domain_attributes = Table('domain_attributes', metadata, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('key', Enum(name='key', *ZONE_ATTRIBUTE_KEYS)), Column('value', String(255), nullable=False),
from sqlalchemy import ForeignKey, Enum, Integer, String, DateTime, Text from sqlalchemy.schema import Column, MetaData from designate.openstack.common import timeutils from designate import utils from designate.storage.impl_sqlalchemy.migrate_repo.utils import Table from designate.storage.impl_sqlalchemy.migrate_repo.utils import create_tables from designate.storage.impl_sqlalchemy.migrate_repo.utils import drop_tables from designate.sqlalchemy.types import Inet from designate.sqlalchemy.types import UUID meta = MetaData() RECORD_TYPES = ['A', 'AAAA', 'CNAME', 'MX', 'SRV', 'TXT', 'NS'] servers = Table('servers', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime(), default=timeutils.utcnow), Column('updated_at', DateTime(), onupdate=timeutils.utcnow), Column('version', Integer(), default=1, nullable=False), Column('name', String(255), nullable=False, unique=True), Column('ipv4', Inet(), nullable=False, unique=True), Column('ipv6', Inet(), default=None, unique=True)) domains = Table('domains', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime(), default=timeutils.utcnow), Column('updated_at', DateTime(), onupdate=timeutils.utcnow), Column('version', Integer(), default=1, nullable=False), Column('tenant_id', String(36), default=None, nullable=True),
from sqlalchemy import Integer, String, DateTime, ForeignKeyConstraint from sqlalchemy.schema import Table, Column, MetaData from sqlalchemy.sql import select from oslo.config import cfg from designate import utils from designate.sqlalchemy.types import UUID meta = MetaData() # Get the default pool_id from the config file default_pool_id = cfg.CONF['service:central'].default_pool_id.replace('-', '') pool_ns_records_table = Table('pool_ns_records', meta, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('created_at', DateTime()), Column('updated_at', DateTime()), Column('version', Integer(), default=1, nullable=False), Column('pool_id', UUID(), nullable=False), Column('priority', Integer(), nullable=False), Column('hostname', String(255), nullable=False), ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'), mysql_engine='INNODB', mysql_charset='utf8') def upgrade(migrate_engine):