Merge "Add Node.instance_info field"

This commit is contained in:
Jenkins 2014-04-07 17:09:09 +00:00 committed by Gerrit Code Review
commit 213eb7a459
6 changed files with 58 additions and 1 deletions

View File

@ -297,6 +297,10 @@ class Node(base.APIBase):
console_enabled = types.boolean
"Indicates whether the console access is enabled or disabled on the node."
instance_info = {wtypes.text: types.MultiType(wtypes.text,
six.integer_types)}
"This node's instance info."
driver = wsme.wsattr(wtypes.text, mandatory=True)
"The driver responsible for controlling the node"
@ -377,7 +381,7 @@ class Node(base.APIBase):
reservation=None, driver='fake', driver_info={}, extra={},
properties={'memory_mb': '1024', 'local_gb': '10',
'cpus': '1'}, updated_at=time, created_at=time,
provision_updated_at=time)
provision_updated_at=time, instance_info={})
# NOTE(matty_dubs): The chassis_uuid getter() is based on the
# _chassis_uuid variable:
sample._chassis_uuid = 'edcad704-b2da-41d5-96d9-afd580ecfa12'

View File

@ -0,0 +1,40 @@
# 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 instance info
Revision ID: 31baaf680d2b
Revises: 3cb628139ea4
Create Date: 2014-03-05 21:09:32.372463
"""
# revision identifiers, used by Alembic.
revision = '31baaf680d2b'
down_revision = '3cb628139ea4'
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('nodes', sa.Column('instance_info',
sa.Text(),
nullable=True))
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('nodes', 'instance_info')
### end Alembic commands ###

View File

@ -149,6 +149,7 @@ class Node(Base):
target_provision_state = Column(String(15), nullable=True)
provision_updated_at = Column(DateTime, nullable=True)
last_error = Column(Text, nullable=True)
instance_info = Column(JSONEncodedDict)
properties = Column(JSONEncodedDict)
driver = Column(String(15))
driver_info = Column(JSONEncodedDict)

View File

@ -20,6 +20,9 @@ from ironic.objects import utils
class Node(base.IronicObject):
# Version 1.1: Added instance_info
version = '1.1'
dbapi = db_api.get_instance()
fields = {
@ -32,6 +35,7 @@ class Node(base.IronicObject):
'driver': utils.str_or_none,
'driver_info': utils.dict_or_none,
'instance_info': utils.dict_or_none,
'properties': utils.dict_or_none,
'reservation': utils.str_or_none,

View File

@ -512,3 +512,10 @@ class TestMigrations(BaseMigrationTestCase, WalkVersionsMixin):
sqlalchemy.types.Boolean) or
isinstance(nodes.c.console_enabled.type,
sqlalchemy.types.Integer))
def _check_31baaf680d2b(self, engine, data):
nodes = db_utils.get_table(engine, 'nodes')
col_names = [column.name for column in nodes.c]
self.assertIn('instance_info', col_names)
self.assertIsInstance(nodes.c.instance_info.type,
sqlalchemy.types.TEXT)

View File

@ -85,6 +85,7 @@ def get_test_node(**kw):
'provision_updated_at': kw.get('provision_updated_at'),
'last_error': kw.get('last_error'),
'instance_uuid': kw.get('instance_uuid'),
'instance_info': kw.get('instance_info', fake_info),
'driver': kw.get('driver', 'fake'),
'driver_info': kw.get('driver_info', fake_info),
'properties': kw.get('properties', properties),