Updated scenario boot-and-delete-server-with-keypairs

Included kwargs missing in the create-server code
Closes-Bug:#1445915

Co-Authored-By: Roman Vasilets <rvasilets@mirantis.com>
Co-Authored-By: Swapnil Kulkarni <me@coolsvap.net>
Change-Id: I961334d097d566127f4930d94e7b21b16e728d54
This commit is contained in:
Swapnil Kulkarni 2015-05-15 05:03:04 +00:00 committed by Roman Vasilets
parent fd628a6af3
commit d21eb8695f
2 changed files with 17 additions and 4 deletions

View File

@ -58,6 +58,7 @@ class NovaKeypair(utils.NovaScenario):
@validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["nova"]})
def boot_and_delete_server_with_keypair(self, image, flavor,
server_kwargs=None,
**kwargs):
"""Boot and delete server with keypair.
@ -69,11 +70,15 @@ class NovaKeypair(utils.NovaScenario):
:param image: ID of the image to be used for server creation
:param flavor: ID of the flavor to be used for server creation
:param server_kwargs: Optional additional arguments for VM creation
:param kwargs: Optional additional arguments for keypair creation
"""
server_kwargs = server_kwargs or {}
keypair = self._create_keypair(**kwargs)
server = self._boot_server(image, flavor,
key_name=keypair)
key_name=keypair,
**server_kwargs)
self._delete_server(server)
self._delete_keypair(keypair)

View File

@ -51,12 +51,20 @@ class NovaKeypairTestCase(test.ScenarioTestCase):
scenario._delete_server = mock.MagicMock()
scenario._delete_keypair = mock.MagicMock()
scenario.boot_and_delete_server_with_keypair("img", 1)
fake_server_args = {
"foo": 1,
"bar": 2,
}
scenario._create_keypair.assert_called_once_with()
scenario.boot_and_delete_server_with_keypair(
"img", 1, server_kwargs=fake_server_args,
fake_arg1="foo", fake_arg2="bar")
scenario._create_keypair.assert_called_once_with(
fake_arg1="foo", fake_arg2="bar")
scenario._boot_server.assert_called_once_with(
"img", 1, key_name="foo_keypair")
"img", 1, foo=1, bar=2, key_name="foo_keypair")
scenario._delete_server.assert_called_once_with("foo_server")