Change in vdsm[master]: events: vm status notifications
piotr.kliczewski at gmail.com
piotr.kliczewski at gmail.com
Thu Mar 19 11:34:35 UTC 2015
Piotr Kliczewski has uploaded a new change for review.
Change subject: events: vm status notifications
......................................................................
events: vm status notifications
Whenever vm changes status we send notification to an engine with vmid
and new status.
Change-Id: I746299f9f1e2f49831a05072f19af1d242796276
Signed-off-by: pkliczewski <piotr.kliczewski at gmail.com>
---
M tests/jsonRpcTests.py
M tests/vmfakelib.py
M vdsm/virt/vm.py
3 files changed, 23 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/38937/1
diff --git a/tests/jsonRpcTests.py b/tests/jsonRpcTests.py
index 7325c0e..01bf3c8 100644
--- a/tests/jsonRpcTests.py
+++ b/tests/jsonRpcTests.py
@@ -60,7 +60,7 @@
def double_response(self):
n = self.cif.create_notification('vdsm.double_response')
- n.emit(content=True)
+ n.emit(**{CALL_ID: True})
return 'sent'
def register_server_address(self, server_address):
@@ -193,7 +193,7 @@
else:
def callback(client, event, params):
self.assertEquals(event, 'vdsm.double_response')
- self.assertEquals(params, {'content': True})
+ self.assertEquals(params, {CALL_ID: True})
client.registerEventCallback(callback)
res = self._callTimeout(client, "double_response", [],
diff --git a/tests/vmfakelib.py b/tests/vmfakelib.py
index 271538e..5fc2861 100644
--- a/tests/vmfakelib.py
+++ b/tests/vmfakelib.py
@@ -35,6 +35,7 @@
from testlib import namedTemporaryDir
from monkeypatch import MonkeyPatchScope
+from yajsonrpc import Notification
class Connection:
@@ -57,6 +58,12 @@
self.vmContainerLock = threading.Lock()
self.vmContainer = {}
+ def create_notification(self, event_id):
+ def send(message):
+ pass
+
+ return Notification(event_id, send)
+
class Domain(object):
def __init__(self, xml='',
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index bb2ab62..8cd4d6c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -865,6 +865,10 @@
def _set_lastStatus(self, value):
with self._statusLock:
+ notification = self.cif.create_notification(
+ '|virt|VM_status|' + self.id
+ )
+ notification.emit(**{self.id: value})
if self._lastStatus == vmstatus.DOWN:
self.log.warning(
'trying to set state to %s when already Down',
@@ -1616,6 +1620,12 @@
self._acquireCpuLockWithTimeout()
try:
self._guestCpuRunning = isRunning
+ if (not self._guestCpuRunning and
+ self._lastStatus in vmstatus.PAUSED_STATES):
+ notification = self.cif.create_notification(
+ '|virt|VM_status|' + self.id
+ )
+ notification.emit(**{self.id: 'Paused'})
finally:
if not guestCpuLocked:
self._guestCpuLock.release()
@@ -5015,6 +5025,10 @@
' (command timeout, age=%s)',
statsAge)
stats['monitorResponse'] = '-1'
+ notification = self.cif.create_notification(
+ '|virt|VM_status|' + self.id
+ )
+ notification.emit(**{self.id: 'NotResponding'})
class LiveMergeCleanupThread(threading.Thread):
--
To view, visit https://gerrit.ovirt.org/38937
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I746299f9f1e2f49831a05072f19af1d242796276
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski at gmail.com>
More information about the vdsm-patches
mailing list