[PATCH 3/4] Ticket #4: interface_id from int to string

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


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



More information about the LNST-developers mailing list