Add rules column to instance_group_policy table.

This adds the rules column to instance_group_policy table.

The ''Text'' column "rules" which is a dict, it can be
applied to the policy, and represents the rules for
specific policy.

Related to blueprint complex-anti-affinity-policies

Change-Id: I61ffb5ddb2d808bfef4e60088f4524bd98e0474e
This commit is contained in:
Yikun Jiang
2018-04-12 10:57:24 +08:00
committed by Dan Smith
parent 0e090f31e8
commit 57b0bb3749
3 changed files with 30 additions and 0 deletions

View File

@@ -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
policies = Table('instance_group_policy', meta, autoload=True)
if not hasattr(policies.c, 'rules'):
policies.create_column(Column('rules', Text))

View File

@@ -417,6 +417,7 @@ class InstanceGroupPolicy(API_BASE):
policy = Column(String(255))
group_id = Column(Integer, ForeignKey('instance_groups.id'),
nullable=False)
rules = Column(Text)
class InstanceGroup(API_BASE):

View File

@@ -713,6 +713,9 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin):
self.assertEqual(1, len(result))
self.assertEqual(0, result[0]['generation'])
def _check_060(self, engine, data):
self.assertColumnExists(engine, 'instance_group_policy', 'rules')
class TestNovaAPIMigrationsWalkSQLite(NovaAPIMigrationsWalk,
test_base.DbTestCase,