[node-patches] Change in ovirt-node[master]: network: Don't loop in hot paths.

fabiand at redhat.com fabiand at redhat.com
Fri Jul 11 07:59:41 UTC 2014


Fabian Deutsch has uploaded a new change for review.

Change subject: network: Don't loop in hot paths.
......................................................................

network: Don't loop in hot paths.

The actual problem needs to be addressed differently.

Change-Id: I9225a22bf7b538397c3ad3c4eb1bab6db30afbe7
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/utils/network.py
1 file changed, 5 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/19/29919/1

diff --git a/src/ovirt/node/utils/network.py b/src/ovirt/node/utils/network.py
index 835a20e..b03dde9 100644
--- a/src/ovirt/node/utils/network.py
+++ b/src/ovirt/node/utils/network.py
@@ -265,26 +265,11 @@
                 LOGGER.debug("Failed to retrieve carrier with NM")
 
         # Fallback
-        has_carrier = False
-        i = 5
-        while i > 0:
-            try:
-                cmd = "ip link set dev {ifname} up".format(ifname=self.ifname)
-                process.check_call(cmd, shell=True)
-            except process.CalledProcessError:
-                LOGGER.debug("Failed to set dev %s link up" % self.ifname)
-            try:
-                content = File("/sys/class/net/%s/carrier" % self.ifname).\
-                    read()
-                has_carrier = "1" in content
-            except:
-                LOGGER.debug("Carrier down for %s" % self.ifname)
-            if not has_carrier:
-                import time
-                time.sleep(1)
-                i -= 1
-            else:
-                break
+        process.call(["ip","link", "set", "dev", self.ifname, "up"])
+
+        content = File("/sys/class/net/%s/carrier" % self.ifname).read()
+        has_carrier = "1" in content
+
         return has_carrier
 
     def ipv4_address(self):


-- 
To view, visit http://gerrit.ovirt.org/29919
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9225a22bf7b538397c3ad3c4eb1bab6db30afbe7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>



More information about the node-patches mailing list