summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin_Zheng <zhengzhenyu@huawei.com>2017-04-25 11:32:01 +0800
committerMatt Riedemann <mriedem.os@gmail.com>2017-04-28 16:59:04 -0400
commite0803fd60e586e87894c114d2ec49138c7409c46 (patch)
tree547277e13cc845c9c7e7d082046a16341b5e8a8e
parenta3621da78477f0f8a8f15d5d8166c4e7f20d0e3d (diff)
downloadnova-e0803fd60e586e87894c114d2ec49138c7409c46.tar.gz
Support tag instances when boot(1)
This is the first patch of the series, this patch adds tags to build_request table and corresponding db update script. Change-Id: I01e1973449a572ecd647ede0a70d274eac1583bd Part of blueprint support-tag-instance-when-boot
-rw-r--r--nova/db/sqlalchemy/api_migrations/migrate_repo/versions/042_build_requests_add_tags.py26
-rw-r--r--nova/db/sqlalchemy/api_models.py1
-rw-r--r--nova/tests/functional/db/api/test_migrations.py3
3 files changed, 30 insertions, 0 deletions
diff --git a/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/042_build_requests_add_tags.py b/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/042_build_requests_add_tags.py
new file mode 100644
index 0000000000..7c34fe3985
--- /dev/null
+++ b/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/042_build_requests_add_tags.py
@@ -0,0 +1,26 @@
+# 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.
+
+from sqlalchemy import Column
+from sqlalchemy import MetaData
+from sqlalchemy import Table
+from sqlalchemy import Text
+
+
+def upgrade(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+
+ build_requests = Table('build_requests', meta, autoload=True)
+
+ if not hasattr(build_requests.c, 'tags'):
+ build_requests.create_column(Column('tags', Text()))
diff --git a/nova/db/sqlalchemy/api_models.py b/nova/db/sqlalchemy/api_models.py
index eb8ecfd615..5807d9e7fd 100644
--- a/nova/db/sqlalchemy/api_models.py
+++ b/nova/db/sqlalchemy/api_models.py
@@ -243,6 +243,7 @@ class BuildRequest(API_BASE):
project_id = Column(String(255), nullable=False)
instance = Column(MediumText())
block_device_mappings = Column(MediumText())
+ tags = Column(Text())
# TODO(alaski): Drop these from the db in Ocata
# columns_to_drop = ['request_spec_id', 'user_id', 'display_name',
# 'instance_metadata', 'progress', 'vm_state', 'task_state',
diff --git a/nova/tests/functional/db/api/test_migrations.py b/nova/tests/functional/db/api/test_migrations.py
index 3b5fa89d8a..8596f0da96 100644
--- a/nova/tests/functional/db/api/test_migrations.py
+++ b/nova/tests/functional/db/api/test_migrations.py
@@ -605,6 +605,9 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin):
self.assertEqual(['resource_provider_id'],
fk['constrained_columns'])
+ def _check_042(self, engine, data):
+ self.assertColumnExists(engine, 'build_requests', 'tags')
+
class TestNovaAPIMigrationsWalkSQLite(NovaAPIMigrationsWalk,
test_base.DbTestCase,