Assaf Muller has uploaded a new change for review.
Change subject: Per device custom properties for before/after vm destroy.
......................................................................
Per device custom properties for before/after vm destroy.
Change-Id: Ic18b838dc51ea6bde31ef1a4bf0d0d372d95cd41
Signed-off-by: Assaf Muller <amuller(a)redhat.com>
---
M vdsm.spec.in
M vdsm/hooks.py
M vdsm/libvirtvm.py
M vdsm/vdsmd.8.in
M vdsm_hooks/Makefile.am
5 files changed, 27 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/11/13411/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 32eb97d..724a113 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -794,6 +794,8 @@
%{_libexecdir}/%{vdsm_name}/spmstop.sh
%dir %{_libexecdir}/%{vdsm_name}/hooks/before_device_create
%dir %{_libexecdir}/%{vdsm_name}/hooks/after_device_create
+%dir %{_libexecdir}/%{vdsm_name}/hooks/before_device_destroy
+%dir %{_libexecdir}/%{vdsm_name}/hooks/after_device_destroy
%dir %{_libexecdir}/%{vdsm_name}/hooks/before_vm_start
%dir %{_libexecdir}/%{vdsm_name}/hooks/after_vm_start
%dir %{_libexecdir}/%{vdsm_name}/hooks/before_vm_cont
diff --git a/vdsm/hooks.py b/vdsm/hooks.py
index a2cb932..c66bfef 100644
--- a/vdsm/hooks.py
+++ b/vdsm/hooks.py
@@ -101,6 +101,16 @@
params=customProperties)
+def before_device_destroy(devicexml, vmconf={}, customProperties={}):
+ return _runHooksDir(devicexml, 'before_device_destroy', vmconf=vmconf,
+ params=customProperties)
+
+
+def after_device_destroy(devicexml, vmconf={}, customProperties={}):
+ return _runHooksDir(devicexml, 'after_device_destroy', vmconf=vmconf,
+ params=customProperties)
+
+
def before_vm_start(domxml, vmconf={}):
return _runHooksDir(domxml, 'before_vm_start', vmconf=vmconf)
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 4c41c6b..3f682dc 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -2599,6 +2599,11 @@
hooks.after_vm_destroy(self._lastXMLDesc, self.conf)
+ for devType in self._devices:
+ for dev in self._devices[devType]:
+ hooks.after_device_destroy(dev._deviceXML, self.conf,
+ getattr(dev, 'custom', {}))
+
self._released = True
return {'status': doneCode}
@@ -2618,6 +2623,11 @@
def destroy(self):
self.log.debug('destroy Called')
+ for devType in self._devices:
+ for dev in self._devices[devType]:
+ hooks.before_device_destroy(dev._deviceXML, self.conf,
+ getattr(dev, 'custom', {}))
+
hooks.before_vm_destroy(self._lastXMLDesc, self.conf)
self.destroyed = True
diff --git a/vdsm/vdsmd.8.in b/vdsm/vdsmd.8.in
index 50da8cf..1803b58 100644
--- a/vdsm/vdsmd.8.in
+++ b/vdsm/vdsmd.8.in
@@ -48,6 +48,7 @@
before_vm_destroy, after_vm_destroy,
before_vm_set_ticket, after_vm_set_ticket,
before_device_create, after_device_create,
+ before_device_destroy, after_device_destroy,
before_nic_hotplug, after_nic_hotplug, after_nic_hotplug_fail,
before_nic_hotunplug, after_nic_hotunplug, after_nic_unhotplug_fail,
before_disk_hotplug, after_disk_hotplug,
@@ -89,7 +90,8 @@
before_nic_hotunplug, after_nic_hotunplug, after_nic_unhotplug_fail,
before_disk_hotplug, after_disk_hotplug,
before_disk_hotunplug, after_disk_hotunplug,
- before_device_create, after_device_create.
+ before_device_create, after_device_create,
+ before_device_destroy, after_device_destroy.
Are all augmented by custom properties specific to those devices, sent by the caller of
the hook. For example if before_nic_hotplug is called with custom: {qos: '0.5',
color: 'red'} then qos and color will be directly available as environment
variables when before_nic_hotplug is called.
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
index 3f890f6..12bea50 100644
--- a/vdsm_hooks/Makefile.am
+++ b/vdsm_hooks/Makefile.am
@@ -61,6 +61,8 @@
VDSMHOOKS = \
before_device_create \
after_device_create \
+ before_device_destroy \
+ after_device_destroy \
before_vm_start \
after_vm_start \
before_vm_cont \
--
To view, visit
http://gerrit.ovirt.org/13411
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic18b838dc51ea6bde31ef1a4bf0d0d372d95cd41
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Assaf Muller <amuller(a)redhat.com>