From 8d9ef0b7c8a40d2bae6386bd82ab300168bfde22 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Wed, 29 Jul 2015 01:46:14 +0300 Subject: [PATCH] Service Instance: Add instance reboot method This patch adds a method in the Service Instance manager class, responsible of rebooting service instances. This will be used by the soon to be introduced Windows Driver. Change-Id: Id82803339f5ddfef64eaf30a72d2c1632c4c6a9b Partially-implements: blueprint windows-smb-support --- manila/share/drivers/service_instance.py | 5 +++++ manila/tests/fake_compute.py | 3 +++ .../tests/share/drivers/test_service_instance.py | 14 ++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/manila/share/drivers/service_instance.py b/manila/share/drivers/service_instance.py index 77bd1e8616..da9c81d105 100644 --- a/manila/share/drivers/service_instance.py +++ b/manila/share/drivers/service_instance.py @@ -629,6 +629,11 @@ class ServiceInstanceManager(object): timeout=timeout, instance_status=instance_status)) + def reboot_server(self, server, soft_reboot=False): + self.compute_api.server_reboot(self.admin_context, + server['instance_id'], + soft_reboot) + @six.add_metaclass(abc.ABCMeta) class BaseNetworkhelper(object): diff --git a/manila/tests/fake_compute.py b/manila/tests/fake_compute.py index fdf14ff299..cac70bd118 100644 --- a/manila/tests/fake_compute.py +++ b/manila/tests/fake_compute.py @@ -90,6 +90,9 @@ class API(object): def server_get_by_name_or_id(self, *args, **kwargs): pass + def server_reboot(self, *args, **kwargs): + pass + def keypair_list(self, *args, **kwargs): pass diff --git a/manila/tests/share/drivers/test_service_instance.py b/manila/tests/share/drivers/test_service_instance.py index 4324327a85..1cf7bf3148 100644 --- a/manila/tests/share/drivers/test_service_instance.py +++ b/manila/tests/share/drivers/test_service_instance.py @@ -1210,6 +1210,20 @@ class ServiceInstanceManagerTestCase(test.TestCase): expected_try_count=1, expected_ret_val=mock_instance) + def test_reboot_server(self): + fake_server = {'instance_id': mock.sentinel.instance_id} + soft_reboot = True + + mock_reboot = mock.Mock() + self.mock_object(self._manager.compute_api, 'server_reboot', + mock_reboot) + + self._manager.reboot_server(fake_server, soft_reboot) + + mock_reboot.assert_called_once_with(self._manager.admin_context, + fake_server['instance_id'], + soft_reboot) + class BaseNetworkHelperTestCase(test.TestCase): """Tests Base network helper for service instance."""