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
This commit is contained in:
Kiran Ranganath 2016-03-04 15:58:05 +05:30
parent 6232405ef2
commit 87cc092d9f
6 changed files with 27 additions and 39 deletions

View File

@ -39,10 +39,7 @@ class VMTasks(vm_utils.VMScenario):
@types.set(image=types.ImageResourceType, @types.set(image=types.ImageResourceType,
flavor=types.FlavorResourceType) flavor=types.FlavorResourceType)
@validation.image_valid_on_flavor("flavor", "image") @validation.image_valid_on_flavor("flavor", "image")
@logging.log_deprecated_args("Use `command' argument instead", "0.0.5", @validation.valid_command("command")
("script", "interpreter"), once=True)
@validation.file_exists("script", required=False)
@validation.valid_command("command", required=False)
@validation.number("port", minval=1, maxval=65535, nullable=True, @validation.number("port", minval=1, maxval=65535, nullable=True,
integer_only=True) integer_only=True)
@validation.external_network_exists("floating_network") @validation.external_network_exists("floating_network")
@ -53,8 +50,6 @@ class VMTasks(vm_utils.VMScenario):
def boot_runcommand_delete(self, image, flavor, def boot_runcommand_delete(self, image, flavor,
username, username,
password=None, password=None,
script=None,
interpreter=None,
command=None, command=None,
volume_args=None, volume_args=None,
floating_network=None, floating_network=None,
@ -64,19 +59,18 @@ class VMTasks(vm_utils.VMScenario):
wait_for_ping=True, wait_for_ping=True,
max_log_length=None, max_log_length=None,
**kwargs): **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 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 image: glance image name to use for the vm
:param flavor: VM flavor name :param flavor: VM flavor name
:param username: ssh username on server, str :param username: ssh username on server, str
:param password: Password on SSH authentication :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 :param command: Command-specifying dictionary that either specifies
remote command path via `remote_path' (can be uploaded from a remote command path via `remote_path' (can be uploaded from a
local file specified by `local_path`), an inline script via 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 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: if volume_args:
volume = self._create_volume(volume_args["size"], imageRef=None) volume = self._create_volume(volume_args["size"], imageRef=None)
kwargs["block_device_mapping"] = {"vdrally": "%s:::1" % volume.id} kwargs["block_device_mapping"] = {"vdrally": "%s:::1" % volume.id}

View File

@ -16,8 +16,9 @@
"floating_network": "public", "floating_network": "public",
"use_floating_ip": true, "use_floating_ip": true,
"force_delete": false, "force_delete": false,
"script": "samples/tasks/support/instance_dd_test.sh", "command": {
"interpreter": "/bin/sh", "remote_path": "samples/tasks/support/instance_dd_test.sh"
},
"username": "cirros" "username": "cirros"
}, },
"runner": { "runner": {

View File

@ -13,8 +13,8 @@
floating_network: "public" floating_network: "public"
use_floating_ip: true use_floating_ip: true
force_delete: false force_delete: false
script: "samples/tasks/support/instance_dd_test.sh" command:
interpreter: "/bin/sh" remote_path: "samples/tasks/support/instance_dd_test.sh"
username: "cirros" username: "cirros"
runner: runner:
type: "constant" type: "constant"

View File

@ -11,8 +11,9 @@
}, },
"floating_network": "public", "floating_network": "public",
"force_delete": false, "force_delete": false,
"script": "samples/tasks/support/instance_dd_test.sh", "command": {
"interpreter": "/bin/sh", "remote_path": "samples/tasks/support/instance_dd_test.sh"
},
"username": "cirros" "username": "cirros"
}, },
"runner": { "runner": {

View File

@ -9,8 +9,8 @@
name: "^cirros.*uec$" name: "^cirros.*uec$"
floating_network: "public" floating_network: "public"
force_delete: false force_delete: false
script: "samples/tasks/support/instance_dd_test.sh" command:
interpreter: "/bin/sh" remote_path: "samples/tasks/support/instance_dd_test.sh"
username: "cirros" username: "cirros"
runner: runner:
type: "constant" type: "constant"

View File

@ -15,7 +15,6 @@
import mock import mock
from rally.common import logging
from rally import exceptions from rally import exceptions
from rally.plugins.openstack.scenarios.vm import vmtasks from rally.plugins.openstack.scenarios.vm import vmtasks
from tests.unit import test from tests.unit import test
@ -39,10 +38,10 @@ class VMTasksTestCase(test.ScenarioTestCase):
return_value=(0, "\"foo_out\"", "foo_err")) return_value=(0, "\"foo_out\"", "foo_err"))
def test_boot_runcommand_delete(self): def test_boot_runcommand_delete(self):
with logging.LogCatcher(logging.LOG) as catcher:
self.scenario.boot_runcommand_delete( self.scenario.boot_runcommand_delete(
"foo_image", "foo_flavor", "foo_image", "foo_flavor",
script="foo_script", interpreter="foo_interpreter", command={"script_file": "foo_script",
"interpreter": "foo_interpreter"},
username="foo_username", username="foo_username",
password="foo_password", password="foo_password",
use_floating_ip="use_fip", use_floating_ip="use_fip",
@ -51,10 +50,6 @@ class VMTasksTestCase(test.ScenarioTestCase):
volume_args={"size": 16}, volume_args={"size": 16},
foo_arg="foo_value") foo_arg="foo_value")
catcher.assertInLogs(
"Use `command' argument instead (args `script', `interpreter' "
"deprecated in Rally v0.0.5)")
self.scenario._create_volume.assert_called_once_with( self.scenario._create_volume.assert_called_once_with(
16, imageRef=None) 16, imageRef=None)
self.scenario._boot_server_with_fip.assert_called_once_with( self.scenario._boot_server_with_fip.assert_called_once_with(