From fa200aaeddb563fa9503489d876aaed1ee5955a8 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Tue, 26 Jul 2016 11:39:30 -0400 Subject: [PATCH] Add storage_interface to node DB table Add storage_interface DB field, database migration, and object entry for storage_interface for boot from volume functionality. Initial versions of this revision added the field to the node object, but since then Ironic's code has drifted such that adding an object for an interface has to take place along with the entire driver interface, thus the object change is in the next revision. Co-Authored-By: Stephane Miller Change-Id: Ib5d5de87163570949c12d9e95c73e17c1c12eec1 Partial-Bug: #1559691 --- ...d68_add_storage_interface_db_field_and_.py | 32 +++++++++++++++++++ ironic/db/sqlalchemy/models.py | 1 + .../unit/db/sqlalchemy/test_migrations.py | 7 ++++ 3 files changed, 40 insertions(+) create mode 100644 ironic/db/sqlalchemy/alembic/versions/1d6951876d68_add_storage_interface_db_field_and_.py diff --git a/ironic/db/sqlalchemy/alembic/versions/1d6951876d68_add_storage_interface_db_field_and_.py b/ironic/db/sqlalchemy/alembic/versions/1d6951876d68_add_storage_interface_db_field_and_.py new file mode 100644 index 0000000000..91ff2c548d --- /dev/null +++ b/ironic/db/sqlalchemy/alembic/versions/1d6951876d68_add_storage_interface_db_field_and_.py @@ -0,0 +1,32 @@ +# 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 storage_interface DB field and object + +Revision ID: 1d6951876d68 +Revises: 493d8f27f235 +Create Date: 2016-07-26 10:33:22.830739 + +""" + +# revision identifiers, used by Alembic. +revision = '1d6951876d68' +down_revision = '493d8f27f235' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('nodes', sa.Column('storage_interface', + sa.String(255), + nullable=True)) diff --git a/ironic/db/sqlalchemy/models.py b/ironic/db/sqlalchemy/models.py index 644816dc46..208793d0c3 100644 --- a/ironic/db/sqlalchemy/models.py +++ b/ironic/db/sqlalchemy/models.py @@ -151,6 +151,7 @@ class Node(Base): management_interface = Column(String(255), nullable=True) network_interface = Column(String(255), nullable=True) raid_interface = Column(String(255), nullable=True) + storage_interface = Column(String(255), nullable=True) power_interface = Column(String(255), nullable=True) vendor_interface = Column(String(255), nullable=True) diff --git a/ironic/tests/unit/db/sqlalchemy/test_migrations.py b/ironic/tests/unit/db/sqlalchemy/test_migrations.py index 27ae2dca33..1db1786653 100644 --- a/ironic/tests/unit/db/sqlalchemy/test_migrations.py +++ b/ironic/tests/unit/db/sqlalchemy/test_migrations.py @@ -623,6 +623,13 @@ class MigrationCheckersMixin(object): for row in result: self.assertEqual(CONF.default_portgroup_mode, row['mode']) + def _check_1d6951876d68(self, engine, data): + nodes = db_utils.get_table(engine, 'nodes') + col_names = [column.name for column in nodes.c] + self.assertIn('storage_interface', col_names) + self.assertIsInstance(nodes.c.storage_interface.type, + sqlalchemy.types.String) + def test_upgrade_and_version(self): with patch_with_engine(self.engine): self.migration_api.upgrade('head')