From 48bd75998a9e68d7dafdeab47fd6c70adb3113f6 Mon Sep 17 00:00:00 2001 From: Arata Notsu Date: Wed, 3 Apr 2013 19:32:34 +0900 Subject: [PATCH] baremetal: drop 'prov_mac_address' column bm_nodes.prov_mac_address is no longer used. So drop it. Change-Id: I3c7294da8f62581aba8c948171cb02f80cf054ef --- nova/tests/baremetal/db/utils.py | 1 - nova/tests/baremetal/test_pxe.py | 1 - nova/tests/baremetal/test_tilera.py | 1 - .../baremetal/test_virtual_power_driver.py | 5 +-- nova/tests/test_migrations.py | 5 +++ .../versions/007_drop_prov_mac_address.py | 36 +++++++++++++++++++ nova/virt/baremetal/db/sqlalchemy/models.py | 1 - 7 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 nova/virt/baremetal/db/sqlalchemy/migrate_repo/versions/007_drop_prov_mac_address.py diff --git a/nova/tests/baremetal/db/utils.py b/nova/tests/baremetal/db/utils.py index f50abd2e606c..c3b3cff5fa01 100644 --- a/nova/tests/baremetal/db/utils.py +++ b/nova/tests/baremetal/db/utils.py @@ -31,7 +31,6 @@ def new_bm_node(**kwargs): h.pm_address = kwargs.pop('pm_address', '192.168.1.1') h.pm_user = kwargs.pop('pm_user', 'ipmi_user') h.pm_password = kwargs.pop('pm_password', 'ipmi_password') - h.prov_mac_address = kwargs.pop('prov_mac_address', '12:34:56:78:90:ab') h.task_state = kwargs.pop('task_state', None) h.terminal_port = kwargs.pop('terminal_port', 8000) if len(kwargs) > 0: diff --git a/nova/tests/baremetal/test_pxe.py b/nova/tests/baremetal/test_pxe.py index 50fe16715659..994a8ee355f2 100644 --- a/nova/tests/baremetal/test_pxe.py +++ b/nova/tests/baremetal/test_pxe.py @@ -74,7 +74,6 @@ class BareMetalPXETestCase(bm_db_base.BMDBTestCase): service_host='test_host', cpus=4, memory_mb=2048, - prov_mac_address='11:11:11:11:11:11', ) self.nic_info = [ {'address': '22:22:22:22:22:22', 'datapath_id': '0x1', diff --git a/nova/tests/baremetal/test_tilera.py b/nova/tests/baremetal/test_tilera.py index f92e9b27096b..a30732a3d138 100755 --- a/nova/tests/baremetal/test_tilera.py +++ b/nova/tests/baremetal/test_tilera.py @@ -70,7 +70,6 @@ class BareMetalTileraTestCase(bm_db_base.BMDBTestCase): service_host='test_host', cpus=4, memory_mb=2048, - prov_mac_address='11:11:11:11:11:11', ) self.nic_info = [ {'address': '22:22:22:22:22:22', 'datapath_id': '0x1', diff --git a/nova/tests/baremetal/test_virtual_power_driver.py b/nova/tests/baremetal/test_virtual_power_driver.py index d6d61519424c..5f4b5f0cb028 100644 --- a/nova/tests/baremetal/test_virtual_power_driver.py +++ b/nova/tests/baremetal/test_virtual_power_driver.py @@ -71,7 +71,6 @@ class BareMetalVPDTestCase(bm_db_base.BMDBTestCase): service_host='test_host', cpus=2, memory_mb=2048, - prov_mac_address='aa:bb:cc:dd:ee:ff', ) self.nic_info = [ {'address': '11:11:11:11:11:11', 'datapath_id': '0x1', @@ -200,9 +199,7 @@ class VPDClassMethodsTestCase(BareMetalVPDTestCase): self.mox.StubOutWithMock(self.pm, '_run_command') cmd = self.pm._vp_cmd.get_node_macs.replace('{_NodeName_}', 'testNode') - # aa:bb:cc:dd:ee:ff is prov_mac_adress. Check it is not used to - # find the node. - self.pm._run_command(cmd).AndReturn(["aabbccddeeff", "ffeeddccbbaa"]) + self.pm._run_command(cmd).AndReturn(["ffeeddccbbaa"]) self.mox.ReplayAll() name = self.pm._check_for_node() diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index d7ef3da2fbd6..de5eb1b40edb 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -1425,3 +1425,8 @@ class TestBaremetalMigrations(BaseMigrationTestCase, CommonTestsMixIn): rows = ifs.select().where(ifs.c.bm_node_id == 2).execute().fetchall() self.assertEqual(len(rows), 0) + + def _check_007(self, engine, data): + bm_nodes = db_utils.get_table(engine, 'bm_nodes') + columns = [c.name for c in bm_nodes.columns] + self.assertNotIn(u'prov_mac_address', columns) diff --git a/nova/virt/baremetal/db/sqlalchemy/migrate_repo/versions/007_drop_prov_mac_address.py b/nova/virt/baremetal/db/sqlalchemy/migrate_repo/versions/007_drop_prov_mac_address.py new file mode 100644 index 000000000000..eb6ae756c14d --- /dev/null +++ b/nova/virt/baremetal/db/sqlalchemy/migrate_repo/versions/007_drop_prov_mac_address.py @@ -0,0 +1,36 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright (c) 2013 NTT DOCOMO, INC. +# +# 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. + +from sqlalchemy import Column, MetaData, String, Table + + +def upgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + nodes = Table('bm_nodes', meta, autoload=True) + nodes.drop_column('prov_mac_address') + + +def downgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + nodes = Table('bm_nodes', meta, autoload=True) + nodes.create_column(Column('prov_mac_address', String(length=255))) + + # NOTE(arata): The values held by prov_mac_address are lost in upgrade. + # So downgrade has no other choice but to set the column to NULL. diff --git a/nova/virt/baremetal/db/sqlalchemy/models.py b/nova/virt/baremetal/db/sqlalchemy/models.py index 61063f031103..dbc9386ecbb7 100644 --- a/nova/virt/baremetal/db/sqlalchemy/models.py +++ b/nova/virt/baremetal/db/sqlalchemy/models.py @@ -45,7 +45,6 @@ class BareMetalNode(BASE, models.NovaBase): pm_address = Column(Text) pm_user = Column(Text) pm_password = Column(Text) - prov_mac_address = Column(Text) task_state = Column(String(255)) terminal_port = Column(Integer) image_path = Column(String(255), nullable=True)