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,
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}

View File

@ -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": {

View File

@ -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"

View File

@ -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": {

View File

@ -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"

View File

@ -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)