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')