Deploy steps - DB model

Adds a 'deploy_step' column to the nodes table.

Co-Authored-By: Ruby Loo <rloo@oath.com>

Change-Id: I31286266f28b1fdcdfeb6002992f4eece25c6ac1
Story: #1753128
Task: #22592
This commit is contained in:
Mark Goddard 2018-07-03 19:26:13 +01:00 committed by Julia Kreger
parent d29dab27ef
commit f5a5af32a3
5 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,33 @@
# All Rights Reserved.
#
# 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 deploy_step to node
Revision ID: b9117ac17882
Revises: fb3f10dd262e
Create Date: 2018-06-19 22:31:45.668156
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b9117ac17882'
down_revision = 'fb3f10dd262e'
def upgrade():
op.add_column('nodes', sa.Column('deploy_step', sa.Text(),
nullable=True))

View File

@ -144,6 +144,7 @@ class Node(Base):
driver_info = Column(db_types.JsonEncodedDict)
driver_internal_info = Column(db_types.JsonEncodedDict)
clean_step = Column(db_types.JsonEncodedDict)
deploy_step = Column(db_types.JsonEncodedDict)
resource_class = Column(String(80), nullable=True)
raid_config = Column(db_types.JsonEncodedDict)

View File

@ -100,6 +100,9 @@ def node_post_data(**kw):
node.pop('chassis_id')
node.pop('tags')
node.pop('traits')
# TODO(mgoddard): Remove this once the deploy_step field is supported in
# the API.
node.pop('deploy_step')
# NOTE(jroll): pop out fields that were introduced in later API versions,
# unless explicitly requested. Otherwise, these will cause tests using

View File

@ -719,6 +719,13 @@ class MigrationCheckersMixin(object):
self.assertIsInstance(nodes_tbl.c.fault.type,
sqlalchemy.types.String)
def _check_b9117ac17882(self, engine, data):
nodes = db_utils.get_table(engine, 'nodes')
col_names = [column.name for column in nodes.c]
self.assertIn('deploy_step', col_names)
self.assertIsInstance(nodes.c.deploy_step.type,
sqlalchemy.types.String)
def test_upgrade_and_version(self):
with patch_with_engine(self.engine):
self.migration_api.upgrade('head')

View File

@ -196,6 +196,7 @@ def get_test_node(**kw):
'driver_internal_info': kw.get('driver_internal_info',
fake_internal_info),
'clean_step': kw.get('clean_step'),
'deploy_step': kw.get('deploy_step'),
'properties': kw.get('properties', properties),
'reservation': kw.get('reservation'),
'maintenance': kw.get('maintenance', False),