From 57249650cc461ebba6e3884646f6b9b295ceb39a Mon Sep 17 00:00:00 2001 From: "OTSUKA, Yuanying" Date: Mon, 9 Feb 2015 12:57:21 +0900 Subject: [PATCH] Add status attribute to bay When a Bay is created, we use Heat to bring up resources to use for the Bay. We would like to see the related status in the Bay resource that tracks what's happening. We use the new status attribute to show what is happening with Heat behind the scenes. Partially-Implements: blueprint magnum-bay-status Change-Id: I7b841f2afbe575b039ebbde0e19d8fc464246608 --- .../versions/5793cd26898d_add_bay_status.py | 34 +++++++++++++++++++ magnum/db/sqlalchemy/models.py | 1 + magnum/objects/bay.py | 16 +++++++++ magnum/tests/db/utils.py | 1 + 4 files changed, 52 insertions(+) create mode 100644 magnum/db/sqlalchemy/alembic/versions/5793cd26898d_add_bay_status.py diff --git a/magnum/db/sqlalchemy/alembic/versions/5793cd26898d_add_bay_status.py b/magnum/db/sqlalchemy/alembic/versions/5793cd26898d_add_bay_status.py new file mode 100644 index 0000000000..93c3f8dc55 --- /dev/null +++ b/magnum/db/sqlalchemy/alembic/versions/5793cd26898d_add_bay_status.py @@ -0,0 +1,34 @@ +# 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 bay status + +Revision ID: 5793cd26898d +Revises: 3bea56f25597 +Create Date: 2015-02-09 12:54:09.449948 + +""" + +# revision identifiers, used by Alembic. +revision = '5793cd26898d' +down_revision = '3bea56f25597' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('bay', sa.Column('status', sa.String(length=20), + nullable=True)) + + +def downgrade(): + op.drop_column('bay', 'status') diff --git a/magnum/db/sqlalchemy/models.py b/magnum/db/sqlalchemy/models.py index 9b134a5702..7f0140330a 100644 --- a/magnum/db/sqlalchemy/models.py +++ b/magnum/db/sqlalchemy/models.py @@ -129,6 +129,7 @@ class Bay(Base): master_address = Column(String(255)) minions_address = Column(JSONEncodedList) node_count = Column(Integer()) + status = Column(String(20), nullable=True) class BayModel(Base): diff --git a/magnum/objects/bay.py b/magnum/objects/bay.py index 56fc1e36eb..8f44b82a01 100644 --- a/magnum/objects/bay.py +++ b/magnum/objects/bay.py @@ -20,6 +20,18 @@ from magnum.objects import base from magnum.objects import utils as obj_utils +class Status(object): + CREATE_IN_PROGRESS = 'CREATE_IN_PROGRESS' + CREATE_FAILED = 'CREATE_FAILED' + CREATED = 'CREATED' + UPDATE_IN_PROGRESS = 'UPDATE_IN_PROGRESS' + UPDATE_FAILED = 'UPDATE_FAILED' + UPDATED = 'UPDATED' + DELETE_IN_PROGRESS = 'DELETE_IN_PROGRESS' + DELETE_FAILED = 'DELETE_FAILED' + DELETED = 'DELETED' + + class Bay(base.MagnumObject): # Version 1.0: Initial version VERSION = '1.0' @@ -34,6 +46,10 @@ class Bay(base.MagnumObject): 'user_id': obj_utils.str_or_none, 'baymodel_id': obj_utils.str_or_none, 'stack_id': obj_utils.str_or_none, + # One of CREATE_IN_PROGRESS|CREATE_FAILED|CREATED + # UPDATE_IN_PROGRESS|UPDATE_FAILED|UPDATED + # DELETE_IN_PROGRESS|DELETE_FAILED|DELETED + 'status': obj_utils.str_or_none, 'master_address': obj_utils.str_or_none, 'minions_address': obj_utils.list_or_none, 'node_count': obj_utils.int_or_none diff --git a/magnum/tests/db/utils.py b/magnum/tests/db/utils.py index 78a8ef76ba..9bc1a349ad 100644 --- a/magnum/tests/db/utils.py +++ b/magnum/tests/db/utils.py @@ -47,6 +47,7 @@ def get_test_bay(**kw): 'baymodel_id': kw.get('baymodel_id', 'e74c40e0-d825-11e2-a28f-0800200c9a66'), 'stack_id': kw.get('stack_id', '047c6319-7abd-4bd9-a033-8c6af0173cd0'), + 'status': kw.get('status', 'CREATE_IN_PROGRESS'), 'master_address': kw.get('master_address', '172.17.2.3'), 'minions_address': kw.get('minions_address', ['172.17.2.4']), 'node_count': kw.get('node_count', 3),