From 8eba2de83de2bf8ad7996ef2e3f961902ec8c181 Mon Sep 17 00:00:00 2001 From: Kiran Ranganath Date: Fri, 4 Mar 2016 15:58:05 +0530 Subject: [PATCH] Remove deprecated 'script' and 'interpreter' in favor of 'command' VM task scenarios executes a script with a interpreter provided through a formatted argument called 'command' which expects the remote_path or local_path of the script and optionally an interpreter with which the script has to be executed. Change-Id: If2e65b553a0f26180267ef0b8e2239e3efe4ea17 --- .../plugins/openstack/scenarios/vm/vmtasks.py | 21 +++++---------- .../vm/boot-runcommand-delete-with-disk.json | 5 ++-- .../vm/boot-runcommand-delete-with-disk.yaml | 4 +-- .../scenarios/vm/boot-runcommand-delete.json | 5 ++-- .../scenarios/vm/boot-runcommand-delete.yaml | 4 +-- .../openstack/scenarios/vm/test_vmtasks.py | 27 ++++++++----------- 6 files changed, 27 insertions(+), 39 deletions(-) diff --git a/rally/plugins/openstack/scenarios/vm/vmtasks.py b/rally/plugins/openstack/scenarios/vm/vmtasks.py index 37c1b5c014..aa2b5bfb53 100644 --- a/rally/plugins/openstack/scenarios/vm/vmtasks.py +++ b/rally/plugins/openstack/scenarios/vm/vmtasks.py @@ -39,10 +39,7 @@ class VMTasks(vm_utils.VMScenario): @types.set(image=types.ImageResourceType, flavor=types.FlavorResourceType) @validation.image_valid_on_flavor("flavor", "image") - @logging.log_deprecated_args("Use `command' argument instead", "0.0.5", - ("script", "interpreter"), once=True) - @validation.file_exists("script", required=False) - @validation.valid_command("command", required=False) + @validation.valid_command("command") @validation.number("port", minval=1, maxval=65535, nullable=True, integer_only=True) @validation.external_network_exists("floating_network") @@ -53,8 +50,6 @@ class VMTasks(vm_utils.VMScenario): def boot_runcommand_delete(self, image, flavor, username, password=None, - script=None, - interpreter=None, command=None, volume_args=None, floating_network=None, @@ -64,19 +59,18 @@ class VMTasks(vm_utils.VMScenario): wait_for_ping=True, max_log_length=None, **kwargs): - """Boot a server, run a script that outputs JSON, delete the server. + """Boot a server, run script specified in command and delete server. Example Script in samples/tasks/support/instance_dd_test.sh + The script to be executed is provided like command['remote_path'] or + command['local_path'] and interpreter in command['interpreter'] + respectively. + :param image: glance image name to use for the vm :param flavor: VM flavor name :param username: ssh username on server, str :param password: Password on SSH authentication - :param script: DEPRECATED. Use `command' instead. Script to run on - server, must output JSON mapping metric names to values (see the - sample script below) - :param interpreter: DEPRECATED. Use `command' instead. server's - interpreter to run the script :param command: Command-specifying dictionary that either specifies remote command path via `remote_path' (can be uploaded from a local file specified by `local_path`), an inline script via @@ -157,9 +151,6 @@ class VMTasks(vm_utils.VMScenario): errors: str, raw data from the script's stderr stream """ - if command is None and script and interpreter: - command = {"script_file": script, "interpreter": interpreter} - if volume_args: volume = self._create_volume(volume_args["size"], imageRef=None) kwargs["block_device_mapping"] = {"vdrally": "%s:::1" % volume.id} diff --git a/samples/tasks/scenarios/vm/boot-runcommand-delete-with-disk.json b/samples/tasks/scenarios/vm/boot-runcommand-delete-with-disk.json index e49b0e48ed..189b005bfb 100644 --- a/samples/tasks/scenarios/vm/boot-runcommand-delete-with-disk.json +++ b/samples/tasks/scenarios/vm/boot-runcommand-delete-with-disk.json @@ -16,8 +16,9 @@ "floating_network": "public", "use_floating_ip": true, "force_delete": false, - "script": "samples/tasks/support/instance_dd_test.sh", - "interpreter": "/bin/sh", + "command": { + "remote_path": "samples/tasks/support/instance_dd_test.sh" + }, "username": "cirros" }, "runner": { diff --git a/samples/tasks/scenarios/vm/boot-runcommand-delete-with-disk.yaml b/samples/tasks/scenarios/vm/boot-runcommand-delete-with-disk.yaml index 8801044618..7b3142c48f 100644 --- a/samples/tasks/scenarios/vm/boot-runcommand-delete-with-disk.yaml +++ b/samples/tasks/scenarios/vm/boot-runcommand-delete-with-disk.yaml @@ -13,8 +13,8 @@ floating_network: "public" use_floating_ip: true force_delete: false - script: "samples/tasks/support/instance_dd_test.sh" - interpreter: "/bin/sh" + command: + remote_path: "samples/tasks/support/instance_dd_test.sh" username: "cirros" runner: type: "constant" diff --git a/samples/tasks/scenarios/vm/boot-runcommand-delete.json b/samples/tasks/scenarios/vm/boot-runcommand-delete.json index b1cf0dcd52..9ba3e86904 100644 --- a/samples/tasks/scenarios/vm/boot-runcommand-delete.json +++ b/samples/tasks/scenarios/vm/boot-runcommand-delete.json @@ -11,8 +11,9 @@ }, "floating_network": "public", "force_delete": false, - "script": "samples/tasks/support/instance_dd_test.sh", - "interpreter": "/bin/sh", + "command": { + "remote_path": "samples/tasks/support/instance_dd_test.sh" + }, "username": "cirros" }, "runner": { diff --git a/samples/tasks/scenarios/vm/boot-runcommand-delete.yaml b/samples/tasks/scenarios/vm/boot-runcommand-delete.yaml index ea993df062..d41fcba6bb 100644 --- a/samples/tasks/scenarios/vm/boot-runcommand-delete.yaml +++ b/samples/tasks/scenarios/vm/boot-runcommand-delete.yaml @@ -9,8 +9,8 @@ name: "^cirros.*uec$" floating_network: "public" force_delete: false - script: "samples/tasks/support/instance_dd_test.sh" - interpreter: "/bin/sh" + command: + remote_path: "samples/tasks/support/instance_dd_test.sh" username: "cirros" runner: type: "constant" diff --git a/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py b/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py index dca89baea8..0227b7aa4d 100644 --- a/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py +++ b/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py @@ -15,7 +15,6 @@ import mock -from rally.common import logging from rally import exceptions from rally.plugins.openstack.scenarios.vm import vmtasks from tests.unit import test @@ -39,21 +38,17 @@ class VMTasksTestCase(test.ScenarioTestCase): return_value=(0, "\"foo_out\"", "foo_err")) def test_boot_runcommand_delete(self): - with logging.LogCatcher(logging.LOG) as catcher: - self.scenario.boot_runcommand_delete( - "foo_image", "foo_flavor", - script="foo_script", interpreter="foo_interpreter", - username="foo_username", - password="foo_password", - use_floating_ip="use_fip", - floating_network="ext_network", - force_delete="foo_force", - volume_args={"size": 16}, - foo_arg="foo_value") - - catcher.assertInLogs( - "Use `command' argument instead (args `script', `interpreter' " - "deprecated in Rally v0.0.5)") + self.scenario.boot_runcommand_delete( + "foo_image", "foo_flavor", + command={"script_file": "foo_script", + "interpreter": "foo_interpreter"}, + username="foo_username", + password="foo_password", + use_floating_ip="use_fip", + floating_network="ext_network", + force_delete="foo_force", + volume_args={"size": 16}, + foo_arg="foo_value") self.scenario._create_volume.assert_called_once_with( 16, imageRef=None)