Mark Wu has uploaded a new change for review.

Change subject: Only run speed() on nic device
......................................................................

Only run speed() on nic device

Change-Id: I721b823a28cc36498119e67061d462b780105e7b
Signed-off-by: Mark Wu <[email protected]>
---
M vdsm/clientIF.py
M vdsm/sampling.py
2 files changed, 10 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/13839/1

diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index ea89276..18a04cd 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -84,12 +84,7 @@
             self.gluster = None
         try:
             self.vmContainer = {}
-            nics, bondings, _, _ = netinfo.getInterfaces()
-            ifids = nics + bondings
-            ifrates = map(netinfo.speed, ifids)
-            self._hostStats = sampling.HostStatsThread(
-                cif=self, log=log, ifids=ifids,
-                ifrates=ifrates)
+            self._hostStats = sampling.HostStatsThread(cif=self, log=log)
             self._hostStats.start()
             mog = min(config.getint('vars', 'max_outgoing_migrations'),
                       caps.CpuTopology().cores())
diff --git a/vdsm/sampling.py b/vdsm/sampling.py
index 551cf2e..f68a011 100644
--- a/vdsm/sampling.py
+++ b/vdsm/sampling.py
@@ -34,6 +34,7 @@
 import ethtool
 
 from vdsm import utils
+from vdsm import netinfo
 from vdsm.constants import P_VDSM_RUN
 from vdsm.config import config
 
@@ -365,18 +366,19 @@
     SAMPLE_INTERVAL_SEC = 2
     MBITTOBYTES = 1000000 / 8
 
-    def __init__(self, log, ifids, ifrates, ifmacs):
+    def __init__(self, log):
         threading.Thread.__init__(self)
         self._log = log
         self._lastCheckTime = 0
         self._stopEvent = threading.Event()
         self._samples = []
-        self._ifids = ifids
-        self._ifrates = ifrates
-        self._ifmacs = ifmacs
+        self.nics, bonds, _, _ = netinfo.getInterfaces()
+        self._ifids = self.nics + bonds
+        self._ifrates = map(netinfo.speed, self.nics) + [0] * len(bonds)
+        self._ifmacs = [''] * len(self._ifids)  # fake ifmacs
         self._ncpus = 1
         # in bytes-per-second
-        self._lineRate = (sum(ifrates) or 1000) * (10 ** 6) / 8
+        self._lineRate = (sum(self._ifrates) or 1000) * (10 ** 6) / 8
         self._paused = False
         self._lastSampleTime = time.time()
 
@@ -487,10 +489,9 @@
     """
     A thread that periodically samples host statistics.
     """
-    def __init__(self, cif, log, ifids, ifrates):
+    def __init__(self, cif, log):
         self.startTime = time.time()
-        StatsThread.__init__(self, log, ifids, ifrates,
-                             [''] * len(ifids))  # fake ifmacs
+        StatsThread.__init__(self, log)
         self._imagesStatus = ImagePathStatus(cif)
         self._pid = os.getpid()
         self._ncpus = max(os.sysconf('SC_NPROCESSORS_ONLN'), 1)
@@ -500,8 +501,6 @@
         StatsThread.stop(self)
 
     def _updateIfRates(self, hs0, hs1):
-        # from vdsm import netinfo only after it imported utils
-        from vdsm.netinfo import speed as nicspeed
 
         i = 0
         for ifid in self.nics:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I721b823a28cc36498119e67061d462b780105e7b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mark Wu <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to