diff --git a/murano/db/migration/alembic_migrations/versions/014_increase_status_time_resolution.py b/murano/db/migration/alembic_migrations/versions/014_increase_status_time_resolution.py new file mode 100644 index 000000000..b0f01e4b2 --- /dev/null +++ b/murano/db/migration/alembic_migrations/versions/014_increase_status_time_resolution.py @@ -0,0 +1,61 @@ +# Copyright 2016 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. + +"""Increase time resolution for status reports + +Revision ID: 014 +Create Date: 2016-04-28 + +""" + +# revision identifiers, used by Alembic. +revision = '014' +down_revision = '013' + +from alembic import op +import sqlalchemy.dialects.mysql as sa_mysql + +MYSQL_ENGINE = 'InnoDB' +MYSQL_CHARSET = 'utf8' + + +def _check_dbms(engine): + dialect = engine.dialect.dialect_description + version = engine.dialect.server_version_info + if dialect.startswith('mysql') and version >= (5, 6, 4): + return True + if 'MariaDB' in version and version >= (5, 3): + return True + return False + + +def upgrade(): + engine = op.get_bind() + if _check_dbms(engine): + with op.batch_alter_table('status') as batch_op: + batch_op.alter_column( + 'created', type_=sa_mysql.DATETIME(fsp=6), nullable=False) + batch_op.alter_column( + 'updated', type_=sa_mysql.DATETIME(fsp=6), nullable=False) + + +def downgrade(): + engine = op.get_bind() + if _check_dbms(engine): + with op.batch_alter_table('status') as batch_op: + batch_op.alter_column( + 'created', type_=sa_mysql.DATETIME(), nullable=False) + batch_op.alter_column( + 'updated', type_=sa_mysql.DATETIME(), nullable=False) diff --git a/murano/engine/system/status_reporter.py b/murano/engine/system/status_reporter.py index 22a3041d6..b7e32d61f 100644 --- a/murano/engine/system/status_reporter.py +++ b/murano/engine/system/status_reporter.py @@ -49,7 +49,7 @@ class StatusReporter(object): 'details': details, 'level': level, 'environment_id': self._environment_id, - 'timestamp': timeutils.isotime() + 'timestamp': timeutils.isotime(subsecond=True) } self._notifier.info({}, 'murano.report_notification', body)