Add standalone_ports_supported to portgroup - DB

This patch is a database change to portgroup object that adds
a new field standalone_ports_supported. The field indicates
whether interfaces that belongs to the portgroup may be used
as individual interfaces. For example when hardware doesn't
support portchannel fallback.

Related-Bug: #1618754
Change-Id: I24c2408a0769b630ce275f8688705fc35efd41a8
This commit is contained in:
Vasyl Saienko 2016-08-26 03:03:18 -04:00
parent dbf9662df4
commit 541947f906
7 changed files with 52 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_standalone_ports_supported_to_portgroup
Revision ID: 60cf717201bc
Revises: c14cef6dfedf
Create Date: 2016-08-25 07:00:56.662645
"""
# revision identifiers, used by Alembic.
revision = '60cf717201bc'
down_revision = 'c14cef6dfedf'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('portgroups', sa.Column('standalone_ports_supported',
sa.Boolean))

View File

@ -182,6 +182,7 @@ class Portgroup(Base):
address = Column(String(18))
extra = Column(db_types.JsonEncodedDict)
internal_info = Column(db_types.JsonEncodedDict)
standalone_ports_supported = Column(Boolean, default=True)
class NodeTag(Base):

View File

@ -28,7 +28,8 @@ from ironic.objects import fields as object_fields
class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat):
# Version 1.0: Initial version
# Version 1.1: Add internal_info field
VERSION = '1.1'
# Version 1.2: Add standalone_ports_supported field
VERSION = '1.2'
dbapi = dbapi.get_instance()
@ -40,6 +41,7 @@ class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat):
'address': object_fields.MACAddressField(nullable=True),
'extra': object_fields.FlexibleDictField(nullable=True),
'internal_info': object_fields.FlexibleDictField(nullable=True),
'standalone_ports_supported': object_fields.BooleanField(),
}
@staticmethod

View File

@ -524,6 +524,14 @@ class MigrationCheckersMixin(object):
self.assertEqual(1, counts['neutron'])
self.assertEqual(0, counts[None])
def _check_60cf717201bc(self, engine, data):
portgroups = db_utils.get_table(engine, 'portgroups')
col_names = [column.name for column in portgroups.c]
self.assertIn('standalone_ports_supported', col_names)
self.assertIsInstance(portgroups.c.standalone_ports_supported.type,
(sqlalchemy.types.Boolean,
sqlalchemy.types.Integer))
def test_upgrade_and_version(self):
with patch_with_engine(self.engine):
self.migration_api.upgrade('head')

View File

@ -387,6 +387,8 @@ def get_test_portgroup(**kw):
'created_at': kw.get('created_at'),
'updated_at': kw.get('updated_at'),
'internal_info': kw.get('internal_info', {"bar": "buzz"}),
'standalone_ports_supported': kw.get('standalone_ports_supported',
True),
}

View File

@ -408,7 +408,7 @@ expected_object_fingerprints = {
'MyObj': '1.5-4f5efe8f0fcaf182bbe1c7fe3ba858db',
'Chassis': '1.3-d656e039fd8ae9f34efc232ab3980905',
'Port': '1.6-609504503d68982a10f495659990084b',
'Portgroup': '1.1-e57da9ca808d3696c34dad8125564696',
'Portgroup': '1.2-37b374b19bfd25db7e86aebc364e611e',
'Conductor': '1.1-5091f249719d4a465062a1b3dc7f860d',
'EventType': '1.0-3daeec50c6deb956990255f92b863333',
'NotificationPublisher': '1.0-51a09397d6c0687771fb5be9a999605d',

View File

@ -0,0 +1,6 @@
---
features:
- Add the field `standalone_ports_supported` to the
portgroup object. This field indicates whether
ports that are members of this portgroup can be
used as stand alone ports. By default is True.