baremetal: Drop unused columns in bm_nodes
Drop these two columns: * bm_nodes.prov_vlan_id * bm_nodes.registration_status And update related code, tests and api_samples. Change-Id: Iadefc83a00ad9ae5a3bb39f357080299875bdf09
This commit is contained in:
		@@ -8,7 +8,6 @@
 | 
			
		||||
        "pm_user": "pm_user",
 | 
			
		||||
        "pm_password": "pm_pass",
 | 
			
		||||
        "prov_mac_address": "12:34:56:78:90:ab",
 | 
			
		||||
        "prov_vlan_id": 1234,
 | 
			
		||||
        "terminal_port": 8000
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -7,6 +7,5 @@
 | 
			
		||||
    pm_address="10.1.2.3"
 | 
			
		||||
    pm_user="pm_user"
 | 
			
		||||
    prov_mac_address="12:34:56:78:90:ab"
 | 
			
		||||
    prov_vlan_id="1234"
 | 
			
		||||
    terminal_port="8000"
 | 
			
		||||
/>
 | 
			
		||||
@@ -9,7 +9,6 @@
 | 
			
		||||
        "pm_address": "10.1.2.3",
 | 
			
		||||
        "pm_user": "pm_user",
 | 
			
		||||
        "prov_mac_address": "12:34:56:78:90:ab",
 | 
			
		||||
        "prov_vlan_id": 1234,
 | 
			
		||||
        "service_host": "host",
 | 
			
		||||
        "terminal_port": 8000
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,6 @@
 | 
			
		||||
  instance_uuid="None"
 | 
			
		||||
  pm_address="10.1.2.3"
 | 
			
		||||
  cpus="8"
 | 
			
		||||
  prov_vlan_id="1234"
 | 
			
		||||
  memory_mb="8192"
 | 
			
		||||
  prov_mac_address="12:34:56:78:90:ab"
 | 
			
		||||
  service_host="host"
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,6 @@
 | 
			
		||||
            "pm_address": "10.1.2.3",
 | 
			
		||||
            "pm_user": "pm_user",
 | 
			
		||||
            "prov_mac_address": "12:34:56:78:90:ab",
 | 
			
		||||
            "prov_vlan_id": 1234,
 | 
			
		||||
            "service_host": "host",
 | 
			
		||||
            "terminal_port": 8000
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@
 | 
			
		||||
    instance_uuid="None"
 | 
			
		||||
    pm_address="10.1.2.3"
 | 
			
		||||
    cpus="8"
 | 
			
		||||
    prov_vlan_id="1234"
 | 
			
		||||
    memory_mb="8192"
 | 
			
		||||
    prov_mac_address="12:34:56:78:90:ab"
 | 
			
		||||
    service_host="host"
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,6 @@
 | 
			
		||||
        "pm_address": "10.1.2.3",
 | 
			
		||||
        "pm_user": "pm_user",
 | 
			
		||||
        "prov_mac_address": "12:34:56:78:90:ab",
 | 
			
		||||
        "prov_vlan_id": 1234,
 | 
			
		||||
        "service_host": "host",
 | 
			
		||||
        "terminal_port": 8000
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,6 @@
 | 
			
		||||
  instance_uuid="None"
 | 
			
		||||
  pm_address="10.1.2.3"
 | 
			
		||||
  cpus="8"
 | 
			
		||||
  prov_vlan_id="1234"
 | 
			
		||||
  memory_mb="8192"
 | 
			
		||||
  prov_mac_address="12:34:56:78:90:ab"
 | 
			
		||||
  service_host="host"
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
 | 
			
		||||
authorize = extensions.extension_authorizer('compute', 'baremetal_nodes')
 | 
			
		||||
 | 
			
		||||
node_fields = ['id', 'cpus', 'local_gb', 'memory_mb', 'pm_address',
 | 
			
		||||
               'pm_user', 'prov_mac_address', 'prov_vlan_id',
 | 
			
		||||
               'pm_user', 'prov_mac_address',
 | 
			
		||||
               'service_host', 'terminal_port', 'instance_uuid',
 | 
			
		||||
               ]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,6 @@ class BareMetalNodesTest(test.TestCase):
 | 
			
		||||
            'pm_user': "pm_user",
 | 
			
		||||
            'pm_password': "pm_pass",
 | 
			
		||||
            'prov_mac_address': "12:34:56:78:90:ab",
 | 
			
		||||
            'prov_vlan_id': 1234,
 | 
			
		||||
            'terminal_port': 8000,
 | 
			
		||||
            'interfaces': [],
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -32,9 +32,7 @@ def new_bm_node(**kwargs):
 | 
			
		||||
    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.registration_status = kwargs.pop('registration_status', 'done')
 | 
			
		||||
    h.task_state = kwargs.pop('task_state', None)
 | 
			
		||||
    h.prov_vlan_id = kwargs.pop('prov_vlan_id', None)
 | 
			
		||||
    h.terminal_port = kwargs.pop('terminal_port', 8000)
 | 
			
		||||
    if len(kwargs) > 0:
 | 
			
		||||
        raise test.TestingException("unknown field: %s"
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,6 @@
 | 
			
		||||
        "pm_user": "pm_user",
 | 
			
		||||
        "pm_password": "pm_pass",
 | 
			
		||||
        "prov_mac_address": "12:34:56:78:90:ab",
 | 
			
		||||
        "prov_vlan_id": 1234,
 | 
			
		||||
        "terminal_port": 8000
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,5 @@
 | 
			
		||||
    pm_address="10.1.2.3"
 | 
			
		||||
    pm_user="pm_user"
 | 
			
		||||
    prov_mac_address="12:34:56:78:90:ab"
 | 
			
		||||
    prov_vlan_id="1234"
 | 
			
		||||
    terminal_port="8000"
 | 
			
		||||
/>
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@
 | 
			
		||||
        "pm_address": "10.1.2.3",
 | 
			
		||||
        "pm_user": "pm_user",
 | 
			
		||||
        "prov_mac_address": "12:34:56:78:90:ab",
 | 
			
		||||
        "prov_vlan_id": 1234,
 | 
			
		||||
        "terminal_port": 8000,
 | 
			
		||||
        "instance_uuid": null,
 | 
			
		||||
        "id": %(node_id)s,
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@
 | 
			
		||||
    pm_address="10.1.2.3"
 | 
			
		||||
    pm_user="pm_user"
 | 
			
		||||
    prov_mac_address="12:34:56:78:90:ab"
 | 
			
		||||
    prov_vlan_id="1234"
 | 
			
		||||
    terminal_port="8000"
 | 
			
		||||
    instance_uuid="None"
 | 
			
		||||
    id="%(node_id)s">
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@
 | 
			
		||||
        "pm_address": "10.1.2.3",
 | 
			
		||||
        "pm_user": "pm_user",
 | 
			
		||||
        "prov_mac_address": "12:34:56:78:90:ab",
 | 
			
		||||
        "prov_vlan_id": 1234,
 | 
			
		||||
        "terminal_port": 8000,
 | 
			
		||||
        "instance_uuid": null,
 | 
			
		||||
        "id": %(node_id)s,
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,6 @@
 | 
			
		||||
    pm_address="10.1.2.3"
 | 
			
		||||
    pm_user="pm_user"
 | 
			
		||||
    prov_mac_address="12:34:56:78:90:ab"
 | 
			
		||||
    prov_vlan_id="1234"
 | 
			
		||||
    terminal_port="8000"
 | 
			
		||||
    instance_uuid="None"
 | 
			
		||||
    id="%(node_id)s">
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@
 | 
			
		||||
        "pm_address": "10.1.2.3",
 | 
			
		||||
        "pm_user": "pm_user",
 | 
			
		||||
        "prov_mac_address": "12:34:56:78:90:ab",
 | 
			
		||||
        "prov_vlan_id": 1234,
 | 
			
		||||
        "terminal_port": 8000,
 | 
			
		||||
        "instance_uuid": null,
 | 
			
		||||
        "id": %(node_id)s,
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@
 | 
			
		||||
    pm_address="10.1.2.3"
 | 
			
		||||
    pm_user="pm_user"
 | 
			
		||||
    prov_mac_address="12:34:56:78:90:ab"
 | 
			
		||||
    prov_vlan_id="1234"
 | 
			
		||||
    terminal_port="8000"
 | 
			
		||||
    instance_uuid="None"
 | 
			
		||||
    id="%(node_id)s">
 | 
			
		||||
 
 | 
			
		||||
@@ -1238,3 +1238,9 @@ class TestBaremetalMigrations(BaseMigrationTestCase, CommonTestsMixIn):
 | 
			
		||||
    def _post_downgrade_004(self, engine):
 | 
			
		||||
        bm_nodes = get_table(engine, 'bm_nodes')
 | 
			
		||||
        self.assertNotIn(u'instance_name', [c.name for c in bm_nodes.columns])
 | 
			
		||||
 | 
			
		||||
    def _check_005(self, engine, data):
 | 
			
		||||
        bm_nodes = get_table(engine, 'bm_nodes')
 | 
			
		||||
        columns = [c.name for c in bm_nodes.columns]
 | 
			
		||||
        self.assertNotIn(u'prov_vlan_id', columns)
 | 
			
		||||
        self.assertNotIn(u'registration_status', columns)
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,35 @@
 | 
			
		||||
# 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, String, Integer, MetaData, Table
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def upgrade(migrate_engine):
 | 
			
		||||
    meta = MetaData()
 | 
			
		||||
    meta.bind = migrate_engine
 | 
			
		||||
 | 
			
		||||
    nodes = Table('bm_nodes', meta, autoload=True)
 | 
			
		||||
    nodes.drop_column('prov_vlan_id')
 | 
			
		||||
    nodes.drop_column('registration_status')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def downgrade(migrate_engine):
 | 
			
		||||
    meta = MetaData()
 | 
			
		||||
    meta.bind = migrate_engine
 | 
			
		||||
 | 
			
		||||
    nodes = Table('bm_nodes', meta, autoload=True)
 | 
			
		||||
    nodes.create_column(Column('prov_vlan_id', Integer))
 | 
			
		||||
    nodes.create_column(Column('registration_status', String(length=16)))
 | 
			
		||||
@@ -46,9 +46,7 @@ class BareMetalNode(BASE, models.NovaBase):
 | 
			
		||||
    pm_user = Column(Text)
 | 
			
		||||
    pm_password = Column(Text)
 | 
			
		||||
    prov_mac_address = Column(Text)
 | 
			
		||||
    registration_status = Column(String(16))
 | 
			
		||||
    task_state = Column(String(255))
 | 
			
		||||
    prov_vlan_id = Column(Integer)
 | 
			
		||||
    terminal_port = Column(Integer)
 | 
			
		||||
    image_path = Column(String(255), nullable=True)
 | 
			
		||||
    pxe_config_path = Column(String(255), nullable=True)
 | 
			
		||||
 
 | 
			
		||||
@@ -387,7 +387,7 @@ class BareMetalDriver(driver.ComputeDriver):
 | 
			
		||||
        vcpus = node['cpus']
 | 
			
		||||
        memory_mb = node['memory_mb']
 | 
			
		||||
        local_gb = node['local_gb']
 | 
			
		||||
        if node['registration_status'] != 'done' or node['instance_uuid']:
 | 
			
		||||
        if node['instance_uuid']:
 | 
			
		||||
            vcpus_used = node['cpus']
 | 
			
		||||
            memory_mb_used = node['memory_mb']
 | 
			
		||||
            local_gb_used = node['local_gb']
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user