[PATCH 2/4] Ticket #4: phys_id from int to string

olichtne at redhat.com olichtne at redhat.com
Wed Aug 22 13:19:16 UTC 2012


From: Ondrej Lichtner <olichtne at 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 at 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 = ""
-- 
1.7.11.4



More information about the LNST-developers mailing list