From b93ea02cf9de6a9b206d4116f6ba7c243001e775 Mon Sep 17 00:00:00 2001 From: Riddhi Shah Date: Wed, 5 Jun 2013 12:07:40 -0500 Subject: [PATCH] Integer Flavor Ids Changed the flavor id type in the instances schema to an Integer in a patch. Made changes to the test code. XML attributes are strings so made changes in code to handle that. Fixes Bug #1165077 Change-Id: I6272c4cf9d22a6090f41b41a66e52506068532cc --- .../versions/014_update_instance_flavor_id.py | 36 +++++++++++++++++++ reddwarf/tests/api/mgmt/instances.py | 9 ++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 reddwarf/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py diff --git a/reddwarf/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py b/reddwarf/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py new file mode 100644 index 0000000000..4aef9a5df7 --- /dev/null +++ b/reddwarf/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py @@ -0,0 +1,36 @@ +# Copyright 2012 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. + +from sqlalchemy.schema import Column +from sqlalchemy.schema import MetaData + +from reddwarf.db.sqlalchemy.migrate_repo.schema import Integer +from reddwarf.db.sqlalchemy.migrate_repo.schema import String +from reddwarf.db.sqlalchemy.migrate_repo.schema import Table + + +def upgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + instances = Table('instances', meta, autoload=True) + #modify column + instances.c.flavor_id.alter(type=Integer()) + + +def downgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + # modify column: + instances = Table('instances', meta, autoload=True) + instances.c.flavor_id.alter(type=String(36)) diff --git a/reddwarf/tests/api/mgmt/instances.py b/reddwarf/tests/api/mgmt/instances.py index a4f4a146f1..391cad7c87 100644 --- a/reddwarf/tests/api/mgmt/instances.py +++ b/reddwarf/tests/api/mgmt/instances.py @@ -36,6 +36,10 @@ from reddwarf.tests.api.instances import GROUP_TEST from reddwarf.tests.util import poll_until GROUP = "dbaas.api.mgmt.instances" +XML_SUPPORT = False +if hasattr(CONFIG, 'reddwarf_client_cls'): + if CONFIG.reddwarf_client_cls == "reddwarfclient.xml.ReddwarfXmlClient": + XML_SUPPORT = True @test(groups=[GROUP]) @@ -48,7 +52,10 @@ def mgmt_index_requires_admin_account(): # These functions check some dictionaries in the returned response. def flavor_check(flavor): with CollectionCheck("flavor", flavor) as check: - check.has_element("id", basestring) + if XML_SUPPORT: + check.has_element("id", basestring) + else: + check.has_element("id", int) check.has_element("links", list)