Merge "Updated scenario boot-and-delete-server-with-keypairs"
This commit is contained in:
commit
ecdd65affc
@ -58,6 +58,7 @@ class NovaKeypair(utils.NovaScenario):
|
|||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@scenario.configure(context={"cleanup": ["nova"]})
|
@scenario.configure(context={"cleanup": ["nova"]})
|
||||||
def boot_and_delete_server_with_keypair(self, image, flavor,
|
def boot_and_delete_server_with_keypair(self, image, flavor,
|
||||||
|
server_kwargs=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
"""Boot and delete server with keypair.
|
"""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 image: ID of the image to be used for server creation
|
||||||
:param flavor: ID of the flavor 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
|
:param kwargs: Optional additional arguments for keypair creation
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
server_kwargs = server_kwargs or {}
|
||||||
|
|
||||||
keypair = self._create_keypair(**kwargs)
|
keypair = self._create_keypair(**kwargs)
|
||||||
server = self._boot_server(image, flavor,
|
server = self._boot_server(image, flavor,
|
||||||
key_name=keypair)
|
key_name=keypair,
|
||||||
|
**server_kwargs)
|
||||||
self._delete_server(server)
|
self._delete_server(server)
|
||||||
self._delete_keypair(keypair)
|
self._delete_keypair(keypair)
|
||||||
|
@ -51,12 +51,20 @@ class NovaKeypairTestCase(test.ScenarioTestCase):
|
|||||||
scenario._delete_server = mock.MagicMock()
|
scenario._delete_server = mock.MagicMock()
|
||||||
scenario._delete_keypair = 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(
|
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")
|
scenario._delete_server.assert_called_once_with("foo_server")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user