diff options
author | Lee Yarwood <lyarwood@redhat.com> | 2020-10-22 15:02:35 +0100 |
---|---|---|
committer | melanie witt <melwittt@gmail.com> | 2022-08-02 21:25:47 +0000 |
commit | cdea73bd9cc811b2d267dd937cf3289dc1a39a15 (patch) | |
tree | ff10c47381f9612599fa7027a8596304cd899f6c /nova/db | |
parent | 065b32483515fd6845dbdbb73202c2dd599933ae (diff) | |
download | nova-cdea73bd9cc811b2d267dd937cf3289dc1a39a15.tar.gz |
BlockDeviceMapping: Add encryption fields
This change adds the `encrypted`, `encryption_secret_uuid`,
`encryption_format` and `encryption_options` to the BlockDeviceMapping
object and associated table in the database.
Change-Id: I6178c9bc249ef4d448de375dc16d82b2d087fc90
Diffstat (limited to 'nova/db')
-rw-r--r-- | nova/db/main/migrations/versions/ccb0fa1a2252_add_encryption_fields_to_.py | 59 | ||||
-rw-r--r-- | nova/db/main/models.py | 12 |
2 files changed, 68 insertions, 3 deletions
diff --git a/nova/db/main/migrations/versions/ccb0fa1a2252_add_encryption_fields_to_.py b/nova/db/main/migrations/versions/ccb0fa1a2252_add_encryption_fields_to_.py new file mode 100644 index 0000000000..1fd3fb4780 --- /dev/null +++ b/nova/db/main/migrations/versions/ccb0fa1a2252_add_encryption_fields_to_.py @@ -0,0 +1,59 @@ +# 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. + +"""Add encryption fields to BlockDeviceMapping + +Revision ID: ccb0fa1a2252 +Revises: 16f1fbcab42b +Create Date: 2022-01-12 15:22:47.524285 +""" + +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = 'ccb0fa1a2252' +down_revision = '16f1fbcab42b' +branch_labels = None +depends_on = None + + +def upgrade(): + for prefix in ('', 'shadow_'): + table_name = prefix + 'block_device_mapping' + with op.batch_alter_table(table_name, schema=None) as batch_op: + batch_op.add_column( + sa.Column( + 'encrypted', + sa.Boolean(), + nullable=True, + ) + ) + batch_op.add_column( + sa.Column( + 'encryption_secret_uuid', + sa.String(length=36), + nullable=True, + ) + ) + batch_op.add_column( + sa.Column('encryption_format', + sa.String(length=128), + nullable=True, + ) + ) + batch_op.add_column( + sa.Column('encryption_options', + sa.String(length=4096), + nullable=True, + ) + ) diff --git a/nova/db/main/models.py b/nova/db/main/models.py index f2f58b2db1..7551584c1c 100644 --- a/nova/db/main/models.py +++ b/nova/db/main/models.py @@ -654,9 +654,15 @@ class BlockDeviceMapping(BASE, NovaBase, models.SoftDeleteMixin): attachment_id = sa.Column(sa.String(36)) + encrypted = sa.Column(sa.Boolean, default=False) + encryption_secret_uuid = sa.Column(sa.String(36)) + encryption_format = sa.Column(sa.String(128)) + encryption_options = sa.Column(sa.String(4096)) # TODO(stephenfin): Remove once we drop the security_groups field from the # Instance table. Until then, this is tied to the SecurityGroup table + + class SecurityGroupInstanceAssociation(BASE, NovaBase, models.SoftDeleteMixin): __tablename__ = 'security_group_instance_association' __table_args__ = ( @@ -679,7 +685,7 @@ class SecurityGroup(BASE, NovaBase, models.SoftDeleteMixin): name='uniq_security_groups0project_id0' 'name0deleted'), ) - id = sa.Column(sa.Integer, primary_key=True) + id = sa.Column(sa.Integer, primary_key = True) name = sa.Column(sa.String(255)) description = sa.Column(sa.String(255)) @@ -687,8 +693,8 @@ class SecurityGroup(BASE, NovaBase, models.SoftDeleteMixin): project_id = sa.Column(sa.String(255)) instances = orm.relationship(Instance, - secondary="security_group_instance_association", - primaryjoin='and_(' + secondary = "security_group_instance_association", + primaryjoin = 'and_(' 'SecurityGroup.id == ' 'SecurityGroupInstanceAssociation.security_group_id,' 'SecurityGroupInstanceAssociation.deleted == 0,' |