From: Ondrej Lichtner olichtne@redhat.com
The following is a set of patches resolving ticket #4. machine_id, phys_id, interface_id and background_id can now have string values. This can be used to make recipes more readable. As far as I know these changes should have no impact on existing recipes but if you encounter any problems please contact me.
Ondrej Lichtner (4): Ticket #4: machine_id from int to string Ticket #4: phys_id from int to string Ticket #4: interface_id from int to string Ticket #4: bg_id from int to string
Common/XmlTemplates.py | 14 +++++++------- NetConfig/NetConfigDevNames.py | 2 +- NetTest/NetTestCommand.py | 18 +++++++++--------- NetTest/NetTestController.py | 18 +++++++++--------- NetTest/NetTestParse.py | 30 +++++++++++++++--------------- netconfig.py | 2 +- 6 files changed, 42 insertions(+), 42 deletions(-)
From: Ondrej Lichtner olichtne@redhat.com
Machine ids in tags <machine id=''> and <command machine_id=''> are no longer converted to integers and are used as strings. Introducing these changes requires a number of changes in formatted strings where integers were required. Machine id is also used as the first parameter in template functions so these had to be changed as well.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- Common/XmlTemplates.py | 8 ++++---- NetTest/NetTestCommand.py | 2 +- NetTest/NetTestController.py | 16 ++++++++-------- NetTest/NetTestParse.py | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/Common/XmlTemplates.py b/Common/XmlTemplates.py index a3be062..3b6c663 100644 --- a/Common/XmlTemplates.py +++ b/Common/XmlTemplates.py @@ -219,7 +219,7 @@ class XmlTemplates: self._validate_func_params("ip", params, 2, 1) recipe = self._get_recipe_data("ip")
- m_id = int(params[0]) + m_id = params[0] if_id = int(params[1]) ip_id = int(params[2]) if len(params) == 3 else 0
@@ -246,7 +246,7 @@ class XmlTemplates: def _hwaddr_func(self, params): self._validate_func_params("hwaddr", params, 2, 0) recipe = self._get_recipe_data("hwaddr") - m_id = int(params[0]) + m_id = params[0] if_id = int(params[1])
if 'machines' not in recipe or m_id not in recipe['machines']: @@ -267,7 +267,7 @@ class XmlTemplates: def _devname_func(self, params): self._validate_func_params("devname", params, 2, 0) recipe = self._get_recipe_data("devname") - m_id = int(params[0]) + m_id = params[0] if_id = int(params[1])
if 'machines' not in recipe or m_id not in recipe['machines']: @@ -295,7 +295,7 @@ class XmlTemplates: err = "Function %s takes %d arguments, %d passed" \ % (name, mandatory, num_params) raise XmlTemplateError(err) - for param in params: + for param in params[1:]: try: int(param) except ValueError: diff --git a/NetTest/NetTestCommand.py b/NetTest/NetTestCommand.py index ae1297f..5403621 100644 --- a/NetTest/NetTestCommand.py +++ b/NetTest/NetTestCommand.py @@ -19,7 +19,7 @@ import pickle, traceback from Common.ExecCmd import exec_cmd, ExecCmdFail
def str_command(command): - out = ("type (%s), machine_id (%d), value (%s)" + out = ("type (%s), machine_id (%s), value (%s)" % (command["type"], command["machine_id"], command["value"])) if "timeout" in command: out += ", timeout (%d)" % command["timeout"] diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py index c70e252..b932ff8 100644 --- a/NetTest/NetTestController.py +++ b/NetTest/NetTestController.py @@ -103,7 +103,7 @@ class NetTestController: if dev["create"] == "libvirt": if not "virt_domain_ctl" in info: msg = "Cannot create device. " \ - "Machine '%d' is not virtual." % (machine_id) + "Machine '%s' is not virtual." % (machine_id) raise NetTestError(msg)
if not "hwaddr" in dev: @@ -121,7 +121,7 @@ class NetTestController: br_name = brctl.get_name() brctl.init()
- logging.info("Creating netdevice %d (%s) on machine %d", + logging.info("Creating netdevice %d (%s) on machine %s", dev_id, dev["hwaddr"], machine_id)
domain_ctl = info["virt_domain_ctl"] @@ -132,7 +132,7 @@ class NetTestController:
if not ready: msg = "Netdevice initialization failed." \ - "Unable to create device %d (%s) on machine %d" \ + "Unable to create device %d (%s) on machine %s" \ % (dev_id, dev["hwaddr"], machine_id) raise NetTestError(msg)
@@ -144,11 +144,11 @@ class NetTestController: if len(phys_devs) == 1: pass elif len(phys_devs) < 1: - msg = "Device %d not found on machine %d" \ + msg = "Device %d not found on machine %s" \ % (dev_id, machine_id) raise NetTestError(msg) elif len(phys_devs) > 1: - msg = "Multiple netdevices with same address %s on machine %d" \ + msg = "Multiple netdevices with same address %s on machine %s" \ % (dev["hwaddr"], machine_id) raise NetTestError(msg)
@@ -186,7 +186,7 @@ class NetTestController: rpc.deconfigure_interface(netdev_config_id)
def _prepare_slave(self, machine_id): - logging.info("Preparing machine #%d", machine_id) + logging.info("Preparing machine %s", machine_id) info = self._get_machineinfo(machine_id)
if "libvirt_domain" in info: @@ -261,7 +261,7 @@ class NetTestController: if "created_devices" not in info: continue for dev_id, dev in reversed(info["created_devices"]): - logging.info("Removing netdevice %d (%s) from machine %d", + logging.info("Removing netdevice %d (%s) from machine %s", dev_id, dev["hwaddr"], machine_id) domain_ctl = info["virt_domain_ctl"] domain_ctl.detach_interface(dev["hwaddr"]) @@ -299,7 +299,7 @@ class NetTestController: except KeyError: pass
- if machine_id == 0: + if machine_id == "0": cmd_res = NetTestCommand(command).run() else: rpc = self._get_machinerpc(machine_id) diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py index 7af2084..b69eea3 100644 --- a/NetTest/NetTestParse.py +++ b/NetTest/NetTestParse.py @@ -86,7 +86,7 @@ class MachineParse(RecipeParser): raise XmlProcessingError("Unknown machine type")
def parse(self, node): - self._id = self._get_attribute(node, "id", int) + self._id = self._get_attribute(node, "id") self._machine = {} self._recipe[self._target][self._id] = self._machine
@@ -361,7 +361,7 @@ class CommandSequenceParse(RecipeParser): bg_ids[machine_id].remove(bg_id) else: logging.error("Found command "%s" for bg_id "%s" on " - "machine "%d" which was not previously " + "machine "%s" which was not previously " "defined", cmd_type, bg_id, machine_id) err = True
@@ -371,13 +371,13 @@ class CommandSequenceParse(RecipeParser): bg_ids[machine_id].add(bg_id) else: logging.error("Command "%d" uses bg_id "%d" on machine " - ""%d" which is already used", + ""%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 "%d" on machine "%d" has no kill/wait " + logging.error("bg_id "%d" on machine "%s" has no kill/wait " "command to it", bg_id, machine_id) err = True if err: @@ -399,11 +399,11 @@ class CommandParse(RecipeParser): self._cmd_num = len(recipe["sequences"][self._seq_num]["commands"]) - 1
if self._has_attribute(node, "machine_id"): - machine_id = self._get_attribute(node, "machine_id", int) + machine_id = self._get_attribute(node, "machine_id") if machine_id and not machine_id in recipe["machines"]: raise XmlProcessingError("Invalid machine_id", node) else: - machine_id = 0 # controller id + machine_id = "0" # controller id
command["machine_id"] = machine_id command["type"] = self._get_attribute(node, "type")
Oh, The subject line is wrong. Please do not mention ticket in there. Anyway, I applied these patches before noticing that, so next time.
Wed, Aug 22, 2012 at 03:19:15PM CEST, olichtne@redhat.com wrote:
From: Ondrej Lichtner olichtne@redhat.com
Machine ids in tags <machine id=''> and <command machine_id=''> are no longer converted to integers and are used as strings. Introducing these changes requires a number of changes in formatted strings where integers were required. Machine id is also used as the first parameter in template functions so these had to be changed as well.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com
Common/XmlTemplates.py | 8 ++++---- NetTest/NetTestCommand.py | 2 +- NetTest/NetTestController.py | 16 ++++++++-------- NetTest/NetTestParse.py | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/Common/XmlTemplates.py b/Common/XmlTemplates.py index a3be062..3b6c663 100644 --- a/Common/XmlTemplates.py +++ b/Common/XmlTemplates.py @@ -219,7 +219,7 @@ class XmlTemplates: self._validate_func_params("ip", params, 2, 1) recipe = self._get_recipe_data("ip")
m_id = int(params[0])
m_id = params[0] if_id = int(params[1]) ip_id = int(params[2]) if len(params) == 3 else 0@@ -246,7 +246,7 @@ class XmlTemplates: def _hwaddr_func(self, params): self._validate_func_params("hwaddr", params, 2, 0) recipe = self._get_recipe_data("hwaddr")
m_id = int(params[0])
m_id = params[0] if_id = int(params[1]) if 'machines' not in recipe or m_id not in recipe['machines']:@@ -267,7 +267,7 @@ class XmlTemplates: def _devname_func(self, params): self._validate_func_params("devname", params, 2, 0) recipe = self._get_recipe_data("devname")
m_id = int(params[0])
m_id = params[0] if_id = int(params[1]) if 'machines' not in recipe or m_id not in recipe['machines']:@@ -295,7 +295,7 @@ class XmlTemplates: err = "Function %s takes %d arguments, %d passed" \ % (name, mandatory, num_params) raise XmlTemplateError(err)
for param in params:
for param in params[1:]: try: int(param) except ValueError:diff --git a/NetTest/NetTestCommand.py b/NetTest/NetTestCommand.py index ae1297f..5403621 100644 --- a/NetTest/NetTestCommand.py +++ b/NetTest/NetTestCommand.py @@ -19,7 +19,7 @@ import pickle, traceback from Common.ExecCmd import exec_cmd, ExecCmdFail
def str_command(command):
- out = ("type (%s), machine_id (%d), value (%s)"
- out = ("type (%s), machine_id (%s), value (%s)" % (command["type"], command["machine_id"], command["value"])) if "timeout" in command: out += ", timeout (%d)" % command["timeout"]
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py index c70e252..b932ff8 100644 --- a/NetTest/NetTestController.py +++ b/NetTest/NetTestController.py @@ -103,7 +103,7 @@ class NetTestController: if dev["create"] == "libvirt": if not "virt_domain_ctl" in info: msg = "Cannot create device. " \
"Machine '%d' is not virtual." % (machine_id)
"Machine '%s' is not virtual." % (machine_id) raise NetTestError(msg) if not "hwaddr" in dev:@@ -121,7 +121,7 @@ class NetTestController: br_name = brctl.get_name() brctl.init()
logging.info("Creating netdevice %d (%s) on machine %d",
logging.info("Creating netdevice %d (%s) on machine %s", dev_id, dev["hwaddr"], machine_id) domain_ctl = info["virt_domain_ctl"]@@ -132,7 +132,7 @@ class NetTestController:
if not ready: msg = "Netdevice initialization failed." \
"Unable to create device %d (%s) on machine %d" \
"Unable to create device %d (%s) on machine %s" \ % (dev_id, dev["hwaddr"], machine_id) raise NetTestError(msg)@@ -144,11 +144,11 @@ class NetTestController: if len(phys_devs) == 1: pass elif len(phys_devs) < 1:
msg = "Device %d not found on machine %d" \
msg = "Device %d not found on machine %s" \ % (dev_id, machine_id) raise NetTestError(msg) elif len(phys_devs) > 1:
msg = "Multiple netdevices with same address %s on machine %d" \
msg = "Multiple netdevices with same address %s on machine %s" \ % (dev["hwaddr"], machine_id) raise NetTestError(msg)@@ -186,7 +186,7 @@ class NetTestController: rpc.deconfigure_interface(netdev_config_id)
def _prepare_slave(self, machine_id):
logging.info("Preparing machine #%d", machine_id)
logging.info("Preparing machine %s", machine_id) info = self._get_machineinfo(machine_id) if "libvirt_domain" in info:@@ -261,7 +261,7 @@ class NetTestController: if "created_devices" not in info: continue for dev_id, dev in reversed(info["created_devices"]):
logging.info("Removing netdevice %d (%s) from machine %d",
logging.info("Removing netdevice %d (%s) from machine %s", dev_id, dev["hwaddr"], machine_id) domain_ctl = info["virt_domain_ctl"] domain_ctl.detach_interface(dev["hwaddr"])@@ -299,7 +299,7 @@ class NetTestController: except KeyError: pass
if machine_id == 0:
if machine_id == "0": cmd_res = NetTestCommand(command).run() else: rpc = self._get_machinerpc(machine_id)diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py index 7af2084..b69eea3 100644 --- a/NetTest/NetTestParse.py +++ b/NetTest/NetTestParse.py @@ -86,7 +86,7 @@ class MachineParse(RecipeParser): raise XmlProcessingError("Unknown machine type")
def parse(self, node):
self._id = self._get_attribute(node, "id", int)
self._id = self._get_attribute(node, "id") self._machine = {} self._recipe[self._target][self._id] = self._machine@@ -361,7 +361,7 @@ class CommandSequenceParse(RecipeParser): bg_ids[machine_id].remove(bg_id) else: logging.error("Found command "%s" for bg_id "%s" on "
"machine \"%d\" which was not previously "
"machine \"%s\" which was not previously " "defined", cmd_type, bg_id, machine_id) err = True@@ -371,13 +371,13 @@ class CommandSequenceParse(RecipeParser): bg_ids[machine_id].add(bg_id) else: logging.error("Command "%d" uses bg_id "%d" on machine "
"\"%d\" which is already used",
"\"%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 \"%d\" on machine \"%d\" has no kill/wait "
logging.error("bg_id \"%d\" on machine \"%s\" has no kill/wait " "command to it", bg_id, machine_id) err = True if err:@@ -399,11 +399,11 @@ class CommandParse(RecipeParser): self._cmd_num = len(recipe["sequences"][self._seq_num]["commands"]) - 1
if self._has_attribute(node, "machine_id"):
machine_id = self._get_attribute(node, "machine_id", int)
machine_id = self._get_attribute(node, "machine_id") if machine_id and not machine_id in recipe["machines"]: raise XmlProcessingError("Invalid machine_id", node) else:
machine_id = 0 # controller id
machine_id = "0" # controller id command["machine_id"] = machine_id command["type"] = self._get_attribute(node, "type")-- 1.7.11.4
LNST-developers mailing list LNST-developers@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/lnst-developers
From: Ondrej Lichtner olichtne@redhat.com
Physical id of devices is no longer converted to integer, and is used as a string. Because of this a few formatted strings had to be changed to expect strings and not integers.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- NetTest/NetTestController.py | 8 ++++---- NetTest/NetTestParse.py | 6 +++--- netconfig.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py index b932ff8..80bff27 100644 --- a/NetTest/NetTestController.py +++ b/NetTest/NetTestController.py @@ -121,7 +121,7 @@ class NetTestController: br_name = brctl.get_name() brctl.init()
- logging.info("Creating netdevice %d (%s) on machine %s", + logging.info("Creating netdevice %s (%s) on machine %s", dev_id, dev["hwaddr"], machine_id)
domain_ctl = info["virt_domain_ctl"] @@ -132,7 +132,7 @@ class NetTestController:
if not ready: msg = "Netdevice initialization failed." \ - "Unable to create device %d (%s) on machine %s" \ + "Unable to create device %s (%s) on machine %s" \ % (dev_id, dev["hwaddr"], machine_id) raise NetTestError(msg)
@@ -144,7 +144,7 @@ class NetTestController: if len(phys_devs) == 1: pass elif len(phys_devs) < 1: - msg = "Device %d not found on machine %s" \ + msg = "Device %s not found on machine %s" \ % (dev_id, machine_id) raise NetTestError(msg) elif len(phys_devs) > 1: @@ -261,7 +261,7 @@ class NetTestController: if "created_devices" not in info: continue for dev_id, dev in reversed(info["created_devices"]): - logging.info("Removing netdevice %d (%s) from machine %s", + logging.info("Removing netdevice %s (%s) from machine %s", dev_id, dev["hwaddr"], machine_id) domain_ctl = info["virt_domain_ctl"] domain_ctl.detach_interface(dev["hwaddr"]) diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py index b69eea3..58e7b29 100644 --- a/NetTest/NetTestParse.py +++ b/NetTest/NetTestParse.py @@ -160,7 +160,7 @@ class NetMachineConfigParse(RecipeParser):
def _netdevice(self, node, params): machine = self._machine - phys_id = self._get_attribute(node, "phys_id", int) + phys_id = self._get_attribute(node, "phys_id")
dev = machine["netdevices"][phys_id] = {} dev["create"] = params["create"] @@ -248,7 +248,7 @@ class NetConfigParse(RecipeParser): devices = self._devices
if dev["type"] == "eth": - phys_id = self._get_attribute(node, "phys_id", int) + phys_id = self._get_attribute(node, "phys_id") self._check_phys_id(node, phys_id, netconfig) dev["phys_id"] = phys_id
@@ -271,7 +271,7 @@ class NetConfigParse(RecipeParser): if not "phys_id" in config[key]: continue if config[key]["phys_id"] == dev_pid: - msg = "same phys_id "%d" used more than once" % dev_pid + msg = "same phys_id "%s" used more than once" % dev_pid raise XmlProcessingError(msg, node)
def _addresses(self, node, params): diff --git a/netconfig.py b/netconfig.py index 9551ac6..c0baf97 100755 --- a/netconfig.py +++ b/netconfig.py @@ -91,7 +91,7 @@ def netmachineconfig_to_xml(machine_data):
devices = "" for phys_id, netdev in machine_data["netdevices"].iteritems(): - pid = "phys_id="%d" " % phys_id + pid = "phys_id="%s" " % phys_id dev_type = "" name = "" hwaddr = ""
From: Ondrej Lichtner olichtne@redhat.com
Interface ids in tags <interface id=''> and <slave id=''> are no longer converted to integers and are used as strings. Introducing these changes requires a number of changes in formatted strings where integers were required. Interface id is also used as the second parameter in template functions so these had to be changed as well.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- Common/XmlTemplates.py | 8 ++++---- NetConfig/NetConfigDevNames.py | 2 +- NetTest/NetTestController.py | 2 +- NetTest/NetTestParse.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/Common/XmlTemplates.py b/Common/XmlTemplates.py index 3b6c663..6afcc05 100644 --- a/Common/XmlTemplates.py +++ b/Common/XmlTemplates.py @@ -220,7 +220,7 @@ class XmlTemplates: recipe = self._get_recipe_data("ip")
m_id = params[0] - if_id = int(params[1]) + if_id = params[1] ip_id = int(params[2]) if len(params) == 3 else 0
if 'machines' not in recipe or m_id not in recipe['machines']: @@ -247,7 +247,7 @@ class XmlTemplates: self._validate_func_params("hwaddr", params, 2, 0) recipe = self._get_recipe_data("hwaddr") m_id = params[0] - if_id = int(params[1]) + if_id = params[1]
if 'machines' not in recipe or m_id not in recipe['machines']: msg = "First parameter of function hwaddr() is invalid: "\ @@ -268,7 +268,7 @@ class XmlTemplates: self._validate_func_params("devname", params, 2, 0) recipe = self._get_recipe_data("devname") m_id = params[0] - if_id = int(params[1]) + if_id = params[1]
if 'machines' not in recipe or m_id not in recipe['machines']: msg = "First parameter of function devname() is invalid: "\ @@ -295,7 +295,7 @@ class XmlTemplates: err = "Function %s takes %d arguments, %d passed" \ % (name, mandatory, num_params) raise XmlTemplateError(err) - for param in params[1:]: + for param in params[2:]: try: int(param) except ValueError: diff --git a/NetConfig/NetConfigDevNames.py b/NetConfig/NetConfigDevNames.py index 0f246d9..581f9b8 100644 --- a/NetConfig/NetConfigDevNames.py +++ b/NetConfig/NetConfigDevNames.py @@ -33,7 +33,7 @@ class NetConfigDevNames: if hwaddr == entry["hwaddr"]: netdev["name"] = entry["name"] if not "name" in netdev: - logging.error("Name for addr "%s" (netdevice id "%d") not found" + logging.error("Name for addr "%s" (netdevice id "%s") not found" % (hwaddr, dev_id)) raise Exception
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py index 80bff27..783e980 100644 --- a/NetTest/NetTestController.py +++ b/NetTest/NetTestController.py @@ -162,7 +162,7 @@ class NetTestController: def _prepare_interface(self, machine_id, netdev_config_id): rpc = self._get_machinerpc(machine_id) info = self._get_machineinfo(machine_id) - logging.info("Configuring interface #%d on %s", netdev_config_id, + logging.info("Configuring interface %s on %s", netdev_config_id, info["hostname"])
self._configure_interface(machine_id, netdev_config_id) diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py index 58e7b29..542f820 100644 --- a/NetTest/NetTestParse.py +++ b/NetTest/NetTestParse.py @@ -211,7 +211,7 @@ class NetConfigParse(RecipeParser): netconfig = self._netconfig devices = self._devices
- dev_id = self._get_attribute(node, "id", int) + dev_id = self._get_attribute(node, "id") if not dev_id in netconfig: netconfig[dev_id] = {} else: @@ -305,9 +305,9 @@ class NetConfigParse(RecipeParser):
def _slave(self, node, params): if self._has_attribute(node, "id"): - slave_id = self._get_attribute(node, "id", int) + slave_id = self._get_attribute(node, "id") else: - slave_id = self._get_text_content(node, int) + slave_id = self._get_text_content(node)
dev_id = params["dev_id"] self._netconfig[dev_id]["slaves"].append(slave_id)
From: Ondrej Lichtner olichtne@redhat.com
Background ids are now treated as strings as well. Changes were made to parsing of the attribute, and to formatting strings where it is later used.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- NetTest/NetTestCommand.py | 16 ++++++++-------- NetTest/NetTestParse.py | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/NetTest/NetTestCommand.py b/NetTest/NetTestCommand.py index 5403621..e89f606 100644 --- a/NetTest/NetTestCommand.py +++ b/NetTest/NetTestCommand.py @@ -24,7 +24,7 @@ def str_command(command): if "timeout" in command: out += ", timeout (%d)" % command["timeout"] if "bg_id" in command: - out += ", bg_id (%d)" % command["bg_id"] + out += ", bg_id (%s)" % command["bg_id"] if "desc" in command: out += ", desc (%s)" % command["desc"] return out @@ -176,9 +176,9 @@ class NetTestCommandSystemConfig(NetTestCommandGeneric):
class NetTestCommandWait(NetTestCommandGeneric): def run(self): - bg_id = int(self._command["value"]) + bg_id = self._command["value"] pid = bg_processes.get_pid(bg_id) - logging.debug("Waiting for background id "%d", pid "%d"" % (bg_id, pid)) + logging.debug("Waiting for background id "%s", pid "%d"" % (bg_id, pid)) os.waitpid(pid, 0) result = bg_processes.get_bg_process_result(bg_id) bg_processes.remove(bg_id) @@ -186,9 +186,9 @@ class NetTestCommandWait(NetTestCommandGeneric):
class NetTestCommandIntr(NetTestCommandGeneric): def run(self): - bg_id = int(self._command["value"]) + bg_id = self._command["value"] pid = bg_processes.get_pid(bg_id) - logging.debug("Interrupting background id "%d", pid "%d"" % (bg_id, pid)) + logging.debug("Interrupting background id "%s", pid "%d"" % (bg_id, pid)) os.killpg(os.getpgid(pid), signal.SIGINT) os.waitpid(pid, 0) result = bg_processes.get_bg_process_result(bg_id) @@ -197,9 +197,9 @@ class NetTestCommandIntr(NetTestCommandGeneric):
class NetTestCommandKill(NetTestCommandGeneric): def run(self): - bg_id = int(self._command["value"]) + bg_id = self._command["value"] pid = bg_processes.get_pid(bg_id) - logging.debug("Killing background id "%d", pid "%d"" % (bg_id, pid)) + logging.debug("Killing background id "%s", pid "%d"" % (bg_id, pid)) os.killpg(os.getpgid(pid), signal.SIGKILL) bg_processes.remove(bg_id) self.set_result({"passed": True}) @@ -236,7 +236,7 @@ class NetTestCommand: if pid: os.close(write_pipe) logging.debug("Running in background with" - " id "%d", pid "%d"" % (bg_id, pid)) + " id "%s", pid "%d"" % (bg_id, pid)) bg_processes.add(bg_id, pid, read_pipe) return {"passed": True} os.close(read_pipe) diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py index 542f820..21bfdd5 100644 --- a/NetTest/NetTestParse.py +++ b/NetTest/NetTestParse.py @@ -356,7 +356,7 @@ class CommandSequenceParse(RecipeParser):
cmd_type = command["type"] if cmd_type in ["wait", "intr", "kill"]: - bg_id = int(command["value"]) + bg_id = command["value"] if bg_id in bg_ids[machine_id]: bg_ids[machine_id].remove(bg_id) else: @@ -370,14 +370,14 @@ class CommandSequenceParse(RecipeParser): if not bg_id in bg_ids[machine_id]: bg_ids[machine_id].add(bg_id) else: - logging.error("Command "%d" uses bg_id "%d" on machine " + logging.error("Command "%d" uses bg_id "%s" on machine " ""%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 "%d" on machine "%s" has no kill/wait " + logging.error("bg_id "%s" on machine "%s" has no kill/wait " "command to it", bg_id, machine_id) err = True if err: @@ -416,7 +416,7 @@ class CommandParse(RecipeParser): command["timeout"] = self._get_attribute(node, "timeout", int)
if self._has_attribute(node, "bg_id"): - command["bg_id"] = self._get_attribute(node, "bg_id", int) + command["bg_id"] = self._get_attribute(node, "bg_id")
if self._has_attribute(node, "desc"): command["desc"] = self._get_attribute(node, "desc")
lnst-developers@lists.fedorahosted.org