Merge "Add NovaServers.boot_and_get_console_url"
This commit is contained in:
commit
40537a3b25
@ -401,6 +401,28 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaServers.boot_and_get_console_url:
|
||||
{% for s in ("novnc", "xvpvnc") %}
|
||||
-
|
||||
args:
|
||||
flavor:
|
||||
name: "{{flavor_name}}"
|
||||
image:
|
||||
name: "{{image_name}}"
|
||||
console_type: {{s}}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
{% endfor %}
|
||||
|
||||
NovaServers.resize_server:
|
||||
-
|
||||
args:
|
||||
|
@ -1063,3 +1063,33 @@ class BootServerAndListInterfaces(utils.NovaScenario):
|
||||
"""
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
self._list_interfaces(server)
|
||||
|
||||
|
||||
@validation.add(
|
||||
"enum", param_name="console_type",
|
||||
values=["novnc", "xvpvnc", "spice-html5", "rdp-html5", "serial", "webmks"])
|
||||
@types.convert(image={"type": "glance_image"},
|
||||
flavor={"type": "nova_flavor"})
|
||||
@validation.add("image_valid_on_flavor", flavor_param="flavor",
|
||||
image_param="image")
|
||||
@validation.add("required_services", services=[consts.Service.NOVA])
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]},
|
||||
name="NovaServers.boot_and_get_console_url")
|
||||
class BootAndGetConsoleUrl(utils.NovaScenario):
|
||||
|
||||
def run(self, image, flavor, console_type, **kwargs):
|
||||
"""Retrieve a console url of a server.
|
||||
|
||||
This simple scenario tests retrieving the console url of a server.
|
||||
|
||||
:param image: image to be used to boot an instance
|
||||
:param flavor: flavor to be used to boot an instance
|
||||
:param console_type: type can be novnc/xvpvnc for protocol vnc;
|
||||
spice-html5 for protocol spice; rdp-html5 for
|
||||
protocol rdp; serial for protocol serial.
|
||||
webmks for protocol mks (since version 2.8).
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
self._get_console_url_server(server, console_type)
|
||||
|
@ -134,6 +134,21 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
return self.clients("nova").servers.get_console_output(server,
|
||||
length=length)
|
||||
|
||||
@atomic.action_timer("nova.get_console_url_server")
|
||||
def _get_console_url_server(self, server, console_type):
|
||||
"""Retrieve a console url of a server.
|
||||
|
||||
:param server: server to get console url for
|
||||
:param console_type: type can be novnc/xvpvnc for protocol vnc;
|
||||
spice-html5 for protocol spice; rdp-html5 for
|
||||
protocol rdp; serial for protocol serial.
|
||||
webmks for protocol mks (since version 2.8).
|
||||
|
||||
:returns: An instance of novaclient.base.DictWithMeta
|
||||
"""
|
||||
return self.clients("nova").servers.get_console_url(server,
|
||||
console_type)
|
||||
|
||||
@atomic.action_timer("nova.reboot_server")
|
||||
def _reboot_server(self, server):
|
||||
"""Reboot a server with hard reboot.
|
||||
|
32
samples/tasks/scenarios/nova/boot-and-get-console-url.json
Normal file
32
samples/tasks/scenarios/nova/boot-and-get-console-url.json
Normal file
@ -0,0 +1,32 @@
|
||||
{% set flavor_name = flavor_name or "m1.tiny" %}
|
||||
{
|
||||
"NovaServers.boot_and_get_console_url": [
|
||||
{
|
||||
"args": {
|
||||
"flavor": {
|
||||
"name": "{{flavor_name}}"
|
||||
},
|
||||
"image": {
|
||||
"name": "^cirros.*-disk$"
|
||||
},
|
||||
"console_type": "novnc"
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 4,
|
||||
"concurrency": 2
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 2,
|
||||
"users_per_tenant": 2
|
||||
}
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
21
samples/tasks/scenarios/nova/boot-and-get-console-url.yaml
Normal file
21
samples/tasks/scenarios/nova/boot-and-get-console-url.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
{% set flavor_name = flavor_name or "m1.tiny" %}
|
||||
---
|
||||
NovaServers.boot_and_get_console_url:
|
||||
-
|
||||
args:
|
||||
flavor:
|
||||
name: "{{flavor_name}}"
|
||||
image:
|
||||
name: "^cirros.*-disk$"
|
||||
console_type: "novnc"
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 4
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
@ -829,6 +829,23 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
||||
scenario._get_server_console_output.assert_called_once_with(server,
|
||||
length)
|
||||
|
||||
def test_boot_and_get_console_url(self):
|
||||
server = fakes.FakeServer()
|
||||
image = fakes.FakeImage()
|
||||
flavor = fakes.FakeFlavor()
|
||||
kwargs = {"fakearg": "fakearg"}
|
||||
|
||||
scenario = servers.BootAndGetConsoleUrl(self.context)
|
||||
scenario._boot_server = mock.MagicMock(return_value=server)
|
||||
scenario._get_console_url_server = mock.MagicMock()
|
||||
|
||||
scenario.run(image, flavor, console_type="novnc", **kwargs)
|
||||
|
||||
scenario._boot_server.assert_called_once_with(image, flavor,
|
||||
**kwargs)
|
||||
scenario._get_console_url_server.assert_called_once_with(
|
||||
server, "novnc")
|
||||
|
||||
@mock.patch(NOVA_SERVERS_MODULE + ".network_wrapper.wrap")
|
||||
def test_boot_and_associate_floating_ip(self, mock_wrap):
|
||||
scenario = servers.BootAndAssociateFloatingIp(self.context)
|
||||
|
@ -495,6 +495,15 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.get_console_output_server")
|
||||
|
||||
def test__get_console_url(self):
|
||||
nova_scenario = utils.NovaScenario(context=self.context)
|
||||
nova_scenario._get_console_url_server(self.server, "foo")
|
||||
self.clients(
|
||||
"nova").servers.get_console_url.assert_called_once_with(
|
||||
self.server, "foo")
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.get_console_url_server")
|
||||
|
||||
def test__associate_floating_ip(self):
|
||||
nova_scenario = utils.NovaScenario(context=self.context)
|
||||
nova_scenario._associate_floating_ip(self.server, self.floating_ip)
|
||||
|
Loading…
Reference in New Issue
Block a user