From a7be9c3824cc1f826f65a2eff63ef3f868df1f62 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 26 Jan 2022 13:55:02 +0900 Subject: [PATCH] Nova: Remove unused server operations Some of the APIs implemented in manila.compute.nova.API are not used by any implementation. This change drops unused implementations rather than keeping them maintained for no use. Change-Id: I5195c31c6a95ed22eb89d734f3eea6a077eb2f68 --- manila/compute/nova.py | 32 ------------------------- manila/tests/compute/test_nova.py | 39 ------------------------------- 2 files changed, 71 deletions(-) diff --git a/manila/compute/nova.py b/manila/compute/nova.py index f7160d9c31..08fb046c90 100644 --- a/manila/compute/nova.py +++ b/manila/compute/nova.py @@ -162,34 +162,11 @@ class API(base.Base): raise exception.ManilaException(msg) return _untranslate_server_summary_view(server) - @translate_server_exception - def server_pause(self, context, instance_id): - novaclient(context).servers.pause(instance_id) - - @translate_server_exception - def server_unpause(self, context, instance_id): - novaclient(context).servers.unpause(instance_id) - - @translate_server_exception - def server_suspend(self, context, instance_id): - novaclient(context).servers.suspend(instance_id) - - @translate_server_exception - def server_resume(self, context, instance_id): - novaclient(context).servers.resume(instance_id) - @translate_server_exception def server_reboot(self, context, instance_id, soft_reboot=False): hardness = 'SOFT' if soft_reboot else 'HARD' novaclient(context).servers.reboot(instance_id, hardness) - @translate_server_exception - def server_rebuild(self, context, instance_id, image_id, password=None): - return _untranslate_server_summary_view( - novaclient(context).servers.rebuild(instance_id, image_id, - password) - ) - @translate_server_exception def instance_volume_attach(self, context, instance_id, volume_id, device=None): @@ -222,15 +199,6 @@ class API(base.Base): novaclient(context).servers.update(instance_id, name=name) ) - def update_server_volume(self, context, instance_id, volume_id, - new_volume_id): - novaclient(context).volumes.update_server_volume(instance_id, - volume_id, - new_volume_id) - - def keypair_create(self, context, name): - return novaclient(context).keypairs.create(name) - def keypair_import(self, context, name, public_key): return novaclient(context).keypairs.create(name, public_key) diff --git a/manila/tests/compute/test_nova.py b/manila/tests/compute/test_nova.py index 96e70a88b2..d5df358976 100644 --- a/manila/tests/compute/test_nova.py +++ b/manila/tests/compute/test_nova.py @@ -242,26 +242,6 @@ class NovaApiTestCase(test.TestCase): instance_id = 'instance_id' self.assertRaises(manila_e, self.api.server_get, self.ctx, instance_id) - def test_server_pause(self): - self.mock_object(self.novaclient.servers, 'pause') - self.api.server_pause(self.ctx, 'id1') - self.novaclient.servers.pause.assert_called_once_with('id1') - - def test_server_unpause(self): - self.mock_object(self.novaclient.servers, 'unpause') - self.api.server_unpause(self.ctx, 'id1') - self.novaclient.servers.unpause.assert_called_once_with('id1') - - def test_server_suspend(self): - self.mock_object(self.novaclient.servers, 'suspend') - self.api.server_suspend(self.ctx, 'id1') - self.novaclient.servers.suspend.assert_called_once_with('id1') - - def test_server_resume(self): - self.mock_object(self.novaclient.servers, 'resume') - self.api.server_resume(self.ctx, 'id1') - self.novaclient.servers.resume.assert_called_once_with('id1') - def test_server_reboot_hard(self): self.mock_object(self.novaclient.servers, 'reboot') self.api.server_reboot(self.ctx, 'id1') @@ -274,13 +254,6 @@ class NovaApiTestCase(test.TestCase): self.novaclient.servers.reboot.assert_called_once_with( 'id1', nova_servers.REBOOT_SOFT) - def test_server_rebuild(self): - self.mock_object(self.novaclient.servers, 'rebuild') - self.api.server_rebuild(self.ctx, 'id1', 'fake_image') - self.novaclient.servers.rebuild.assert_called_once_with('id1', - 'fake_image', - None) - def test_instance_volume_attach(self): self.mock_object(self.novaclient.volumes, 'create_server_volume') self.api.instance_volume_attach(self.ctx, 'instance_id', @@ -313,18 +286,6 @@ class NovaApiTestCase(test.TestCase): self.novaclient.servers.update.assert_called_once_with('id1', name='new_name') - def test_update_server_volume(self): - self.mock_object(self.novaclient.volumes, 'update_server_volume') - self.api.update_server_volume(self.ctx, 'instance_id', 'att_id', - 'new_vol_id') - (self.novaclient.volumes.update_server_volume. - assert_called_once_with('instance_id', 'att_id', 'new_vol_id')) - - def test_keypair_create(self): - self.mock_object(self.novaclient.keypairs, 'create') - self.api.keypair_create(self.ctx, 'keypair_name') - self.novaclient.keypairs.create.assert_called_once_with('keypair_name') - def test_keypair_import(self): self.mock_object(self.novaclient.keypairs, 'create') self.api.keypair_import(self.ctx, 'keypair_name', 'fake_pub_key')