commit f2275631ff1b64314257cf458be5a88bcd277fdd
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue May 6 10:01:53 2014 +0200
Controller: rename 'machine' to 'host'
This commit renames the internally used 'machine' keyword to 'host', and
'command_sequence' to 'task' also updating relevant output messages. The
reson for this is the automatic generation of result xmls, that use this
keyword and were inconsistent with the recipe xml format.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/NetTestCommand.py | 8 ++--
lnst/Controller/NetTestController.py | 44 ++++++++++++++--------------
lnst/Controller/NetTestResultSerializer.py | 14 ++++----
lnst/Controller/RecipeParser.py | 6 ++--
lnst/Controller/Task.py | 10 +++---
5 files changed, 41 insertions(+), 41 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 47a3e4a..7b45b33 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -25,7 +25,7 @@ def str_command(command):
attrs = ["type(%s)" % command["type"]]
if command["type"] == "test":
attrs.append("module(%s)" % command["module"])
- attrs.append("host(%s)" % command["machine"])
+ attrs.append("host(%s)" % command["host"])
if "bg_id" in command:
attrs.append("bg_id(%s)" % command["bg_id"])
@@ -33,7 +33,7 @@ def str_command(command):
attrs.append("timeout(%s)" % command["timeout"])
elif command["type"] == "exec":
attrs.append("command(%s)" % command["command"])
- attrs.append("machine(%s)" % command["machine"])
+ attrs.append("host(%s)" % command["host"])
if "from" in command:
attrs.append("from(%s)" % command["from"])
@@ -42,10 +42,10 @@ def str_command(command):
if "timeout" in command:
attrs.append("timeout(%s)" % command["timeout"])
elif command["type"] in ["wait", "intr", "kill"]:
- attrs.append("machine(%s)" % command["machine"])
+ attrs.append("host(%s)" % command["host"])
attrs.append("bg_id(%s)" % command["proc_id"])
elif command["type"] == "config":
- attrs.append("machine(%s)" % command["machine"])
+ attrs.append("host(%s)" % command["host"])
if "option" in command:
attrs.append("option(%s)" % command["option"])
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 7324a7c..400cd19 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -105,8 +105,8 @@ class NetTestController:
# There must be some machines specified in the recipe
if "machines" not in recipe or \
("machines" in recipe and len(recipe["machines"]) == 0):
- msg = "No machines specified in the recipe. At least two " \
- "machines are required to perform a network test."
+ msg = "No hosts specified in the recipe. At least two " \
+ "hosts are required to perform a network test."
raise RecipeError(msg, recipe)
# machine requirements
@@ -122,7 +122,7 @@ class NetTestController:
if "params" in machine:
for p in machine["params"]:
if p["name"] in params:
- msg = "Parameter '%s' of machine %s was specified " \
+ msg = "Parameter '%s' of host %s was specified " \
"multiple times. Overriding the previous value." \
% (p["name"], m_id)
logging.warn(RecipeError(msg, p))
@@ -133,14 +133,14 @@ class NetTestController:
# Each machine must have at least one interface
if "interfaces" not in machine or \
("interfaces" in machine and len(machine["interfaces"]) == 0):
- msg = "Machine '%s' has no interfaces specified." % m_id
+ msg = "Hot '%s' has no interfaces specified." % m_id
raise RecipeError(msg, machine)
ifaces = {}
for iface in machine["interfaces"]:
if_id = iface["id"]
if if_id in ifaces:
- msg = "Interface with id='%s' already exists on machine " \
+ msg = "Interface with id='%s' already exists on host " \
"'%s'." % (if_id, m_id)
iface_type = iface["type"]
@@ -152,7 +152,7 @@ class NetTestController:
for i in iface["params"]:
if i["name"] in iface_params:
msg = "Parameter '%s' of interface %s of " \
- "machine %s was defined multiple times. " \
+ "host %s was defined multiple times. " \
"Overriding the previous value." \
% (i["name"], if_id, m_id)
logging.warn(RecipeError(msg, p))
@@ -197,14 +197,14 @@ class NetTestController:
if sp.is_setup_virtual() and os.geteuid() != 0:
msg = "Provisioning this setup requires additional configuration "\
- "of the virtual machines in the pool. LNST needs root "\
+ "of the virtual hosts in the pool. LNST needs root "\
"priviledges so it can connect to qemu."
raise NetTestError(msg)
logging.info("Provisioning initialized")
for m_id in machines.keys():
provisioner = sp.get_provisioner_id(m_id)
- logging.info(" machine %s uses %s" % (m_id, provisioner))
+ logging.info(" host %s uses %s" % (m_id, provisioner))
def _prepare_machine(self, m_id, resource_sync=True):
machine = self._machines[m_id]
@@ -236,7 +236,7 @@ class NetTestController:
else:
continue
for cmd in task['commands']:
- if 'machine' not in cmd or cmd['machine'] != m_id:
+ if 'host' not in cmd or cmd['host'] != m_id:
continue
if cmd['type'] == 'test':
mod = cmd['module']
@@ -318,10 +318,10 @@ class NetTestController:
for cmd_data in task["commands"]:
cmd = {"type": cmd_data["type"]}
- if "machine" in cmd_data:
- cmd["machine"] = cmd_data["machine"]
- if cmd["machine"] not in self._machines:
- msg = "Invalid machine id '%s'." % cmd["machine"]
+ if "host" in cmd_data:
+ cmd["host"] = cmd_data["host"]
+ if cmd["host"] not in self._machines:
+ msg = "Invalid host id '%s'." % cmd["host"]
raise RecipeError(msg, cmd_data)
if cmd["type"] in ["test", "exec"]:
@@ -339,10 +339,10 @@ class NetTestController:
def _prepare_command(self, cmd_data):
cmd = {"type": cmd_data["type"]}
- if "machine" in cmd_data:
- cmd["machine"] = cmd_data["machine"]
- if cmd["machine"] not in self._machines:
- msg = "Invalid machine id '%s'." % cmd["machine"]
+ if "host" in cmd_data:
+ cmd["host"] = cmd_data["host"]
+ if cmd["host"] not in self._machines:
+ msg = "Invalid host id '%s'." % cmd["host"]
raise RecipeError(msg, cmd_data)
if "expect" in cmd_data:
@@ -412,7 +412,7 @@ class NetTestController:
if command["type"] == "ctl_wait":
continue
- machine_id = command["machine"]
+ machine_id = command["host"]
if not machine_id in bg_ids:
bg_ids[machine_id] = set()
@@ -423,7 +423,7 @@ class NetTestController:
bg_ids[machine_id].remove(bg_id)
else:
logging.error("Found command \"%s\" for bg_id \"%s\" on "
- "machine \"%s\" which was not previously "
+ "host \"%s\" which was not previously "
"defined", cmd_type, bg_id, machine_id)
err = True
@@ -432,14 +432,14 @@ class NetTestController:
if not bg_id in bg_ids[machine_id]:
bg_ids[machine_id].add(bg_id)
else:
- logging.error("Command \"%d\" uses bg_id \"%s\" on machine "
+ logging.error("Command \"%d\" uses bg_id \"%s\" on host"
"\"%s\" which is already used",
i, bg_id, machine_id)
err = True
for machine_id in bg_ids:
for bg_id in bg_ids[machine_id]:
- logging.error("bg_id \"%s\" on machine \"%s\" has no kill/wait "
+ logging.error("bg_id \"%s\" on host \"%s\" has no kill/wait "
"command to it", bg_id, machine_id)
err = True
@@ -664,7 +664,7 @@ class NetTestController:
self._res_serializer.add_cmd_result(command, cmd_res)
return cmd_res
- machine_id = command["machine"]
+ machine_id = command["host"]
machine = self._machines[machine_id]
try:
diff --git a/lnst/Controller/NetTestResultSerializer.py b/lnst/Controller/NetTestResultSerializer.py
index 7f2e6d1..a7702fc 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -86,9 +86,9 @@ class NetTestResultSerializer:
m_id_max = 0
for cmd, cmd_res in task:
- if "machine" in cmd and\
- len(cmd["machine"]) > m_id_max:
- m_id_max = len(cmd["machine"])
+ if "host" in cmd and\
+ len(cmd["host"]) > m_id_max:
+ m_id_max = len(cmd["host"])
for cmd, cmd_res in task:
self._format_command(cmd, cmd_res, output_pairs, m_id_max)
@@ -100,9 +100,9 @@ class NetTestResultSerializer:
else:
res = "FAIL"
- if "machine" in command:
- m_id = "host %s: " % command["machine"]
- m_id += " " * (m_id_max - len(command["machine"]))
+ if "host" in command:
+ m_id = "host %s: " % command["host"]
+ m_id += " " * (m_id_max - len(command["host"]))
else:
#len("ctl") == 3; len("host ") == 5; 5-3 = 2
m_id = "ctl: " + " " * (m_id_max + 2)
@@ -174,7 +174,7 @@ class NetTestResultSerializer:
recipe_el.appendChild(err_el)
for task in recipe["tasks"]:
- cmd_seq_el = doc.createElement("command_sequence")
+ cmd_seq_el = doc.createElement("task")
recipe_el.appendChild(cmd_seq_el)
for cmd, cmd_res in task:
diff --git a/lnst/Controller/RecipeParser.py b/lnst/Controller/RecipeParser.py
index 2b554d7..046d6d9 100644
--- a/lnst/Controller/RecipeParser.py
+++ b/lnst/Controller/RecipeParser.py
@@ -260,7 +260,7 @@ class RecipeParser(XmlParser):
def _process_run_cmd(self, cmd_tag):
cmd = XmlData(cmd_tag)
- cmd["machine"] = self._get_attribute(cmd_tag, "host")
+ cmd["host"] = self._get_attribute(cmd_tag, "host")
has_module = self._has_attribute(cmd_tag, "module")
has_command = self._has_attribute(cmd_tag, "command")
@@ -300,7 +300,7 @@ class RecipeParser(XmlParser):
def _process_config_cmd(self, cmd_tag):
cmd = XmlData(cmd_tag)
cmd["type"] = "config"
- cmd["machine"] = self._get_attribute(cmd_tag, "host")
+ cmd["host"] = self._get_attribute(cmd_tag, "host")
if self._has_attribute(cmd_tag, "persistent"):
cmd["persistent"] = self._get_attribute(cmd_tag, "persistent")
@@ -335,6 +335,6 @@ class RecipeParser(XmlParser):
def _process_signal_cmd(self, cmd_tag):
cmd = XmlData(cmd_tag)
cmd["type"] = cmd_tag.tag
- cmd["machine"] = self._get_attribute(cmd_tag, "host")
+ cmd["host"] = self._get_attribute(cmd_tag, "host")
cmd["bg_id"] = self._get_attribute(cmd_tag, "bg_id")
return cmd
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index 10c9f02..59f17c5 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -114,7 +114,7 @@ class HostAPI(object):
:return: Command result.
:rtype: dict
"""
- cmd = {"machine": str(self._id), "type": "config"}
+ cmd = {"host": str(self._id), "type": "config"}
cmd["options"] = [{"name": option, "value": value}]
cmd["persistent"] = persistent
@@ -139,7 +139,7 @@ class HostAPI(object):
:return: A handle for process.
:rtype: ProcessAPI
"""
- cmd = {"machine": str(self._id)}
+ cmd = {"host": str(self._id)}
bg_id = None
for arg, argval in kwargs.iteritems():
@@ -307,7 +307,7 @@ class ProcessAPI(object):
def wait(self):
""" Blocking wait until the command returns. """
if self._bg_id:
- cmd = {"machine": self._host,
+ cmd = {"host": self._host,
"type": "wait",
"proc_id": self._bg_id}
self._res = self._ctl._run_command(cmd)
@@ -315,7 +315,7 @@ class ProcessAPI(object):
def intr(self):
""" Interrupt the command. """
if self._bg_id:
- cmd = {"machine": self._host,
+ cmd = {"host": self._host,
"type": "intr",
"proc_id": self._bg_id}
self._res = self._ctl._run_command(cmd)
@@ -329,7 +329,7 @@ class ProcessAPI(object):
to keep the results, use 'intr' instead.
"""
if self._bg_id:
- cmd = {"machine": self._host,
+ cmd = {"host": self._host,
"type": "kill",
"proc_id": self._bg_id}
self._res = self._ctl._run_command(cmd)