From 8a80f126d9377c55ca836cb6a492aa9663c4043d Mon Sep 17 00:00:00 2001 From: Igor Malinovskiy Date: Tue, 3 Mar 2015 10:58:47 +0200 Subject: [PATCH] Remove copypasted export_location field from snapshots Field export_location in snapshots db table and models is leftover from Cinder, which should be removed. - Remove export_location field from share_snapshots table in manila_init migration - Create db migration which removes export_location field from share_snapshots in db - Remove usages of export_location in snapshots related code - Update functional and unit tests Change-Id: I7566e74479cd7474d5576edae0e21b6eca18c394 --- .../api/share/admin/test_shares_actions.py | 4 +- .../tempest/tempest/api/share/test_shares.py | 2 +- .../tempest/api/share/test_shares_actions.py | 4 +- manila/api/v1/share_snapshots.py | 3 +- manila/api/views/share_snapshots.py | 1 - ..._remove_share_snapshots_export_location.py | 38 +++++++++++++++++++ manila/db/sqlalchemy/models.py | 1 - manila/share/api.py | 3 +- manila/tests/api/v1/test_share_snapshots.py | 3 -- .../share/drivers/zfssa/test_zfssashare.py | 1 - manila/tests/share/test_api.py | 2 - 11 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 manila/db/migrations/alembic/versions/4ee2cf4be19a_remove_share_snapshots_export_location.py diff --git a/contrib/tempest/tempest/api/share/admin/test_shares_actions.py b/contrib/tempest/tempest/api/share/admin/test_shares_actions.py index 1dafbe77..8719c218 100644 --- a/contrib/tempest/tempest/api/share/admin/test_shares_actions.py +++ b/contrib/tempest/tempest/api/share/admin/test_shares_actions.py @@ -322,7 +322,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest): # verify keys expected_keys = ["status", "links", "share_id", "name", - "export_location", "share_proto", "created_at", + "share_proto", "created_at", "description", "id", "share_size"] actual_keys = get.keys() [self.assertIn(key, actual_keys) for key in expected_keys] @@ -369,7 +369,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest): # verify keys keys = ["status", "links", "share_id", "name", - "export_location", "share_proto", "created_at", + "share_proto", "created_at", "description", "id", "share_size"] [self.assertIn(key, sn.keys()) for sn in snaps for key in keys] diff --git a/contrib/tempest/tempest/api/share/test_shares.py b/contrib/tempest/tempest/api/share/test_shares.py index 23a037f1..1a39e9f3 100644 --- a/contrib/tempest/tempest/api/share/test_shares.py +++ b/contrib/tempest/tempest/api/share/test_shares.py @@ -66,7 +66,7 @@ class SharesNFSTest(base.BaseSharesTest): # create snapshot resp, snap = self.create_snapshot_wait_for_active(self.share["id"]) self.assertIn(int(resp["status"]), self.HTTP_SUCCESS) - detailed_elements = {'name', 'id', 'description', 'export_location', + detailed_elements = {'name', 'id', 'description', 'created_at', 'share_proto', 'size', 'share_size', 'share_id', 'status', 'links'} self.assertTrue(detailed_elements.issubset(snap.keys()), diff --git a/contrib/tempest/tempest/api/share/test_shares_actions.py b/contrib/tempest/tempest/api/share/test_shares_actions.py index 86c41073..dd877b77 100644 --- a/contrib/tempest/tempest/api/share/test_shares_actions.py +++ b/contrib/tempest/tempest/api/share/test_shares_actions.py @@ -266,7 +266,7 @@ class SharesActionsTest(base.BaseSharesTest): # verify keys expected_keys = ["status", "links", "share_id", "name", - "export_location", "share_proto", "created_at", + "share_proto", "created_at", "description", "id", "share_size"] actual_keys = get.keys() [self.assertIn(key, actual_keys) for key in expected_keys] @@ -313,7 +313,7 @@ class SharesActionsTest(base.BaseSharesTest): # verify keys keys = ["status", "links", "share_id", "name", - "export_location", "share_proto", "created_at", + "share_proto", "created_at", "description", "id", "share_size"] [self.assertIn(key, sn.keys()) for sn in snaps for key in keys] diff --git a/manila/api/v1/share_snapshots.py b/manila/api/v1/share_snapshots.py index 6f8e65ae..0feb6bc4 100644 --- a/manila/api/v1/share_snapshots.py +++ b/manila/api/v1/share_snapshots.py @@ -33,8 +33,7 @@ LOG = log.getLogger(__name__) def make_snapshot(elem): attrs = ['id', 'size', 'status', 'name', 'description', 'share_proto', - 'export_location', 'links', 'share_id', 'created_at', - 'share_size'] + 'links', 'share_id', 'created_at', 'share_size'] for attr in attrs: elem.set(attr) diff --git a/manila/api/views/share_snapshots.py b/manila/api/views/share_snapshots.py index 6d90b9c7..a74f6536 100644 --- a/manila/api/views/share_snapshots.py +++ b/manila/api/views/share_snapshots.py @@ -52,7 +52,6 @@ class ViewBuilder(common.ViewBuilder): 'description': snapshot.get('display_description'), 'size': snapshot.get('size'), 'share_proto': snapshot.get('share_proto'), - 'export_location': snapshot.get('export_location'), 'links': self._get_links(request, snapshot['id']) } } diff --git a/manila/db/migrations/alembic/versions/4ee2cf4be19a_remove_share_snapshots_export_location.py b/manila/db/migrations/alembic/versions/4ee2cf4be19a_remove_share_snapshots_export_location.py new file mode 100644 index 00000000..3f6e6279 --- /dev/null +++ b/manila/db/migrations/alembic/versions/4ee2cf4be19a_remove_share_snapshots_export_location.py @@ -0,0 +1,38 @@ +# Copyright 2015 Mirantis Inc. +# All Rights Reserved. +# +# 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. + +"""Remove share_snapshots.export_location + +Revision ID: 4ee2cf4be19a +Revises: 17115072e1c3 +Create Date: 2015-02-26 11:11:55.734663 + +""" + +# revision identifiers, used by Alembic. +revision = '4ee2cf4be19a' +down_revision = '17115072e1c3' + +from alembic import op +import sqlalchemy as sql + + +def upgrade(): + op.drop_column('share_snapshots', 'export_location') + + +def downgrade(): + op.add_column('share_snapshots', + sql.Column('export_location', sql.String(255))) diff --git a/manila/db/sqlalchemy/models.py b/manila/db/sqlalchemy/models.py index 7c3c4575..4005433c 100644 --- a/manila/db/sqlalchemy/models.py +++ b/manila/db/sqlalchemy/models.py @@ -291,7 +291,6 @@ class ShareSnapshot(BASE, ManilaBase): display_description = Column(String(255)) share_size = Column(Integer) share_proto = Column(String(255)) - export_location = Column(String(255)) share = orm.relationship(Share, backref="snapshots", foreign_keys=share_id, primaryjoin='and_(' diff --git a/manila/share/api.py b/manila/share/api.py index 86f394f9..2632d149 100644 --- a/manila/share/api.py +++ b/manila/share/api.py @@ -308,8 +308,7 @@ class API(base.Base): 'share_size': share['size'], 'display_name': name, 'display_description': description, - 'share_proto': share['share_proto'], - 'export_location': share['export_location']} + 'share_proto': share['share_proto']} try: snapshot = self.db.share_snapshot_create(context, options) diff --git a/manila/tests/api/v1/test_share_snapshots.py b/manila/tests/api/v1/test_share_snapshots.py index 7fdb7f55..5ce75c39 100644 --- a/manila/tests/api/v1/test_share_snapshots.py +++ b/manila/tests/api/v1/test_share_snapshots.py @@ -72,7 +72,6 @@ class ShareSnapshotApiTest(test.TestCase): 'size': 1, 'description': 'fake_share_description', 'share_proto': 'fakesnapproto', - 'export_location': 'fakesnaplocation', 'links': [ { 'href': 'http://localhost/v1/fake/snapshots/200', @@ -125,7 +124,6 @@ class ShareSnapshotApiTest(test.TestCase): 'size': 1, 'description': 'displaysnapdesc', 'share_proto': 'fakesnapproto', - 'export_location': 'fakesnaplocation', 'links': [ { 'href': 'http://localhost/v1/fake/snapshots/200', @@ -300,7 +298,6 @@ class ShareSnapshotApiTest(test.TestCase): 'name': 'displaysnapname', 'description': 'displaysnapdesc', 'share_proto': 'fakesnapproto', - 'export_location': 'fakesnaplocation', 'links': [ { 'href': 'http://localhost/v1/fake/snapshots/' diff --git a/manila/tests/share/drivers/zfssa/test_zfssashare.py b/manila/tests/share/drivers/zfssa/test_zfssashare.py index 93f985c9..55f1f95d 100644 --- a/manila/tests/share/drivers/zfssa/test_zfssashare.py +++ b/manila/tests/share/drivers/zfssa/test_zfssashare.py @@ -46,7 +46,6 @@ class ZFSSAShareDriverTestCase(test.TestCase): 'name': 'fakesnapshotname', 'share_size': 1, 'share_proto': 'NFS', - 'export_location': '127.0.0.1:/mnt/nfs/volume-00002', } access = { diff --git a/manila/tests/share/test_api.py b/manila/tests/share/test_api.py index 3139373e..b8a29c0c 100644 --- a/manila/tests/share/test_api.py +++ b/manila/tests/share/test_api.py @@ -79,7 +79,6 @@ def fake_snapshot(id, **kwargs): 'display_name': 'fakename', 'display_description': 'fakedesc', 'share_proto': 'nfs', - 'export_location': 'fake_location', 'progress': 'fakeprogress99%', 'scheduled_at': datetime.datetime(1, 1, 1, 1, 1, 1), 'launched_at': datetime.datetime(1, 1, 1, 1, 1, 1), @@ -489,7 +488,6 @@ class ShareAPITestCase(test.TestCase): 'display_name': fake_name, 'display_description': fake_desc, 'share_proto': share['share_proto'], - 'export_location': share['export_location'], } with mock.patch.object(db_driver, 'share_snapshot_create', mock.Mock(return_value=snapshot)):