Switch server suspend and server resume to SDK

Switch the server suspend and server resume commands from novaclient to
SDK. Use the SDK versions of test fakes to support fake Server
resources.

Change-Id: Idd0b4f13fab0f238e42844a7d759538bbda24f68
This commit is contained in:
Thrivikram Mudunuri
2021-11-13 17:39:41 -05:00
parent b515fe61b2
commit ff96fea012
3 changed files with 19 additions and 14 deletions

View File

@@ -4081,13 +4081,13 @@ class ResumeServer(command.Command):
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
compute_client = self.app.client_manager.sdk_connection.compute
compute_client = self.app.client_manager.compute
for server in parsed_args.server: for server in parsed_args.server:
utils.find_resource( server_id = compute_client.find_server(
compute_client.servers,
server, server,
).resume() ignore_missing=False,
).id
compute_client.resume_server(server_id)
class SetServer(command.Command): class SetServer(command.Command):
@@ -4652,13 +4652,13 @@ class SuspendServer(command.Command):
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
compute_client = self.app.client_manager.sdk_connection.compute
compute_client = self.app.client_manager.compute
for server in parsed_args.server: for server in parsed_args.server:
utils.find_resource( server_id = compute_client.find_server(
compute_client.servers,
server, server,
).suspend() ignore_missing=False,
).id
compute_client.suspend_server(server_id)
class UnlockServer(command.Command): class UnlockServer(command.Command):

View File

@@ -7617,10 +7617,10 @@ class TestServerResume(TestServer):
} }
def test_server_resume_one_server(self): def test_server_resume_one_server(self):
self.run_method_with_servers('resume', 1) self.run_method_with_sdk_servers('resume_server', 1)
def test_server_resume_multi_servers(self): def test_server_resume_multi_servers(self):
self.run_method_with_servers('resume', 3) self.run_method_with_sdk_servers('resume_server', 3)
class TestServerSet(TestServer): class TestServerSet(TestServer):
@@ -8284,10 +8284,10 @@ class TestServerSuspend(TestServer):
} }
def test_server_suspend_one_server(self): def test_server_suspend_one_server(self):
self.run_method_with_servers('suspend', 1) self.run_method_with_sdk_servers('suspend_server', 1)
def test_server_suspend_multi_servers(self): def test_server_suspend_multi_servers(self):
self.run_method_with_servers('suspend', 3) self.run_method_with_sdk_servers('suspend_server', 3)
class TestServerUnlock(TestServer): class TestServerUnlock(TestServer):

View File

@@ -0,0 +1,5 @@
---
features:
- |
Migrate ``server suspend`` and ``server resume`` commands from novaclient
to sdk.