Merge "Add network_interface node field to DB and object"

This commit is contained in:
Jenkins 2016-07-01 04:06:30 +00:00 committed by Gerrit Code Review
commit ff692c5eb2
7 changed files with 49 additions and 2 deletions

View File

@ -0,0 +1,31 @@
# 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-node-network-interface
Revision ID: e294876e8028
Revises: f6fdb920c182
Create Date: 2016-03-02 14:30:54.402864
"""
# revision identifiers, used by Alembic.
revision = 'e294876e8028'
down_revision = 'f6fdb920c182'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('nodes', sa.Column('network_interface', sa.String(255),
nullable=True))

View File

@ -143,6 +143,8 @@ class Node(Base):
inspection_started_at = Column(DateTime, nullable=True)
extra = Column(db_types.JsonEncodedDict)
network_interface = Column(String(255), nullable=True)
class Port(Base):
"""Represents a network port of a bare metal node."""

View File

@ -46,7 +46,8 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
# Version 1.14: Add _validate_property_values() and make create()
# and save() validate the input of property values.
# Version 1.15: Add get_by_port_addresses
VERSION = '1.15'
# Version 1.16: Add network_interface field
VERSION = '1.16'
dbapi = db_api.get_instance()
@ -102,6 +103,8 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
'inspection_started_at': object_fields.DateTimeField(nullable=True),
'extra': object_fields.FlexibleDictField(nullable=True),
'network_interface': object_fields.StringField(nullable=True),
}
def _validate_property_values(self, properties):

View File

@ -94,6 +94,9 @@ def node_post_data(**kw):
node.pop('conductor_affinity')
node.pop('chassis_id')
node.pop('tags')
# TODO(vdrok): Remove popping network_interface when it's exposed in API
if 'network_interface' not in kw:
node.pop('network_interface')
internal = node_controller.NodePatchType.internal_attrs()
return remove_internal(node, internal)

View File

@ -414,6 +414,13 @@ class MigrationCheckersMixin(object):
if _was_inserted(row['uuid']):
self.assertTrue(row['pxe_enabled'])
def _check_e294876e8028(self, engine, data):
nodes = db_utils.get_table(engine, 'nodes')
col_names = [column.name for column in nodes.c]
self.assertIn('network_interface', col_names)
self.assertIsInstance(nodes.c.network_interface.type,
sqlalchemy.types.String)
def test_upgrade_and_version(self):
with patch_with_engine(self.engine):
self.migration_api.upgrade('head')

View File

@ -226,6 +226,7 @@ def get_test_node(**kw):
'raid_config': kw.get('raid_config'),
'target_raid_config': kw.get('target_raid_config'),
'tags': kw.get('tags', []),
'network_interface': kw.get('network_interface'),
}

View File

@ -404,7 +404,7 @@ class TestObject(_LocalTest, _TestObject):
# version bump. It is md5 hash of object fields and remotable methods.
# The fingerprint values should only be changed if there is a version bump.
expected_object_fingerprints = {
'Node': '1.15-9ee8ab283b06398545880dfdedb49891',
'Node': '1.16-2a6646627cb937f083f428f5d54e6458',
'MyObj': '1.5-4f5efe8f0fcaf182bbe1c7fe3ba858db',
'Chassis': '1.3-d656e039fd8ae9f34efc232ab3980905',
'Port': '1.5-a224755c3da5bc5cf1a14a11c0d00f3f',