Add param volume_type when creating volume in nova scenarios

Volume_type can specify a certain volume type when there are
multiple backends.

Change-Id: Ifdc80f5bb6c0a05c64f0b0c6b28b536a2e46f714
This commit is contained in:
Lv Fumei 2016-07-01 17:09:21 +08:00
parent cf0dc61303
commit 65bb33ed97
11 changed files with 56 additions and 13 deletions

4
rally-jobs/nova.yaml Normal file → Executable file
View File

@ -1,6 +1,7 @@
{%- set cirros_image_url = "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img" %} {%- set cirros_image_url = "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img" %}
{% set image_name = "^(cirros.*uec|TestVM)$" %} {% set image_name = "^(cirros.*uec|TestVM)$" %}
{% set flavor_name = "m1.tiny" %} {% set flavor_name = "m1.tiny" %}
{% set volume_type = "" %}
--- ---
Authenticate.validate_nova: Authenticate.validate_nova:
- -
@ -465,6 +466,7 @@
image: image:
name: {{image_name}} name: {{image_name}}
volume_size: 1 volume_size: 1
volume_type: {{volume_type}}
runner: runner:
type: "constant" type: "constant"
times: 2 times: 2
@ -485,6 +487,7 @@
image: image:
name: {{image_name}} name: {{image_name}}
volume_size: 1 volume_size: 1
volume_type: {{volume_type}}
runner: runner:
type: "constant" type: "constant"
times: 2 times: 2
@ -1107,6 +1110,7 @@
image: image:
name: {{image_name}} name: {{image_name}}
volume_size: 1 volume_size: 1
volume_type: {{volume_type}}
runner: runner:
type: "constant" type: "constant"
times: 2 times: 2

View File

@ -135,6 +135,7 @@ class NovaServers(utils.NovaScenario,
@scenario.configure(context={"cleanup": ["nova", "cinder"]}) @scenario.configure(context={"cleanup": ["nova", "cinder"]})
def boot_server_from_volume_and_delete(self, image, flavor, def boot_server_from_volume_and_delete(self, image, flavor,
volume_size, volume_size,
volume_type=None,
min_sleep=0, max_sleep=0, min_sleep=0, max_sleep=0,
force_delete=False, **kwargs): force_delete=False, **kwargs):
"""Boot a server from volume and then delete it. """Boot a server from volume and then delete it.
@ -147,12 +148,15 @@ class NovaServers(utils.NovaScenario,
:param image: image to be used to boot an instance :param image: image to be used to boot an instance
:param flavor: flavor to be used to boot an instance :param flavor: flavor to be used to boot an instance
:param volume_size: volume size (in GB) :param volume_size: volume size (in GB)
:param volume_type: specifies volume type when there are
multiple backends
:param min_sleep: Minimum sleep time in seconds (non-negative) :param min_sleep: Minimum sleep time in seconds (non-negative)
:param max_sleep: Maximum sleep time in seconds (non-negative) :param max_sleep: Maximum sleep time in seconds (non-negative)
:param force_delete: True if force_delete should be used :param force_delete: True if force_delete should be used
:param kwargs: Optional additional arguments for server creation :param kwargs: Optional additional arguments for server creation
""" """
volume = self._create_volume(volume_size, imageRef=image) volume = self._create_volume(volume_size, imageRef=image,
volume_type=volume_type)
block_device_mapping = {"vda": "%s:::1" % volume.id} block_device_mapping = {"vda": "%s:::1" % volume.id}
server = self._boot_server(None, flavor, server = self._boot_server(None, flavor,
block_device_mapping=block_device_mapping, block_device_mapping=block_device_mapping,
@ -278,7 +282,8 @@ class NovaServers(utils.NovaScenario,
@validation.required_openstack(users=True) @validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["nova", "cinder"]}) @scenario.configure(context={"cleanup": ["nova", "cinder"]})
def boot_server_from_volume(self, image, flavor, volume_size, def boot_server_from_volume(self, image, flavor, volume_size,
auto_assign_nic=False, **kwargs): volume_type=None, auto_assign_nic=False,
**kwargs):
"""Boot a server from volume. """Boot a server from volume.
The scenario first creates a volume and then a server. The scenario first creates a volume and then a server.
@ -287,10 +292,13 @@ class NovaServers(utils.NovaScenario,
:param image: image to be used to boot an instance :param image: image to be used to boot an instance
:param flavor: flavor to be used to boot an instance :param flavor: flavor to be used to boot an instance
:param volume_size: volume size (in GB) :param volume_size: volume size (in GB)
:param volume_type: specifies volume type when there are
multiple backends
:param auto_assign_nic: True if NICs should be assigned :param auto_assign_nic: True if NICs should be assigned
:param kwargs: Optional additional arguments for server creation :param kwargs: Optional additional arguments for server creation
""" """
volume = self._create_volume(volume_size, imageRef=image) volume = self._create_volume(volume_size, imageRef=image,
volume_type=volume_type)
block_device_mapping = {"vda": "%s:::1" % volume.id} block_device_mapping = {"vda": "%s:::1" % volume.id}
self._boot_server(None, flavor, auto_assign_nic=auto_assign_nic, self._boot_server(None, flavor, auto_assign_nic=auto_assign_nic,
block_device_mapping=block_device_mapping, block_device_mapping=block_device_mapping,
@ -649,6 +657,7 @@ class NovaServers(utils.NovaScenario,
@scenario.configure(context={"cleanup": ["nova", "cinder"]}) @scenario.configure(context={"cleanup": ["nova", "cinder"]})
def boot_server_from_volume_and_live_migrate(self, image, flavor, def boot_server_from_volume_and_live_migrate(self, image, flavor,
volume_size, volume_size,
volume_type=None,
block_migration=False, block_migration=False,
disk_over_commit=False, disk_over_commit=False,
force_delete=False, force_delete=False,
@ -668,6 +677,8 @@ class NovaServers(utils.NovaScenario,
:param image: image to be used to boot an instance :param image: image to be used to boot an instance
:param flavor: flavor to be used to boot an instance :param flavor: flavor to be used to boot an instance
:param volume_size: volume size (in GB) :param volume_size: volume size (in GB)
:param volume_type: specifies volume type when there are
multiple backends
:param block_migration: Specifies the migration type :param block_migration: Specifies the migration type
:param disk_over_commit: Specifies whether to allow overcommit :param disk_over_commit: Specifies whether to allow overcommit
on migrated instance or not on migrated instance or not
@ -676,7 +687,8 @@ class NovaServers(utils.NovaScenario,
:param max_sleep: Maximum sleep time in seconds (non-negative) :param max_sleep: Maximum sleep time in seconds (non-negative)
:param kwargs: Optional additional arguments for server creation :param kwargs: Optional additional arguments for server creation
""" """
volume = self._create_volume(volume_size, imageRef=image) volume = self._create_volume(volume_size, imageRef=image,
volume_type=volume_type)
block_device_mapping = {"vda": "%s:::1" % volume.id} block_device_mapping = {"vda": "%s:::1" % volume.id}
server = self._boot_server(None, flavor, server = self._boot_server(None, flavor,
block_device_mapping=block_device_mapping, block_device_mapping=block_device_mapping,
@ -889,6 +901,7 @@ class NovaServers(utils.NovaScenario,
@validation.required_openstack(users=True) @validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["nova", "cinder"]}) @scenario.configure(context={"cleanup": ["nova", "cinder"]})
def boot_server_from_volume_snapshot(self, image, flavor, volume_size, def boot_server_from_volume_snapshot(self, image, flavor, volume_size,
volume_type=None,
auto_assign_nic=False, **kwargs): auto_assign_nic=False, **kwargs):
"""Boot a server from a snapshot. """Boot a server from a snapshot.
@ -900,10 +913,13 @@ class NovaServers(utils.NovaScenario,
:param image: image to be used to boot an instance :param image: image to be used to boot an instance
:param flavor: flavor to be used to boot an instance :param flavor: flavor to be used to boot an instance
:param volume_size: volume size (in GB) :param volume_size: volume size (in GB)
:param volume_type: specifies volume type when there are
multiple backends
:param auto_assign_nic: True if NICs should be assigned :param auto_assign_nic: True if NICs should be assigned
:param kwargs: Optional additional arguments for server creation :param kwargs: Optional additional arguments for server creation
""" """
volume = self._create_volume(volume_size, imageRef=image) volume = self._create_volume(volume_size, imageRef=image,
volume_type=volume_type)
snapshot = self._create_snapshot(volume.id, False) snapshot = self._create_snapshot(volume.id, False)
block_device_mapping = {"vda": "%s:snap::1" % snapshot.id} block_device_mapping = {"vda": "%s:snap::1" % snapshot.id}
self._boot_server(None, flavor, auto_assign_nic=auto_assign_nic, self._boot_server(None, flavor, auto_assign_nic=auto_assign_nic,

View File

@ -1,4 +1,5 @@
{% set flavor_name = flavor_name or "m1.tiny" %} {% set flavor_name = flavor_name or "m1.tiny" %}
{% set volume_type = volume_type or "" %}
{ {
"NovaServers.boot_server_from_volume_and_delete": [ "NovaServers.boot_server_from_volume_and_delete": [
{ {
@ -10,6 +11,7 @@
"name": "^cirros.*uec$" "name": "^cirros.*uec$"
}, },
"volume_size": 10, "volume_size": 10,
"volume_type": "{{volume_type}}",
"force_delete": false "force_delete": false
}, },
"runner": { "runner": {

View File

@ -1,4 +1,5 @@
{% set flavor_name = flavor_name or "m1.tiny" %} {% set flavor_name = flavor_name or "m1.tiny" %}
{% set volume_type = volume_type or "" %}
--- ---
NovaServers.boot_server_from_volume_and_delete: NovaServers.boot_server_from_volume_and_delete:
- -
@ -8,6 +9,7 @@
image: image:
name: "^cirros.*uec$" name: "^cirros.*uec$"
volume_size: 10 volume_size: 10
volume_type: "{{volume_type}}"
force_delete: false force_delete: false
runner: runner:
type: "constant" type: "constant"

View File

@ -1,4 +1,5 @@
{% set flavor_name = flavor_name or "m1.tiny" %} {% set flavor_name = flavor_name or "m1.tiny" %}
{% set volume_type = volume_type or "" %}
{ {
"NovaServers.boot_server_from_volume_snapshot": [ "NovaServers.boot_server_from_volume_snapshot": [
{ {
@ -9,7 +10,8 @@
"image": { "image": {
"name": "^cirros.*uec$" "name": "^cirros.*uec$"
}, },
"volume_size": 10 "volume_size": 10,
"volume_type": "{{volume_type}}"
}, },
"runner": { "runner": {
"type": "constant", "type": "constant",

View File

@ -1,4 +1,5 @@
{% set flavor_name = flavor_name or "m1.tiny" %} {% set flavor_name = flavor_name or "m1.tiny" %}
{% set volume_type = volume_type or "" %}
--- ---
NovaServers.boot_server_from_volume_snapshot: NovaServers.boot_server_from_volume_snapshot:
- -
@ -8,6 +9,7 @@
image: image:
name: "^cirros.*uec$" name: "^cirros.*uec$"
volume_size: 10 volume_size: 10
volume_type: "{{volume_type}}"
runner: runner:
type: "constant" type: "constant"
times: 10 times: 10

4
samples/tasks/scenarios/nova/boot-from-volume.json Normal file → Executable file
View File

@ -1,4 +1,5 @@
{% set flavor_name = flavor_name or "m1.tiny" %} {% set flavor_name = flavor_name or "m1.tiny" %}
{% set volume_type = volume_type or "" %}
{ {
"NovaServers.boot_server_from_volume": [ "NovaServers.boot_server_from_volume": [
{ {
@ -9,7 +10,8 @@
"image": { "image": {
"name": "^cirros.*uec$" "name": "^cirros.*uec$"
}, },
"volume_size": 10 "volume_size": 10,
"volume_type": "{{volume_type}}"
}, },
"runner": { "runner": {
"type": "constant", "type": "constant",

2
samples/tasks/scenarios/nova/boot-from-volume.yaml Normal file → Executable file
View File

@ -1,4 +1,5 @@
{% set flavor_name = flavor_name or "m1.tiny" %} {% set flavor_name = flavor_name or "m1.tiny" %}
{% set volume_type = volume_type or "" %}
--- ---
NovaServers.boot_server_from_volume: NovaServers.boot_server_from_volume:
- -
@ -8,6 +9,7 @@
image: image:
name: "^cirros.*uec$" name: "^cirros.*uec$"
volume_size: 10 volume_size: 10
volume_type: "{{volume_type}}"
runner: runner:
type: "constant" type: "constant"
times: 10 times: 10

View File

@ -1,4 +1,5 @@
{% set flavor_name = flavor_name or "m1.tiny" %} {% set flavor_name = flavor_name or "m1.tiny" %}
{% set volume_type = volume_type or "" %}
{ {
"NovaServers.boot_server_from_volume_and_live_migrate": [ "NovaServers.boot_server_from_volume_and_live_migrate": [
{ {
@ -11,6 +12,7 @@
}, },
"block_migration": false, "block_migration": false,
"volume_size": 10, "volume_size": 10,
"volume_type": "{{volume_type}}",
"force_delete": false "force_delete": false
}, },
"runner": { "runner": {

View File

@ -1,4 +1,5 @@
{% set flavor_name = flavor_name or "m1.tiny" %} {% set flavor_name = flavor_name or "m1.tiny" %}
{% set volume_type = volume_type or "" %}
--- ---
NovaServers.boot_server_from_volume_and_live_migrate: NovaServers.boot_server_from_volume_and_live_migrate:
- args: - args:
@ -8,6 +9,7 @@
name: "^cirros.*uec$" name: "^cirros.*uec$"
block_migration: false block_migration: false
volume_size: 10 volume_size: 10
volume_type: "{{volume_type}}"
force_delete: false force_delete: false
runner: runner:
type: "constant" type: "constant"

View File

@ -329,10 +329,12 @@ class NovaServersTestCase(test.ScenarioTestCase):
fake_volume.id = "volume_id" fake_volume.id = "volume_id"
scenario._create_volume = mock.MagicMock(return_value=fake_volume) scenario._create_volume = mock.MagicMock(return_value=fake_volume)
scenario.boot_server_from_volume("img", 0, 5, auto_assign_nic=False, scenario.boot_server_from_volume("img", 0, 5, volume_type=None,
auto_assign_nic=False,
fakearg="f") fakearg="f")
scenario._create_volume.assert_called_once_with(5, imageRef="img") scenario._create_volume.assert_called_once_with(5, imageRef="img",
volume_type=None)
scenario._boot_server.assert_called_once_with( scenario._boot_server.assert_called_once_with(
None, 0, auto_assign_nic=False, None, 0, auto_assign_nic=False,
block_device_mapping={"vda": "volume_id:::1"}, block_device_mapping={"vda": "volume_id:::1"},
@ -349,10 +351,11 @@ class NovaServersTestCase(test.ScenarioTestCase):
fake_volume.id = "volume_id" fake_volume.id = "volume_id"
scenario._create_volume = mock.MagicMock(return_value=fake_volume) scenario._create_volume = mock.MagicMock(return_value=fake_volume)
scenario.boot_server_from_volume_and_delete("img", 0, 5, 10, 20, scenario.boot_server_from_volume_and_delete("img", 0, 5, None, 10, 20,
fakearg="f") fakearg="f")
scenario._create_volume.assert_called_once_with(5, imageRef="img") scenario._create_volume.assert_called_once_with(5, imageRef="img",
volume_type=None)
scenario._boot_server.assert_called_once_with( scenario._boot_server.assert_called_once_with(
None, 0, None, 0,
block_device_mapping={"vda": "volume_id:::1"}, block_device_mapping={"vda": "volume_id:::1"},
@ -584,11 +587,13 @@ class NovaServersTestCase(test.ScenarioTestCase):
scenario._create_volume = mock.MagicMock(return_value=fake_volume) scenario._create_volume = mock.MagicMock(return_value=fake_volume)
scenario.boot_server_from_volume_and_live_migrate("img", 0, 5, scenario.boot_server_from_volume_and_live_migrate("img", 0, 5,
volume_type=None,
min_sleep=10, min_sleep=10,
max_sleep=20, max_sleep=20,
fakearg="f") fakearg="f")
scenario._create_volume.assert_called_once_with(5, imageRef="img") scenario._create_volume.assert_called_once_with(5, imageRef="img",
volume_type=None)
scenario._boot_server.assert_called_once_with( scenario._boot_server.assert_called_once_with(
None, 0, None, 0,
@ -780,10 +785,12 @@ class NovaServersTestCase(test.ScenarioTestCase):
scenario._create_snapshot = mock.MagicMock(return_value=fake_snapshot) scenario._create_snapshot = mock.MagicMock(return_value=fake_snapshot)
scenario.boot_server_from_volume_snapshot("img", "flavor", 1, scenario.boot_server_from_volume_snapshot("img", "flavor", 1,
volume_type=None,
auto_assign_nic=False, auto_assign_nic=False,
fakearg="f") fakearg="f")
scenario._create_volume.assert_called_once_with(1, imageRef="img") scenario._create_volume.assert_called_once_with(1, imageRef="img",
volume_type=None)
scenario._create_snapshot.assert_called_once_with("volume_id", False) scenario._create_snapshot.assert_called_once_with("volume_id", False)
scenario._boot_server.assert_called_once_with( scenario._boot_server.assert_called_once_with(
None, "flavor", auto_assign_nic=False, None, "flavor", auto_assign_nic=False,