Merge "Increase internal_ip and management_ip column size"
This commit is contained in:
commit
fc9187bb83
@ -0,0 +1,36 @@
|
|||||||
|
# Copyright 2015 Telles Nobrega
|
||||||
|
#
|
||||||
|
# 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 internal_ip and management_ip column size to work with IPv6
|
||||||
|
|
||||||
|
Revision ID: 025
|
||||||
|
Revises: 024
|
||||||
|
Create Date: 2015-07-17 09:58:22.128263
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '025'
|
||||||
|
down_revision = '024'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.alter_column('instances', 'internal_ip', type_=sa.String(45),
|
||||||
|
nullable=True)
|
||||||
|
op.alter_column('instances', 'management_ip', type_=sa.String(45),
|
||||||
|
nullable=True)
|
@ -152,8 +152,8 @@ class Instance(mb.SaharaBase):
|
|||||||
node_group_id = sa.Column(sa.String(36), sa.ForeignKey('node_groups.id'))
|
node_group_id = sa.Column(sa.String(36), sa.ForeignKey('node_groups.id'))
|
||||||
instance_id = sa.Column(sa.String(36))
|
instance_id = sa.Column(sa.String(36))
|
||||||
instance_name = sa.Column(sa.String(80), nullable=False)
|
instance_name = sa.Column(sa.String(80), nullable=False)
|
||||||
internal_ip = sa.Column(sa.String(15))
|
internal_ip = sa.Column(sa.String(45))
|
||||||
management_ip = sa.Column(sa.String(15))
|
management_ip = sa.Column(sa.String(45))
|
||||||
volumes = sa.Column(st.JsonListType())
|
volumes = sa.Column(st.JsonListType())
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,6 +229,14 @@ class ClusterTest(test_base.ConductorManagerTestCase):
|
|||||||
}
|
}
|
||||||
return self.api.instance_add(ctx, ng_id, instance)
|
return self.api.instance_add(ctx, ng_id, instance)
|
||||||
|
|
||||||
|
def _add_instance_ipv6(self, ctx, ng_id, instance_name):
|
||||||
|
instance = {
|
||||||
|
"instance_name": instance_name,
|
||||||
|
"internal_ip": "FE80:0000:0000:0000:0202:B3FF:FE1E:8329",
|
||||||
|
"management_ip": "FE80:0000:0000:0000:0202:B3FF:FE1E:8329"
|
||||||
|
}
|
||||||
|
return self.api.instance_add(ctx, ng_id, instance)
|
||||||
|
|
||||||
def test_add_instance(self):
|
def test_add_instance(self):
|
||||||
ctx = context.ctx()
|
ctx = context.ctx()
|
||||||
cluster_db_obj = self.api.cluster_create(ctx, SAMPLE_CLUSTER)
|
cluster_db_obj = self.api.cluster_create(ctx, SAMPLE_CLUSTER)
|
||||||
@ -249,6 +257,27 @@ class ClusterTest(test_base.ConductorManagerTestCase):
|
|||||||
self.assertEqual("additional_vm",
|
self.assertEqual("additional_vm",
|
||||||
ng["instances"][0]["instance_name"])
|
ng["instances"][0]["instance_name"])
|
||||||
|
|
||||||
|
def test_add_instance_ipv6(self):
|
||||||
|
ctx = context.ctx()
|
||||||
|
cluster_db_obj = self.api.cluster_create(ctx, SAMPLE_CLUSTER)
|
||||||
|
_id = cluster_db_obj["id"]
|
||||||
|
|
||||||
|
ng_id = cluster_db_obj["node_groups"][-1]["id"]
|
||||||
|
count = cluster_db_obj["node_groups"][-1]["count"]
|
||||||
|
|
||||||
|
instance_name = "additional_vm_ipv6"
|
||||||
|
self._add_instance_ipv6(ctx, ng_id, instance_name)
|
||||||
|
|
||||||
|
cluster_db_obj = self.api.cluster_get(ctx, _id)
|
||||||
|
for ng in cluster_db_obj["node_groups"]:
|
||||||
|
if ng["id"] != ng_id:
|
||||||
|
continue
|
||||||
|
|
||||||
|
ng.pop('tenant_id')
|
||||||
|
self.assertEqual(count + 1, ng["count"])
|
||||||
|
self.assertEqual(instance_name,
|
||||||
|
ng["instances"][0]["instance_name"])
|
||||||
|
|
||||||
def test_update_instance(self):
|
def test_update_instance(self):
|
||||||
ctx = context.ctx()
|
ctx = context.ctx()
|
||||||
cluster_db_obj = self.api.cluster_create(ctx, SAMPLE_CLUSTER)
|
cluster_db_obj = self.api.cluster_create(ctx, SAMPLE_CLUSTER)
|
||||||
@ -268,6 +297,25 @@ class ClusterTest(test_base.ConductorManagerTestCase):
|
|||||||
|
|
||||||
self.assertEqual("1.1.1.1", ng["instances"][0]["management_ip"])
|
self.assertEqual("1.1.1.1", ng["instances"][0]["management_ip"])
|
||||||
|
|
||||||
|
def test_update_instance_ipv6(self):
|
||||||
|
ctx = context.ctx()
|
||||||
|
ip = "FE80:0000:0000:0000:0202:B3FF:FE1E:8329"
|
||||||
|
cluster_db_obj = self.api.cluster_create(ctx, SAMPLE_CLUSTER)
|
||||||
|
_id = cluster_db_obj["id"]
|
||||||
|
|
||||||
|
ng_id = cluster_db_obj["node_groups"][-1]["id"]
|
||||||
|
|
||||||
|
instance_id = self._add_instance(ctx, ng_id)
|
||||||
|
|
||||||
|
self.api.instance_update(ctx, instance_id, {"management_ip": ip})
|
||||||
|
|
||||||
|
cluster_db_obj = self.api.cluster_get(ctx, _id)
|
||||||
|
for ng in cluster_db_obj["node_groups"]:
|
||||||
|
if ng["id"] != ng_id:
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.assertEqual(ip, ng["instances"][0]["management_ip"])
|
||||||
|
|
||||||
def test_remove_instance(self):
|
def test_remove_instance(self):
|
||||||
ctx = context.ctx()
|
ctx = context.ctx()
|
||||||
cluster_db_obj = self.api.cluster_create(ctx, SAMPLE_CLUSTER)
|
cluster_db_obj = self.api.cluster_create(ctx, SAMPLE_CLUSTER)
|
||||||
|
@ -47,6 +47,11 @@ class SaharaMigrationsCheckers(object):
|
|||||||
for column in columns:
|
for column in columns:
|
||||||
self.assertColumnExists(engine, table, column)
|
self.assertColumnExists(engine, table, column)
|
||||||
|
|
||||||
|
def assertColumnType(self, engine, table, column, column_type):
|
||||||
|
t = db_utils.get_table(engine, table)
|
||||||
|
column_ref_type = str(t.c[column].type)
|
||||||
|
self.assertEqual(column_ref_type, column_type)
|
||||||
|
|
||||||
def assertColumnCount(self, engine, table, columns):
|
def assertColumnCount(self, engine, table, columns):
|
||||||
t = db_utils.get_table(engine, table)
|
t = db_utils.get_table(engine, table)
|
||||||
self.assertEqual(len(columns), len(t.columns))
|
self.assertEqual(len(columns), len(t.columns))
|
||||||
@ -508,6 +513,12 @@ class SaharaMigrationsCheckers(object):
|
|||||||
for table in tables:
|
for table in tables:
|
||||||
self.assertColumnExists(engine, table, 'shares')
|
self.assertColumnExists(engine, table, 'shares')
|
||||||
|
|
||||||
|
def _check_025(self, engine, data):
|
||||||
|
self.assertColumnType(engine, 'instances', 'internal_ip',
|
||||||
|
'VARCHAR(45)')
|
||||||
|
self.assertColumnType(engine, 'instances', 'management_ip',
|
||||||
|
'VARCHAR(45)')
|
||||||
|
|
||||||
|
|
||||||
class TestMigrationsMySQL(SaharaMigrationsCheckers,
|
class TestMigrationsMySQL(SaharaMigrationsCheckers,
|
||||||
base.BaseWalkMigrationTestCase,
|
base.BaseWalkMigrationTestCase,
|
||||||
|
Loading…
Reference in New Issue
Block a user