From 9647ccde9984f79d8c441772802faad019cd666f Mon Sep 17 00:00:00 2001 From: Mikhail Zhnichkov Date: Tue, 8 Nov 2016 09:48:45 +0000 Subject: [PATCH] Revert "Add tag API" This reverts commit 327f754d9055005d867b38d60b9b02868ed3549e. Change-Id: I58474fd358287ad21f0f36ec5be9a565fc24c67c --- nailgun/nailgun/api/v1/handlers/tag.py | 129 ------------------ nailgun/nailgun/api/v1/urls.py | 10 -- .../api/v1/validators/json_schema/tag.py | 27 ---- nailgun/nailgun/api/v1/validators/tag.py | 32 ----- nailgun/nailgun/consts.py | 6 - .../alembic_migrations/versions/fuel_10_0.py | 106 -------------- .../nailgun/db/sqlalchemy/models/__init__.py | 2 - nailgun/nailgun/db/sqlalchemy/models/node.py | 24 +--- .../nailgun/db/sqlalchemy/models/release.py | 1 - nailgun/nailgun/db/sqlalchemy/models/tag.py | 26 ---- nailgun/nailgun/objects/__init__.py | 3 - nailgun/nailgun/objects/node.py | 38 ------ nailgun/nailgun/objects/serializers/node.py | 1 - nailgun/nailgun/objects/serializers/tag.py | 28 ---- nailgun/nailgun/objects/tag.py | 35 ----- .../test_installation_info.py | 3 +- .../test/unit/test_downgrade_fuel_10_0.py | 9 -- .../test/unit/test_migration_fuel_10_0.py | 94 ------------- 18 files changed, 2 insertions(+), 572 deletions(-) delete mode 100644 nailgun/nailgun/api/v1/handlers/tag.py delete mode 100644 nailgun/nailgun/api/v1/validators/json_schema/tag.py delete mode 100644 nailgun/nailgun/api/v1/validators/tag.py delete mode 100644 nailgun/nailgun/db/sqlalchemy/models/tag.py delete mode 100644 nailgun/nailgun/objects/serializers/tag.py delete mode 100644 nailgun/nailgun/objects/tag.py diff --git a/nailgun/nailgun/api/v1/handlers/tag.py b/nailgun/nailgun/api/v1/handlers/tag.py deleted file mode 100644 index 99578fc50a..0000000000 --- a/nailgun/nailgun/api/v1/handlers/tag.py +++ /dev/null @@ -1,129 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2016 Mirantis, Inc. -# -# 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. - -""" -Handlers dealing with tags -""" -from nailgun.api.v1.handlers.base import BaseHandler -from nailgun.api.v1.handlers.base import CollectionHandler -from nailgun.api.v1.handlers.base import handle_errors -from nailgun.api.v1.handlers.base import SingleHandler - -from nailgun.api.v1.validators.tag import TagValidator - -from nailgun import errors -from nailgun import objects - - -class TagOwnerHandler(CollectionHandler): - - collection = objects.TagCollection - owner_map = { - 'releases': 'release', - 'clusters': 'cluster', - 'plugins': 'plugin' - } - - @handle_errors - def GET(self, owner_type, owner_id): - """:returns: JSONized list of tags. - - :http: * 200 (OK) - """ - - tags = objects.TagCollection.filter_by( - None, - owner_type=self.owner_map[owner_type], - owner_id=owner_id - ) - return self.collection.to_list(tags) - - @handle_errors - def POST(self, owner_type, owner_id): - """Assign tags to node - - :http: - * 201 (tag successfully created) - * 400 (invalid object data specified) - """ - data = self.checked_data() - data['owner_type'] = self.owner_map[owner_type] - data['owner_id'] = owner_id - - try: - tag = self.collection.create(data) - except errors.CannotCreate as exc: - raise self.http(400, exc.message) - - raise self.http(201, self.collection.single.to_json(tag)) - - -class TagHandler(SingleHandler): - """Tag single handler""" - - single = objects.Tag - validator = TagValidator - - -class NodeTagAssignmentHandler(BaseHandler): - - @handle_errors - def POST(self, node_id): - """Assign tags to node - - :http: - * 200 (tags successfully assigned) - * 400 (invalid object data specified) - * 404 (node instance or tags not found) - """ - node = self.get_object_or_404( - objects.Node, - node_id - ) - - tag_ids = self.get_param_as_set('tags') - - tags = self.get_objects_list_or_404( - objects.TagCollection, - tag_ids - ) - - objects.Node.assign_tags(node, tags) - raise self.http(200, None) - - @handle_errors - def DELETE(self, node_id): - """Unassign tags from node - - :http: - * 200 (tags successfully unassigned) - * 400 (invalid object data specified) - * 404 (node instance or tags not found) - """ - node = self.get_object_or_404( - objects.Node, - node_id - ) - - tag_ids = self.get_param_as_set('tags') - - tags = self.get_objects_list_or_404( - objects.TagCollection, - tag_ids - ) - - objects.Node.unassign_tags(node, tags) - raise self.http(200, None) diff --git a/nailgun/nailgun/api/v1/urls.py b/nailgun/nailgun/api/v1/urls.py index f32ceebc8f..761145bf94 100644 --- a/nailgun/nailgun/api/v1/urls.py +++ b/nailgun/nailgun/api/v1/urls.py @@ -114,10 +114,6 @@ from nailgun.api.v1.handlers.role import ClusterRolesHandler from nailgun.api.v1.handlers.role import RoleCollectionHandler from nailgun.api.v1.handlers.role import RoleHandler -from nailgun.api.v1.handlers.tag import NodeTagAssignmentHandler -from nailgun.api.v1.handlers.tag import TagHandler -from nailgun.api.v1.handlers.tag import TagOwnerHandler - from nailgun.api.v1.handlers.tasks import TaskCollectionHandler from nailgun.api.v1.handlers.tasks import TaskHandler @@ -298,12 +294,6 @@ urls = ( NodeAttributesDefaultsHandler, r'/nodes/allocation/stats/?$', NodesAllocationStatsHandler, - r'/nodes/(?P\d+)/tags/?$', - NodeTagAssignmentHandler, - r'/tags/(?P\d+)/?$', - TagHandler, - r'/(releases|clusters|plugins)/(?P\d+)/tags/?$', - TagOwnerHandler, r'/tasks/?$', TaskCollectionHandler, r'/tasks/(?P\d+)/?$', diff --git a/nailgun/nailgun/api/v1/validators/json_schema/tag.py b/nailgun/nailgun/api/v1/validators/json_schema/tag.py deleted file mode 100644 index 5db1cc81e6..0000000000 --- a/nailgun/nailgun/api/v1/validators/json_schema/tag.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2016 Mirantis, Inc. - -# -# 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. - -TAG_CREATION_SCHEMA = { - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Tag", - "description": "Serialized Tag object", - "type": "object", - "properties": { - "id": {"type": "integer"}, - "tag": {"type": "string"}, - "has_primary": {"type": "boolean"} - }, - "required": ["tag"], -} diff --git a/nailgun/nailgun/api/v1/validators/tag.py b/nailgun/nailgun/api/v1/validators/tag.py deleted file mode 100644 index 098063af05..0000000000 --- a/nailgun/nailgun/api/v1/validators/tag.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2016 Mirantis, Inc. -# -# 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 nailgun.api.v1.validators.base import BasicValidator -from nailgun.api.v1.validators.json_schema import tag - -from nailgun import errors - - -class TagValidator(BasicValidator): - - single_schema = tag.TAG_CREATION_SCHEMA - - @classmethod - def validate_delete(cls, data, instance): - if instance.read_only: - raise errors.CannotDelete( - "Read-only tags cannot be deleted." - ) diff --git a/nailgun/nailgun/consts.py b/nailgun/nailgun/consts.py index b5e800c2ff..a341e22732 100644 --- a/nailgun/nailgun/consts.py +++ b/nailgun/nailgun/consts.py @@ -526,9 +526,3 @@ HYPERVISORS = Enum( "kvm", "qemu" ) - -TAG_OWNER_TYPES = Enum( - 'release', - 'cluster', - 'plugin' -) diff --git a/nailgun/nailgun/db/migration/alembic_migrations/versions/fuel_10_0.py b/nailgun/nailgun/db/migration/alembic_migrations/versions/fuel_10_0.py index 35d5b233f9..39387f2ed2 100644 --- a/nailgun/nailgun/db/migration/alembic_migrations/versions/fuel_10_0.py +++ b/nailgun/nailgun/db/migration/alembic_migrations/versions/fuel_10_0.py @@ -22,12 +22,9 @@ Create Date: 2016-04-08 15:20:43.989472 from alembic import op from oslo_serialization import jsonutils - import sqlalchemy as sa -from nailgun import consts from nailgun.db.sqlalchemy.models import fields -from nailgun.utils.migration import drop_enum # revision identifiers, used by Alembic. @@ -38,116 +35,13 @@ down_revision = 'f2314e5d63c9' def upgrade(): upgrade_plugin_links_constraints() upgrade_release_required_component_types() - upgrade_node_tagging() - upgrade_tags_existing_nodes() def downgrade(): - downgrade_node_tagging() downgrade_release_required_component_types() downgrade_plugin_links_constraints() -def upgrade_tags_existing_nodes(): - connection = op.get_bind() - node_query = sa.sql.text( - "SELECT n.id as n_id, unnest(roles || pending_roles) AS role, " - "primary_roles, r.id AS release_id FROM nodes n " - "JOIN clusters c ON n.cluster_id=c.id " - "JOIN releases r ON r.id=c.release_id" - ) - tag_assign_query = sa.sql.text( - "INSERT INTO node_tags (node_id, tag_id, is_primary) " - "VALUES(:node_id, :tag_id, :is_primary)" - ) - tag_select_query = sa.sql.text( - "SELECT id FROM tags WHERE owner_id=:id AND " - "owner_type='release' AND tag=:tag" - ) - select_query = sa.sql.text( - "SELECT id, roles_metadata FROM releases " - "WHERE roles_metadata IS NOT NULL" - ) - insert_query = sa.sql.text( - "INSERT INTO tags (tag, owner_id, owner_type, has_primary, read_only) " - "VALUES(:tag, :owner_id, 'release', :has_primary, true) RETURNING id" - ) - - # Create tags for all release roles - for id, roles_metadata in connection.execute(select_query): - roles_metadata = jsonutils.loads(roles_metadata) - for role_name, role_metadata in roles_metadata.items(): - connection.execute( - insert_query, - tag=role_name, - owner_id=id, - has_primary=roles_metadata.get('has_primary', False) - ) - - for id, role, primary_roles, release_id in connection.execute(node_query): - tag = connection.execute( - tag_select_query, - id=release_id, - tag=role - ).fetchone() - - if not tag: - continue - - connection.execute( - tag_assign_query, - node_id=id, - tag_id=tag.id, - is_primary=role in primary_roles - ) - - -def upgrade_node_tagging(): - op.create_table( - 'tags', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('tag', sa.String(64), nullable=False), - sa.Column('owner_id', sa.Integer(), nullable=False), - sa.Column( - 'owner_type', - sa.Enum( - *consts.TAG_OWNER_TYPES, - name='tag_owner_type'), - nullable=False), - sa.Column('has_primary', sa.Boolean), - sa.Column('read_only', sa.Boolean), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint( - 'owner_type', 'owner_id', 'tag', - name='__tag_owner_uc'), - ) - - op.create_table( - 'node_tags', - sa.Column('id', sa.Integer()), - sa.Column('node_id', sa.Integer(), nullable=False), - sa.Column('tag_id', sa.Integer(), nullable=False), - sa.Column('is_primary', sa.Boolean, default=False), - sa.ForeignKeyConstraint( - ['node_id'], ['nodes.id'], ondelete='CASCADE' - ), - sa.ForeignKeyConstraint( - ['tag_id'], ['tags.id'], ondelete='CASCADE' - ) - ) - op.add_column( - 'releases', - sa.Column('tags_metadata', fields.JSON(), nullable=True), - ) - - -def downgrade_node_tagging(): - op.drop_table('node_tags') - op.drop_table('tags') - drop_enum('tag_owner_type') - op.drop_column('releases', 'tags_metadata') - - def upgrade_plugin_links_constraints(): connection = op.get_bind() diff --git a/nailgun/nailgun/db/sqlalchemy/models/__init__.py b/nailgun/nailgun/db/sqlalchemy/models/__init__.py index 82c2d1bfea..78d1ce8593 100644 --- a/nailgun/nailgun/db/sqlalchemy/models/__init__.py +++ b/nailgun/nailgun/db/sqlalchemy/models/__init__.py @@ -52,9 +52,7 @@ from nailgun.extensions.network_manager.models.network import \ from nailgun.extensions.network_manager.models import network from nailgun.db.sqlalchemy.models.node import Node from nailgun.db.sqlalchemy.models.node import NodeGroup -from nailgun.db.sqlalchemy.models.node import NodeTag -from nailgun.db.sqlalchemy.models.tag import Tag from nailgun.extensions.network_manager.models.network_config import \ NetworkingConfig diff --git a/nailgun/nailgun/db/sqlalchemy/models/node.py b/nailgun/nailgun/db/sqlalchemy/models/node.py index ebd80b4301..731ab5b501 100644 --- a/nailgun/nailgun/db/sqlalchemy/models/node.py +++ b/nailgun/nailgun/db/sqlalchemy/models/node.py @@ -55,24 +55,6 @@ class NodeGroup(Base): ) -class NodeTag(Base): - __tablename__ = 'node_tags' - - # NOTE(rmoe): This is required to satisfy some tests. When DEVELOPMENT=1 - # in settings.yaml ObserverModelBase is used as the declarative base - # class. __setattr__ defined in that class requires a mapped object to - # have an id field. - id = Column(Integer) - node_id = Column( - ForeignKey('nodes.id', ondelete='CASCADE'), primary_key=True - ) - tag_id = Column( - ForeignKey('tags.id', ondelete='CASCADE'), primary_key=True - ) - is_primary = Column(Boolean, default=False) - tag = relationship('Tag') - - class Node(Base): __tablename__ = 'nodes' __table_args__ = ( @@ -113,13 +95,13 @@ class Node(Base): online = Column(Boolean, default=True) labels = Column( MutableDict.as_mutable(JSON), nullable=False, server_default='{}') - tags = relationship('NodeTag', cascade='delete, delete-orphan') roles = Column(psql.ARRAY(String(consts.ROLE_NAME_MAX_SIZE)), default=[], nullable=False, server_default='{}') pending_roles = Column(psql.ARRAY(String(consts.ROLE_NAME_MAX_SIZE)), default=[], nullable=False, server_default='{}') primary_roles = Column(psql.ARRAY(String(consts.ROLE_NAME_MAX_SIZE)), default=[], nullable=False, server_default='{}') + nic_interfaces = relationship("NodeNICInterface", backref="node", cascade="all, delete-orphan", order_by="NodeNICInterface.name") @@ -187,10 +169,6 @@ class Node(Base): def full_name(self): return u'%s (id=%s, mac=%s)' % (self.name, self.id, self.mac) - @property - def tag_names(self): - return (t.tag.tag for t in self.tags) - @property def all_roles(self): """Returns all roles, self.roles and self.pending_roles.""" diff --git a/nailgun/nailgun/db/sqlalchemy/models/release.py b/nailgun/nailgun/db/sqlalchemy/models/release.py index 751cf5f24c..b5437da365 100644 --- a/nailgun/nailgun/db/sqlalchemy/models/release.py +++ b/nailgun/nailgun/db/sqlalchemy/models/release.py @@ -54,7 +54,6 @@ class Release(Base): volumes_metadata = Column(MutableDict.as_mutable(JSON), default={}) modes_metadata = Column(MutableDict.as_mutable(JSON), default={}) roles_metadata = Column(MutableDict.as_mutable(JSON), default={}) - tags_metadata = Column(MutableDict.as_mutable(JSON), default={}) network_roles_metadata = Column( MutableList.as_mutable(JSON), default=[], server_default='[]') vmware_attributes_metadata = Column( diff --git a/nailgun/nailgun/db/sqlalchemy/models/tag.py b/nailgun/nailgun/db/sqlalchemy/models/tag.py deleted file mode 100644 index 4d57bcd2de..0000000000 --- a/nailgun/nailgun/db/sqlalchemy/models/tag.py +++ /dev/null @@ -1,26 +0,0 @@ -from sqlalchemy import Boolean -from sqlalchemy import Column -from sqlalchemy import Enum -from sqlalchemy import Integer -from sqlalchemy import String -from sqlalchemy import UniqueConstraint - -from nailgun import consts -from nailgun.db.sqlalchemy.models.base import Base - - -class Tag(Base): - __tablename__ = 'tags' - __table_args__ = ( - UniqueConstraint('owner_type', 'owner_id', 'tag', - name='_tag_owner_uc'), - ) - id = Column(Integer, primary_key=True) - tag = Column(String(64), nullable=False) - owner_id = Column(Integer, nullable=False) - owner_type = Column( - Enum(*consts.TAG_OWNER_TYPES, name='tag_owner_type'), - nullable=False - ) - has_primary = Column(Boolean, default=False) - read_only = Column(Boolean, default=False) diff --git a/nailgun/nailgun/objects/__init__.py b/nailgun/nailgun/objects/__init__.py index cf0f7767dd..6d6e113dca 100644 --- a/nailgun/nailgun/objects/__init__.py +++ b/nailgun/nailgun/objects/__init__.py @@ -66,9 +66,6 @@ from nailgun.extensions.network_manager.objects.interface import NICCollection from nailgun.extensions.network_manager.objects.bond import Bond from nailgun.extensions.network_manager.objects.bond import BondCollection -from nailgun.objects.tag import Tag -from nailgun.objects.tag import TagCollection - from nailgun.objects.node import Node from nailgun.objects.node import NodeAttributes from nailgun.objects.node import NodeCollection diff --git a/nailgun/nailgun/objects/node.py b/nailgun/nailgun/objects/node.py index b88249a7a8..42e1ca214c 100644 --- a/nailgun/nailgun/objects/node.py +++ b/nailgun/nailgun/objects/node.py @@ -596,7 +596,6 @@ class Node(NailgunObject): """ data.pop("id", None) data.pop("network_data", None) - data.pop("tags", None) roles = data.pop("roles", None) pending_roles = data.pop("pending_roles", None) @@ -1032,43 +1031,6 @@ class Node(NailgunObject): db().flush() db().refresh(instance) - @classmethod - def assign_tags(cls, instance, tags): - """Assign tags to node. - - Assigns tags to node skipping already assigned - tags. - - :param instance: Node instance - :param tags: List of tags - :returns: None - """ - node_tags = set(t.tag for t in instance.tags) - tags_to_assign = set(tags) - node_tags - for tag in tags_to_assign: - t = models.NodeTag(tag=tag, node_id=instance.id) - db().add(t) - instance.tags.append(t) - - db().flush() - - @classmethod - def unassign_tags(cls, instance, tags): - """Remove tags from node. - - :param instance: Node instance - :param tags: List of tags - :returns: None - """ - node_tags = set(t.tag for t in instance.tags) - tags_to_remove = set(tags) & node_tags - tags = copy.copy(instance.tags) - for assoc in tags: - if assoc.tag in tags_to_remove: - instance.tags.remove(assoc) - - db().flush() - @classmethod def move_roles_to_pending_roles(cls, instance): """Move roles to pending_roles""" diff --git a/nailgun/nailgun/objects/serializers/node.py b/nailgun/nailgun/objects/serializers/node.py index 5c887d3011..f137204979 100644 --- a/nailgun/nailgun/objects/serializers/node.py +++ b/nailgun/nailgun/objects/serializers/node.py @@ -50,7 +50,6 @@ class NodeSerializer(BasicSerializer): data_dict = super(NodeSerializer, cls).serialize(instance, fields) data_dict['fqdn'] = Node.get_node_fqdn(instance) data_dict['status'] = Node.get_status(instance) - data_dict['tags'] = instance.tag_names return data_dict diff --git a/nailgun/nailgun/objects/serializers/tag.py b/nailgun/nailgun/objects/serializers/tag.py deleted file mode 100644 index aee98ac92c..0000000000 --- a/nailgun/nailgun/objects/serializers/tag.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2016 Mirantis, Inc. -# -# 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 nailgun.objects.serializers.base import BasicSerializer - - -class TagSerializer(BasicSerializer): - - fields = ( - "id", - "tag", - "owner_id", - "owner_type", - "has_primary" - ) diff --git a/nailgun/nailgun/objects/tag.py b/nailgun/nailgun/objects/tag.py deleted file mode 100644 index da2ec31ad5..0000000000 --- a/nailgun/nailgun/objects/tag.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2016 Mirantis, Inc. -# -# 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. - -""" -Tag object and collection -""" - -from nailgun.db.sqlalchemy import models -from nailgun.objects import NailgunCollection -from nailgun.objects import NailgunObject -from nailgun.objects.serializers.tag import TagSerializer - - -class Tag(NailgunObject): - - model = models.Tag - serializer = TagSerializer - - -class TagCollection(NailgunCollection): - - single = Tag diff --git a/nailgun/nailgun/test/unit/fuel_statistics_tests/test_installation_info.py b/nailgun/nailgun/test/unit/fuel_statistics_tests/test_installation_info.py index 9a7c69959f..c2fa3dae93 100644 --- a/nailgun/nailgun/test/unit/fuel_statistics_tests/test_installation_info.py +++ b/nailgun/nailgun/test/unit/fuel_statistics_tests/test_installation_info.py @@ -529,8 +529,7 @@ class TestInstallationInfo(BaseTestCase): 'nodegroups', 'ip_addrs', 'node_nic_interfaces', 'node_bond_interfaces', 'network_groups', 'node_nic_interface_cluster_plugins', - 'node_bond_interface_cluster_plugins', 'node_cluster_plugins', - 'node_tags' + 'node_bond_interface_cluster_plugins', 'node_cluster_plugins' ) for field in remove_fields: node_schema.pop(field) diff --git a/nailgun/nailgun/test/unit/test_downgrade_fuel_10_0.py b/nailgun/nailgun/test/unit/test_downgrade_fuel_10_0.py index d3092c8c66..6e4195caae 100644 --- a/nailgun/nailgun/test/unit/test_downgrade_fuel_10_0.py +++ b/nailgun/nailgun/test/unit/test_downgrade_fuel_10_0.py @@ -109,12 +109,3 @@ class TestRequiredComponentTypesField(base.BaseAlembicMigrationTest): def test_downgrade_release_required_component_types(self): releases_table = self.meta.tables['releases'] self.assertNotIn('required_component_types', releases_table.c) - - -class TestNodeTagging(base.BaseAlembicMigrationTest): - - def test_downgrade_release_tags_metadata(self): - releases_table = self.meta.tables['releases'] - self.assertNotIn('tags_metadata', releases_table.c) - self.assertNotIn('tags', self.meta.tables) - self.assertNotIn('node_tags', self.meta.tables) diff --git a/nailgun/nailgun/test/unit/test_migration_fuel_10_0.py b/nailgun/nailgun/test/unit/test_migration_fuel_10_0.py index ff05f1ef59..2d5701be5a 100644 --- a/nailgun/nailgun/test/unit/test_migration_fuel_10_0.py +++ b/nailgun/nailgun/test/unit/test_migration_fuel_10_0.py @@ -175,11 +175,9 @@ def prepare(): }]) cluster_ids.append(result.inserted_primary_key[0]) - node_id = 1 result = db.execute( meta.tables['nodes'].insert(), [{ - 'id': node_id, 'uuid': '26b508d0-0d76-4159-bce9-f67ec2765480', 'cluster_id': None, 'group_id': None, @@ -326,102 +324,10 @@ def prepare(): ] ) - db.execute( - meta.tables['node_nic_interfaces'].insert(), - [{ - 'id': 1, - 'node_id': node_id, - 'name': 'test_interface', - 'mac': '00:00:00:00:00:01', - 'max_speed': 200, - 'current_speed': 100, - 'ip_addr': '10.20.0.2', - 'netmask': '255.255.255.0', - 'state': 'test_state', - 'interface_properties': jsonutils.dumps( - {'test_property': 'test_value'}), - 'driver': 'test_driver', - 'bus_info': 'some_test_info' - }] - ) - - db.execute( - meta.tables['node_bond_interfaces'].insert(), - [{ - 'node_id': node_id, - 'name': 'test_bond_interface', - 'mode': 'active-backup', - 'bond_properties': jsonutils.dumps( - {'test_property': 'test_value'}) - }] - ) - - result = db.execute( - meta.tables['tasks'].insert(), - [ - { - 'id': 55, - 'uuid': '219eaafe-01a1-4f26-8edc-b9d9b0df06b3', - 'name': 'deployment', - 'status': 'running', - 'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[55]) - }, - { - 'id': 56, - 'uuid': 'a45fbbcd-792c-4245-a619-f4fb2f094d38', - 'name': 'deployment', - 'status': 'running', - 'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[56]) - } - ] - ) - - result = db.execute( - meta.tables['nodes'].insert(), - [{ - 'id': 2, - 'uuid': 'fcd49872-3917-4a18-98f9-3f5acfe3fdec', - 'cluster_id': cluster_ids[0], - 'group_id': None, - 'status': 'ready', - 'roles': ['controller', 'ceph-osd'], - 'meta': '{}', - 'mac': 'bb:aa:aa:aa:aa:aa', - 'timestamp': datetime.datetime.utcnow(), - }] - ) - TestRequiredComponentTypesField.prepare(meta) db.commit() -class TestTagExistingNodes(base.BaseAlembicMigrationTest): - def test_tags_created_on_upgrade(self): - tags_count = db.execute( - sa.select( - [sa.func.count(self.meta.tables['tags'].c.id)] - )).fetchone()[0] - - self.assertEqual(tags_count, 11) - - def test_nodes_assigned_tags(self): - tags = self.meta.tables['tags'] - node_tags = self.meta.tables['node_tags'] - - query = sa.select([tags.c.tag]).select_from( - sa.join( - tags, node_tags, - tags.c.id == node_tags.c.tag_id - ) - ).where( - node_tags.c.node_id == 2 - ) - - res = db.execute(query) - tags = [t[0] for t in res] - self.assertItemsEqual(tags, ['controller', 'ceph-osd']) - - class TestPluginLinksConstraints(base.BaseAlembicMigrationTest): # see initial data in setup section def test_plugin_links_duplicate_cleanup(self):