Add new events objects to Sahara
Implements: blueprint event-log Change-Id: Ifacf309b75ccf85a5bdec7d8926fb9804b45571e
This commit is contained in:
parent
3bf970dffa
commit
19befd02c6
|
@ -0,0 +1,98 @@
|
|||
# Copyright 2014 OpenStack Foundation.
|
||||
#
|
||||
# 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_events_objects
|
||||
|
||||
Revision ID: 015
|
||||
Revises: 014
|
||||
Create Date: 2014-11-07 15:20:21.806128
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '015'
|
||||
down_revision = '014'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
MYSQL_ENGINE = 'InnoDB'
|
||||
MYSQL_CHARSET = 'utf8'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table('cluster_provision_steps',
|
||||
sa.Column('created_at', sa.DateTime(),
|
||||
nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(),
|
||||
nullable=True),
|
||||
sa.Column('id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('cluster_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.Column('tenant_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.Column('step_name', sa.String(length=80),
|
||||
nullable=True),
|
||||
sa.Column('step_type', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.Column('completed', sa.Integer(),
|
||||
nullable=True),
|
||||
sa.Column('total', sa.Integer(),
|
||||
nullable=True),
|
||||
sa.Column('successful', sa.Boolean(),
|
||||
nullable=True),
|
||||
sa.Column('started_at', sa.DateTime(),
|
||||
nullable=True),
|
||||
sa.Column('completed_at', sa.DateTime(),
|
||||
nullable=True),
|
||||
sa.ForeignKeyConstraint(['cluster_id'],
|
||||
['clusters.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('id', 'cluster_id'),
|
||||
mysql_engine=MYSQL_ENGINE,
|
||||
mysql_charset=MYSQL_CHARSET)
|
||||
|
||||
op.create_table('cluster_events',
|
||||
sa.Column('created_at', sa.DateTime(),
|
||||
nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(),
|
||||
nullable=True),
|
||||
sa.Column('id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('node_group_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.Column('instance_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.Column('instance_name', sa.String(length=80),
|
||||
nullable=True),
|
||||
sa.Column('event_info', sa.Text(),
|
||||
nullable=True),
|
||||
sa.Column('successful', sa.Boolean(),
|
||||
nullable=False),
|
||||
sa.Column('step_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
['step_id'],
|
||||
['cluster_provision_steps.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('id', 'step_id'),
|
||||
mysql_engine=MYSQL_ENGINE,
|
||||
mysql_charset=MYSQL_CHARSET)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('cluster_events')
|
||||
op.drop_table('cluster_provision_steps')
|
|
@ -67,6 +67,10 @@ class Cluster(mb.SaharaBase):
|
|||
extra = sa.Column(st.JsonDictType())
|
||||
rollback_info = sa.Column(st.JsonDictType())
|
||||
sahara_info = sa.Column(st.JsonDictType())
|
||||
provision_progress = relationship('ClusterProvisionStep',
|
||||
cascade="all,delete",
|
||||
backref='cluster',
|
||||
lazy='joined')
|
||||
node_groups = relationship('NodeGroup', cascade="all,delete",
|
||||
backref='cluster', lazy='joined')
|
||||
cluster_template_id = sa.Column(sa.String(36),
|
||||
|
@ -77,6 +81,8 @@ class Cluster(mb.SaharaBase):
|
|||
def to_dict(self):
|
||||
d = super(Cluster, self).to_dict()
|
||||
d['node_groups'] = [ng.to_dict() for ng in self.node_groups]
|
||||
d['provision_progress'] = [pp.to_dict() for pp in
|
||||
self.provision_progress]
|
||||
return d
|
||||
|
||||
|
||||
|
@ -368,3 +374,46 @@ class JobBinary(mb.SaharaBase):
|
|||
description = sa.Column(sa.Text())
|
||||
url = sa.Column(sa.String(256), nullable=False)
|
||||
extra = sa.Column(st.JsonDictType())
|
||||
|
||||
|
||||
class ClusterEvent(mb.SaharaBase):
|
||||
""""Event - represent a info about current provision step."""
|
||||
|
||||
__tablename__ = 'cluster_events'
|
||||
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint('id', 'step_id'),
|
||||
)
|
||||
|
||||
id = _id_column()
|
||||
node_group_id = sa.Column(sa.String(36))
|
||||
instance_id = sa.Column(sa.String(36))
|
||||
instance_name = sa.Column(sa.String(80))
|
||||
event_info = sa.Column(sa.Text)
|
||||
successful = sa.Column(sa.Boolean, nullable=False)
|
||||
step_id = sa.Column(sa.String(36), sa.ForeignKey(
|
||||
'cluster_provision_steps.id'))
|
||||
|
||||
|
||||
class ClusterProvisionStep(mb.SaharaBase):
|
||||
"""ProvisionStep - represent a current provision step of cluster."""
|
||||
|
||||
__tablename__ = 'cluster_provision_steps'
|
||||
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint('id', 'cluster_id'),
|
||||
)
|
||||
|
||||
id = _id_column()
|
||||
cluster_id = sa.Column(sa.String(36), sa.ForeignKey('clusters.id'))
|
||||
tenant_id = sa.Column(sa.String(36))
|
||||
step_name = sa.Column(sa.String(80))
|
||||
step_type = sa.Column(sa.String(36))
|
||||
completed = sa.Column(sa.Integer)
|
||||
total = sa.Column(sa.Integer)
|
||||
successful = sa.Column(sa.Boolean, nullable=True)
|
||||
started_at = sa.Column(sa.DateTime())
|
||||
completed_at = sa.Column(sa.DateTime())
|
||||
events = relationship('ClusterEvent', cascade="all,delete",
|
||||
backref='ClusterProvisionStep',
|
||||
lazy='joined')
|
||||
|
|
|
@ -412,3 +412,38 @@ class TestMigrations(base.BaseWalkMigrationTestCase, base.CommonTestsMixIn):
|
|||
self.assertColumnExists(engine, 'node_group_templates', 'volume_type')
|
||||
self.assertColumnExists(engine, 'node_groups', 'volume_type')
|
||||
self.assertColumnExists(engine, 'templates_relations', 'volume_type')
|
||||
|
||||
def _check_015(self, engine, data):
|
||||
provision_steps_columns = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'id',
|
||||
'cluster_id',
|
||||
'tenant_id',
|
||||
'step_name',
|
||||
'step_type',
|
||||
'completed',
|
||||
'total',
|
||||
'successful',
|
||||
'started_at',
|
||||
'completed_at',
|
||||
]
|
||||
events_columns = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'id',
|
||||
'node_group_id',
|
||||
'instance_id',
|
||||
'instance_name',
|
||||
'event_info',
|
||||
'successful',
|
||||
'step_id',
|
||||
]
|
||||
|
||||
self.assertColumnCount(engine, 'cluster_provision_steps',
|
||||
provision_steps_columns)
|
||||
self.assertColumnsExists(engine, 'cluster_provision_steps',
|
||||
provision_steps_columns)
|
||||
|
||||
self.assertColumnCount(engine, 'cluster_events', events_columns)
|
||||
self.assertColumnsExists(engine, 'cluster_events', events_columns)
|
||||
|
|
Loading…
Reference in New Issue