From 004b2ab2fbad3655915f226ca2f479b35f7bfc46 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 19 Dec 2022 16:08:27 +0000 Subject: [PATCH] compute: Switch server restore to SDK Change-Id: I8df9711b736991c01136988aa06c8540d640f52f Signed-off-by: Stephen Finucane Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/868108 --- openstackclient/compute/v2/server.py | 11 ++++++----- openstackclient/tests/unit/compute/v2/test_server.py | 11 +++-------- ...igrate-server-restore-to-sdk-4540f26753031779.yaml | 4 ++++ 3 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 releasenotes/notes/migrate-server-restore-to-sdk-4540f26753031779.yaml diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index 8496a13eb9..dbeaf51323 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -4050,12 +4050,13 @@ class RestoreServer(command.Command): return parser def take_action(self, parsed_args): - compute_client = self.app.client_manager.compute + compute_client = self.app.client_manager.sdk_connection.compute for server in parsed_args.server: - utils.find_resource( - compute_client.servers, - server - ).restore() + server_id = compute_client.find_server( + server, + ignore_missing=False, + ).id + compute_client.restore_server(server_id) class ResumeServer(command.Command): diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py index f412216278..bf738bfc1e 100644 --- a/openstackclient/tests/unit/compute/v2/test_server.py +++ b/openstackclient/tests/unit/compute/v2/test_server.py @@ -7499,21 +7499,16 @@ class TestServerRevertMigration(TestServer): class TestServerRestore(TestServer): def setUp(self): - super(TestServerRestore, self).setUp() + super().setUp() # Get the command object to test self.cmd = server.RestoreServer(self.app, None) - # Set methods to be tested. - self.methods = { - 'restore': None, - } - def test_server_restore_one_server(self): - self.run_method_with_servers('restore', 1) + self.run_method_with_sdk_servers('restore_server', 1) def test_server_restore_multi_servers(self): - self.run_method_with_servers('restore', 3) + self.run_method_with_sdk_servers('restore_server', 3) class TestServerResume(TestServer): diff --git a/releasenotes/notes/migrate-server-restore-to-sdk-4540f26753031779.yaml b/releasenotes/notes/migrate-server-restore-to-sdk-4540f26753031779.yaml new file mode 100644 index 0000000000..1adc40beae --- /dev/null +++ b/releasenotes/notes/migrate-server-restore-to-sdk-4540f26753031779.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + The ``server restore`` command has been migrated to SDK.