Francesco Romani has uploaded a new change for review.

Change subject: vm: make Vm.stats public
......................................................................

vm: make Vm.stats public

future patches want to make use of it.
Moreover, to have it public actually reduces coupling.

Change-Id: Ic5e8086028c9bfcb5aeb2e918756fc2408861246
Signed-off-by: Francesco Romani <from...@redhat.com>
---
M tests/numaUtilsTests.py
M tests/vmApiTests.py
M vdsm/numaUtils.py
M vdsm/virt/migration.py
M vdsm/virt/vm.py
5 files changed, 16 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/18/36718/1

diff --git a/tests/numaUtilsTests.py b/tests/numaUtilsTests.py
index 82caf57..5b77aac 100644
--- a/tests/numaUtilsTests.py
+++ b/tests/numaUtilsTests.py
@@ -70,7 +70,7 @@
                                          'memory': '1024',
                                          'nodeIndex': 1}]}
         with fake.VM(VM_PARAMS) as testvm:
-            testvm._vmStats = fake.VmStatsThread(testvm)
+            testvm.stats = fake.VmStatsThread(testvm)
             expectedResult = {'0': [0, 1], '1': [0, 1]}
             vmNumaNodeRuntimeMap = numaUtils.getVmNumaNodeRuntimeInfo(testvm)
             self.assertEqual(expectedResult, vmNumaNodeRuntimeMap)
diff --git a/tests/vmApiTests.py b/tests/vmApiTests.py
index eb89fb1..2cd2905 100644
--- a/tests/vmApiTests.py
+++ b/tests/vmApiTests.py
@@ -60,7 +60,7 @@
     try:
         yield vm
     finally:
-        vm._vmStats.stop()
+        vm.stats.stop()
 
 
 class TestVmStats(TestSchemaCompliancyBase):
diff --git a/vdsm/numaUtils.py b/vdsm/numaUtils.py
index 2053ce1..df0c9b7 100644
--- a/vdsm/numaUtils.py
+++ b/vdsm/numaUtils.py
@@ -91,8 +91,8 @@
 
 def _getVcpuRuntimePinMap(vm):
     vCpuRuntimePinMap = {}
-    if vm._vmStats:
-        sample = vm._vmStats.sampleVcpuPinning.getLastSample()
+    if vm.stats:
+        sample = vm.stats.sampleVcpuPinning.getLastSample()
         vCpuInfos = sample if sample is not None else []
         for vCpuInfo in vCpuInfos:
             vCpuRuntimePinMap[vCpuInfo[0]] = vCpuInfo[3]
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 6afa9d4..32c5c7f 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -280,14 +280,14 @@
         if self.hibernating:
             hooks.before_vm_hibernate(self._vm._dom.XMLDesc(0), self._vm.conf)
             try:
-                self._vm._vmStats.pause()
+                self._vm.stats.pause()
                 fname = self._vm.cif.prepareVolumePath(self._dst)
                 try:
                     self._vm._dom.save(fname)
                 finally:
                     self._vm.cif.teardownVolumePath(self._dst)
             except Exception:
-                self._vm._vmStats.cont()
+                self._vm.stats.cont()
                 raise
         else:
             for dev in self._vm._customDevices():
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 20d526e..12ab230 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1378,7 +1378,7 @@
         self._initTimeRTC = long(self.conf.get('timeOffset', 0))
         self._guestEvent = vmstatus.POWERING_UP
         self._guestEventTime = 0
-        self._vmStats = None
+        self.stats = None
         self._guestCpuRunning = False
         self._guestCpuLock = threading.Lock()
         self._startTime = time.time() - \
@@ -1869,7 +1869,7 @@
             return
         toSave = self.status()
         toSave['startTime'] = self._startTime
-        if self.lastStatus != vmstatus.DOWN and self._vmStats:
+        if self.lastStatus != vmstatus.DOWN and self.stats:
             toSave['username'] = self.guestAgent.guestInfo['username']
             toSave['guestIPs'] = self.guestAgent.guestInfo['guestIPs']
             toSave['guestFQDN'] = self.guestAgent.guestInfo['guestFQDN']
@@ -2260,7 +2260,7 @@
         except Exception:
             pass
         try:
-            self._vmStats.stop()
+            self.stats.stop()
         except Exception:
             pass
         self.saveState()
@@ -2338,8 +2338,8 @@
 
         decStats = {}
         try:
-            if self._vmStats:
-                decStats = self._vmStats.get()
+            if self.stats:
+                decStats = self.stats.get()
                 self._setUnresponsiveIfTimeout(stats, decStats['statsAge'])
         except Exception:
             self.log.exception("Error fetching vm stats")
@@ -2560,8 +2560,8 @@
         return domxml.toxml()
 
     def _initVmStats(self):
-        self._vmStats = VmStatsThread(self)
-        self._vmStats.start()
+        self.stats = VmStatsThread(self)
+        self.stats.start()
         self._guestEventTime = self._startTime
 
     @staticmethod
@@ -4393,8 +4393,8 @@
             self.lastStatus = vmstatus.POWERING_DOWN
             # Terminate the VM's creation thread.
             self._incomingMigrationFinished.set()
-            if self._vmStats:
-                self._vmStats.stop()
+            if self.stats:
+                self.stats.stop()
             self.guestAgent.stop()
             if self._dom:
                 response = self._destroyVmGraceful()
@@ -5305,7 +5305,7 @@
 
         # Trigger the collection of stats before returning so that callers
         # of getVmStats after this returns will see the new job
-        self._vmStats.sampleVmJobs()
+        self.stats.sampleVmJobs()
 
         return {'status': doneCode}
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5e8086028c9bfcb5aeb2e918756fc2408861246
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <from...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to