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 90b1ee9b75..ac511ceeee 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 06070cd714..75c335bf71 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),