sqlalchemy: Import String from sqlalchemy directly

With dropping of MySQL NDB cluster support in oslo.db the String
subclass that implemented specific options is gone [1]

[1]: Ia8b4ed8cd755d283bb773e55293457190b34c482

Change-Id: I4ae0943a9cfdf6ed96bcd9ca54d98d008f6a5573
This commit is contained in:
Michal Nasiadka 2023-09-26 22:08:05 +02:00
parent ce3003a4ab
commit d18aa8ffa2
19 changed files with 64 additions and 111 deletions

View File

@ -24,13 +24,11 @@ down_revision = '57fbdf2327a2'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('baymodel', sa.Column('volume_driver', op.add_column('baymodel', sa.Column('volume_driver',
String(255, mysql_ndb_type=TINYTEXT), nullable=True)) String(255), nullable=True))

View File

@ -25,12 +25,10 @@ down_revision = None
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
# commands auto generated by Alembic - please adjust! # commands auto generated by Alembic - please adjust!
@ -61,8 +59,7 @@ def upgrade():
sa.Column('keypair_id', sa.String(length=255), nullable=True), sa.Column('keypair_id', sa.String(length=255), nullable=True),
sa.Column('image_id', sa.String(length=255), nullable=True), sa.Column('image_id', sa.String(length=255), nullable=True),
sa.Column('external_network_id', sa.String(length=255), nullable=True), sa.Column('external_network_id', sa.String(length=255), nullable=True),
sa.Column('dns_nameserver', String(255, mysql_ndb_type=TINYTEXT), sa.Column('dns_nameserver', String(255), nullable=True),
nullable=True),
sa.Column('apiserver_port', sa.Integer(), nullable=True), sa.Column('apiserver_port', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'), sa.PrimaryKeyConstraint('id'),
mysql_ENGINE='InnoDB', mysql_ENGINE='InnoDB',

View File

@ -25,14 +25,11 @@ down_revision = '3a938526b35d'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('baymodel', sa.Column('fixed_network', op.add_column('baymodel', sa.Column('fixed_network',
String(255, mysql_ndb_type=TINYTEXT), String(255), nullable=True))
nullable=True))

View File

@ -27,13 +27,11 @@ down_revision = '4e263f236334'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('baymodel', sa.Column('network_driver', op.add_column('baymodel', sa.Column('network_driver',
String(255, mysql_ndb_type=TINYTEXT), nullable=True)) String(255), nullable=True))

View File

@ -29,9 +29,9 @@ from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402
from oslo_serialization import jsonutils # noqa: E402 from oslo_serialization import jsonutils # noqa: E402
from oslo_utils import uuidutils # noqa: E402 from oslo_utils import uuidutils # noqa: E402
from sqlalchemy.types import String # noqa: E402
from magnum.db.sqlalchemy import models # noqa: E402 from magnum.db.sqlalchemy import models # noqa: E402

View File

@ -23,18 +23,15 @@ revision = '47380964133d'
down_revision = '461d798132c7' down_revision = '461d798132c7'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402 from sqlalchemy.types import String # noqa: E402
def upgrade(): def upgrade():
op.add_column('cluster', sa.Column('fixed_network', op.add_column('cluster', sa.Column('fixed_network',
String(255, mysql_ndb_type=TINYTEXT), String(255), nullable=True))
nullable=True))
op.add_column('cluster', sa.Column('fixed_subnet', op.add_column('cluster', sa.Column('fixed_subnet',
String(255, mysql_ndb_type=TINYTEXT), String(255), nullable=True))
nullable=True))
op.add_column('cluster', sa.Column('floating_ip_enabled', op.add_column('cluster', sa.Column('floating_ip_enabled',
sa.Boolean(create_constraint=False), sa.Boolean(create_constraint=False),
default=False)) default=False))

View File

@ -24,13 +24,11 @@ down_revision = '2d8657c0cdc'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('baymodel', sa.Column('cluster_distro', op.add_column('baymodel', sa.Column('cluster_distro',
String(255, mysql_ndb_type=TINYTEXT), nullable=True)) String(255), nullable=True))

View File

@ -23,15 +23,12 @@ down_revision = '456126c6c9e9'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('bay', op.add_column('bay',
sa.Column('discovery_url', sa.Column('discovery_url',
String(255, mysql_ndb_type=TINYTEXT), String(255), nullable=True))
nullable=True))

View File

@ -23,21 +23,17 @@ down_revision = '6f21dc920bb'
from alembic import op # noqa: E402 # noqa: E402 from alembic import op # noqa: E402 # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TEXT # noqa: E402
def upgrade(): def upgrade():
op.alter_column('bay', 'ca_cert_uuid', op.alter_column('bay', 'ca_cert_uuid',
new_column_name='ca_cert_ref', new_column_name='ca_cert_ref',
existing_type=sa.String(length=36), existing_type=sa.String(length=36),
type_=String(512, mysql_ndb_type=TEXT), type_=String(512), nullable=True)
nullable=True)
op.alter_column('bay', 'magnum_cert_uuid', op.alter_column('bay', 'magnum_cert_uuid',
new_column_name='magnum_cert_ref', new_column_name='magnum_cert_ref',
existing_type=sa.String(length=36), existing_type=sa.String(length=36),
type_=String(512, mysql_ndb_type=TEXT), type_=String(512), nullable=True)
nullable=True)

View File

@ -24,24 +24,20 @@ down_revision = '4956f03cabad'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import magnum.conf # noqa: E402 import magnum.conf # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
CONF = magnum.conf.CONF CONF = magnum.conf.CONF
def upgrade(): def upgrade():
op.add_column('baymodel', sa.Column('coe', String(255, op.add_column('baymodel', sa.Column('coe', String(255),
mysql_ndb_type=TINYTEXT),
nullable=True)) nullable=True))
baymodel = sa.sql.table('baymodel', baymodel = sa.sql.table('baymodel',
sa.sql.column('coe', String(255, sa.sql.column('coe', String(255)))
mysql_ndb_type=TINYTEXT)))
op.execute( op.execute(
baymodel.update().values({ baymodel.update().values({

View File

@ -27,22 +27,18 @@ down_revision = 'bb42b7cad130'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.alter_column('bay', 'registry_trust_id', op.alter_column('bay', 'registry_trust_id',
new_column_name='trust_id', new_column_name='trust_id',
existing_type=sa.String(255)) existing_type=sa.String(255))
op.add_column('bay', sa.Column('trustee_username', op.add_column('bay', sa.Column('trustee_username',
String(255, mysql_ndb_type=TINYTEXT), String(255), nullable=True))
nullable=True))
op.add_column('bay', sa.Column('trustee_user_id', op.add_column('bay', sa.Column('trustee_user_id',
sa.String(length=255), nullable=True)) sa.String(length=255), nullable=True))
op.add_column('bay', sa.Column('trustee_password', op.add_column('bay', sa.Column('trustee_password',
String(255, mysql_ndb_type=TINYTEXT), String(255), nullable=True))
nullable=True))

View File

@ -26,17 +26,15 @@ down_revision = 'f1d8b0ab8b8d'
from alembic import op # noqa: E402 # noqa: E402 from alembic import op # noqa: E402 # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('cluster', sa.Column('etcd_ca_cert_ref', op.add_column('cluster', sa.Column('etcd_ca_cert_ref',
String(512, mysql_ndb_type=TEXT), String(512),
nullable=True)) nullable=True))
op.add_column('cluster', sa.Column('front_proxy_ca_cert_ref', op.add_column('cluster', sa.Column('front_proxy_ca_cert_ref',
String(512, mysql_ndb_type=TEXT), String(512),
nullable=True)) nullable=True))

View File

@ -23,20 +23,18 @@ down_revision = '6f21dc998bb'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 # noqa: E402 import sqlalchemy as sa # noqa: E402 # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('baymodel', sa.Column('http_proxy', op.add_column('baymodel', sa.Column('http_proxy',
String(255, mysql_ndb_type=TINYTEXT), String(255),
nullable=True)) nullable=True))
op.add_column('baymodel', sa.Column('https_proxy', op.add_column('baymodel', sa.Column('https_proxy',
String(255, mysql_ndb_type=TINYTEXT), String(255),
nullable=True)) nullable=True))
op.add_column('baymodel', sa.Column('no_proxy', op.add_column('baymodel', sa.Column('no_proxy',
String(255, mysql_ndb_type=TINYTEXT), String(255),
nullable=True)) nullable=True))

View File

@ -29,7 +29,7 @@ from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
from magnum.db.sqlalchemy import models # noqa: E402 from magnum.db.sqlalchemy import models # noqa: E402

View File

@ -29,7 +29,7 @@ from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
def upgrade(): def upgrade():

View File

@ -23,14 +23,11 @@ down_revision = '68ce16dfd341'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('baymodel', sa.Column('fixed_subnet', op.add_column('baymodel', sa.Column('fixed_subnet',
String(255, mysql_ndb_type=TINYTEXT), String(255), nullable=True))
nullable=True))

View File

@ -23,14 +23,11 @@ down_revision = '049f81f6f584'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('baymodel', sa.Column('insecure_registry', op.add_column('baymodel', sa.Column('insecure_registry',
String(255, mysql_ndb_type=TINYTEXT), String(255), nullable=True))
nullable=True))

View File

@ -23,19 +23,15 @@ down_revision = 'b1f612248cab'
from alembic import op # noqa: E402 from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402 from sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402 import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade(): def upgrade():
op.add_column('bay', op.add_column('bay',
sa.Column('coe_version', String(255, sa.Column('coe_version', String(255),
mysql_ndb_type=TINYTEXT),
nullable=True)) nullable=True))
op.add_column('bay', op.add_column('bay',
sa.Column('container_version', String(255, sa.Column('container_version', String(255),
mysql_ndb_type=TINYTEXT),
nullable=True)) nullable=True))

View File

@ -17,7 +17,6 @@ SQLAlchemy models for container service
""" """
from oslo_db.sqlalchemy import models from oslo_db.sqlalchemy import models
from oslo_db.sqlalchemy.types import String
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
from sqlalchemy import Boolean from sqlalchemy import Boolean
@ -27,9 +26,7 @@ from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Integer from sqlalchemy import Integer
from sqlalchemy import schema from sqlalchemy import schema
from sqlalchemy import Text from sqlalchemy import Text
from sqlalchemy.types import TypeDecorator, TEXT from sqlalchemy.types import TypeDecorator, TEXT, String
from sqlalchemy.dialects.mysql import TEXT as mysql_TEXT
from sqlalchemy.dialects.mysql import TINYTEXT
import magnum.conf import magnum.conf
@ -128,27 +125,27 @@ class Cluster(Base):
health_status = Column(String(20)) health_status = Column(String(20))
health_status_reason = Column(JSONEncodedDict) health_status_reason = Column(JSONEncodedDict)
create_timeout = Column(Integer()) create_timeout = Column(Integer())
discovery_url = Column(String(255, mysql_ndb_type=TINYTEXT)) discovery_url = Column(String(255))
# TODO(wanghua): encrypt trust_id in db # TODO(wanghua): encrypt trust_id in db
trust_id = Column(String(255)) trust_id = Column(String(255))
trustee_username = Column(String(255, mysql_ndb_type=TINYTEXT)) trustee_username = Column(String(255))
trustee_user_id = Column(String(255)) trustee_user_id = Column(String(255))
# TODO(wanghua): encrypt trustee_password in db # TODO(wanghua): encrypt trustee_password in db
trustee_password = Column(String(255, mysql_ndb_type=TINYTEXT)) trustee_password = Column(String(255))
coe_version = Column(String(255, mysql_ndb_type=TINYTEXT)) coe_version = Column(String(255))
container_version = Column(String(255, mysql_ndb_type=TINYTEXT)) container_version = Column(String(255))
# (yuanying) if we use barbican, # (yuanying) if we use barbican,
# cert_ref size is determined by below format # cert_ref size is determined by below format
# * http(s)://${DOMAIN_NAME}/v1/containers/${UUID} # * http(s)://${DOMAIN_NAME}/v1/containers/${UUID}
# as a result, cert_ref length is estimated to 312 chars. # as a result, cert_ref length is estimated to 312 chars.
# but we can use another backend to store certs. # but we can use another backend to store certs.
# so, we use 512 chars to get some buffer. # so, we use 512 chars to get some buffer.
ca_cert_ref = Column(String(512, mysql_ndb_type=mysql_TEXT)) ca_cert_ref = Column(String(512))
magnum_cert_ref = Column(String(512, mysql_ndb_type=mysql_TEXT)) magnum_cert_ref = Column(String(512))
etcd_ca_cert_ref = Column(String(512, mysql_ndb_type=mysql_TEXT)) etcd_ca_cert_ref = Column(String(512))
front_proxy_ca_cert_ref = Column(String(512, mysql_ndb_type=mysql_TEXT)) front_proxy_ca_cert_ref = Column(String(512))
fixed_network = Column(String(255, mysql_ndb_type=TINYTEXT)) fixed_network = Column(String(255))
fixed_subnet = Column(String(255, mysql_ndb_type=TINYTEXT)) fixed_subnet = Column(String(255))
floating_ip_enabled = Column(Boolean, default=True) floating_ip_enabled = Column(Boolean, default=True)
master_lb_enabled = Column(Boolean, default=False) master_lb_enabled = Column(Boolean, default=False)
@ -171,25 +168,25 @@ class ClusterTemplate(Base):
master_flavor_id = Column(String(255)) master_flavor_id = Column(String(255))
keypair_id = Column(String(255)) keypair_id = Column(String(255))
external_network_id = Column(String(255)) external_network_id = Column(String(255))
fixed_network = Column(String(255, mysql_ndb_type=TINYTEXT)) fixed_network = Column(String(255))
fixed_subnet = Column(String(255, mysql_ndb_type=TINYTEXT)) fixed_subnet = Column(String(255))
network_driver = Column(String(255, mysql_ndb_type=TINYTEXT)) network_driver = Column(String(255))
volume_driver = Column(String(255, mysql_ndb_type=TINYTEXT)) volume_driver = Column(String(255))
dns_nameserver = Column(String(255, mysql_ndb_type=TINYTEXT)) dns_nameserver = Column(String(255))
apiserver_port = Column(Integer()) apiserver_port = Column(Integer())
docker_volume_size = Column(Integer()) docker_volume_size = Column(Integer())
docker_storage_driver = Column(String(255)) docker_storage_driver = Column(String(255))
cluster_distro = Column(String(255, mysql_ndb_type=TINYTEXT)) cluster_distro = Column(String(255))
coe = Column(String(255, mysql_ndb_type=TINYTEXT)) coe = Column(String(255))
http_proxy = Column(String(255, mysql_ndb_type=TINYTEXT)) http_proxy = Column(String(255))
https_proxy = Column(String(255, mysql_ndb_type=TINYTEXT)) https_proxy = Column(String(255))
no_proxy = Column(String(255, mysql_ndb_type=TINYTEXT)) no_proxy = Column(String(255))
registry_enabled = Column(Boolean, default=False) registry_enabled = Column(Boolean, default=False)
labels = Column(JSONEncodedDict) labels = Column(JSONEncodedDict)
tls_disabled = Column(Boolean, default=False) tls_disabled = Column(Boolean, default=False)
public = Column(Boolean, default=False) public = Column(Boolean, default=False)
server_type = Column(String(255)) server_type = Column(String(255))
insecure_registry = Column(String(255, mysql_ndb_type=TINYTEXT)) insecure_registry = Column(String(255))
master_lb_enabled = Column(Boolean, default=False) master_lb_enabled = Column(Boolean, default=False)
floating_ip_enabled = Column(Boolean, default=True) floating_ip_enabled = Column(Boolean, default=True)
hidden = Column(Boolean, default=False) hidden = Column(Boolean, default=False)